Skip to content

Defining generic functional type fails #17114

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
xp500 opened this issue Jul 12, 2017 · 3 comments
Closed

Defining generic functional type fails #17114

xp500 opened this issue Jul 12, 2017 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@xp500
Copy link

xp500 commented Jul 12, 2017

TypeScript Version: 2.4.1

Code

class A {
}

class B extends A {
  prop: number
}

type C = <S extends A>(p: S) => void;

const a: C = (p: B) => {}

Expected behavior:
The function a (p :B) => {} should be a valid C because B extends A
Actual behavior:
Build fails with the following error

error TS2322: Type '(p: B) => void' is not assignable to type 'C'.
  Types of parameters 'p' and 'p' are incompatible.
    Type 'S' is not assignable to type 'B'.
      Type 'A' is not assignable to type 'B'.
        Property 'prop' is missing in type 'A'.

This used to work in 2.3.4.

@kitsonk
Copy link
Contributor

kitsonk commented Jul 12, 2017

Dupe of #16985

@HerringtonDarkholme
Copy link
Contributor

See this #16797 (comment)

@mhegazy mhegazy added the Duplicate An existing issue was already created label Aug 28, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Sep 12, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Sep 12, 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

4 participants