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

Regress: Deep recursive type transform gives any #29577

Closed
cevek opened this issue Jan 25, 2019 · 2 comments · Fixed by #29740
Closed

Regress: Deep recursive type transform gives any #29577

cevek opened this issue Jan 25, 2019 · 2 comments · Fixed by #29740
Assignees
Labels
Duplicate An existing issue was already created Fixed A PR has been merged for this issue

Comments

@cevek
Copy link

cevek commented Jan 25, 2019

TypeScript Version: 3.3.0-dev.20190125

Search Terms:

It works in 3.1.6, but in 3.2 and 3.3 it gives any

Code

export type Transform<T> = { [K in keyof T]: Transform<T[K]> };
interface User {
    avatar: string;
}

interface Guest {
    displayName: string;
}

interface Product {
    users: (User | Guest)[];
}
declare var product:Transform<Product>;
product.users // any[] 

Expected behavior:
Transform<(User | Guest)>[]
Actual behavior:
any[]

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jan 25, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.4.0 milestone Jan 25, 2019
@ahejlsberg
Copy link
Member

Duplicate of #27881 and any results from fix in #27911. With #26063 we map arrays and tuples to transformed arrays and tuples, but because we have to eagerly resolve the element type in order to instantiate an Array<T>, we end up triggering a circularity and resolve to any.

@ahejlsberg ahejlsberg added Duplicate An existing issue was already created and removed Bug A bug in TypeScript labels Jan 25, 2019
@ahejlsberg ahejlsberg removed this from the TypeScript 3.4.0 milestone Jan 25, 2019
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants