Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Debug Failure. Unhandled SyntaxKind: ImportClause. #33

Closed
sleeyax opened this issue Apr 13, 2023 · 5 comments
Closed

Error: Debug Failure. Unhandled SyntaxKind: ImportClause. #33

sleeyax opened this issue Apr 13, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@sleeyax
Copy link

sleeyax commented Apr 13, 2023

I tied to run the command using npx but I get the following error:

❯ npx -p typescript -p cjstoesm cjstoesm ./src/lib
Need to install the following packages:
  typescript@5.0.4
  cjstoesm@2.1.2
Ok to proceed? (y) 
/home/ user/.npm/_npx/6ca627352432bfda/node_modules/typescript/lib/typescript.js:110792
      Debug.fail(`Unhandled SyntaxKind: ${Debug.formatSyntaxKind(node.kind)}.`);
            ^

Error: Debug Failure. Unhandled SyntaxKind: ImportClause.
    at pipelineEmitWithHintWorker (/home/ user/.npm/_npx/6ca627352432bfda/node_modules/typescript/lib/typescript.js:110792:13)
    at pipelineEmitWithHint (/home/ user/.npm/_npx/6ca627352432bfda/node_modules/typescript/lib/typescript.js:110333:9)
    at pipelineEmitWithComments (/home/ user/.npm/_npx/6ca627352432bfda/node_modules/typescript/lib/typescript.js:114112:7)
    at pipelineEmit (/home/ user/.npm/_npx/6ca627352432bfda/node_modules/typescript/lib/typescript.js:110282:7)
    at emitExpression (/home/ user/.npm/_npx/6ca627352432bfda/node_modules/typescript/lib/typescript.js:110266:7)
    at emitImportDeclaration (/home/ user/.npm/_npx/6ca627352432bfda/node_modules/typescript/lib/typescript.js:112325:7)
    at pipelineEmitWithHintWorker (/home/ user/.npm/_npx/6ca627352432bfda/node_modules/typescript/lib/typescript.js:110533:20)
    at pipelineEmitWithHint (/home/ user/.npm/_npx/6ca627352432bfda/node_modules/typescript/lib/typescript.js:110333:9)
    at pipelineEmitWithComments (/home/ user/.npm/_npx/6ca627352432bfda/node_modules/typescript/lib/typescript.js:114112:7)
    at pipelineEmit (/home/ user/.npm/_npx/6ca627352432bfda/node_modules/typescript/lib/typescript.js:110282:7)

Seems like TypeScript is broken somehow but I don't understand why this happens. Any clues?

@sleeyax sleeyax added the bug Something isn't working label Apr 13, 2023
@sleeyax
Copy link
Author

sleeyax commented Apr 13, 2023

Never mind, I fixed it by explicitly specifying the typescript version that is specified in this project's package.json: npx -p typescript@4.7.3 -p cjstoesm cjstoesm ./src/lib. I wish this was documented in the README though.

@sleeyax sleeyax closed this as completed Apr 13, 2023
@christinachimi
Copy link

I'm experiencing this same issue but setting the TS version isn't helping. May create a new issue if I can't figure it out.

@dmnsgn
Copy link

dmnsgn commented Jun 16, 2023

With TypeScript 4.9.5, I am getting the following warning:

DeprecationWarning: 'isTypeAssertion' has been deprecated since v4.0.0. Use `isTypeAssertionExpression` instead.
DeprecationWarning: 'createImportDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createExportAssignment' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.

They seem related to the ImportClause issue above.

Can we reopen this issue or create a new one as it seems TypeScript 5 support is not 100% here?

@mistadikay
Copy link

I'm experiencing this same issue but setting the TS version isn't helping. May create a new issue if I can't figure it out.

Might be late for you, but for others for future reference: make sure you install cjstoesm in your project directory with typescript@4. If you install it globally, then make sure that typescript globally is also v4.

@tobice
Copy link

tobice commented Jul 24, 2024

Personally, I have only been able to get this working using:

 npx -p typescript@4.7.3 -p cjstoesm cjstoesm file.js

Processing my whole folder hierarchy was also challenging (struggled with this, so this is what I ended up with:

 find src -type d | xargs -I {} npx  -p typescript@4.7.3 -p cjstoesm cjstoesm {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants