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
Assignability check for types which has same property with different types, yet where the properties are still assignable (e.g. assinging null to string[]|null) stopped to work.
I wasn't certain if this was an intended behavior or a regression.
🔎 Search Terms
assignability
generic
interfaces
extends
🕗 Version & Regression Information
Start to appear from 4.3.1-rc. All other versions work.
interfaceA<T>{field : T|null;}typeassignTo=A<string[]>;interfaceassignToExtendedextendsA<string[]>{}functionfoo() : A<null>{return{field : null};}// This consistently fails on all versions. (and I think this is intended)consta : assignTo=foo();// This used to work, but now starts to fail from 4.3.1-rcconstb : assignToExtended=foo();
🙁 Actual behavior
A<null> is not assignable to assignToExtended
🙂 Expected behavior
A<null> be assignable to assignToExtended
The text was updated successfully, but these errors were encountered:
I don't understand why const a : assignTo = foo() should fail. I think it is a bug.
Consider the example:
typeNullable<T>={field: T|null};declarevara: Nullable<number>;declarevarb: {field: null};declarevarc: Nullable<null>;a=b;b=c;a=c;// ^Error here.// Why it is an error when b is assignable to a, and c is assignable to b, but c is not assignable to a???
Duping to #40312. The root cause of the break now is I believe the improved type alias preservation, which "lets" us use the more efficient (but ultimately incorrect) type parameter check rather than a structural check.
Bug Report
Assignability check for types which has same property with different types, yet where the properties are still assignable (e.g. assinging
null
tostring[]|null
) stopped to work.I wasn't certain if this was an intended behavior or a regression.
🔎 Search Terms
🕗 Version & Regression Information
⏯ Playground Link
Playground link
💻 Code
🙁 Actual behavior
A<null>
is not assignable toassignToExtended
🙂 Expected behavior
A<null>
be assignable toassignToExtended
The text was updated successfully, but these errors were encountered: