-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use homomorphic templated type for Omit
- Loading branch information
Showing
10 changed files
with
103 additions
and
28 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
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
13 changes: 13 additions & 0 deletions
13
tests/baselines/reference/omitOfTypeExtendingIndexSignature.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,13 @@ | ||
//// [omitOfTypeExtendingIndexSignature.ts] | ||
// #36981 | ||
type AnyRecord = Record<string, any>; | ||
interface ExtendsAny extends AnyRecord { | ||
myKey1: string; | ||
myKey2: string; | ||
} | ||
|
||
type OmitsKey = Omit<ExtendsAny, "myKey2">; | ||
type OmitsKey1 = OmitsKey["myKey1"]; // should be `string` | ||
type OmitsKey2 = OmitsKey["myKey2"]; // should be `any` | ||
|
||
//// [omitOfTypeExtendingIndexSignature.js] |
30 changes: 30 additions & 0 deletions
30
tests/baselines/reference/omitOfTypeExtendingIndexSignature.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,30 @@ | ||
=== tests/cases/compiler/omitOfTypeExtendingIndexSignature.ts === | ||
// #36981 | ||
type AnyRecord = Record<string, any>; | ||
>AnyRecord : Symbol(AnyRecord, Decl(omitOfTypeExtendingIndexSignature.ts, 0, 0)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
|
||
interface ExtendsAny extends AnyRecord { | ||
>ExtendsAny : Symbol(ExtendsAny, Decl(omitOfTypeExtendingIndexSignature.ts, 1, 37)) | ||
>AnyRecord : Symbol(AnyRecord, Decl(omitOfTypeExtendingIndexSignature.ts, 0, 0)) | ||
|
||
myKey1: string; | ||
>myKey1 : Symbol(ExtendsAny.myKey1, Decl(omitOfTypeExtendingIndexSignature.ts, 2, 40)) | ||
|
||
myKey2: string; | ||
>myKey2 : Symbol(ExtendsAny.myKey2, Decl(omitOfTypeExtendingIndexSignature.ts, 3, 19)) | ||
} | ||
|
||
type OmitsKey = Omit<ExtendsAny, "myKey2">; | ||
>OmitsKey : Symbol(OmitsKey, Decl(omitOfTypeExtendingIndexSignature.ts, 5, 1)) | ||
>Omit : Symbol(Omit, Decl(lib.es5.d.ts, --, --)) | ||
>ExtendsAny : Symbol(ExtendsAny, Decl(omitOfTypeExtendingIndexSignature.ts, 1, 37)) | ||
|
||
type OmitsKey1 = OmitsKey["myKey1"]; // should be `string` | ||
>OmitsKey1 : Symbol(OmitsKey1, Decl(omitOfTypeExtendingIndexSignature.ts, 7, 43)) | ||
>OmitsKey : Symbol(OmitsKey, Decl(omitOfTypeExtendingIndexSignature.ts, 5, 1)) | ||
|
||
type OmitsKey2 = OmitsKey["myKey2"]; // should be `any` | ||
>OmitsKey2 : Symbol(OmitsKey2, Decl(omitOfTypeExtendingIndexSignature.ts, 8, 36)) | ||
>OmitsKey : Symbol(OmitsKey, Decl(omitOfTypeExtendingIndexSignature.ts, 5, 1)) | ||
|
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/omitOfTypeExtendingIndexSignature.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,22 @@ | ||
=== tests/cases/compiler/omitOfTypeExtendingIndexSignature.ts === | ||
// #36981 | ||
type AnyRecord = Record<string, any>; | ||
>AnyRecord : AnyRecord | ||
|
||
interface ExtendsAny extends AnyRecord { | ||
myKey1: string; | ||
>myKey1 : string | ||
|
||
myKey2: string; | ||
>myKey2 : string | ||
} | ||
|
||
type OmitsKey = Omit<ExtendsAny, "myKey2">; | ||
>OmitsKey : Omit<ExtendsAny, "myKey2"> | ||
|
||
type OmitsKey1 = OmitsKey["myKey1"]; // should be `string` | ||
>OmitsKey1 : string | ||
|
||
type OmitsKey2 = OmitsKey["myKey2"]; // should be `any` | ||
>OmitsKey2 : any | ||
|
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
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
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
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
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 @@ | ||
// #36981 | ||
type AnyRecord = Record<string, any>; | ||
interface ExtendsAny extends AnyRecord { | ||
myKey1: string; | ||
myKey2: string; | ||
} | ||
|
||
type OmitsKey = Omit<ExtendsAny, "myKey2">; | ||
type OmitsKey1 = OmitsKey["myKey1"]; // should be `string` | ||
type OmitsKey2 = OmitsKey["myKey2"]; // should be `any` |