Skip to content

Commit

Permalink
Add t.buildUndefinedNode (#15893)
Browse files Browse the repository at this point in the history
* add

* JLHwung feedback

---------

Co-authored-by: Nicolò Ribaudo <[email protected]>
  • Loading branch information
liuxingbaoyu and nicolo-ribaudo authored Sep 25, 2023
1 parent 38ee8b4 commit c7e6806
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/babel-traverse/src/scope/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
memberExpression,
numericLiteral,
toIdentifier,
unaryExpression,
variableDeclaration,
variableDeclarator,
isRecordExpression,
Expand All @@ -50,6 +49,7 @@ import {
isMetaProperty,
isPrivateName,
isExportDeclaration,
buildUndefinedNode,
} from "@babel/types";
import * as t from "@babel/types";
import { scope as scopeCache } from "../cache.ts";
Expand Down Expand Up @@ -783,7 +783,7 @@ export default class Scope {
}

buildUndefinedNode() {
return unaryExpression("void", numericLiteral(0), true);
return buildUndefinedNode();
}

registerConstantViolation(path: NodePath) {
Expand Down
5 changes: 5 additions & 0 deletions packages/babel-types/src/builders/productions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { numericLiteral, unaryExpression } from "./generated/index.ts";

export function buildUndefinedNode() {
return unaryExpression("void", numericLiteral(0), true);
}
1 change: 1 addition & 0 deletions packages/babel-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export { default as createFlowUnionType } from "./builders/flow/createFlowUnionT
export { default as createTSUnionType } from "./builders/typescript/createTSUnionType.ts";
export * from "./builders/generated/index.ts";
export * from "./builders/generated/uppercase.js";
export * from "./builders/productions.ts";

// clone
export { default as cloneNode } from "./clone/cloneNode.ts";
Expand Down

0 comments on commit c7e6806

Please sign in to comment.