Skip to content

🚨 Array .map() type too wide #60542

Closed as not planned
Closed as not planned
@regnaio

Description

@regnaio

πŸ”Ž Search Terms

TypeScript Playground Link

πŸ•— Version & Regression Information

Unknown

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/MYewdgzgLgBACgQQJICUDKMC8MDaAoGQ3AcgENiAaGABgF0KCidiAjSmARnscOeHYBM3WjFIQYoSFADcePJOgwAwgHkAckoQAVAKJrtOgCJZ4ydADoAtqQAOACgBupADYBXAKZYAfDAAGAEgBvJzd3HDoAXwBaIJCPHC4I31FxBSgASlk8KABPG08lcGBSKHcwEvcAExM7XPyQADNldU1dfV1DdJwwV0sWdwAnWlkgA

πŸ’» Code

const PAIRS = [
    ['a', 0],
    ['b', 1],
    ['c', 2],
] as const;

const CONCATENATED = PAIRS.map(value => `${value[0]}-${value[1]}` as const);

type Concatenated = (typeof CONCATENATED)[number];

πŸ™ Actual behavior

If you hover over Concatenated, you can see that its type is type Concatenated = "a-0" | "a-2" | "a-1" | "b-0" | "b-2" | "b-1" | "c-0" | "c-2" | "c-1".

πŸ™‚ Expected behavior

The expected type should instead be type Concatenated = "a-0" | "b-1" | "c-2".

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions