I have a private repo that fails to compile on 2.7.1 and 2.8.0-dev.20180213.
It is compiling fine on 2.6.1.
The only thing special in this repo is that it has allowJs turned on.
error on 2.7.1
> tsc -p tsconfig.es5.json
D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:59841
throw e;
^
TypeError: Cannot read property '230' of undefined
at getTypeOfVariableOrParameterOrProperty (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:22960:81)
at getTypeOfSymbol (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:23122:24)
at checkPropertyAccessExpressionOrQualifiedName (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:31751:55)
at checkPropertyAccessExpression (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:31706:20)
at checkExpressionWorker (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:34360:28)
at checkExpression (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:34310:42)
at getBaseConstructorTypeOfClass (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:23272:43)
at getBaseTypeVariableOfClass (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:23043:39)
at getTypeOfFuncClassEnumModule (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:23055:48)
at getTypeOfSymbol (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:23125:24)
error on 2.8.0-dev.20180213
D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:60503
throw e;
^
TypeError: Cannot read property '233' of undefined
at Object.showSyntaxKind (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:2413:33)
at getTypeOfVariableOrParameterOrProperty (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:23146:77)
at getTypeOfSymbol (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:23308:24)
at checkPropertyAccessExpressionOrQualifiedName (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:32265:55)
at checkPropertyAccessExpression (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:32220:20)
at checkExpressionWorker (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:34872:28)
at checkExpression (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:34822:42)
at getBaseConstructorTypeOfClass (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:23462:43)
at getBaseTypeVariableOfClass (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:23229:39)
at getTypeOfFuncClassEnumModule (D:\hwong\bitbucket\pan\extjs3\node_modules\typescript\lib\tsc.js:23241:48)
It does seems to be related to allowJs.
Once I take that off, it compiles (but of course fails later on as I do need the JS files).
The error seems to come from here (for 2.7.1):
ts.Debug.fail("Unhandled declaration kind! " + ts.SyntaxKind[declaration.kind]);
Where the ts.SyntaxKind is undefined.
233 seems to be ClassDeclaration if I'm not mistaken.
> ts.SyntaxKind[233]
'ClassDeclaration'
> ts.version
'2.8.0-dev.20180213'
This one is probably my fault (#21837). It looks like in tsserver.js we preserve const enums, but not for tsc.js. So ts.SyntaxKind will be undefined when using the compiler from the command line.
We could just fall back to printing the kind as a number is SyntaxKind is undefined.
@unional Note that my PR won't fix your actual issue, which is that we somehow get a ClassDeclaration in getTypeOfVariableOrParameterOrProperty. A code sample that reproduces that error would be appreciated.
It is hard to reproduce in this case, because it is private code and a big one.
If you can fix the error then I can try to run again and report my findings.
I seem to be getting the same issue. Works in 2.5.3, but breaks in TS 2.7.2 and 2.6
It fails on this line:
ts.Debug.fail(ts.SyntaxKind[d.kind]);
Stack trace: TS 2.7.2
/Users/jason/projects/cSpell-Tools/node_modules/typescript/lib/tsc.js:59957
throw e;
^
TypeError: Cannot read property '269' of undefined
at getDeclarationSpaces (/Users/jason/projects/cSpell-Tools/node_modules/typescript/lib/tsc.js:35312:52)
at /Users/jason/projects/cSpell-Tools/node_modules/typescript/lib/tsc.js:35304:84
at Object.forEach (/Users/jason/projects/cSpell-Tools/node_modules/typescript/lib/tsc.js:260:30)
at getDeclarationSpaces (/Users/jason/projects/cSpell-Tools/node_modules/typescript/lib/tsc.js:35304:28)
at checkExportsOnMergedDeclarations (/Users/jason/projects/cSpell-Tools/node_modules/typescript/lib/tsc.js:35256:41)
at checkInterfaceDeclaration (/Users/jason/projects/cSpell-Tools/node_modules/typescript/lib/tsc.js:37101:17)
at checkSourceElement (/Users/jason/projects/cSpell-Tools/node_modules/typescript/lib/tsc.js:37865:28)
at Object.forEach (/Users/jason/projects/cSpell-Tools/node_modules/typescript/lib/tsc.js:260:30)
at checkSourceFileWorker (/Users/jason/projects/cSpell-Tools/node_modules/typescript/lib/tsc.js:37975:20)
at checkSourceFile (/Users/jason/projects/cSpell-Tools/node_modules/typescript/lib/tsc.js:37959:13)
How to reproduce:
npm install
npm run build # this will work
npm install -SD [email protected]
npm run build # this will fail
@andy-ms I believe I have a repo case for you. See above steps.
@Jason3S installing typescript@next in that repository fixes the error.
Most helpful comment
@Jason3S installing
typescript@nextin that repository fixes the error.