[ts] Add support for template interpolations in types (#12131)

Co-authored-by: Brian Ng <bng412@gmail.com>
This commit is contained in:
Nicolò Ribaudo
2020-10-14 20:15:42 +02:00
committed by GitHub
parent 9f40d6fcd0
commit 3fd963fdc8
10 changed files with 106 additions and 19 deletions

View File

@@ -1608,7 +1608,7 @@ export default class ExpressionParser extends LValParser {
node.quasis = [curElt];
while (!curElt.tail) {
this.expect(tt.dollarBraceL);
node.expressions.push(this.parseExpression());
node.expressions.push(this.parseTemplateSubstitution());
this.expect(tt.braceR);
node.quasis.push((curElt = this.parseTemplateElement(isTagged)));
}
@@ -1616,6 +1616,11 @@ export default class ExpressionParser extends LValParser {
return this.finishNode(node, "TemplateLiteral");
}
// This is overwritten by the TypeScript plugin to parse template types
parseTemplateSubstitution(): N.Expression {
return this.parseExpression();
}
// Parse an object literal, binding pattern, or record.
parseObjectLike<T: N.ObjectPattern | N.ObjectExpression>(