|
145 | 145 | import com.semmle.ts.ast.ParenthesizedTypeExpr; |
146 | 146 | import com.semmle.ts.ast.PredicateTypeExpr; |
147 | 147 | import com.semmle.ts.ast.RestTypeExpr; |
| 148 | +import com.semmle.ts.ast.TemplateLiteralTypeExpr; |
148 | 149 | import com.semmle.ts.ast.TupleTypeExpr; |
149 | 150 | import com.semmle.ts.ast.TypeAliasDeclaration; |
150 | 151 | import com.semmle.ts.ast.TypeAssertion; |
@@ -576,6 +577,8 @@ private Node convertNodeUntyped(JsonObject node, String defaultKind) throws Pars |
576 | 577 | case "TemplateMiddle": |
577 | 578 | case "TemplateTail": |
578 | 579 | return convertTemplateElement(node, kind, loc); |
| 580 | + case "TemplateLiteralType": |
| 581 | + return convertTemplateLiteralType(node, loc); |
579 | 582 | case "ThisKeyword": |
580 | 583 | return convertThisKeyword(loc); |
581 | 584 | case "ThisType": |
@@ -2152,6 +2155,19 @@ private Node convertTemplateExpression(JsonObject node, SourceLocation loc) thro |
2152 | 2155 | return new TemplateLiteral(loc, expressions, quasis); |
2153 | 2156 | } |
2154 | 2157 |
|
| 2158 | + private Node convertTemplateLiteralType(JsonObject node, SourceLocation loc) throws ParseError { |
| 2159 | + List<TemplateElement> quasis; |
| 2160 | + List<ITypeExpression> expressions = new ArrayList<>(); |
| 2161 | + quasis = new ArrayList<>(); |
| 2162 | + quasis.add(convertChild(node, "head")); |
| 2163 | + for (JsonElement elt : node.get("templateSpans").getAsJsonArray()) { |
| 2164 | + JsonObject templateSpan = (JsonObject) elt; |
| 2165 | + expressions.add(convertChildAsType(templateSpan, "type")); |
| 2166 | + quasis.add(convertChild(templateSpan, "literal")); |
| 2167 | + } |
| 2168 | + return new TemplateLiteralTypeExpr(loc, expressions, quasis); |
| 2169 | + } |
| 2170 | + |
2155 | 2171 | private Node convertTemplateElement(JsonObject node, String kind, SourceLocation loc) { |
2156 | 2172 | boolean tail = "TemplateTail".equals(kind); |
2157 | 2173 | if (loc.getSource().startsWith("`") || loc.getSource().startsWith("}")) { |
|
0 commit comments