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

Doesn't work with newer TypeScript versions #34

Closed
DRKV333 opened this issue Jul 2, 2023 · 9 comments
Closed

Doesn't work with newer TypeScript versions #34

DRKV333 opened this issue Jul 2, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@DRKV333
Copy link

DRKV333 commented Jul 2, 2023

  • Version: 2.1.2
  • TypeScript Version: 5.1.6

Description

cjstoesm doesn't seem to work with TypeScript 5. Since TypeScript is a peer dependency, I don't think there is a way to provide cjstoesm with the right version, if a newer TypeScript is installed in the parent project. This workaround: #33 (comment) only works if it is not installed.

Expected Behavior

cjstoesm should work with projects that are using TypeScript 5.

Actual Behavior

C:\work\test\node_modules\typescript\lib\typescript.js:111514
      Debug.fail(`Unhandled SyntaxKind: ${Debug.formatSyntaxKind(node.kind)}.`);
            ^

Error: Debug Failure. Unhandled SyntaxKind: Unknown.
    at pipelineEmitWithHintWorker (C:\work\test\node_modules\typescript\lib\typescript.js:111514:13)
    at pipelineEmitWithHint (C:\work\test\node_modules\typescript\lib\typescript.js:111058:9)
    at pipelineEmitWithComments (C:\work\test\node_modules\typescript\lib\typescript.js:114842:7)
    at pipelineEmit (C:\work\test\node_modules\typescript\lib\typescript.js:111007:7)
    at emitExpression (C:\work\test\node_modules\typescript\lib\typescript.js:110991:7)
    at emitExportAssignment (C:\work\test\node_modules\typescript\lib\typescript.js:113087:7)
    at pipelineEmitWithHintWorker (C:\work\test\node_modules\typescript\lib\typescript.js:111270:20)
    at pipelineEmitWithHint (C:\work\test\node_modules\typescript\lib\typescript.js:111058:9)
    at pipelineEmitWithComments (C:\work\test\node_modules\typescript\lib\typescript.js:114842:7)
    at pipelineEmit (C:\work\test\node_modules\typescript\lib\typescript.js:111007:7)
@DRKV333 DRKV333 added the bug Something isn't working label Jul 2, 2023
@atjn
Copy link

atjn commented Aug 12, 2023

I have the same issue. I was able to temporarily fix it by adding this in my package.json:

"overrides": {
     "cjstoesm": {
        "typescript": "3.9.10"
    }
}

@dschnare
Copy link

dschnare commented Sep 7, 2023

Thanks, we'll need to downgrade our Typescript dependency then I guess.

@dschnare
Copy link

dschnare commented Sep 7, 2023

Works with Typescript 4.9.5.

@inoyakaigor
Copy link

Still doesn't work
image

C:\Users\InoY\AppData\Local\npm-cache\_npx\a471d542563e35be\node_modules\typescript\lib\typescript.js:115406
      Debug.fail(`Unhandled SyntaxKind: ${Debug.formatSyntaxKind(node.kind)}.`);
            ^

Error: Debug Failure. Unhandled SyntaxKind: ImportClause.
    at pipelineEmitWithHintWorker (C:\Users\InoY\AppData\Local\npm-cache\_npx\a471d542563e35be\node_modules\typescript\lib\typescript.js:115406:13)
    at pipelineEmitWithHint (C:\Users\InoY\AppData\Local\npm-cache\_npx\a471d542563e35be\node_modules\typescript\lib\typescript.js:114948:9)
    at pipelineEmitWithComments (C:\Users\InoY\AppData\Local\npm-cache\_npx\a471d542563e35be\node_modules\typescript\lib\typescript.js:118762:7)
    at pipelineEmit (C:\Users\InoY\AppData\Local\npm-cache\_npx\a471d542563e35be\node_modules\typescript\lib\typescript.js:114897:7)
    at emitExpression (C:\Users\InoY\AppData\Local\npm-cache\_npx\a471d542563e35be\node_modules\typescript\lib\typescript.js:114881:7)
    at emitImportDeclaration (C:\Users\InoY\AppData\Local\npm-cache\_npx\a471d542563e35be\node_modules\typescript\lib\typescript.js:116943:7)
    at pipelineEmitWithHintWorker (C:\Users\InoY\AppData\Local\npm-cache\_npx\a471d542563e35be\node_modules\typescript\lib\typescript.js:115150:20)
    at pipelineEmitWithHint (C:\Users\InoY\AppData\Local\npm-cache\_npx\a471d542563e35be\node_modules\typescript\lib\typescript.js:114948:9)
    at pipelineEmitWithComments (C:\Users\InoY\AppData\Local\npm-cache\_npx\a471d542563e35be\node_modules\typescript\lib\typescript.js:118762:7)
    at pipelineEmit (C:\Users\InoY\AppData\Local\npm-cache\_npx\a471d542563e35be\node_modules\typescript\lib\typescript.js:114897:7)

@adamscybot
Copy link

For users of pnpm, in package.json:

  "pnpm": {
    "overrides": {
      "cjstoesm>typescript": "^4.9.5"
    }
  }

@nvuillam
Copy link

Same here :(

33614@LAPTOP-9FSG2200 MINGW64 /c/git/njre (main)
$ cjstoesm --import-assertions false  **/*.*
C:\Users\33614\AppData\Roaming\npm\node_modules\cjstoesm\node_modules\typescript\lib\typescript.js:119075
    Debug.fail(`Unhandled SyntaxKind: ${Debug.formatSyntaxKind(node.kind)}.`);
          ^

Error: Debug Failure. Unhandled SyntaxKind: ImportClause.
    at pipelineEmitWithHintWorker (C:\Users\33614\AppData\Roaming\npm\node_modules\cjstoesm\node_modules\typescript\lib\typescript.js:119075:11)
    at pipelineEmitWithHint (C:\Users\33614\AppData\Roaming\npm\node_modules\cjstoesm\node_modules\typescript\lib\typescript.js:118634:7)
    at pipelineEmitWithComments (C:\Users\33614\AppData\Roaming\npm\node_modules\cjstoesm\node_modules\typescript\lib\typescript.js:122279:5)
    at pipelineEmit (C:\Users\33614\AppData\Roaming\npm\node_modules\cjstoesm\node_modules\typescript\lib\typescript.js:118583:5)
    at emitExpression (C:\Users\33614\AppData\Roaming\npm\node_modules\cjstoesm\node_modules\typescript\lib\typescript.js:118567:5)
    at emitImportDeclaration (C:\Users\33614\AppData\Roaming\npm\node_modules\cjstoesm\node_modules\typescript\lib\typescript.js:120520:5)
    at pipelineEmitWithHintWorker (C:\Users\33614\AppData\Roaming\npm\node_modules\cjstoesm\node_modules\typescript\lib\typescript.js:118831:18)
    at pipelineEmitWithHint (C:\Users\33614\AppData\Roaming\npm\node_modules\cjstoesm\node_modules\typescript\lib\typescript.js:118634:7)
    at pipelineEmitWithComments (C:\Users\33614\AppData\Roaming\npm\node_modules\cjstoesm\node_modules\typescript\lib\typescript.js:122279:5)
    at pipelineEmit (C:\Users\33614\AppData\Roaming\npm\node_modules\cjstoesm\node_modules\typescript\lib\typescript.js:118583:5)

Node.js v18.18.2

33614@LAPTOP-9FSG2200 MINGW64 /c/git/njre (main)
$ tsc -v
Version 5.2.2

@aleclarson
Copy link

I've found success with this package by @ph-fritsche.

pnpm install cjstoesm@npm:@ph.fritsche/cjstoesm@2.1.3-alpha.1

@abauzac
Copy link

abauzac commented Oct 24, 2024

This worked for me :
npx -p typescript@4.9.5 -p cjstoesm cjstoesm test/**

@wessberg
Copy link
Owner

Hi everyone.

With v3.0.0, cjstoesm is now fully compatible with all TypeScript versions between 3.2 and 5.6!

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
9 participants