TypeChain icon indicating copy to clipboard operation
TypeChain copied to clipboard

Problems with generation for projects that starts with a number

Open Pzixel opened this issue 3 years ago • 3 comments

When importing import "@0x/utils/blabla.sol"; there is an error:

SyntaxError: An identifier or keyword cannot immediately follow a numeric literal. (4:19)
  2 | /* tslint:disable */
  3 | /* eslint-disable */
> 4 | import type * as 0x from './@0x';
    |                   ^
  5 | export type { 0x };
    at qe (/Users/pzixel/Documents/Repos/test/node_modules/prettier/parser-typescript.js:1:15607)
    at UU (/Users/pzixel/Documents/Repos/test/node_modules/prettier/parser-typescript.js:280:5918)
    at Object.zU [as parse] (/Users/pzixel/Documents/Repos/test/node_modules/prettier/parser-typescript.js:280:6241)
    at Object.parse (/Users/pzixel/Documents/Repos/test/node_modules/prettier/index.js:7361:23)
    at coreFormat (/Users/pzixel/Documents/Repos/test/node_modules/prettier/index.js:8672:18)
    at formatWithCursor2 (/Users/pzixel/Documents/Repos/test/node_modules/prettier/index.js:8864:18)
    at /Users/pzixel/Documents/Repos/test/node_modules/prettier/index.js:39174:12
    at Object.format (/Users/pzixel/Documents/Repos/test/node_modules/prettier/index.js:39188:12)
    at prettierOutputTransformer (/Users/pzixel/Documents/Repos/test/node_modules/typechain/src/codegen/outputTransformers/prettier.ts:8:19)
    at /Users/pzixel/Documents/Repos/test/node_modules/typechain/src/typechain/io.ts:22:33 {

Similar problem exists for other projects starting with a number, e.g. 1inch.

Pzixel avatar Jun 09 '22 17:06 Pzixel

I've faced the same issue with the same @0x package

An unexpected error occurred:

SyntaxError: Hexadecimal digit expected. (5:20)
  3 | /* tslint:disable */
  4 | /* eslint-disable */
> 5 | import type * as 0X from './@0x';
    |                    ^
  6 | export type { 0X };

gueux avatar Apr 17 '23 17:04 gueux

Feel free to submit PR fixing this issue. We will definitely need a test for this. Probably we need to rename incorrect symbols such as0X to something else.

krzkaczor avatar May 07 '23 13:05 krzkaczor

I would be happy to help with PR but i'm not sure how to fix it and how to test it actually does what's needed

Pzixel avatar May 07 '23 19:05 Pzixel