镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Mapped tuple types don't infer as arrays in generics #26163

Description

TypeScript Version: 3.1.0-dev.20180802

Search Terms:

Mapped tuple type generic infer array

Code

type Element<T> = T extends Array<infer U> ? U : never;
type Mapped<T> = { [K in keyof T]: T[K] };

type F<T> = Element<Mapped<T>>;
type R1 = F<[string, number, boolean]>; // never
type R2 = Element<Mapped<[string, number, boolean]>>; // string | number | boolean

Expected behavior:

The type of R1 should be string | number | boolean.

Actual behavior:

The type of R1 is never.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions