-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Unexpected error 2322 in TypeScript 4.8.2 #50616
Comments
Intersection, not union. Just wanted to get that out of the way. That’s interesting, it seems to be doing excess property checking on the individual components of an intersection. |
Good catch. Fixed. |
Not only unions. Here is a simpler example with the most basic types and no unions or intersection types: function SendBlob(data: unknown, encoding: unknown) {
if (encoding !== undefined && encoding !== 'utf8') {
throw new Error('encoding');
}
// Mouse hover to see detected type
// When using TS v4.8.2 it is {} | undefined
// When using TS v4.7.4 it is "utf8" | undefined
encoding;
}; |
I don’t think that’s the same bug. In this issue an assignability check is going wrong but the types are otherwise correct, yours is just an outright failure to narrow to the correct type. You should open a new issue. |
Fixed in 4.8.3 |
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
🙂 Expected behavior
The text was updated successfully, but these errors were encountered: