Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 1.04 KB

File metadata and controls

38 lines (29 loc) · 1.04 KB

[HIGHLIGHT]Support TypeScript 4.1 (#9473, #9636 by @sosukesuzuki)

// Input
type MappedTypeWithNewKeys<T> = {
  [K in keyof T as NewKeyType]: T[K]
};

// Prettier stable
SyntaxError: Unexpected token, expected "]" (2:17)
  1 | type MappedTypeWithNewKeys<T> = {
> 2 |   [K in keyof T as NewKeyType]: T[K]
    |                 ^
  3 | };

// Prettier master
type MappedTypeWithNewKeys<T> = {
  [K in keyof T as NewKeyType]: T[K]
};
// Input
type HelloWorld = `Hello, ${keyof World}`

// Prettier stable
SyntaxError: Unexpected token, expected "}" (1:35)
> 1 | type HelloWorld = `Hello, ${keyof World}`
    |                                   ^

// Prettier master
type HelloWorld = `Hello, ${keyof World}`;