Skip to content

Commit 0e4c652

Browse files
committed
Add regression test
1 parent b95ad97 commit 0e4c652

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed

tests/baselines/reference/templateLiteralTypes3.errors.txt

+8
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,12 @@ templateLiteralTypes3.ts(141,9): error TS2367: This comparison appears to be uni
221221
// Repro from #52685
222222

223223
type Boom = 'abc' | 'def' | `a${string}` | Lowercase<string>;
224+
225+
// Repro from #56582
226+
227+
function a<T extends {id: string}>() {
228+
let x: keyof T & string | `-${keyof T & string}`;
229+
x = "id";
230+
x = "-id";
231+
}
224232

tests/baselines/reference/templateLiteralTypes3.js

+17
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ function ft1<T extends string>(t: T, u: Uppercase<T>, u1: Uppercase<`1.${T}.3`>,
195195
// Repro from #52685
196196

197197
type Boom = 'abc' | 'def' | `a${string}` | Lowercase<string>;
198+
199+
// Repro from #56582
200+
201+
function a<T extends {id: string}>() {
202+
let x: keyof T & string | `-${keyof T & string}`;
203+
x = "id";
204+
x = "-id";
205+
}
198206

199207

200208
//// [templateLiteralTypes3.js]
@@ -291,6 +299,12 @@ function ft1(t, u, u1, u2) {
291299
spread("1.".concat(u, ".3"), "1.".concat(u, ".4"));
292300
spread(u1, u2);
293301
}
302+
// Repro from #56582
303+
function a() {
304+
var x;
305+
x = "id";
306+
x = "-id";
307+
}
294308

295309

296310
//// [templateLiteralTypes3.d.ts]
@@ -363,3 +377,6 @@ declare function noSpread<P extends DotString>(args: P[]): P;
363377
declare function spread<P extends DotString>(...args: P[]): P;
364378
declare function ft1<T extends string>(t: T, u: Uppercase<T>, u1: Uppercase<`1.${T}.3`>, u2: Uppercase<`1.${T}.4`>): void;
365379
type Boom = 'abc' | 'def' | `a${string}` | Lowercase<string>;
380+
declare function a<T extends {
381+
id: string;
382+
}>(): void;

tests/baselines/reference/templateLiteralTypes3.symbols

+19
Original file line numberDiff line numberDiff line change
@@ -588,3 +588,22 @@ type Boom = 'abc' | 'def' | `a${string}` | Lowercase<string>;
588588
>Boom : Symbol(Boom, Decl(templateLiteralTypes3.ts, 189, 1))
589589
>Lowercase : Symbol(Lowercase, Decl(lib.es5.d.ts, --, --))
590590

591+
// Repro from #56582
592+
593+
function a<T extends {id: string}>() {
594+
>a : Symbol(a, Decl(templateLiteralTypes3.ts, 193, 61))
595+
>T : Symbol(T, Decl(templateLiteralTypes3.ts, 197, 11))
596+
>id : Symbol(id, Decl(templateLiteralTypes3.ts, 197, 22))
597+
598+
let x: keyof T & string | `-${keyof T & string}`;
599+
>x : Symbol(x, Decl(templateLiteralTypes3.ts, 198, 7))
600+
>T : Symbol(T, Decl(templateLiteralTypes3.ts, 197, 11))
601+
>T : Symbol(T, Decl(templateLiteralTypes3.ts, 197, 11))
602+
603+
x = "id";
604+
>x : Symbol(x, Decl(templateLiteralTypes3.ts, 198, 7))
605+
606+
x = "-id";
607+
>x : Symbol(x, Decl(templateLiteralTypes3.ts, 198, 7))
608+
}
609+

tests/baselines/reference/templateLiteralTypes3.types

+20
Original file line numberDiff line numberDiff line change
@@ -601,3 +601,23 @@ function ft1<T extends string>(t: T, u: Uppercase<T>, u1: Uppercase<`1.${T}.3`>,
601601
type Boom = 'abc' | 'def' | `a${string}` | Lowercase<string>;
602602
>Boom : `a${string}` | Lowercase<string> | "def"
603603

604+
// Repro from #56582
605+
606+
function a<T extends {id: string}>() {
607+
>a : <T extends { id: string; }>() => void
608+
>id : string
609+
610+
let x: keyof T & string | `-${keyof T & string}`;
611+
>x : (keyof T & string) | `-${keyof T & string}`
612+
613+
x = "id";
614+
>x = "id" : "id"
615+
>x : (keyof T & string) | `-${keyof T & string}`
616+
>"id" : "id"
617+
618+
x = "-id";
619+
>x = "-id" : "-id"
620+
>x : (keyof T & string) | `-${keyof T & string}`
621+
>"-id" : "-id"
622+
}
623+

tests/cases/conformance/types/literal/templateLiteralTypes3.ts

+8
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,11 @@ function ft1<T extends string>(t: T, u: Uppercase<T>, u1: Uppercase<`1.${T}.3`>,
195195
// Repro from #52685
196196

197197
type Boom = 'abc' | 'def' | `a${string}` | Lowercase<string>;
198+
199+
// Repro from #56582
200+
201+
function a<T extends {id: string}>() {
202+
let x: keyof T & string | `-${keyof T & string}`;
203+
x = "id";
204+
x = "-id";
205+
}

0 commit comments

Comments
 (0)