deepkit-framework icon indicating copy to clipboard operation
deepkit-framework copied to clipboard

Incompatible with Typescript 4.8+

Open adam-coster opened this issue 3 years ago • 1 comments

Typescript 4.8 has is in Beta/RC and will be fully live soon, and 4.9 is in active dev.

I tried to use @deepkit/type in projects where I'm using Typescript 4.8.1-rc, and found that tsc fails. After experiments, I found that:

  1. For a single file that has only the content type a = string;:
    • ✅ Typescript 4.7.4: Works as expected
    • ✅ Typescript 4.8.1-rc.1: Works as expected
    • ✅ Typescript 4.9.0-dev.20220819: Works as expected
  2. Once that type is exported (changing the file content to export type a = string;):
    • ✅ Typescript 4.7.4: Works as expected
    • ❌ Typescript 4.8.1-rc.1: Error: Debug Failure. Unhandled SyntaxKind: 273.
    • ❌ Typescript 4.9.0-dev.20220819: Error: Debug Failure. Unhandled SyntaxKind: 273.
  3. Confirmed that the above are true when using either npm or pnpm

I got the full error stack, but I can't see anything of any obvious value.

The command: $ NODE_OPTIONS='--stack-trace-limit=10000' node.exe node_modules/typescript/lib/tsc.js

The stack trace:

node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:98429
                throw e;
                ^

Error: Debug Failure. Unhandled SyntaxKind: 273.
    at pipelineEmitWithHintWorker (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:93024:22)
    at pipelineEmitWithHint (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:92590:17)
    at pipelineEmitWithSourceMaps (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:96207:13)
    at pipelineEmitWithComments (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:95912:13)
    at pipelineEmit (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:92534:13)
    at emitExpression (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:92518:13)
    at emitExportDeclaration (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:94407:17)
    at pipelineEmitWithHintWorker (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:92791:32)
    at pipelineEmitWithHint (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:92590:17)
    at pipelineEmitWithSourceMaps (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:96207:13)
    at pipelineEmitWithComments (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:95912:13)
    at pipelineEmit (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:92534:13)
    at emit (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:92507:13)
    at emitListItemWithParenthesizerRule (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:96337:9)
    at emitNodeListItems (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:95275:17)
    at emitNodeList (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:95213:17)
    at emitList (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:95179:13)
    at emitSourceFileWorker (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:94880:13)
    at emitBodyWithDetachedComments (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:96018:17)
    at emitSourceFile (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:94799:17)
    at pipelineEmitWithHintWorker (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:92604:24)
    at pipelineEmitWithHint (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:92590:17)
    at noEmitNotification (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:91202:9)
    at onEmitNode (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:79299:13)
    at onEmitNode (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:80396:13)
    at onEmitNode (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:89325:17)
    at onEmitNode (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:89392:24)
    at emitNodeWithNotification (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:91324:21)
    at pipelineEmitWithNotification (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:92579:13)
    at pipelineEmit (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:92534:13)
    at print (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:92470:13)
    at Object.writeFile (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:92454:13)
    at printSourceFileOrBundle (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:91961:25)
    at emitJsFileOrBundle (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:91874:13)
    at emitSourceFileOrBundle (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:91802:13)
    at forEachEmittedFile (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:91560:34)
    at Object.emitFiles (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:91783:9)
    at emitWorker (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:98355:33)
    at node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:98340:72
    at runWithCancellationToken (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:98423:24)
    at Object.emit (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:98340:26)
    at emitFilesAndReportErrors (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:103453:23)
    at Object.emitFilesAndReportErrorsAndGetExitStatus (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:103476:18)
    at performCompilation (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:106628:29)
    at executeCommandLineWorker (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:106512:17)
    at Object.executeCommandLine (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:106557:20)
    at Object.<anonymous> (node_modules\.pnpm\[email protected]\node_modules\typescript\lib\tsc.js:106852:4)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

adam-coster avatar Aug 22 '22 20:08 adam-coster

This seems to be an issue with TypeScript, not replated to DeepKit as I see it elsewhere in search results. Try allowJs if you're not importing js files.

NexZhu avatar Aug 27 '22 04:08 NexZhu

same problem.

MatrixAge avatar Sep 27 '22 18:09 MatrixAge

Same, sticking with 4.7.4 for now

NexZhu avatar Sep 29 '22 09:09 NexZhu

I got a similar issue using TypeScript 4.8.4:

$ tsc
/Users/user/src/personal/deepkit-test/node_modules/typescript/lib/tsc.js:98459
                throw e;
                ^

Error: Debug Failure. False expression.
    at onBeforeVisitNode (/Users/user/src/personal/deepkit-test/node_modules/typescript/lib/tsc.js:78257:34)
    at saveStateAndInvoke (/Users/user/src/personal/deepkit-test/node_modules/typescript/lib/tsc.js:78230:13)
    at sourceElementVisitor (/Users/user/src/personal/deepkit-test/node_modules/typescript/lib/tsc.js:78272:20)
    at visitArrayWorker (/Users/user/src/personal/deepkit-test/node_modules/typescript/lib/tsc.js:76222:48)
    at visitNodes (/Users/user/src/personal/deepkit-test/node_modules/typescript/lib/tsc.js:76191:23)
    at Object.visitLexicalEnvironment (/Users/user/src/personal/deepkit-test/node_modules/typescript/lib/tsc.js:76247:22)
    at visitSourceFile (/Users/user/src/personal/deepkit-test/node_modules/typescript/lib/tsc.js:78491:54)
    at saveStateAndInvoke (/Users/user/src/personal/deepkit-test/node_modules/typescript/lib/tsc.js:78231:27)
    at transformSourceFile (/Users/user/src/personal/deepkit-test/node_modules/typescript/lib/tsc.js:78221:27)
    at transformSourceFileOrBundle (/Users/user/src/personal/deepkit-test/node_modules/typescript/lib/tsc.js:78206:20)
error Command failed with exit code 1.

treykasada avatar Sep 30 '22 06:09 treykasada

@marcj Hi, now that TypeScript 4.9 will be released soon, I wonder what's the plan of supporting TypeScript 4.8 or maybe directly 4.9?

NexZhu avatar Oct 16 '22 07:10 NexZhu

TypeScript: 4.8.4

Trying to run ./app.ts results:

/node_modules/typescript/lib/typescript.js:43193:

ts.Debug.assert(typeof typeReferenceDirectiveName === "string", "Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.");
Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.
    at Object.resolveTypeReferenceDirective (/Volumes/Projects/sample-structured-data/node_modules/typescript/lib/typescript.js:43193:18)
    at /usr/local/lib/node_modules/ts-node/src/resolver-functions.ts:131:51
    at Array.map (<anonymous>)
    at Object.resolveTypeReferenceDirectives (/usr/local/lib/node_modules/ts-node/src/resolver-functions.ts:130:31)
    at actualResolveTypeReferenceDirectiveNamesWorker (/Volumes/Projects/sample-structured-data/node_modules/typescript/lib/typescript.js:118277:163)
    at resolveTypeReferenceDirectiveNamesWorker (/Volumes/Projects/sample-structured-data/node_modules/typescript/lib/typescript.js:118577:26)
    at processTypeReferenceDirectives (/Volumes/Projects/sample-structured-data/node_modules/typescript/lib/typescript.js:120074:31)
    at findSourceFileWorker (/Volumes/Projects/sample-structured-data/node_modules/typescript/lib/typescript.js:119959:21)
    at findSourceFile (/Volumes/Projects/sample-structured-data/node_modules/typescript/lib/typescript.js:119811:26)
    at processImportedModules (/Volumes/Projects/sample-structured-data/node_modules/typescript/lib/typescript.js:120220:25)

markadrake avatar Oct 22 '22 16:10 markadrake

@NexZhu Angular doesn't support yet TypeScript v4.8, so we have to wait until they release it. Should be in a couple of days, but the main issues described in this issue are already fixed in Deepkit, so we will follow with a release soon after that too

marcj avatar Oct 24 '22 07:10 marcj

Good to know. If i'm guessing correctly, Angular should only block the web-based debugger and DB inspector though? Maybe other modules can be independently published.

NexZhu avatar Oct 24 '22 10:10 NexZhu

Maybe other modules can be independently published.

they could, but that would increase the maintainability costs enormously with almost no advantage. Supporting very early the newest TypeScript version has almost no advantage for Deepkit, especially when it means older TypeScript version can not be used anymore. The smallest user group is the one that switched to a completely new TS version within the first few weeks.

Unfortunately TypeScript v4.8 had really dirty breaking changes so I hope this was an outliner in terms of how long it took to support it.

marcj avatar Oct 24 '22 11:10 marcj

I've just created a NX monorepo typescript ~4.8.2 and angular 15 is the default

colorcube avatar Nov 23 '22 11:11 colorcube

This is fixed in master and will be released soon

marcj avatar Dec 02 '22 07:12 marcj