Skip to content

Regress: Deep recursive type transform gives any #29577

Closed

Description

@cevek

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[]

Activity

  1. ahejlsberg commented on Jan 25, 2019

    @ahejlsberg
    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.

  2. added
    Duplicate
    and removed
    Bug
    on Jan 25, 2019
  3. typescript-bot commented on Jan 27, 2019

    @typescript-bot
    Contributor

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

  4. added
    Fixed
    on Feb 6, 2019
  5. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

DuplicateFixed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions