-
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.
Improve relationship check for mapped type sources under `exactOption…
…alPropertyTypes`
- Loading branch information
Showing
4 changed files
with
177 additions
and
7 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
91 changes: 91 additions & 0 deletions
91
.../baselines/reference/mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.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,91 @@ | ||
//// [tests/cases/compiler/mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts] //// | ||
|
||
=== mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/60233 | ||
|
||
type T = { | ||
>T : Symbol(T, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 0, 0)) | ||
|
||
foo?: true; | ||
>foo : Symbol(foo, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 2, 10)) | ||
|
||
bar?: true; | ||
>bar : Symbol(bar, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 3, 13)) | ||
|
||
}; | ||
|
||
type WrappedT<t extends T> = [t]; | ||
>WrappedT : Symbol(WrappedT, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 5, 2)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 7, 14)) | ||
>T : Symbol(T, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 0, 0)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 7, 14)) | ||
|
||
type OmitBarFromWrapped<t> = t extends WrappedT<infer inner> | ||
>OmitBarFromWrapped : Symbol(OmitBarFromWrapped, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 7, 33)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 9, 24)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 9, 24)) | ||
>WrappedT : Symbol(WrappedT, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 5, 2)) | ||
>inner : Symbol(inner, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 9, 53)) | ||
|
||
? WrappedT<Omit<inner, "bar">> | ||
>WrappedT : Symbol(WrappedT, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 5, 2)) | ||
>Omit : Symbol(Omit, Decl(lib.es5.d.ts, --, --)) | ||
>inner : Symbol(inner, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 9, 53)) | ||
|
||
: never; | ||
|
||
type OmitHomomorphicFromWrapped<t> = t extends WrappedT<infer inner> | ||
>OmitHomomorphicFromWrapped : Symbol(OmitHomomorphicFromWrapped, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 11, 10)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 13, 32)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 13, 32)) | ||
>WrappedT : Symbol(WrappedT, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 5, 2)) | ||
>inner : Symbol(inner, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 13, 61)) | ||
|
||
? WrappedT<HomomorphicOmit<inner, "bar">> | ||
>WrappedT : Symbol(WrappedT, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 5, 2)) | ||
>HomomorphicOmit : Symbol(HomomorphicOmit, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 15, 10)) | ||
>inner : Symbol(inner, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 13, 61)) | ||
|
||
: never; | ||
|
||
type HomomorphicOmit<t, keyToOmit> = { | ||
>HomomorphicOmit : Symbol(HomomorphicOmit, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 15, 10)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 17, 21)) | ||
>keyToOmit : Symbol(keyToOmit, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 17, 23)) | ||
|
||
[k in keyof t as k extends keyToOmit ? never : k]: t[k]; | ||
>k : Symbol(k, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 18, 3)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 17, 21)) | ||
>k : Symbol(k, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 18, 3)) | ||
>keyToOmit : Symbol(keyToOmit, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 17, 23)) | ||
>k : Symbol(k, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 18, 3)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 17, 21)) | ||
>k : Symbol(k, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 18, 3)) | ||
|
||
}; | ||
|
||
type OmitHomomorphicFromWrappedConformed<t> = t extends WrappedT<infer inner> | ||
>OmitHomomorphicFromWrappedConformed : Symbol(OmitHomomorphicFromWrappedConformed, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 19, 2)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 21, 41)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 21, 41)) | ||
>WrappedT : Symbol(WrappedT, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 5, 2)) | ||
>inner : Symbol(inner, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 21, 70)) | ||
|
||
? WrappedT<conform<HomomorphicOmit<inner, "bar">, T>> | ||
>WrappedT : Symbol(WrappedT, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 5, 2)) | ||
>conform : Symbol(conform, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 23, 10)) | ||
>HomomorphicOmit : Symbol(HomomorphicOmit, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 15, 10)) | ||
>inner : Symbol(inner, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 21, 70)) | ||
>T : Symbol(T, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 0, 0)) | ||
|
||
: never; | ||
|
||
type conform<t, base> = t extends base ? t : base; | ||
>conform : Symbol(conform, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 23, 10)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 25, 13)) | ||
>base : Symbol(base, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 25, 15)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 25, 13)) | ||
>base : Symbol(base, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 25, 15)) | ||
>t : Symbol(t, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 25, 13)) | ||
>base : Symbol(base, Decl(mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts, 25, 15)) | ||
|
59 changes: 59 additions & 0 deletions
59
tests/baselines/reference/mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.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,59 @@ | ||
//// [tests/cases/compiler/mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts] //// | ||
|
||
=== mappedTypeConstraintAssignabilityExactOptionalPropertyTypes1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/60233 | ||
|
||
type T = { | ||
>T : T | ||
> : ^ | ||
|
||
foo?: true; | ||
>foo : true | undefined | ||
> : ^^^^^^^^^^^^^^^^ | ||
>true : true | ||
> : ^^^^ | ||
|
||
bar?: true; | ||
>bar : true | undefined | ||
> : ^^^^^^^^^^^^^^^^ | ||
>true : true | ||
> : ^^^^ | ||
|
||
}; | ||
|
||
type WrappedT<t extends T> = [t]; | ||
>WrappedT : WrappedT<t> | ||
> : ^^^^^^^^^^^ | ||
|
||
type OmitBarFromWrapped<t> = t extends WrappedT<infer inner> | ||
>OmitBarFromWrapped : OmitBarFromWrapped<t> | ||
> : ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
? WrappedT<Omit<inner, "bar">> | ||
: never; | ||
|
||
type OmitHomomorphicFromWrapped<t> = t extends WrappedT<infer inner> | ||
>OmitHomomorphicFromWrapped : OmitHomomorphicFromWrapped<t> | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
? WrappedT<HomomorphicOmit<inner, "bar">> | ||
: never; | ||
|
||
type HomomorphicOmit<t, keyToOmit> = { | ||
>HomomorphicOmit : HomomorphicOmit<t, keyToOmit> | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
[k in keyof t as k extends keyToOmit ? never : k]: t[k]; | ||
}; | ||
|
||
type OmitHomomorphicFromWrappedConformed<t> = t extends WrappedT<infer inner> | ||
>OmitHomomorphicFromWrappedConformed : OmitHomomorphicFromWrappedConformed<t> | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
? WrappedT<conform<HomomorphicOmit<inner, "bar">, T>> | ||
: never; | ||
|
||
type conform<t, base> = t extends base ? t : base; | ||
>conform : conform<t, base> | ||
> : ^^^^^^^^^^^^^^^^ | ||
|