Merge pull request #1415 from spanishpear/master

Feat: support Typescript type arguments on tagged template literals
This commit is contained in:
Brian Donovan 2025-03-02 17:45:33 -08:00 committed by GitHub
commit 23af4519a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View file

@ -1587,7 +1587,12 @@ function genericPrintNoParens(path: any, options: any, print: any) {
}
case "TaggedTemplateExpression":
return concat([path.call(print, "tag"), path.call(print, "quasi")]);
parts.push(path.call(print, "tag"));
if (n.typeParameters) {
parts.push(path.call(print, "typeParameters"));
}
parts.push(path.call(print, "quasi"));
return concat(parts);
// These types are unprintable because they serve as abstract
// supertypes for other (printable) types.

View file

@ -331,6 +331,14 @@ const nodeMajorVersion = parseInt(process.versions.node, 10);
check(["type Class<T> = new (...args: any) => T;"]);
check(["type T1 = [...Array<any>];", "type T2 = [...any[]];"]);
check([
"const a = styled.h1<{",
" $upsideDown?: boolean;",
"}>`",
' ${props => props.$upsideDown && "transform: rotate(180deg);"}',
" text-align: center;",
"`;",
]);
check([
"type Color = [r: number, g: number, b: number, a?: number];",