diff --git a/tests/baselines/reference/templateLiteralTypes3.errors.txt b/tests/baselines/reference/templateLiteralTypes3.errors.txt index 4c6e98d936..d47b0932cc 100644 --- a/tests/baselines/reference/templateLiteralTypes3.errors.txt +++ b/tests/baselines/reference/templateLiteralTypes3.errors.txt @@ -198,4 +198,17 @@ tests/cases/conformance/types/literal/templateLiteralTypes3.ts(141,9): error TS2 action.response; } } + + // Repro from #46768 + + type DotString = `${string}.${string}.${string}`; + + declare function noSpread

(args: P[]): P; + declare function spread

(...args: P[]): P; + + noSpread([`1.${'2'}.3`, `1.${'2'}.4`]); + noSpread([`1.${'2' as string}.3`, `1.${'2' as string}.4`]); + + spread(`1.${'2'}.3`, `1.${'2'}.4`); + spread(`1.${'2' as string}.3`, `1.${'2' as string}.4`); \ No newline at end of file diff --git a/tests/baselines/reference/templateLiteralTypes3.js b/tests/baselines/reference/templateLiteralTypes3.js index fc2df68a40..ff4d95a524 100644 --- a/tests/baselines/reference/templateLiteralTypes3.js +++ b/tests/baselines/reference/templateLiteralTypes3.js @@ -170,6 +170,19 @@ function reducer(action: Action) { action.response; } } + +// Repro from #46768 + +type DotString = `${string}.${string}.${string}`; + +declare function noSpread

(args: P[]): P; +declare function spread

(...args: P[]): P; + +noSpread([`1.${'2'}.3`, `1.${'2'}.4`]); +noSpread([`1.${'2' as string}.3`, `1.${'2' as string}.4`]); + +spread(`1.${'2'}.3`, `1.${'2'}.4`); +spread(`1.${'2' as string}.3`, `1.${'2' as string}.4`); //// [templateLiteralTypes3.js] @@ -257,6 +270,10 @@ function reducer(action) { action.response; } } +noSpread(["1.".concat('2', ".3"), "1.".concat('2', ".4")]); +noSpread(["1.".concat('2', ".3"), "1.".concat('2', ".4")]); +spread("1.".concat('2', ".3"), "1.".concat('2', ".4")); +spread("1.".concat('2', ".3"), "1.".concat('2', ".4")); //// [templateLiteralTypes3.d.ts] @@ -324,3 +341,6 @@ declare type Action = { response: string; }; declare function reducer(action: Action): void; +declare type DotString = `${string}.${string}.${string}`; +declare function noSpread

(args: P[]): P; +declare function spread

(...args: P[]): P; diff --git a/tests/baselines/reference/templateLiteralTypes3.symbols b/tests/baselines/reference/templateLiteralTypes3.symbols index 570a85a809..cad983377a 100644 --- a/tests/baselines/reference/templateLiteralTypes3.symbols +++ b/tests/baselines/reference/templateLiteralTypes3.symbols @@ -516,3 +516,36 @@ function reducer(action: Action) { } } +// Repro from #46768 + +type DotString = `${string}.${string}.${string}`; +>DotString : Symbol(DotString, Decl(templateLiteralTypes3.ts, 170, 1)) + +declare function noSpread

(args: P[]): P; +>noSpread : Symbol(noSpread, Decl(templateLiteralTypes3.ts, 174, 49)) +>P : Symbol(P, Decl(templateLiteralTypes3.ts, 176, 26)) +>DotString : Symbol(DotString, Decl(templateLiteralTypes3.ts, 170, 1)) +>args : Symbol(args, Decl(templateLiteralTypes3.ts, 176, 47)) +>P : Symbol(P, Decl(templateLiteralTypes3.ts, 176, 26)) +>P : Symbol(P, Decl(templateLiteralTypes3.ts, 176, 26)) + +declare function spread

(...args: P[]): P; +>spread : Symbol(spread, Decl(templateLiteralTypes3.ts, 176, 61)) +>P : Symbol(P, Decl(templateLiteralTypes3.ts, 177, 24)) +>DotString : Symbol(DotString, Decl(templateLiteralTypes3.ts, 170, 1)) +>args : Symbol(args, Decl(templateLiteralTypes3.ts, 177, 45)) +>P : Symbol(P, Decl(templateLiteralTypes3.ts, 177, 24)) +>P : Symbol(P, Decl(templateLiteralTypes3.ts, 177, 24)) + +noSpread([`1.${'2'}.3`, `1.${'2'}.4`]); +>noSpread : Symbol(noSpread, Decl(templateLiteralTypes3.ts, 174, 49)) + +noSpread([`1.${'2' as string}.3`, `1.${'2' as string}.4`]); +>noSpread : Symbol(noSpread, Decl(templateLiteralTypes3.ts, 174, 49)) + +spread(`1.${'2'}.3`, `1.${'2'}.4`); +>spread : Symbol(spread, Decl(templateLiteralTypes3.ts, 176, 61)) + +spread(`1.${'2' as string}.3`, `1.${'2' as string}.4`); +>spread : Symbol(spread, Decl(templateLiteralTypes3.ts, 176, 61)) + diff --git a/tests/baselines/reference/templateLiteralTypes3.types b/tests/baselines/reference/templateLiteralTypes3.types index 5a8f15f27f..b0207d8b08 100644 --- a/tests/baselines/reference/templateLiteralTypes3.types +++ b/tests/baselines/reference/templateLiteralTypes3.types @@ -513,3 +513,54 @@ function reducer(action: Action) { } } +// Repro from #46768 + +type DotString = `${string}.${string}.${string}`; +>DotString : `${string}.${string}.${string}` + +declare function noSpread

(args: P[]): P; +>noSpread :

(args: P[]) => P +>args : P[] + +declare function spread

(...args: P[]): P; +>spread :

(...args: P[]) => P +>args : P[] + +noSpread([`1.${'2'}.3`, `1.${'2'}.4`]); +>noSpread([`1.${'2'}.3`, `1.${'2'}.4`]) : "1.2.3" | "1.2.4" +>noSpread :

(args: P[]) => P +>[`1.${'2'}.3`, `1.${'2'}.4`] : ("1.2.3" | "1.2.4")[] +>`1.${'2'}.3` : "1.2.3" +>'2' : "2" +>`1.${'2'}.4` : "1.2.4" +>'2' : "2" + +noSpread([`1.${'2' as string}.3`, `1.${'2' as string}.4`]); +>noSpread([`1.${'2' as string}.3`, `1.${'2' as string}.4`]) : `1.${string}.3` | `1.${string}.4` +>noSpread :

(args: P[]) => P +>[`1.${'2' as string}.3`, `1.${'2' as string}.4`] : (`1.${string}.3` | `1.${string}.4`)[] +>`1.${'2' as string}.3` : `1.${string}.3` +>'2' as string : string +>'2' : "2" +>`1.${'2' as string}.4` : `1.${string}.4` +>'2' as string : string +>'2' : "2" + +spread(`1.${'2'}.3`, `1.${'2'}.4`); +>spread(`1.${'2'}.3`, `1.${'2'}.4`) : "1.2.3" | "1.2.4" +>spread :

(...args: P[]) => P +>`1.${'2'}.3` : "1.2.3" +>'2' : "2" +>`1.${'2'}.4` : "1.2.4" +>'2' : "2" + +spread(`1.${'2' as string}.3`, `1.${'2' as string}.4`); +>spread(`1.${'2' as string}.3`, `1.${'2' as string}.4`) : `1.${string}.3` | `1.${string}.4` +>spread :

(...args: P[]) => P +>`1.${'2' as string}.3` : `1.${string}.3` +>'2' as string : string +>'2' : "2" +>`1.${'2' as string}.4` : `1.${string}.4` +>'2' as string : string +>'2' : "2" + diff --git a/tests/cases/conformance/types/literal/templateLiteralTypes3.ts b/tests/cases/conformance/types/literal/templateLiteralTypes3.ts index fbeae4b3f6..0d3092954d 100644 --- a/tests/cases/conformance/types/literal/templateLiteralTypes3.ts +++ b/tests/cases/conformance/types/literal/templateLiteralTypes3.ts @@ -172,3 +172,16 @@ function reducer(action: Action) { action.response; } } + +// Repro from #46768 + +type DotString = `${string}.${string}.${string}`; + +declare function noSpread

(args: P[]): P; +declare function spread

(...args: P[]): P; + +noSpread([`1.${'2'}.3`, `1.${'2'}.4`]); +noSpread([`1.${'2' as string}.3`, `1.${'2' as string}.4`]); + +spread(`1.${'2'}.3`, `1.${'2'}.4`); +spread(`1.${'2' as string}.3`, `1.${'2' as string}.4`);