6aeb8c12cc
* Create separate types for equivalent aliased unions * Accept new baselines * Preserve original types for union types * Accept new baselines * Preserve intersection origin for union types * Accept new baselines * Accept new baselines * Preserve aliases during relationship checks * Accept new baselines * Preserve aliases for intersection and indexed access types * Accept new baselines * Compute intersection-of-unions cross product without recursion * Accept new baselines * Use denormalized type objects for origin / support 'keyof' origins * Accept new baselines * Fix fourslash test * Recursively extract named union types * Accept new baselines * Map on union origin in mapType to better preserve aliases and origins * Remove redundant call * Accept new baselines * Revert back to declared type when branches produce equivalent union * Accept new baselines * Don't include denormal origin types in regular type statistics * Fix issue with unions not being marked primitive-only * Allow new alias to be associated with type alias instantiation * Accept new baselines * Revert "Accept new baselines" This reverts commit4507270cc1
. * Revert "Allow new alias to be associated with type alias instantiation" This reverts commit2c2d06dfe1
.
61 lines
952 B
Plaintext
61 lines
952 B
Plaintext
=== tests/cases/compiler/mappedTypeIndexedAccess.ts ===
|
|
// Repro from #15756
|
|
|
|
type Pairs<T> = {
|
|
>Pairs : Pairs<T>
|
|
|
|
[TKey in keyof T]: {
|
|
key: TKey;
|
|
>key : TKey
|
|
|
|
value: T[TKey];
|
|
>value : T[TKey]
|
|
|
|
};
|
|
};
|
|
|
|
type Pair<T> = Pairs<T>[keyof T];
|
|
>Pair : Pair<T>
|
|
|
|
type FooBar = {
|
|
>FooBar : FooBar
|
|
|
|
foo: string;
|
|
>foo : string
|
|
|
|
bar: number;
|
|
>bar : number
|
|
|
|
};
|
|
|
|
// Error expected here
|
|
let pair1: Pair<FooBar> = {
|
|
>pair1 : Pair<FooBar>
|
|
>{ key: "foo", value: 3} : { key: "foo"; value: number; }
|
|
|
|
key: "foo",
|
|
>key : "foo"
|
|
>"foo" : "foo"
|
|
|
|
value: 3
|
|
>value : number
|
|
>3 : 3
|
|
|
|
};
|
|
|
|
// Error expected here
|
|
let pair2: Pairs<FooBar>[keyof FooBar] = {
|
|
>pair2 : { key: "foo"; value: string; } | { key: "bar"; value: number; }
|
|
>{ key: "foo", value: 3} : { key: "foo"; value: number; }
|
|
|
|
key: "foo",
|
|
>key : "foo"
|
|
>"foo" : "foo"
|
|
|
|
value: 3
|
|
>value : number
|
|
>3 : 3
|
|
|
|
};
|
|
|