-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed as not planned
Closed as not planned
Copy link
Labels
Won't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix itThe severity and priority of this issue do not warrant the time or complexity needed to fix it
Description
π Search Terms
assignability mapped type sub type
π Version & Regression Information
- This changed between versions 3.3 and 3.5, but the behavior was not correct in 3.3 either, 3.5 just makes it a bit better but less consistent.
β― Playground Link
π» Code
interface Table<B> { schema: B; }
interface DerivedTable<S extends DerivedSchema<any, any>> extends Table<S["base"] & S["new"]>{
// readonlySchema: Readonly<S["base"] & S["new"]>
}
type DerivedSchema<B, N> = { base: B; new: N };
interface Base { baseProp: number; }
interface New { newProp: boolean; }
declare const source: DerivedTable<{ base: Base, new: New }>
const destination: DerivedTable<{ base: Base; new: New & Base }> = source;π Actual behavior
There is an error on the last line
π Expected behavior
DerivedTable<{ base: Base, new: New }> and DerivedTable<{ base: Base; new: New & Base }> are both equivalent to Table<New & Base> and so the assignment on the last line should succeed. Commenting out the readonlySchema property will actually make the assignment succeed. At the very least this should always be an error as it was in 3.3.
Additional information about the issue
Found while testing tsgo which depending on type order might errors on it even with readonlySchema present. Reported as microsoft/typescript-go#1781
Metadata
Metadata
Assignees
Labels
Won't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix itThe severity and priority of this issue do not warrant the time or complexity needed to fix it