Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add regression test
  • Loading branch information
ahejlsberg committed Mar 25, 2021
commit c8ce5c6494048987a2028436e6164d1d65f12c46
6 changes: 6 additions & 0 deletions tests/baselines/reference/templateLiteralTypes2.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,10 @@ tests/cases/conformance/types/literal/templateLiteralTypes2.ts(70,9): error TS23
const pixelString: PixelValueType = `22px`;

const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`;

// Repro from #43143

function getCardTitle(title: string): `test-${string}` {
return `test-${title}`;
}

11 changes: 11 additions & 0 deletions tests/baselines/reference/templateLiteralTypes2.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ type PixelValueType = `${number}px`;
const pixelString: PixelValueType = `22px`;

const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`;

// Repro from #43143

function getCardTitle(title: string): `test-${string}` {
return `test-${title}`;
}


//// [templateLiteralTypes2.js]
Expand Down Expand Up @@ -172,6 +178,10 @@ var t5 = takesLiteral("foo.bar." + someUnion); // "abc" | "def" | "ghi"
var pixelValue = 22;
var pixelString = "22px";
var pixelStringWithTemplate = pixelValue + "px";
// Repro from #43143
function getCardTitle(title) {
return "test-" + title;
}


//// [templateLiteralTypes2.d.ts]
Expand Down Expand Up @@ -199,3 +209,4 @@ declare const pixelValue: number;
declare type PixelValueType = `${number}px`;
declare const pixelString: PixelValueType;
declare const pixelStringWithTemplate: PixelValueType;
declare function getCardTitle(title: string): `test-${string}`;
10 changes: 10 additions & 0 deletions tests/baselines/reference/templateLiteralTypes2.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,13 @@ const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`;
>PixelValueType : Symbol(PixelValueType, Decl(templateLiteralTypes2.ts, 91, 30))
>pixelValue : Symbol(pixelValue, Decl(templateLiteralTypes2.ts, 91, 5))

// Repro from #43143

function getCardTitle(title: string): `test-${string}` {
>getCardTitle : Symbol(getCardTitle, Decl(templateLiteralTypes2.ts, 97, 66))
>title : Symbol(title, Decl(templateLiteralTypes2.ts, 101, 22))

return `test-${title}`;
>title : Symbol(title, Decl(templateLiteralTypes2.ts, 101, 22))
}

11 changes: 11 additions & 0 deletions tests/baselines/reference/templateLiteralTypes2.types
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,14 @@ const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`;
>`${pixelValue}px` : `${number}px`
>pixelValue : number

// Repro from #43143

function getCardTitle(title: string): `test-${string}` {
>getCardTitle : (title: string) => `test-${string}`
>title : string

return `test-${title}`;
>`test-${title}` : `test-${string}`
>title : string
}

Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,9 @@ type PixelValueType = `${number}px`;
const pixelString: PixelValueType = `22px`;

const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`;

// Repro from #43143

function getCardTitle(title: string): `test-${string}` {
return `test-${title}`;
}