-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad6fcb4
commit f5110fe
Showing
3 changed files
with
231 additions
and
0 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
...selines/reference/homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.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,93 @@ | ||
//// [tests/cases/compiler/homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts] //// | ||
|
||
=== homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts === | ||
type HandleOptions<O> = { | ||
>HandleOptions : Symbol(HandleOptions, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 0, 0)) | ||
>O : Symbol(O, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 0, 19)) | ||
|
||
[I in keyof O]: { | ||
>I : Symbol(I, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 1, 5)) | ||
>O : Symbol(O, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 0, 19)) | ||
|
||
value: O[I]; | ||
>value : Symbol(value, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 1, 21)) | ||
>O : Symbol(O, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 0, 19)) | ||
>I : Symbol(I, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 1, 5)) | ||
|
||
}; | ||
}; | ||
|
||
declare function func1< | ||
>func1 : Symbol(func1, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 4, 2)) | ||
|
||
T extends Record<PropertyKey, readonly any[]>, | ||
>T : Symbol(T, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 6, 23)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
>PropertyKey : Symbol(PropertyKey, Decl(lib.es5.d.ts, --, --)) | ||
|
||
>(fields: { | ||
>fields : Symbol(fields, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 8, 2)) | ||
|
||
[K in keyof T]: { | ||
>K : Symbol(K, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 9, 5)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 6, 23)) | ||
|
||
label: string; | ||
>label : Symbol(label, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 9, 21)) | ||
|
||
options: [...HandleOptions<T[K]>]; | ||
>options : Symbol(options, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 10, 22)) | ||
>HandleOptions : Symbol(HandleOptions, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 0, 0)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 6, 23)) | ||
>K : Symbol(K, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 9, 5)) | ||
|
||
}; | ||
}): T; | ||
>T : Symbol(T, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 6, 23)) | ||
|
||
const result = func1({ | ||
>result : Symbol(result, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 15, 5)) | ||
>func1 : Symbol(func1, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 4, 2)) | ||
|
||
prop: { | ||
>prop : Symbol(prop, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 15, 22)) | ||
|
||
label: "first", | ||
>label : Symbol(label, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 16, 11)) | ||
|
||
options: [ | ||
>options : Symbol(options, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 17, 23)) | ||
{ | ||
value: 123, | ||
>value : Symbol(value, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 19, 13)) | ||
|
||
}, | ||
{ | ||
value: "foo", | ||
>value : Symbol(value, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 22, 13)) | ||
|
||
}, | ||
], | ||
}, | ||
other: { | ||
>other : Symbol(other, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 26, 6)) | ||
|
||
label: "second", | ||
>label : Symbol(label, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 27, 12)) | ||
|
||
options: [ | ||
>options : Symbol(options, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 28, 24)) | ||
{ | ||
value: "bar", | ||
>value : Symbol(value, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 30, 13)) | ||
|
||
}, | ||
{ | ||
value: true, | ||
>value : Symbol(value, Decl(homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts, 33, 13)) | ||
|
||
}, | ||
], | ||
}, | ||
}); | ||
|
96 changes: 96 additions & 0 deletions
96
...baselines/reference/homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.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,96 @@ | ||
//// [tests/cases/compiler/homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts] //// | ||
|
||
=== homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts === | ||
type HandleOptions<O> = { | ||
>HandleOptions : HandleOptions<O> | ||
|
||
[I in keyof O]: { | ||
value: O[I]; | ||
>value : O[I] | ||
|
||
}; | ||
}; | ||
|
||
declare function func1< | ||
>func1 : <T extends Record<PropertyKey, readonly any[]>>(fields: { [K in keyof T]: { label: string; options: [...HandleOptions<T[K]>]; }; }) => T | ||
|
||
T extends Record<PropertyKey, readonly any[]>, | ||
>(fields: { | ||
>fields : { [K in keyof T]: { label: string; options: [...HandleOptions<T[K]>]; }; } | ||
|
||
[K in keyof T]: { | ||
label: string; | ||
>label : string | ||
|
||
options: [...HandleOptions<T[K]>]; | ||
>options : [...HandleOptions<T[K]>] | ||
|
||
}; | ||
}): T; | ||
|
||
const result = func1({ | ||
>result : { prop: [number, string]; other: [string, boolean]; } | ||
>func1({ prop: { label: "first", options: [ { value: 123, }, { value: "foo", }, ], }, other: { label: "second", options: [ { value: "bar", }, { value: true, }, ], },}) : { prop: [number, string]; other: [string, boolean]; } | ||
>func1 : <T extends Record<PropertyKey, readonly any[]>>(fields: { [K in keyof T]: { label: string; options: [...HandleOptions<T[K]>]; }; }) => T | ||
>{ prop: { label: "first", options: [ { value: 123, }, { value: "foo", }, ], }, other: { label: "second", options: [ { value: "bar", }, { value: true, }, ], },} : { prop: { label: string; options: [{ value: number; }, { value: string; }]; }; other: { label: string; options: [{ value: string; }, { value: true; }]; }; } | ||
|
||
prop: { | ||
>prop : { label: string; options: [{ value: number; }, { value: string; }]; } | ||
>{ label: "first", options: [ { value: 123, }, { value: "foo", }, ], } : { label: string; options: [{ value: number; }, { value: string; }]; } | ||
|
||
label: "first", | ||
>label : string | ||
>"first" : "first" | ||
|
||
options: [ | ||
>options : [{ value: number; }, { value: string; }] | ||
>[ { value: 123, }, { value: "foo", }, ] : [{ value: number; }, { value: string; }] | ||
{ | ||
>{ value: 123, } : { value: number; } | ||
|
||
value: 123, | ||
>value : number | ||
>123 : 123 | ||
|
||
}, | ||
{ | ||
>{ value: "foo", } : { value: string; } | ||
|
||
value: "foo", | ||
>value : string | ||
>"foo" : "foo" | ||
|
||
}, | ||
], | ||
}, | ||
other: { | ||
>other : { label: string; options: [{ value: string; }, { value: true; }]; } | ||
>{ label: "second", options: [ { value: "bar", }, { value: true, }, ], } : { label: string; options: [{ value: string; }, { value: true; }]; } | ||
|
||
label: "second", | ||
>label : string | ||
>"second" : "second" | ||
|
||
options: [ | ||
>options : [{ value: string; }, { value: true; }] | ||
>[ { value: "bar", }, { value: true, }, ] : [{ value: string; }, { value: true; }] | ||
{ | ||
>{ value: "bar", } : { value: string; } | ||
|
||
value: "bar", | ||
>value : string | ||
>"bar" : "bar" | ||
|
||
}, | ||
{ | ||
>{ value: true, } : { value: true; } | ||
|
||
value: true, | ||
>value : true | ||
>true : true | ||
|
||
}, | ||
], | ||
}, | ||
}); | ||
|
42 changes: 42 additions & 0 deletions
42
tests/cases/compiler/homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.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,42 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
|
||
type HandleOptions<O> = { | ||
[I in keyof O]: { | ||
value: O[I]; | ||
}; | ||
}; | ||
|
||
declare function func1< | ||
T extends Record<PropertyKey, readonly any[]>, | ||
>(fields: { | ||
[K in keyof T]: { | ||
label: string; | ||
options: [...HandleOptions<T[K]>]; | ||
}; | ||
}): T; | ||
|
||
const result = func1({ | ||
prop: { | ||
label: "first", | ||
options: [ | ||
{ | ||
value: 123, | ||
}, | ||
{ | ||
value: "foo", | ||
}, | ||
], | ||
}, | ||
other: { | ||
label: "second", | ||
options: [ | ||
{ | ||
value: "bar", | ||
}, | ||
{ | ||
value: true, | ||
}, | ||
], | ||
}, | ||
}); |