Skip to content

Commit c8ce5c6

Browse files
committed
Add regression test
1 parent 1ba291c commit c8ce5c6

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

tests/baselines/reference/templateLiteralTypes2.errors.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,10 @@ tests/cases/conformance/types/literal/templateLiteralTypes2.ts(70,9): error TS23
120120
const pixelString: PixelValueType = `22px`;
121121

122122
const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`;
123+
124+
// Repro from #43143
125+
126+
function getCardTitle(title: string): `test-${string}` {
127+
return `test-${title}`;
128+
}
123129

tests/baselines/reference/templateLiteralTypes2.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ type PixelValueType = `${number}px`;
9797
const pixelString: PixelValueType = `22px`;
9898

9999
const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`;
100+
101+
// Repro from #43143
102+
103+
function getCardTitle(title: string): `test-${string}` {
104+
return `test-${title}`;
105+
}
100106

101107

102108
//// [templateLiteralTypes2.js]
@@ -172,6 +178,10 @@ var t5 = takesLiteral("foo.bar." + someUnion); // "abc" | "def" | "ghi"
172178
var pixelValue = 22;
173179
var pixelString = "22px";
174180
var pixelStringWithTemplate = pixelValue + "px";
181+
// Repro from #43143
182+
function getCardTitle(title) {
183+
return "test-" + title;
184+
}
175185

176186

177187
//// [templateLiteralTypes2.d.ts]
@@ -199,3 +209,4 @@ declare const pixelValue: number;
199209
declare type PixelValueType = `${number}px`;
200210
declare const pixelString: PixelValueType;
201211
declare const pixelStringWithTemplate: PixelValueType;
212+
declare function getCardTitle(title: string): `test-${string}`;

tests/baselines/reference/templateLiteralTypes2.symbols

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,13 @@ const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`;
322322
>PixelValueType : Symbol(PixelValueType, Decl(templateLiteralTypes2.ts, 91, 30))
323323
>pixelValue : Symbol(pixelValue, Decl(templateLiteralTypes2.ts, 91, 5))
324324

325+
// Repro from #43143
326+
327+
function getCardTitle(title: string): `test-${string}` {
328+
>getCardTitle : Symbol(getCardTitle, Decl(templateLiteralTypes2.ts, 97, 66))
329+
>title : Symbol(title, Decl(templateLiteralTypes2.ts, 101, 22))
330+
331+
return `test-${title}`;
332+
>title : Symbol(title, Decl(templateLiteralTypes2.ts, 101, 22))
333+
}
334+

tests/baselines/reference/templateLiteralTypes2.types

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,14 @@ const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`;
354354
>`${pixelValue}px` : `${number}px`
355355
>pixelValue : number
356356

357+
// Repro from #43143
358+
359+
function getCardTitle(title: string): `test-${string}` {
360+
>getCardTitle : (title: string) => `test-${string}`
361+
>title : string
362+
363+
return `test-${title}`;
364+
>`test-${title}` : `test-${string}`
365+
>title : string
366+
}
367+

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,9 @@ type PixelValueType = `${number}px`;
9999
const pixelString: PixelValueType = `22px`;
100100

101101
const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`;
102+
103+
// Repro from #43143
104+
105+
function getCardTitle(title: string): `test-${string}` {
106+
return `test-${title}`;
107+
}

0 commit comments

Comments
 (0)