Skip to content

Commit 23af451

Browse files
Merge pull request #1415 from spanishpear/master
Feat: support Typescript type arguments on tagged template literals
2 parents 82249ff + 539b8d3 commit 23af451

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/printer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,12 @@ function genericPrintNoParens(path: any, options: any, print: any) {
15871587
}
15881588

15891589
case "TaggedTemplateExpression":
1590-
return concat([path.call(print, "tag"), path.call(print, "quasi")]);
1590+
parts.push(path.call(print, "tag"));
1591+
if (n.typeParameters) {
1592+
parts.push(path.call(print, "typeParameters"));
1593+
}
1594+
parts.push(path.call(print, "quasi"));
1595+
return concat(parts);
15911596

15921597
// These types are unprintable because they serve as abstract
15931598
// supertypes for other (printable) types.

test/typescript.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,14 @@ const nodeMajorVersion = parseInt(process.versions.node, 10);
331331
check(["type Class<T> = new (...args: any) => T;"]);
332332

333333
check(["type T1 = [...Array<any>];", "type T2 = [...any[]];"]);
334+
check([
335+
"const a = styled.h1<{",
336+
" $upsideDown?: boolean;",
337+
"}>`",
338+
' ${props => props.$upsideDown && "transform: rotate(180deg);"}',
339+
" text-align: center;",
340+
"`;",
341+
]);
334342

335343
check([
336344
"type Color = [r: number, g: number, b: number, a?: number];",

0 commit comments

Comments
 (0)