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

Two equally defined mapped types are incompatible #14613

Closed
jtheisen opened this issue Mar 12, 2017 · 1 comment
Closed

Two equally defined mapped types are incompatible #14613

jtheisen opened this issue Mar 12, 2017 · 1 comment
Labels
Duplicate An existing issue was already created Fixed A PR has been merged for this issue

Comments

@jtheisen
Copy link

jtheisen commented Mar 12, 2017

TypeScript Version: 2.1.5

Code

class A<T> { a: T }
type M<T> = {[P in keyof T]: A<T[P]>}

function foo<T>(m: (t: T) => M<T>, t: T) {
    let x: {[P in keyof T]: A<T[P]> } = m(t);
}

Expected behavior:

Should compile.

Actual behavior:

Fails to compile at the initialization of x with the claim the types were incompatible:

app.ts(200,9): error TS2322: Type 'M<T>' is not assignable to type '{ [P in keyof T]: A<T[P]>; }'.
  Type 'A<T[P]>' is not assignable to type 'A<T[P]>'. Two different types with this name exist, but they are unrelated.

    Type 'T[P]' is not assignable to type 'T[P]'. Two different types with this name exist, but they are unrelated.

(Maybe this is the expected behavior for some reason, but it seems off to me.)

@ahejlsberg
Copy link
Member

Duplicated of #12832. Already fixed in #13448.

@ahejlsberg ahejlsberg added Duplicate An existing issue was already created Fixed A PR has been merged for this issue labels Mar 12, 2017
@mhegazy mhegazy closed this as completed Mar 13, 2017
@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
Duplicate An existing issue was already created Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants