Skip to content

Commit a20204c

Browse files
committed
fix: parser error when node content has word that contain in
1 parent f5d4c32 commit a20204c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/transform.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -308,17 +308,23 @@ async function removeTypesFromVueSfcScript(
308308
enter(node) {
309309
let content = "";
310310
if (isVueSimpleExpressionNode(node) && !node.isStatic) {
311-
const ForOfOrInRE = /\s*(of|in)\s*/;
311+
const ForOfOrInRE = /\s+(of|in)\s+/;
312312
if (node.content.match(ForOfOrInRE)) {
313313
const parts = node.content.split(ForOfOrInRE);
314-
content = parts[parts.length - 1];
314+
if (parts.length === 3) {
315+
content = parts[parts.length - 1];
316+
} else {
317+
content = node.content;
318+
}
315319
} else {
316320
content = node.content;
317321
}
318322
} else if (isVueComponentNode(node)) {
319323
content = node.tag;
320324
}
321-
expressions.add(`[${content}]`);
325+
if (content) {
326+
expressions.add(`[${content}]`);
327+
}
322328
},
323329
});
324330

0 commit comments

Comments
 (0)