Skip to content

Commit

Permalink
merge intermediate node declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed May 9, 2022
1 parent fbadf00 commit 2600b5a
Show file tree
Hide file tree
Showing 2 changed files with 832 additions and 955 deletions.
12 changes: 6 additions & 6 deletions packages/babel-types/scripts/generators/builders.js
Expand Up @@ -117,16 +117,16 @@ import type * as t from "../..";

output += `${
formatedBuilderNameLocal === formatedBuilderName ? "export " : ""
}function ${formatedBuilderNameLocal}(${defArgs.join(
", "
)}) {\n const node: t.${type} = {\n${objectFields
}function ${formatedBuilderNameLocal}(${defArgs.join(", ")}): t.${type} {`;

const nodeObjectExpression = `{\n${objectFields
.map(([k, v]) => (k === v ? ` ${k},` : ` ${k}: ${v},`))
.join("\n")} };`;
.join("\n")}\n }`;

if (builderNames.length > 0) {
output += `\n return validateNode(node);`;
output += `\n return validateNode<t.${type}>(${nodeObjectExpression});`;
} else {
output += `\n return node;`;
output += `\n return ${nodeObjectExpression};`;
}
output += `\n}\n`;

Expand Down

0 comments on commit 2600b5a

Please sign in to comment.