Skip to content

Class extension in generics does not work when using Partial. #15832

Closed
@TomerKr

Description

@TomerKr

TypeScript Version: 2.3.2 (or whatever is running in the playground, something similar is reproduced locally of course.)

Code

class Foo{
    something: boolean;
    something2: boolean;
}

class MyClass<T extends Foo>{
    func(x): Partial<T>{
        return {
            something: true
        }
    }
}

Expected behavior:
The code is valid and the TS compiler recognizes that T in the context of MyClass can have a 'something' field.

Actual behavior:
The code does not compile. The error is: "Type '{ something: true; }' is not assignable to type 'Partial'."

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions