Skip to content

JSDoc @return, @template tags crash tsc even with --checkJs=false #42812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
freshp86 opened this issue Feb 15, 2021 · 0 comments · Fixed by #42851
Closed

JSDoc @return, @template tags crash tsc even with --checkJs=false #42812

freshp86 opened this issue Feb 15, 2021 · 0 comments · Fixed by #42851
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@freshp86
Copy link

freshp86 commented Feb 15, 2021

Bug Report

🔎 Search Terms

TypeError: Cannot read property 'flags' of undefined

🕗 Version & Regression Information

  • This is a crash that was introduced after version 3.8.3 and before (or on) version 3.9.9. Also crashes on latest version 4.1.5.

⏯ Playground Link

Playground link with relevant code

See crash in DevTools console

💻 Code

Contents of repro.js. Note: removed a lot of code from actual production code (in @polymer/polymer), to create a minimal repro.

/** @return {T} */
const dedupingMixin = function(mixin) {};

 /** @template {T} */
const PropertyAccessors = dedupingMixin(() => {
  class Bar {
    static bar() { this.prototype.foo(); }
  }
});

Repro with the following command

tsc repro.js --allowJs --outDir temp

🙁 Actual behavior

tsc crashes with the following stack trace

/private/tmp/debug_tsc/node_modules/typescript/lib/tsc.js:82931
                throw e;
                ^

TypeError: Cannot read property 'flags' of undefined
    at lookupSymbolChainWorker (/private/tmp/debug_tsc/node_modules/typescript/lib/tsc.js:32382:46)
    at lookupSymbolChain (/private/tmp/debug_tsc/node_modules/typescript/lib/tsc.js:32378:24)
    at symbolToTypeNode (/private/tmp/debug_tsc/node_modules/typescript/lib/tsc.js:32529:29)
    at typeReferenceToTypeNode (/private/tmp/debug_tsc/node_modules/typescript/lib/tsc.js:32019:47)
    at typeToTypeNodeHelper (/private/tmp/debug_tsc/node_modules/typescript/lib/tsc.js:31767:95)
    at /private/tmp/debug_tsc/node_modules/typescript/lib/tsc.js:31584:106
    at withContext (/private/tmp/debug_tsc/node_modules/typescript/lib/tsc.js:31633:37)
    at Object.typeToTypeNode (/private/tmp/debug_tsc/node_modules/typescript/lib/tsc.js:31584:28)
    at typeToString (/private/tmp/debug_tsc/node_modules/typescript/lib/tsc.js:31551:40)
    at reportNonexistentProperty (/private/tmp/debug_tsc/node_modules/typescript/lib/tsc.js:47826:209)

Note that removing either the @return or the @template JSDoc tags causes the crash to go away.

🙂 Expected behavior

Typescript compiler should not crash. Moreover, it crashes even with the --checkJs false flag.

Note: Found another similar, but not identical issue at #29570.

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Feb 16, 2021
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.3.0 milestone Feb 16, 2021
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants