mirror of
https://github.com/swc-project/swc.git
synced 2024-11-27 13:38:33 +03:00
fix(node-swc): Fix handling of tagged template expressions in Visitor (#1544)
This commit is contained in:
parent
beeb1f9067
commit
228429c7bb
@ -83,6 +83,9 @@ const Visitor = require("../../../Visitor").default;
|
||||
call(...foo);
|
||||
call(foo);
|
||||
|
||||
// Verify that visitor can handle tagged template expressions.
|
||||
css\`color: red\`;
|
||||
|
||||
let arr = [elem, , ...foo];
|
||||
|
||||
module.exports = {
|
||||
|
@ -1156,7 +1156,10 @@ export default class Visitor {
|
||||
|
||||
visitTaggedTemplateExpression(n: TaggedTemplateExpression): Expression {
|
||||
n.tag = this.visitExpression(n.tag);
|
||||
n.expressions = n.expressions.map(this.visitExpression.bind(this));
|
||||
const template = this.visitTemplateLiteral(n.template);
|
||||
if (template.type === "TemplateLiteral") {
|
||||
n.template = template;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -957,21 +957,21 @@ export interface AwaitExpression extends ExpressionBase {
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
export interface TplBase {
|
||||
export interface TemplateLiteral extends ExpressionBase {
|
||||
type: "TemplateLiteral";
|
||||
|
||||
expressions: Expression[];
|
||||
|
||||
quasis: TemplateElement[];
|
||||
}
|
||||
|
||||
export interface TemplateLiteral extends ExpressionBase, TplBase {
|
||||
type: "TemplateLiteral";
|
||||
}
|
||||
|
||||
export interface TaggedTemplateExpression extends ExpressionBase, TplBase {
|
||||
export interface TaggedTemplateExpression extends ExpressionBase {
|
||||
type: "TaggedTemplateExpression";
|
||||
|
||||
tag: Expression;
|
||||
|
||||
template: TemplateLiteral;
|
||||
|
||||
typeParameters: TsTypeParameterInstantiation;
|
||||
}
|
||||
|
||||
@ -1272,7 +1272,7 @@ export interface ImportNamespaceSpecifier extends Node, HasSpan {
|
||||
export interface NamedImportSpecifier extends Node, HasSpan {
|
||||
type: "ImportSpecifier";
|
||||
local: Identifier;
|
||||
imported: Identifier;
|
||||
imported: Identifier | null;
|
||||
}
|
||||
|
||||
export type ExportSpecifier =
|
||||
|
Loading…
Reference in New Issue
Block a user