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
.
45 lines
1.7 KiB
Plaintext
45 lines
1.7 KiB
Plaintext
tests/cases/compiler/mappedTypeIndexedAccess.ts(18,5): error TS2322: Type '{ key: "foo"; value: number; }' is not assignable to type 'Pair<FooBar>'.
|
|
Types of property 'value' are incompatible.
|
|
Type 'number' is not assignable to type 'string'.
|
|
tests/cases/compiler/mappedTypeIndexedAccess.ts(24,5): error TS2322: Type '{ key: "foo"; value: number; }' is not assignable to type '{ key: "foo"; value: string; } | { key: "bar"; value: number; }'.
|
|
Types of property 'value' are incompatible.
|
|
Type 'number' is not assignable to type 'string'.
|
|
|
|
|
|
==== tests/cases/compiler/mappedTypeIndexedAccess.ts (2 errors) ====
|
|
// Repro from #15756
|
|
|
|
type Pairs<T> = {
|
|
[TKey in keyof T]: {
|
|
key: TKey;
|
|
value: T[TKey];
|
|
};
|
|
};
|
|
|
|
type Pair<T> = Pairs<T>[keyof T];
|
|
|
|
type FooBar = {
|
|
foo: string;
|
|
bar: number;
|
|
};
|
|
|
|
// Error expected here
|
|
let pair1: Pair<FooBar> = {
|
|
~~~~~
|
|
!!! error TS2322: Type '{ key: "foo"; value: number; }' is not assignable to type 'Pair<FooBar>'.
|
|
!!! error TS2322: Types of property 'value' are incompatible.
|
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
|
key: "foo",
|
|
value: 3
|
|
};
|
|
|
|
// Error expected here
|
|
let pair2: Pairs<FooBar>[keyof FooBar] = {
|
|
~~~~~
|
|
!!! error TS2322: Type '{ key: "foo"; value: number; }' is not assignable to type '{ key: "foo"; value: string; } | { key: "bar"; value: number; }'.
|
|
!!! error TS2322: Types of property 'value' are incompatible.
|
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
|
key: "foo",
|
|
value: 3
|
|
};
|
|
|