Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Jul 14, 2022
1 parent 13011e1 commit 90a28cb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
5 changes: 4 additions & 1 deletion packages/babel-types/scripts/utils/stringifyValidator.js
Expand Up @@ -8,7 +8,10 @@ export default function stringifyValidator(validator, nodePrefix) {
}

if (validator.chainOf) {
return stringifyValidator(validator.chainOf[1], nodePrefix);
const ret = stringifyValidator(validator.chainOf[1], nodePrefix);
return Array.isArray(ret) && ret.length === 1 && ret[0] === "any"
? stringifyValidator(validator.chainOf[0], nodePrefix)
: ret;
}

if (validator.oneOf) {
Expand Down
27 changes: 12 additions & 15 deletions packages/babel-types/src/definitions/core.ts
Expand Up @@ -1961,20 +1961,6 @@ defineType("TaggedTemplateExpression", {
},
});

function templateElementCookedValidator(node: t.TemplateElement) {
const raw = node.value.raw;
if (node.value.cooked != null) {
return;
}

let cooked = null;
try {
cooked = unraw(raw);
} catch (error) {}
node.value.cooked = cooked;
}
templateElementCookedValidator.type = "{ raw: string; cooked?: string }"; // hack

defineType("TemplateElement", {
builder: ["value", "tail"],
fields: {
Expand All @@ -1989,7 +1975,18 @@ defineType("TemplateElement", {
optional: true,
},
}),
templateElementCookedValidator,
function templateElementCookedValidator(node: t.TemplateElement) {
const raw = node.value.raw;
if (node.value.cooked != null) {
return;
}

let cooked = null;
try {
cooked = unraw(raw);
} catch (error) {}
node.value.cooked = cooked;
},
),
},
tail: {
Expand Down

0 comments on commit 90a28cb

Please sign in to comment.