Skip to content

Mapped type property causses different assignability error of compatible subtypes #1781

@dragomirtitian

Description

@dragomirtitian

Steps to reproduce

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;

Behavior with typescript@5.8

No error

Behavior with tsgo

Error on final line. Reordering the types to have Table be after DerivedTable also gives the same behavior as 5.8

Related to microsoft/TypeScript#62520

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Type CheckingRelated to type checking, grammar checkingType OrderingAn issue related to ordering of types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions