TypeScript/tests/baselines/reference/primitiveUnionDetection.types
Anders Hejlsberg 56f81075f9
Properly check whether union type contains only primitive types (#46645)
* Properly check whether union type contains only primitive types

* Add regression test

* Remove 'export' modifier from test
2021-11-02 12:46:26 -07:00

21 lines
828 B
Plaintext

=== tests/cases/compiler/primitiveUnionDetection.ts ===
// Repro from #46624
type Kind = "one" | "two" | "three";
>Kind : Kind
declare function getInterfaceFromString<T extends Kind>(options?: { type?: T } & { type?: Kind }): T;
>getInterfaceFromString : <T extends Kind>(options?: ({ type?: T | undefined; } & { type?: Kind | undefined; }) | undefined) => T
>options : ({ type?: T | undefined; } & { type?: Kind | undefined; }) | undefined
>type : T | undefined
>type : Kind | undefined
const result = getInterfaceFromString({ type: 'two' });
>result : "two"
>getInterfaceFromString({ type: 'two' }) : "two"
>getInterfaceFromString : <T extends Kind>(options?: ({ type?: T | undefined; } & { type?: Kind | undefined; }) | undefined) => T
>{ type: 'two' } : { type: "two"; }
>type : "two"
>'two' : "two"