Skip to content

Commit 1c1506a

Browse files
committed
add a test case
1 parent 1d8fb6f commit 1c1506a

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//// [tests/cases/compiler/homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts] ////
2+
3+
=== homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/29919
5+
6+
type FuncParams<T> = T extends (...args: infer P) => any ? P : never;
7+
>FuncParams : Symbol(FuncParams, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 0, 0))
8+
>T : Symbol(T, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 2, 16))
9+
>T : Symbol(T, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 2, 16))
10+
>args : Symbol(args, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 2, 32))
11+
>P : Symbol(P, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 2, 46))
12+
>P : Symbol(P, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 2, 46))
13+
14+
type Stringify<T> = {
15+
>Stringify : Symbol(Stringify, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 2, 69))
16+
>T : Symbol(T, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 3, 15))
17+
18+
[K in keyof T]: string;
19+
>K : Symbol(K, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 4, 3))
20+
>T : Symbol(T, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 3, 15))
21+
22+
};
23+
type Optional<T> = {
24+
>Optional : Symbol(Optional, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 5, 2))
25+
>T : Symbol(T, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 6, 14))
26+
27+
[K in keyof T]?: T[K];
28+
>K : Symbol(K, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 7, 3))
29+
>T : Symbol(T, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 6, 14))
30+
>T : Symbol(T, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 6, 14))
31+
>K : Symbol(K, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 7, 3))
32+
33+
};
34+
35+
function doOptionalStuff<T>(func: T, ...params: Optional<FuncParams<T>>) {}
36+
>doOptionalStuff : Symbol(doOptionalStuff, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 8, 2))
37+
>T : Symbol(T, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 10, 25))
38+
>func : Symbol(func, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 10, 28))
39+
>T : Symbol(T, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 10, 25))
40+
>params : Symbol(params, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 10, 36))
41+
>Optional : Symbol(Optional, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 5, 2))
42+
>FuncParams : Symbol(FuncParams, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 0, 0))
43+
>T : Symbol(T, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 10, 25))
44+
45+
function doStringStuff<T>(func: T, ...params: Stringify<FuncParams<T>>) {}
46+
>doStringStuff : Symbol(doStringStuff, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 10, 75))
47+
>T : Symbol(T, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 12, 23))
48+
>func : Symbol(func, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 12, 26))
49+
>T : Symbol(T, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 12, 23))
50+
>params : Symbol(params, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 12, 34))
51+
>Stringify : Symbol(Stringify, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 2, 69))
52+
>FuncParams : Symbol(FuncParams, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 0, 0))
53+
>T : Symbol(T, Decl(homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts, 12, 23))
54+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//// [tests/cases/compiler/homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts] ////
2+
3+
=== homomorphicMappedTypesAppliedToParametersUsedAsRest1.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/29919
5+
6+
type FuncParams<T> = T extends (...args: infer P) => any ? P : never;
7+
>FuncParams : FuncParams<T>
8+
>args : P
9+
10+
type Stringify<T> = {
11+
>Stringify : Stringify<T>
12+
13+
[K in keyof T]: string;
14+
};
15+
type Optional<T> = {
16+
>Optional : Optional<T>
17+
18+
[K in keyof T]?: T[K];
19+
};
20+
21+
function doOptionalStuff<T>(func: T, ...params: Optional<FuncParams<T>>) {}
22+
>doOptionalStuff : <T>(func: T, ...params: Optional<FuncParams<T>>) => void
23+
>func : T
24+
>params : Optional<FuncParams<T>>
25+
26+
function doStringStuff<T>(func: T, ...params: Stringify<FuncParams<T>>) {}
27+
>doStringStuff : <T>(func: T, ...params: Stringify<FuncParams<T>>) => void
28+
>func : T
29+
>params : Stringify<FuncParams<T>>
30+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @strict: true
2+
// @noEmit: true
3+
4+
// https://github.com/microsoft/TypeScript/issues/29919
5+
6+
type FuncParams<T> = T extends (...args: infer P) => any ? P : never;
7+
type Stringify<T> = {
8+
[K in keyof T]: string;
9+
};
10+
type Optional<T> = {
11+
[K in keyof T]?: T[K];
12+
};
13+
14+
function doOptionalStuff<T>(func: T, ...params: Optional<FuncParams<T>>) {}
15+
16+
function doStringStuff<T>(func: T, ...params: Stringify<FuncParams<T>>) {}

0 commit comments

Comments
 (0)