Skip to content

Cannot assign value to variable of the same type #31259

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
profencer opened this issue May 5, 2019 · 2 comments
Closed

Cannot assign value to variable of the same type #31259

profencer opened this issue May 5, 2019 · 2 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Conditional Types The issue relates to conditional types

Comments

@profencer
Copy link

TypeScript Version: 3.5.0-dev.20190504

Search Terms:
Two different types with this name exist, but they are unrelated.

Code

type Type<G extends boolean, T> = G extends true ? (input: number) => T : (input: T) => number
type U = <T>(x: <G extends boolean>() => Type<G, T>) => void;
const i: U = <T>(x: <G extends boolean>() => Type<G, T>) => {};

Expected behavior:
No error

Actual behavior:
Error

Type '<T>(x: <G extends boolean>() => Type<G, T>) => void' is not assignable to type 'U'.
  Types of parameters 'x' and 'x' are incompatible.
    Type 'Type<G, T>' is not assignable to type 'Type<G, number>'.
      Type '(input: number) => T' is not assignable to type '(input: number) => number'.
        Type 'T' is not assignable to type 'number'.

Playground Link:
link

Related Issues:
#26627
#25373

@weswigham weswigham added Bug A bug in TypeScript Domain: Conditional Types The issue relates to conditional types labels May 8, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.6.0 milestone Jun 12, 2019
@jack-williams
Copy link
Collaborator

This is fixed: playground

@weswigham
Copy link
Member

So it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Conditional Types The issue relates to conditional types
Projects
None yet
Development

No branches or pull requests

5 participants