Skip to content

Commit

Permalink
test(TypeScript): test ...infer type with parens (#9056)
Browse files Browse the repository at this point in the history
  • Loading branch information
brodycj authored Aug 26, 2020
1 parent ee57066 commit 77c8da7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/typescript/rest-type/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,25 @@ printWidth: 80
=====================================input======================================
type Tail<T extends any[]> = T extends [infer U, ...infer R] ? R : never;
// should remove parens from this, to avoid a type issue with TypeScript 4.0:
type Tail2<T extends any[]> = T extends [infer U, ...(infer R)] ? R : never;
// but not remove parens from this:
type Tail3<T extends any[]> = T extends [infer U, ...(infer R)[]] ? R : never;
type ReduceNextElement<
T extends readonly unknown[]
> = T extends readonly [infer V, ...infer R] ? [V, R] : never
=====================================output=====================================
type Tail<T extends any[]> = T extends [infer U, ...infer R] ? R : never;
// should remove parens from this, to avoid a type issue with TypeScript 4.0:
type Tail2<T extends any[]> = T extends [infer U, ...infer R] ? R : never;
// but not remove parens from this:
type Tail3<T extends any[]> = T extends [infer U, ...(infer R)[]] ? R : never;
type ReduceNextElement<T extends readonly unknown[]> = T extends readonly [
infer V,
...infer R
Expand Down
6 changes: 6 additions & 0 deletions tests/typescript/rest-type/infer-type.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
type Tail<T extends any[]> = T extends [infer U, ...infer R] ? R : never;

// should remove parens from this, to avoid a type issue with TypeScript 4.0:
type Tail2<T extends any[]> = T extends [infer U, ...(infer R)] ? R : never;

// but not remove parens from this:
type Tail3<T extends any[]> = T extends [infer U, ...(infer R)[]] ? R : never;

type ReduceNextElement<
T extends readonly unknown[]
> = T extends readonly [infer V, ...infer R] ? [V, R] : never

0 comments on commit 77c8da7

Please sign in to comment.