Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TomerKr opened this issue May 14, 2017 · 2 comments
Closed

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

TomerKr opened this issue May 14, 2017 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@TomerKr
Copy link

TomerKr commented May 14, 2017

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'."

@RyanCavanaugh
Copy link
Member

Duplicate #12731

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label May 15, 2017
@TomerKr
Copy link
Author

TomerKr commented May 16, 2017

I'll be closing this issue then and try discussing it in the duplicate. Thanks.

@TomerKr TomerKr closed this as completed May 16, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants