Open calebpitan opened 1 year ago
We'd need a way to reproduce the problem. Do you have a repo we can clone, or other way to produce this crash?
To help narrow it down, you might be able to modify your tsc.js
at /Users/calebpitan/source/work/zendwa/emailing-service/node_modules/typescript/lib/tsc.js
symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) {
+ console.log("FILE NAME", ts.getSourceFileOfNode(enclosingDeclaration).fileName);
return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); });
},
It starts at line 44125 in TypeScript 4.9.5's tsc.js
.
Thanks to @DanielRosenwasser "debug snippet" which seems to have pointed me in the right direction, and did help narrow it down just as he mentioned. I inserted a console statement on that line and it was able to log the filenames till it crashed again. I inspected the last logged file before crash and found out it imported files that imported uninstalled modules/deps.
Instaliing the missing module fixed it and tsc
could build successfully.
But this doesn't mean there's no problem. The problem is: the compiler couldn't resolve a specifier, why couldn't it just say so in an understandable, helpful error message, rather than an elusive jargon like "Error: Debug Failure. False expression."?
first(array) {
ts.Debug.assert(array.length !== 0);
return array[0];
}
It seems, apparently, the only thing that makes this array empty is an unresolved module specifier, if so, the Debug.assert
could make room for a custom error message rather than a generic "Debug Failure. False expression"
But this doesn't mean there's no problem. The problem is: the compiler couldn't resolve a specifier, why couldn't it just say so in an understandable, helpful error message, rather than an elusive jargon like "Error: Debug Failure. False expression."?
The message is cryptic because it's intended for TS developers, not end-users. A debug assert being hit means the compiler has done something that, if it were functioning correctly, would literally never happen (in this case calling first()
with an empty array); it always indicates a bug that has to be fixed elsewhere. In this case, it sounds like there might be a missing check during module specifier resolution.
In other words: "Debug Failure" is a crash, not an expected error condition.
I got this same error.
Specifically, it seems like I had @types/gopd
installed, and then also made a types/gopd/index.d.ts
, in which I provided my own definition that uses export =
. @RyanCavanaugh can you reproduce it with that approach?
Note that it does not crash when my overload uses export default
, but every CJS module's type is export =
so I need to use that.
I tried briefly, but haven't gotten far. Can you do the same thing I told @calebpitan to try above and see if you can provide a pared down version of that file? A pared-down config file is going to be helpful too.
@DanielRosenwasser when i apply that console log diff (which is slightly tricker in TS 5 beta), it's never hit - the line it dies on is Debug.assert(node.kind !== 257 /* VariableDeclaration */);
inside checkAliasSymbol
, and when i add a console.log(node)
in front of it, i get:
Happy to debug live elsewhere, or with comments here, since it's consistently reproducible for me - just not in a branch i'm ready to share publicly.
Config file:
That seems like a separate stack trace then, right? If so, what is the stack trace? And can you switch the console.log(node)
to console.log("FILE NAME", ts.getSourceFileOfNode(enclosingDeclaration).fileName);
?
I can't, because ts
is not defined in that function.
Stack trace:
$PWD/node_modules/typescript/lib/tsc.js:113967
throw e;
^
Error: Debug Failure. False expression.
at checkAliasSymbol ($PWD/node_modules/typescript/lib/tsc.js:78641:17)
at checkVariableLikeDeclaration ($PWD/node_modules/typescript/lib/tsc.js:76204:7)
at checkVariableDeclaration (/$PWD/node_modules/typescript/lib/tsc.js:76287:5)
at checkSourceElementWorker ($PWD/node_modules/typescript/lib/tsc.js:79258:16)
at checkSourceElement ($PWD/node_modules/typescript/lib/tsc.js:79089:7)
at forEach ($PWD/node_modules/typescript/lib/tsc.js:37:22)
at checkVariableStatement ($PWD/node_modules/typescript/lib/tsc.js:76297:5)
at checkSourceElementWorker ($PWD/node_modules/typescript/lib/tsc.js:79227:16)
at checkSourceElement ($PWD/node_modules/typescript/lib/tsc.js:79089:7)
at forEach ($PWD/node_modules/typescript/lib/tsc.js:37:22)
Node.js v19.6.1
@DanielRosenwasser actually turns out i was authoring my "declare module" incorrectly - i was doing type x = whatever
instead of function x
, and the export =
with the type
was what was crashing. Hope that helps :-)
This is happening to me on version 5.3.3 of TypeScript.
I'm going to try 5.4.5 to see if this is resolved.
@divmgl that seems like an unrelated stack trace. Feel free to open a separate issue if you can provide a repro on the latest version of TS.
I'm getting this too after updating from 5.2.2
to 5.6.2
. Similar to others reporting this, I have allowJs: true
set.
@zigcccc could you prepare a repro case of the problem? you could try to remove as much lines from your project as possible (gradually) and bisect the problem this way to the minimal repro case
Bug Report
🔎 Search Terms
debug failure, false expression, at object.first
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
stack trace:
source: node_modules/typescript/lib/tsc.js
tsconfig.json:
🙁 Actual behavior
Error happens when I turn on
allowJs
🙂 Expected behavior
allowJs
shouldn't crash build process and should include the js files from the source in the build output 😔