Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(TypeScript): test ...infer type with parens #9056

Merged
merged 1 commit into from Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/typescript/rest-type/__snapshots__/jsfmt.spec.js.snap
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
@@ -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