-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed an issue with not being able to use mapped type over union cons…
…traint as rest param
- Loading branch information
Showing
4 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/restParamUsingMappedTypeOverUnionConstraint.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
=== tests/cases/compiler/restParamUsingMappedTypeOverUnionConstraint.ts === | ||
// repro 29919#issuecomment-470948453 | ||
|
||
type Mapped<T> = { [P in keyof T]: T[P] extends string ? [number] : [string] } | ||
>Mapped : Symbol(Mapped, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 0, 0)) | ||
>T : Symbol(T, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 2, 12)) | ||
>P : Symbol(P, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 2, 20)) | ||
>T : Symbol(T, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 2, 12)) | ||
>T : Symbol(T, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 2, 12)) | ||
>P : Symbol(P, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 2, 20)) | ||
|
||
declare function test<T extends [number] | [string]>( | ||
>test : Symbol(test, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 2, 78)) | ||
>T : Symbol(T, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 4, 22)) | ||
|
||
args: T, | ||
>args : Symbol(args, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 4, 53)) | ||
>T : Symbol(T, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 4, 22)) | ||
|
||
fn: (...args: Mapped<T>) => void | ||
>fn : Symbol(fn, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 5, 10)) | ||
>args : Symbol(args, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 6, 7)) | ||
>Mapped : Symbol(Mapped, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 0, 0)) | ||
>T : Symbol(T, Decl(restParamUsingMappedTypeOverUnionConstraint.ts, 4, 22)) | ||
|
||
): number | ||
|
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/restParamUsingMappedTypeOverUnionConstraint.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
=== tests/cases/compiler/restParamUsingMappedTypeOverUnionConstraint.ts === | ||
// repro 29919#issuecomment-470948453 | ||
|
||
type Mapped<T> = { [P in keyof T]: T[P] extends string ? [number] : [string] } | ||
>Mapped : Mapped<T> | ||
|
||
declare function test<T extends [number] | [string]>( | ||
>test : <T extends [number] | [string]>(args: T, fn: (...args: Mapped<T>) => void) => number | ||
|
||
args: T, | ||
>args : T | ||
|
||
fn: (...args: Mapped<T>) => void | ||
>fn : (...args: Mapped<T>) => void | ||
>args : Mapped<T> | ||
|
||
): number | ||
|
11 changes: 11 additions & 0 deletions
11
tests/cases/compiler/restParamUsingMappedTypeOverUnionConstraint.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// @noEmit: true | ||
// @strict: true | ||
|
||
// repro 29919#issuecomment-470948453 | ||
|
||
type Mapped<T> = { [P in keyof T]: T[P] extends string ? [number] : [string] } | ||
|
||
declare function test<T extends [number] | [string]>( | ||
args: T, | ||
fn: (...args: Mapped<T>) => void | ||
): number |