-
Notifications
You must be signed in to change notification settings - Fork 12.8k
tsc 2.5.1 crashes with error: TypeError: Cannot read property '240' of undefined. #17982
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
Comments
can you share a sample that causes this to happen? |
So I can guess that this change is due to changes made in #16766, however I am unsure what, exactly to do to reproduce this. As far as I can tell, only difference is that when @svstanev, if you can't get a repro (although that'd be really helpful), could you try this branch from this PR (or do you need a built version)? I certainly can't guarantee that we won't regress this again, if that does fix it, without some kind of reproduction in our test suite, though. |
I finally managed to reproduce the problem: a module (b.ts) is imported into a variable ( Either way it would be great if the compiler can handle this case appropriately -- report the exact error (name already exists) or compile the code as in the previous version. @weswigham, I hope you can better explain what's going on and how should tsc handle cases like this. Here is how to reproduce the problem: a.ts
b.ts (the content of this module is not important - you just need a second module to import into module a)
|
A few more things:
IMO, it's clearly an ambiguous use of the same name (as opposite of a partial definition of one thing like the partial classes in C# for example) and the compiler should complain about it (compile time error). Either way the language service should be alined with the compiler behavior. I hope this helps. |
Hi! I have similar problem (with '239' instead of '240') is there a way to extract some debug info from the compiler to track down the problematic files? |
Hi @Katona,
assuming you're in the project's root folder (where For more info: HTH |
The problem appears to be invoking the
getDeclarationSpaces
(tsc.js:33049) function with a node of kind240
(NamespaceImport
). For some reason thets.SyntaxKind
enum is missing thus the error. In this case (d.kind === 240
) the default switch clause is triggered which either way appears to be an error. The same source code compiles just fine withtsc
v2.4.2 though. At first glance thegetDeclarationSpaces
function seems to be changed in the latest version while the node its been called with appears pretty much the same.As of now I have no clue which part of my source code is related to problem. What I've found so far is that the error appears while processing a .ts source file that has these two imports:
and the node in question (NamespaceImport) has a symbol named 'Signal' so I can only guess that the issue may have be related to the 2nd line from the snippet above.
TypeScript Version: 2.5.1
Code
tsc.js v2.5.1:
Expected behavior:
Actual behavior:
The text was updated successfully, but these errors were encountered: