-
Notifications
You must be signed in to change notification settings - Fork 12.8k
tsc crashes with typescript@>4.0.0 #40239
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
Thanks for the debugging on this! |
Edit: Nevermind, I can reproduce this in dozens of other places. Well, after some digging with try/catch and It seems it has something to do with dynamic import and Reproduction: https://github.com/anilanar/tscbug
|
Here's a standalone repro: // @esModuleInterop: true
// @file:empty-export.d.ts
export {}
// @file:index.ts
declare function mock<M>(_: M): {} & M;
mock(await import('./empty-export')) Edit: For me, I had to turn ON esModuleInterop. Here's the command line I'm using:
This was true for the tscbug repo as well. |
The type is the shim type created for a module by esModuleInterop. It has an export named 'default' that's an alias for the I'm not sure whether the shim type's symbol shouldn't be used anywhere, or whether the mapped type instantiation should be dereferencing or ignoring the shim, or whether the shim needs to better stand in for a real type/symbol. @weswigham any ideas? |
PR that introduces this crash is #38673 |
Iirc, its marked as a literal because module objects get marked at literals so they can have inferred index signatures during assignment (since they're immutable). Honestly we should probably just err on the side of being better at handling a symbol without declarations more gracefully (the esmodule synthetic symbol is far from the only one without a declaration). |
When new version with this fix will be released? Faced this crash while upgrading monorepo with angular projects to ng10 and ts 4.0.2.. |
And FWIW, I'm still getting this on v4.0.3 |
@artaommahe @JackCA Please try |
That did the trick!
…On Thu, Sep 24, 2020 at 10:45 AM Anıl Anar ***@***.***> wrote:
@artaommahe <https://github.com/artaommahe> @JackCA
<https://github.com/JackCA> Please try beta which is prerelease 4.1.0.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#40239 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACIJZ7GNKSEPDWO2LD3FPLSHOASFANCNFSM4QKLHKSQ>
.
|
@anilanar cant use 4.1.x cause angular-cli 10.1.x does not support it. Also this issue marked as fixed by 4.0.3 (https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=milestone%3A%22TypeScript+4.0.3%22+is%3Aclosed+) but it's not, still crashing 😕 |
Maybe the info is relevant, but i also ran into this by adding the |
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 4.1.0-dev.20200824
Search Terms: tsc cannot read property 'length' of undefined getResolvedMembersOrExportsOfSymbol symbol.declarations
Problem
tsc
crashes after upgrading from3.9.6
to4.x
.Code
This problem happens after upgrading typescript on a project with 100k lines of code.
I don't have reproduction but I did my best to figure out what might be going wrong.
The crash stack trace:
So the crash happens in the first line of the following for loop, while trying to iterate
symbol.declarations
which is undefined:I modified
tsc.js
to place someconsole.log
statements. Right before the line that causes the crash:The result:
If I
console.log(symbol.type.propertires)
orsymbol.type.members
, I notice that it's pointing to@types/react-redux/index.d.ts
.It looks like it works when the for loop for
symbol.declarations
is wrapped with an if condition as below:If there's anything more I can help with, please let me know.
The text was updated successfully, but these errors were encountered: