Skip to content

JSDOC tag @type crashes tsc #29570

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
attila-kun opened this issue Jan 24, 2019 · 1 comment
Closed

JSDOC tag @type crashes tsc #29570

attila-kun opened this issue Jan 24, 2019 · 1 comment
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Domain: JSDoc Relates to JSDoc parsing and type generation
Milestone

Comments

@attila-kun
Copy link

TypeScript Version: 3.3.0-dev.20190124

Search Terms:

  • tsc jsdoc crash
  • TypeError: Cannot read property 'flags' of undefined

Code

This snippet crashes the compiler:

function Foo() { }
/** @type {{}} **/
Foo.Bar = null;

Stack trace:

> ./node_modules/typescript/bin/tsc crash.ts

/home/attila/dev/projects/temp/2019-01-24/tsc-jsdoc-crash/node_modules/typescript/lib/tsc.js:71419
                throw e;
                ^

TypeError: Cannot read property 'flags' of undefined
    at getMembersOfSymbol (/home/attila/dev/projects/temp/2019-01-24/tsc-jsdoc-crash/node_modules/typescript/lib/tsc.js:30458:27)
    at getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode (/home/attila/dev/projects/temp/2019-01-24/tsc-jsdoc-crash/node_modules/typescript/lib/tsc.js:33423:21)
    at getTypeFromTypeNode (/home/attila/dev/projects/temp/2019-01-24/tsc-jsdoc-crash/node_modules/typescript/lib/tsc.js:33702:28)
    at getJSDocTypeFromAssignmentDeclaration (/home/attila/dev/projects/temp/2019-01-24/tsc-jsdoc-crash/node_modules/typescript/lib/tsc.js:29309:43)
    at getWidenedTypeFromAssignmentDeclaration (/home/attila/dev/projects/temp/2019-01-24/tsc-jsdoc-crash/node_modules/typescript/lib/tsc.js:29260:33)
    at getTypeOfVariableOrParameterOrPropertyWorker (/home/attila/dev/projects/temp/2019-01-24/tsc-jsdoc-crash/node_modules/typescript/lib/tsc.js:29557:21)
    at getTypeOfVariableOrParameterOrProperty (/home/attila/dev/projects/temp/2019-01-24/tsc-jsdoc-crash/node_modules/typescript/lib/tsc.js:29502:48)
    at getTypeOfSymbol (/home/attila/dev/projects/temp/2019-01-24/tsc-jsdoc-crash/node_modules/typescript/lib/tsc.js:29777:24)
    at checkPropertyAccessExpressionOrQualifiedName (/home/attila/dev/projects/temp/2019-01-24/tsc-jsdoc-crash/node_modules/typescript/lib/tsc.js:40629:53)
    at checkPropertyAccessExpression (/home/attila/dev/projects/temp/2019-01-24/tsc-jsdoc-crash/node_modules/typescript/lib/tsc.js:40581:20)

A self contained demonstration can be found here: https://github.com/attila-kun/tsc-jsdoc-crash
Or on the Playground (observe exception in the console): https://www.typescriptlang.org/play/#src=function%20Foo()%20%7B%20%7D%0D%0A%2F**%20%40type%20%7B%7B%7D%7D%20**%2F%0D%0AFoo.Bar%20%3D%20null%3B

Expected behavior:
No crash.

Actual behavior:
tsc crashes.

Related Issues:
#17383
#25264

@weswigham weswigham added Bug A bug in TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output labels Jan 29, 2019
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 14, 2019
@TimvdLippe
Copy link
Contributor

This no longer seems to crash on TypeScript 4.0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Domain: JSDoc Relates to JSDoc parsing and type generation
Projects
None yet
Development

No branches or pull requests

4 participants