Skip to content
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

inference doesn't work #21644

Closed
zpdDG4gta8XKpMCd opened this issue Feb 5, 2018 · 3 comments
Closed

inference doesn't work #21644

zpdDG4gta8XKpMCd opened this issue Feb 5, 2018 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@zpdDG4gta8XKpMCd
Copy link

zpdDG4gta8XKpMCd commented Feb 5, 2018

type Unknown = {} | null | undefined | void;
void function f<T, K extends keyof T>(
   fn: (data: T) => T[K]
): (data: T) => Unknown {
    return fn; /* <-- expected to work, actual:
    Type '(data: T) => T[K]' is not assignable to type '(data: T) => Unknown'.
      Type 'T[K]' is not assignable to type 'Unknown'.
        Type 'T[K]' is not assignable to type '{}'.
*/
}
@ajafff
Copy link
Contributor

ajafff commented Feb 5, 2018

Duplicate of #21368

@mhegazy mhegazy added the Duplicate An existing issue was already created label Feb 5, 2018
@zpdDG4gta8XKpMCd
Copy link
Author

zpdDG4gta8XKpMCd commented Feb 5, 2018

how is it a duplicate of a work as intended? excuse me Unknown | null | undefined | void is a top type to any other type out there, and it is in co-variant position, so it must work

@typescript-bot
Copy link
Collaborator

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

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 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