Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(opt-in) Improve @babel/types with env.BABEL_TYPES_8_BREAKING #10917

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/babel-types/scripts/generators/docs.js
Expand Up @@ -101,8 +101,12 @@ Object.keys(types.BUILDER_KEYS)
}
if (defaultValue !== null || types.NODE_FIELDS[key][field].optional) {
fieldDescription.push(
" (default: `" + util.inspect(defaultValue) + "`)"
" (default: `" + util.inspect(defaultValue) + "`"
);
if (types.BUILDER_KEYS[key].indexOf(field) < 0) {
fieldDescription.push(", excluded from builder function");
}
fieldDescription.push(")");
} else {
fieldDescription.push(" (required)");
}
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-types/src/asserts/generated/index.js
Expand Up @@ -224,12 +224,12 @@ export function assertArrowFunctionExpression(
export function assertClassBody(node: Object, opts?: Object = {}): void {
assert("ClassBody", node, opts);
}
export function assertClassDeclaration(node: Object, opts?: Object = {}): void {
assert("ClassDeclaration", node, opts);
}
export function assertClassExpression(node: Object, opts?: Object = {}): void {
assert("ClassExpression", node, opts);
}
export function assertClassDeclaration(node: Object, opts?: Object = {}): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they are sorted alphabetically?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is automatically generated. I had to swap then in the definitions/es2015 file, so they got swapped here.

assert("ClassDeclaration", node, opts);
}
export function assertExportAllDeclaration(
node: Object,
opts?: Object = {},
Expand Down
8 changes: 4 additions & 4 deletions packages/babel-types/src/builders/generated/index.js
Expand Up @@ -225,14 +225,14 @@ export function ClassBody(...args: Array<any>): Object {
return builder("ClassBody", ...args);
}
export { ClassBody as classBody };
export function ClassDeclaration(...args: Array<any>): Object {
return builder("ClassDeclaration", ...args);
}
export { ClassDeclaration as classDeclaration };
export function ClassExpression(...args: Array<any>): Object {
return builder("ClassExpression", ...args);
}
export { ClassExpression as classExpression };
export function ClassDeclaration(...args: Array<any>): Object {
return builder("ClassDeclaration", ...args);
}
export { ClassDeclaration as classDeclaration };
export function ExportAllDeclaration(...args: Array<any>): Object {
return builder("ExportAllDeclaration", ...args);
}
Expand Down
6 changes: 6 additions & 0 deletions packages/babel-types/src/constants/index.js
Expand Up @@ -41,6 +41,12 @@ export const BINARY_OPERATORS = [
...BOOLEAN_BINARY_OPERATORS,
];

export const ASSIGNMENT_OPERATORS = [
"=",
"+=",
...NUMBER_BINARY_OPERATORS.map(op => op + "="),
];

export const BOOLEAN_UNARY_OPERATORS = ["delete", "!"];
export const NUMBER_UNARY_OPERATORS = ["+", "-", "~"];
export const STRING_UNARY_OPERATORS = ["typeof"];
Expand Down