You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Intersection Types can be cast to any type V as long as it is nullable #45640
interfaceA{a: string;}interfaceB{b: string;}constobjA: A={a: "hello"}constobjB: B={b: "hello"}constobjAB: A&B={a: "hello",b: "world"}constcastA=objAasnull;// always an errorconstcastB=objBasnull;// always an errorconstcastAB=objABasnull;// error on TypeScript 4.2.3 and 4.4.2, not an error on TypeScript 4.3.5 constcastAB_string=objABasstring|null;// error on TypeScript 4.2.3 and 4.4.2, not an error on TypeScript 4.3.5 constcastAB_number=objABasnumber|null;// error on TypeScript 4.2.3 and 4.4.2, not an error on TypeScript 4.3.5
🙁 Actual behavior
In v4.3.5, we don't see the expected type error when casting an intersection type to null or null unions.
This issue does not occur in earlier or later versions.
🙂 Expected behavior
The type error behavior does not change depending on what version is being used, unless there is a well-documented breaking change.
It's worth noting that 4.3.5 is the default version used in the latest VS Code, so it is probably widely used
But you don't compile with the TypeScript version shipped with VSCode. And I'm confident that with the next August release of VSCode they will ship 4.4, as per microsoft/vscode#130601.
It's worth noting that 4.3.5 is the default version used in the latest VS Code, so it is probably widely used
But you don't compile with the TypeScript version shipped with VSCode. And I'm confident that with the next August release of VSCode they will ship 4.4, as per microsoft/vscode#130601.
Okay, well regardless of VS Code, there are people who use 4.3.x to build their code. 4.4.x has breaking changes. There should be a way to address this issue without requiring users to take on breaking changes. This is what the patch version is for.
Ultimately I can't make you fix it. I found a serious bug that wasted my time and I wanted to save other people the hassle by writing up a report.
Activity
MartinJohns commentedon Aug 30, 2021
Sounds like it was just a bug in 4.3.5.
agrattaqrypt commentedon Aug 30, 2021
Yes, I would assume this is something that needs to be patched on the 4.3.x minor version only
agrattaqrypt commentedon Aug 30, 2021
It's worth noting that 4.3.5 is the default version used in the latest VS Code, so it is probably widely used
MartinJohns commentedon Aug 30, 2021
But you don't compile with the TypeScript version shipped with VSCode. And I'm confident that with the next August release of VSCode they will ship 4.4, as per microsoft/vscode#130601.
agrattaqrypt commentedon Aug 30, 2021
Okay, well regardless of VS Code, there are people who use 4.3.x to build their code. 4.4.x has breaking changes. There should be a way to address this issue without requiring users to take on breaking changes. This is what the patch version is for.
Ultimately I can't make you fix it. I found a serious bug that wasted my time and I wanted to save other people the hassle by writing up a report.
andrewbranch commentedon Aug 30, 2021
We'll monitor comments on this issue, but if it wasn't noticed until a full version later, it's unlikely this warrants a patch.