Repository navigation
"Debug Failure. False expression." when using default export from js fileΒ #60692
Description
Activity
The playground can be set to Javascript, and does seem to get the same error: https://www.typescriptlang.org/play/?filetype=js#code/KYDwDg9gTgLgBAE2AMwIYFcA28DuBLAOwQhwG4AoIA
tsMode.js:8 Uncaught (in promise) Error: Debug Failure. False expression. at Object.isUndefinedIdentifierExpression (tsWorker.js:344:245998) at Z (tsWorker.js:362:12320) at h (tsWorker.js:362:8628) at Object._ [as serializeTypeOfDeclaration] (tsWorker.js:362:8889) at g0 (tsWorker.js:348:14998) at hM (tsWorker.js:351:9451) at y0 (tsWorker.js:351:8083) at jr (tsWorker.js:348:24089) at Vn (tsWorker.js:348:21713) at tsWorker.js:348:21375boneskull commented
on Feb 12, 2025 ContributorMore actionsvia bisect, I've determined the problem was introduced in #59282 and is likely in
src/compiler/expressionToTypeNode.tssomewhere. unfortunately, that's about as far as I can get. cc Titian Cernicova-Dragomir (@dragomirtitian)Reacted by Josh Holmerboneskull commented
on Feb 12, 2025 ContributorMore actionsOK, I lied, I got closer. The switch in
isExpressionNodeis failing here:TypeScript/src/compiler/utilities.ts
Lines 3604 to 3609 in 476e9ee
case SyntaxKind.Identifier: if (node.parent.kind === SyntaxKind.TypeQuery || isJSDocLinkLike(node.parent) || isJSDocNameReference(node.parent) || isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through Given:
export default baz
where
bazwas not defined anywhere in the module (so it must beglobalThis.baz), we find thatbazis anIdentifier, and its parent is anExportAssignment(default), so it does not returntruehere, and falls through to the bottom of theswitch, returningfalseand failing the assertion.I'm wondering if there will be a fix for this or should I start looking to change my own code to try to solve this? I am unable to upgrade because of this
Reacted by RubenPersonally, I did a workaround. It's pretty simple since it works as long as you set the value before you export it
// Change from: export default console; // To: const myConsole = console; export default myConsole;- added a commit that references this issue
on Mar 20, 2025 I had to patch the package in order to skip this check so that my bundler can work. It's not a good idea, though.
diff --git a/lib/typescript.js b/lib/typescript.js index dc0fe9a56bb4d9b08efe8b5948a60a74a4e9997b..3949bd42b5d2f120c1f1521de685164884ed1d7a 100755 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -55006,7 +55006,7 @@ function createTypeChecker(host) { }, isOptionalParameter, isUndefinedIdentifierExpression(node) { - Debug.assert(isExpressionNode(node)); + // Debug.assert(isExpressionNode(node)); // To get rid of: [!] (plugin typescript) Error: Debug Failure. False expression. return getSymbolAtLocation(node) === undefinedSymbol; }, isEntityNameVisible(context, entityName, shouldComputeAliasToMakeVisible) {
I'm getting the exact same error in my code. Also began in TS 5.7
Reacted by Yoojun Zhou, JC Brand, Robert Daly and Zellione- added a commit that references this issue
on Apr 24, 2025 boneskull commented
on Apr 24, 2025 ContributorMore actionsThis was fixed in #61582 by Andrew Branch (@andrewbranch). I can reproduce in v5.8.3, but not
main.Reacted by Jordan Harband and Benjamin KindleReacted by Andrew Branch- assigned and unassigned
on Apr 28, 2025 - locked as resolved and limited conversation to collaborators
on Oct 28, 2025
π Search Terms
debug failure false expression export default composite allowjs js
π Version & Regression Information
β― Playground Link
https://stackblitz.com/edit/ts-false-expression-tqxlxy?file=tsconfig.json,package.json
π» Code
The error also seems to happen if you replace
consolewith anything fromglobalThis(screen, scroll, fetch, etc.)TSConfig.json:
π Actual behavior
Running tsc results in this error:
π Expected behavior
No Error :-)
Additional information about the issue
I see this both locally and in stackblitz. I don't know how to reproduce in the playground because it only seems to happen when using a JS file.
This does not cause an error: