TypeScript/tests/baselines/reference/keyofIntersection.types
Anders Hejlsberg c456bbd466
Support re-aliasing of type alias instantiations (#42284)
* New aliases for type alias instantiations

* New aliases for conditional, mapped, and anonymous object type instantiations

* Accept new baselines

* Fix issues with re-aliasing

* Accept new baselines
2021-01-11 13:29:46 -10:00

60 lines
1.4 KiB
Plaintext

=== tests/cases/conformance/types/keyof/keyofIntersection.ts ===
type A = { a: string };
>A : A
>a : string
type B = { b: string };
>B : B
>b : string
type T01 = keyof (A & B); // "a" | "b"
>T01 : "b" | "a"
type T02<T> = keyof (T & B); // "b" | keyof T
>T02 : keyof T | "b"
type T03<U> = keyof (A & U); // "a" | keyof U
>T03 : "a" | keyof U
type T04<T, U> = keyof (T & U); // keyof T | keyof U
>T04 : keyof T | keyof U
type T05 = T02<A>; // "a" | "b"
>T05 : T05
type T06 = T03<B>; // "a" | "b"
>T06 : T06
type T07 = T04<A, B>; // "a" | "b"
>T07 : T07
// Repros from #22291
type Example1<T extends string, U extends string> = keyof (Record<T, any> & Record<U, any>);
>Example1 : T | U
type Result1 = Example1<'x', 'y'>; // "x" | "y"
>Result1 : Result1
type Result2 = keyof (Record<'x', any> & Record<'y', any>); // "x" | "y"
>Result2 : "x" | "y"
type Example3<T extends string> = keyof (Record<T, any>);
>Example3 : T
type Result3 = Example3<'x' | 'y'>; // "x" | "y"
>Result3 : "x" | "y"
type Example4<T extends string, U extends string> = (Record<T, any> & Record<U, any>);
>Example4 : Example4<T, U>
type Result4 = keyof Example4<'x', 'y'>; // "x" | "y"
>Result4 : "x" | "y"
type Example5<T, U> = keyof (T & U);
>Example5 : keyof T | keyof U
type Result5 = Example5<Record<'x', any>, Record<'y', any>>; // "x" | "y"
>Result5 : Result5