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

Type parameter inferred incorrectly when intersected with another type #7272

Closed
vsiao opened this issue Feb 26, 2016 · 2 comments
Closed

Type parameter inferred incorrectly when intersected with another type #7272

vsiao opened this issue Feb 26, 2016 · 2 comments
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@vsiao
Copy link

vsiao commented Feb 26, 2016

TypeScript Version:

1.8.0

Code

declare function foo1<T extends U, U>(target: T, source: U);
declare function foo2<T extends U, U>(target: T, source: U & { key?: string });
let x = { a: 1, b: 2 };

foo1(x, { c: 3 }); // Error as expected
foo2(x, { c: 3 }); // OK (Should be Error)

Expected behavior:
call to foo2 should error with the same error as the call to foo1.

Actual behavior:
call to foo2 infers type parameter U as {}, to which { c: number } is assignable.

cf. #7234

@mhegazy
Copy link
Contributor

mhegazy commented Mar 3, 2016

not sure what is the proposal here, {} for U seems like a correct inference.

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Mar 28, 2016
@mhegazy mhegazy closed this as completed Mar 28, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Mar 28, 2016

please reopen if there is additional information.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

2 participants