Skip to content

'Foo' is not assignable to 'Partial<T>' where generic 'T extends Foo' #19467

@GregorioBR

Description

@GregorioBR

TypeScript Version: 2.5.3

Code

interface IViewState {
    data?: string;
}

class View<S extends IViewState> {

    public processState(): Partial<S> {
        return {data: "test"};
    }
}

Expected behavior:

Code to compile

Actual behavior:

C:\Users\Greg\Desktop\demo-app\greg>tsc --version
Version 2.5.3

C:\Users\Greg\Desktop\demo-app\greg>tsc --init
message TS6071: Successfully created a tsconfig.json file.

C:\Users\Greg\Desktop\demo-app\greg>tsc
test.ts(12,9): error TS2322: Type '{ data: string; }' is not assignable to type 'Partial<S>'.

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