cli/tsc crashes with Uncaught TypeError

Using latest Deno (1.32.4), this only happens on certain files, but it effectively means that I cannot do type checking with Deno now. The error (somewhat opaque since this looks like generated code):
error: Uncaught TypeError: Cannot read properties of undefined (reading 'kind')
at <anonymous> (internal:deno_tsc/tsc/00_typescript.js:19111:18)
error: Uncaught TypeError: Cannot read properties of undefined (reading 'kind')
at <anonymous> (internal:deno_tsc/tsc/00_typescript.js:19111:18)
2 Replies
Patrick (he/him)
Patrick (he/him)OP2y ago
appears to be happening on the first line of this function:
function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) {
if (node.kind >= 0 /* FirstToken */ && node.kind <= 162 /* LastToken */) {
return 0 /* None */;
}
if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) {
node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */;
}
if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) {
node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */;
}
return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */);
}
function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) {
if (node.kind >= 0 /* FirstToken */ && node.kind <= 162 /* LastToken */) {
return 0 /* None */;
}
if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) {
node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */;
}
if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) {
node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */;
}
return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */);
}
it's probably some syntax error in my code at the moment that's causing the crash. If I git stash the error goes away ok I figured it out. Seems like it is a bug in the cli/tsc code. If I use Parameters<typeof someValue["someProperty"]>[1] in a function's parameters, it crashes. However, if I assign that type to a type alias (e.g. type Param1 = Parameters<typeof someValue["someProperty"]>[1]) then use that alias in the function's parameters, no crash. Not too bad, makes my code more readable anyway.
lcasdev
lcasdev2y ago
Can you share the project this is happening in? cc @dsherret Oh I see you figured it out already. May be worth opening an issue in the TypeScript repo