Running tsc on a project which allows JS files and it has a JS file with a @typedef comment crashes the compiler.
The actual project is a lot bigger and I also encountered the following error:
TypeError: Cannot read property 'kind' of undefined
at isIdentifierThatStartsWithUnderScore (node_modules/typescript/lib/typescript.js:44501:24)
at errorUnusedLocal (node_modules/typescript/lib/typescript.js:44487:17)
at node_modules/typescript/lib/typescript.js:44551:33
at Map.forEach (native)
at checkUnusedModuleMembers (node_modules/typescript/lib/typescript.js:44546:29)
at checkUnusedIdentifiers (node_modules/typescript/lib/typescript.js:44417:29)
at checkSourceFileWorker (node_modules/typescript/lib/typescript.js:46868:21)
at checkSourceFile (node_modules/typescript/lib/typescript.js:46842:13)
at Object.forEach (node_modules/typescript/lib/typescript.js:1506:30)
at getDiagnosticsWorker (node_modules/typescript/lib/typescript.js:46924:16)
Removing the @typedef from the comment fixes the compiler crash as well.
Apart from the minimal reproducible case, I encountered the actual crash on the following snippet:
/**
* @typedef {{
* _templatizerTemplate: HTMLTemplateElement,
* _parentModel: boolean,
* _instanceProps: Object,
* _forwardHostPropV2: Function,
* _notifyInstancePropV2: Function,
* ctor: TemplateInstanceBase
* }}
*/
let TemplatizerUser; // eslint-disable-line
TypeScript Version: 2.4.2
Code
src/index.ts
src/export.js
/**
* @typedef {{
* }}
*/
export const foo = 5;
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"lib": [
"es2016",
"esnext.asynciterable",
"dom"
],
"allowJs": true,
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitAny": true,
"removeComments": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": false,
"strict": true,
"strictNullChecks": false,
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/**/*"
]
}
Expected behavior:
No compiler crash.
Actual behavior:
TypeError: Cannot read property 'end' of undefined
at getFullWidth (/global/node_modules/typescript/lib/tsc.js:5106:20)
at Object.declarationNameToString (/global/node_modules/typescript/lib/tsc.js:5400:16)
at checkExportsOnMergedDeclarations (/global/node_modules/typescript/lib/tsc.js:36417:138)
at checkVariableLikeDeclaration (/global/node_modules/typescript/lib/tsc.js:37184:17)
at checkVariableDeclaration (/global/node_modules/typescript/lib/tsc.js:37213:20)
at checkSourceElement (/global/node_modules/typescript/lib/tsc.js:38763:28)
at Object.forEach (/global/node_modules/typescript/lib/tsc.js:298:30)
at checkVariableStatement (/global/node_modules/typescript/lib/tsc.js:37221:16)
at checkSourceElement (/global/node_modules/typescript/lib/tsc.js:38732:28)
at Object.forEach (/global/node_modules/typescript/lib/tsc.js:298:30)
Running
tscon a project which allows JS files and it has a JS file with a@typedefcomment crashes the compiler.The actual project is a lot bigger and I also encountered the following error:
Removing the
@typedeffrom the comment fixes the compiler crash as well.Apart from the minimal reproducible case, I encountered the actual crash on the following snippet:
TypeScript Version: 2.4.2
Code
src/index.tssrc/export.jstsconfig.json{ "compilerOptions": { "target": "es6", "lib": [ "es2016", "esnext.asynciterable", "dom" ], "allowJs": true, "module": "commonjs", "moduleResolution": "node", "isolatedModules": false, "noUnusedLocals": true, "noUnusedParameters": true, "noImplicitAny": true, "removeComments": false, "preserveConstEnums": true, "suppressImplicitAnyIndexErrors": false, "strict": true, "strictNullChecks": false, "outDir": "lib", "rootDir": "src" }, "include": [ "src/**/*" ] }Expected behavior:
No compiler crash.
Actual behavior: