Skip to content

The results of the 'Mapped Types' distribution have changed. #44325

Open
@SoraKumo001

Description

@SoraKumo001

Bug Report

The conversion result of 'Mapped Types' has changed in 4.3.2 or later typescript.

💻 Code

type Base = { 100: { a: number }; 200: { b: string } }
type NewType<T = Base> = {
  [P in keyof T ]: {
    code: P
    body: T[P]
  }
} extends {
  [P in any]: infer R
}
  ? R
  : never

let test: NewType

🙁 Actual behavior

  • 4.3.0-beta and earlier
let test: {
    code: 100;
    body: {
        a: number;
    };
} | {
    code: 200;
    body: {
        b: string;
    };
}
  • 4.3.2
let test: {
    code: keyof Base;
    body: {
        a: number;
    } | {
        b: string;
    };
}

🙂 Expected behavior

Hoping to return to pre-4.3.0-beta behavior!

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions