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
Expected behavior:
No error -- this worked fine in 3.8 (and should)
Actual behavior:
Error:
Argument of type 'CommitFileNode | ResultsFileNode | (ResultsFileNode & StashFileNode)' is not assignable to parameter of type 'CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode'.
Type 'ResultsFileNode & StashFileNode' is not assignable to type 'CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode'.
Type 'ResultsFileNode & StashFileNode' is not assignable to type 'StashFileNode'.
Property '_foo1' has conflicting declarations and is inaccessible in type 'ResultsFileNode & StashFileNode'.(2345)
classA{privatex: unknown}classB{privatex: unknown}functionfoo2(node: A|B){if(nodeinstanceofA||nodeinstanceofA){node;// A | A & B, should be just A}else{node;// B}node;// A | B | A & B, should be just A | B}
In the second instanceof check we form the intersection A & B (because we have a B and need a type that is also an A). This intersection used to be assignable to both A and B, but it now isn't because with #37195 we check the whole object for assignability and (correctly) detect the conflicting private fields.
We can fix this by ensuring that every intersection we create in a CFA operation is actually assignable to the individual constituents and otherwise resolve to never. Currently we implicitly assume this to be true, but there are plenty of intersections for which it isn't.
TypeScript Version: 3.9.0-dev.20200327
Search Terms:
Expected behavior:
No error -- this worked fine in 3.8 (and should)
Actual behavior:
Error:
Related Issues:
Code
Output
Compiler Options
Playground Link: Provided
The text was updated successfully, but these errors were encountered: