-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When relating a deferred index type over a mapped type on the source …
…side ... (#56742)
- Loading branch information
Showing
5 changed files
with
128 additions
and
10 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
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/declarationEmitNestedAnonymousMappedType.js
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,26 @@ | ||
//// [tests/cases/compiler/declarationEmitNestedAnonymousMappedType.ts] //// | ||
|
||
//// [declarationEmitNestedAnonymousMappedType.ts] | ||
export function enumFromStrings<const Members extends readonly string[]>() { | ||
type Part1 = { | ||
[key in keyof Members as Members[key] extends string | ||
? Members[key] | ||
: never]: Members[key]; | ||
}; | ||
type Part2 = { [Property in keyof Part1]: Part1[Property] }; | ||
return Object.create(null) as Part2; | ||
} | ||
|
||
|
||
//// [declarationEmitNestedAnonymousMappedType.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.enumFromStrings = void 0; | ||
function enumFromStrings() { | ||
return Object.create(null); | ||
} | ||
exports.enumFromStrings = enumFromStrings; | ||
|
||
|
||
//// [declarationEmitNestedAnonymousMappedType.d.ts] | ||
export declare function enumFromStrings<const Members extends readonly string[]>(): { [Property in keyof { [key in keyof Members as Members[key] extends string ? Members[key] : never]: Members[key]; }]: { [key in keyof Members as Members[key] extends string ? Members[key] : never]: Members[key]; }[Property]; }; |
39 changes: 39 additions & 0 deletions
39
tests/baselines/reference/declarationEmitNestedAnonymousMappedType.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,39 @@ | ||
//// [tests/cases/compiler/declarationEmitNestedAnonymousMappedType.ts] //// | ||
|
||
=== declarationEmitNestedAnonymousMappedType.ts === | ||
export function enumFromStrings<const Members extends readonly string[]>() { | ||
>enumFromStrings : Symbol(enumFromStrings, Decl(declarationEmitNestedAnonymousMappedType.ts, 0, 0)) | ||
>Members : Symbol(Members, Decl(declarationEmitNestedAnonymousMappedType.ts, 0, 32)) | ||
|
||
type Part1 = { | ||
>Part1 : Symbol(Part1, Decl(declarationEmitNestedAnonymousMappedType.ts, 0, 76)) | ||
|
||
[key in keyof Members as Members[key] extends string | ||
>key : Symbol(key, Decl(declarationEmitNestedAnonymousMappedType.ts, 2, 9)) | ||
>Members : Symbol(Members, Decl(declarationEmitNestedAnonymousMappedType.ts, 0, 32)) | ||
>Members : Symbol(Members, Decl(declarationEmitNestedAnonymousMappedType.ts, 0, 32)) | ||
>key : Symbol(key, Decl(declarationEmitNestedAnonymousMappedType.ts, 2, 9)) | ||
|
||
? Members[key] | ||
>Members : Symbol(Members, Decl(declarationEmitNestedAnonymousMappedType.ts, 0, 32)) | ||
>key : Symbol(key, Decl(declarationEmitNestedAnonymousMappedType.ts, 2, 9)) | ||
|
||
: never]: Members[key]; | ||
>Members : Symbol(Members, Decl(declarationEmitNestedAnonymousMappedType.ts, 0, 32)) | ||
>key : Symbol(key, Decl(declarationEmitNestedAnonymousMappedType.ts, 2, 9)) | ||
|
||
}; | ||
type Part2 = { [Property in keyof Part1]: Part1[Property] }; | ||
>Part2 : Symbol(Part2, Decl(declarationEmitNestedAnonymousMappedType.ts, 5, 6)) | ||
>Property : Symbol(Property, Decl(declarationEmitNestedAnonymousMappedType.ts, 6, 20)) | ||
>Part1 : Symbol(Part1, Decl(declarationEmitNestedAnonymousMappedType.ts, 0, 76)) | ||
>Part1 : Symbol(Part1, Decl(declarationEmitNestedAnonymousMappedType.ts, 0, 76)) | ||
>Property : Symbol(Property, Decl(declarationEmitNestedAnonymousMappedType.ts, 6, 20)) | ||
|
||
return Object.create(null) as Part2; | ||
>Object.create : Symbol(ObjectConstructor.create, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>create : Symbol(ObjectConstructor.create, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>Part2 : Symbol(Part2, Decl(declarationEmitNestedAnonymousMappedType.ts, 5, 6)) | ||
} | ||
|
24 changes: 24 additions & 0 deletions
24
tests/baselines/reference/declarationEmitNestedAnonymousMappedType.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,24 @@ | ||
//// [tests/cases/compiler/declarationEmitNestedAnonymousMappedType.ts] //// | ||
|
||
=== declarationEmitNestedAnonymousMappedType.ts === | ||
export function enumFromStrings<const Members extends readonly string[]>() { | ||
>enumFromStrings : <const Members extends readonly string[]>() => { [Property in keyof { [key in keyof Members as Members[key] extends string ? Members[key] : never]: Members[key]; }]: { [key in keyof Members as Members[key] extends string ? Members[key] : never]: Members[key]; }[Property]; } | ||
|
||
type Part1 = { | ||
>Part1 : { [key in keyof Members as Members[key] extends string ? Members[key] : never]: Members[key]; } | ||
|
||
[key in keyof Members as Members[key] extends string | ||
? Members[key] | ||
: never]: Members[key]; | ||
}; | ||
type Part2 = { [Property in keyof Part1]: Part1[Property] }; | ||
>Part2 : { [Property in keyof { [key in keyof Members as Members[key] extends string ? Members[key] : never]: Members[key]; }]: { [key in keyof Members as Members[key] extends string ? Members[key] : never]: Members[key]; }[Property]; } | ||
|
||
return Object.create(null) as Part2; | ||
>Object.create(null) as Part2 : { [Property in keyof { [key in keyof Members as Members[key] extends string ? Members[key] : never]: Members[key]; }]: { [key in keyof Members as Members[key] extends string ? Members[key] : never]: Members[key]; }[Property]; } | ||
>Object.create(null) : any | ||
>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType<any>): any; } | ||
>Object : ObjectConstructor | ||
>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType<any>): any; } | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
tests/cases/compiler/declarationEmitNestedAnonymousMappedType.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,10 @@ | ||
// @declaration: true | ||
export function enumFromStrings<const Members extends readonly string[]>() { | ||
type Part1 = { | ||
[key in keyof Members as Members[key] extends string | ||
? Members[key] | ||
: never]: Members[key]; | ||
}; | ||
type Part2 = { [Property in keyof Part1]: Part1[Property] }; | ||
return Object.create(null) as Part2; | ||
} |