-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
tsc crash with "TypeError: Cannot read properties of undefined (reading 'flags')" #58371
Comments
It's close to impossible to fix an issue like this without a repro case. https://antfu.me/posts/why-reproductions-are-required |
Fair enough, I thought stacktrace gives enough hints. I'll try to narrow it down. |
This should be a pretty easy one to isolate based on seeing which nodes/types/symbols are in the preceding stack frames. |
Is there a way to dump it easily? Still going through picking changes from refactor pull request that introduced it (it's quarter of a million LoC project). |
I'd setup a breakpoint there, like this: function getCheckFlags(symbol) {
+ if (!symbol) { debugger; }
return symbol.flags & 33554432 ? symbol.links.checkFlags : 0;
} And when u get inevitably paused there you could look up the call stack, look through objects used there etc and try to narrow it down based on that information. |
I encountered the same error in my project, and I can provide the code to reproduce it. type T1 = "A" | "B"
type T2 = {
"C": [string]
"D": [number]
}
const commands: {
[K in T1 | keyof T2]: (...args: K extends keyof T2 ? T2[K] : []) => unknown
} = {
async A() { },
async B() { },
async C() { },
async D() { },
}
for (const [key, fn] of Object.entries(commands)) {
// @ts-expect-error
fn(...args)
}
const x: number = "a" // the ts server is dead and no compilation error is shown |
Thanks! This can be slimmed down further to: type T1 = "A" | "B";
type T2 = {
C: [string];
D: [number];
};
declare const map: {
[K in T1 | keyof T2]: (...args: K extends keyof T2 ? T2[K] : []) => unknown;
};
for (const [key, fn] of Object.entries(map)) {
fn(...args);
} |
@mirek could you check if this build fixes your issue? |
@Andarist yes, this build fixes issue on my side. There is no crash. I can see some type errors, some look completely unrelated, some look closer to the changes introduced in the PR that was triggering the crash. I'll assume those are irrelevant unless somebody says otherwise then I can go through them. They look like normal, good/genuine tsc errors. |
@mirek you can check this new build |
@Andarist looks good on my side, there is no crash. |
π Search Terms
none
π Version & Regression Information
β― Playground Link
No response
π» Code
// Too large / internal
π Actual behavior
tsc crashes
π Expected behavior
tsc should not crash
Additional information about the issue
The text was updated successfully, but these errors were encountered: