Skip to content

Omit properties from generic type which set by default and have extend #33484

Closed
@Vardner

Description

@Vardner

TypeScript Version: 3.6.3
Omit extended generic type, type has no properties in common with type Pick Exclude

interface Bar {
    type: string;
    id?: string;
}

class Foo\<T extends Bar = Bar> {
    getParam (param: keyof Omit<T, 'type'>) {}

    test () {
        this.getParam('id');
    }
}

Expected behavior:
exclude the "type" property, and get in the available properties for the parameter "param" id and the rest that will be present in the interface because Bar is default param for T

Actual behavior:
Error "Type 'type' has no properties in common with type Pick <T, Exclude , 'type'>"

Playground Link:
https://stackblitz.com/edit/typescript-8zyjig

Related Issues: #24791

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions