Skip to content

"Debug Failure. False expression." when using default export from js fileΒ #60692

Closed
@literalpie

Description

@literalpie

πŸ”Ž Search Terms

debug failure false expression export default composite allowjs js

πŸ•— Version & Regression Information

  • This changed between versions 5.6.2 and 5.7.2

⏯ Playground Link

https://stackblitz.com/edit/ts-false-expression-tqxlxy?file=tsconfig.json,package.json

πŸ’» Code

// In a JS file
export default console; 

The error also seems to happen if you replace console with anything from globalThis (screen, scroll, fetch, etc.)

TSConfig.json:

    "composite": true,
    "allowJs": true,

πŸ™ Actual behavior

Running tsc results in this error:

> tsc

Error: Debug Failure. False expression.
    at Object.isUndefinedIdentifierExpression (/home/projects/ts-false-expression-tqxlxy/node_modules/typescript/lib/_tsc.js:50211:15)
    at typeFromExpression (/home/projects/ts-false-expression-tqxlxy/node_modules/typescript/lib/_tsc.js:132377:22)
    at serializeTypeOfExpression (/home/projects/ts-false-expression-tqxlxy/node_modules/typescript/lib/_tsc.js:132107:20)
    at Object.serializeTypeOfDeclaration (/home/projects/ts-false-expression-tqxlxy/node_modules/typescript/lib/_tsc.js:132131:16)
    at serializeTypeForDeclaration (/home/projects/ts-false-expression-tqxlxy/node_modules/typescript/lib/_tsc.js:52640:41)
    at serializeMaybeAliasAssignment (/home/projects/ts-false-expression-tqxlxy/node_modules/typescript/lib/_tsc.js:54015:19)
    at serializeAsAlias (/home/projects/ts-false-expression-tqxlxy/node_modules/typescript/lib/_tsc.js:53899:13)
    at serializeSymbolWorker (/home/projects/ts-false-expression-tqxlxy/node_modules/typescript/lib/_tsc.js:53255:11)
    at serializeSymbol (/home/projects/ts-false-expression-tqxlxy/node_modules/typescript/lib/_tsc.js:53119:11)
    at eval (/home/projects/ts-false-expression-tqxlxy/node_modules/typescript/lib/_tsc.js:53089:11)

Node.js v18.20.3

πŸ™‚ 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:

const thing = console;
export default thing;

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions