Skip to content

Commit f9aa40e

Browse files
committed
Add regression test
1 parent c79dff1 commit f9aa40e

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//// [primitiveUnionDetection.ts]
2+
// Repro from #46624
3+
4+
export type Kind = "one" | "two" | "three";
5+
6+
declare function getInterfaceFromString<T extends Kind>(options?: { type?: T } & { type?: Kind }): T;
7+
8+
const result = getInterfaceFromString({ type: 'two' });
9+
10+
11+
//// [primitiveUnionDetection.js]
12+
"use strict";
13+
// Repro from #46624
14+
exports.__esModule = true;
15+
var result = getInterfaceFromString({ type: 'two' });
16+
17+
18+
//// [primitiveUnionDetection.d.ts]
19+
export declare type Kind = "one" | "two" | "three";
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== tests/cases/compiler/primitiveUnionDetection.ts ===
2+
// Repro from #46624
3+
4+
export type Kind = "one" | "two" | "three";
5+
>Kind : Symbol(Kind, Decl(primitiveUnionDetection.ts, 0, 0))
6+
7+
declare function getInterfaceFromString<T extends Kind>(options?: { type?: T } & { type?: Kind }): T;
8+
>getInterfaceFromString : Symbol(getInterfaceFromString, Decl(primitiveUnionDetection.ts, 2, 43))
9+
>T : Symbol(T, Decl(primitiveUnionDetection.ts, 4, 40))
10+
>Kind : Symbol(Kind, Decl(primitiveUnionDetection.ts, 0, 0))
11+
>options : Symbol(options, Decl(primitiveUnionDetection.ts, 4, 56))
12+
>type : Symbol(type, Decl(primitiveUnionDetection.ts, 4, 67))
13+
>T : Symbol(T, Decl(primitiveUnionDetection.ts, 4, 40))
14+
>type : Symbol(type, Decl(primitiveUnionDetection.ts, 4, 82))
15+
>Kind : Symbol(Kind, Decl(primitiveUnionDetection.ts, 0, 0))
16+
>T : Symbol(T, Decl(primitiveUnionDetection.ts, 4, 40))
17+
18+
const result = getInterfaceFromString({ type: 'two' });
19+
>result : Symbol(result, Decl(primitiveUnionDetection.ts, 6, 5))
20+
>getInterfaceFromString : Symbol(getInterfaceFromString, Decl(primitiveUnionDetection.ts, 2, 43))
21+
>type : Symbol(type, Decl(primitiveUnionDetection.ts, 6, 39))
22+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
=== tests/cases/compiler/primitiveUnionDetection.ts ===
2+
// Repro from #46624
3+
4+
export type Kind = "one" | "two" | "three";
5+
>Kind : Kind
6+
7+
declare function getInterfaceFromString<T extends Kind>(options?: { type?: T } & { type?: Kind }): T;
8+
>getInterfaceFromString : <T extends Kind>(options?: ({ type?: T | undefined; } & { type?: Kind | undefined; }) | undefined) => T
9+
>options : ({ type?: T | undefined; } & { type?: Kind | undefined; }) | undefined
10+
>type : T | undefined
11+
>type : Kind | undefined
12+
13+
const result = getInterfaceFromString({ type: 'two' });
14+
>result : "two"
15+
>getInterfaceFromString({ type: 'two' }) : "two"
16+
>getInterfaceFromString : <T extends Kind>(options?: ({ type?: T | undefined; } & { type?: Kind | undefined; }) | undefined) => T
17+
>{ type: 'two' } : { type: "two"; }
18+
>type : "two"
19+
>'two' : "two"
20+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @strict: true
2+
// @declaration: true
3+
4+
// Repro from #46624
5+
6+
export type Kind = "one" | "two" | "three";
7+
8+
declare function getInterfaceFromString<T extends Kind>(options?: { type?: T } & { type?: Kind }): T;
9+
10+
const result = getInterfaceFromString({ type: 'two' });

0 commit comments

Comments
 (0)