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

Make ClassDeclaration["id"] optional in babel-types #15920

Merged
merged 1 commit into from
Sep 7, 2023
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
2 changes: 1 addition & 1 deletion packages/babel-types/src/ast-types/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ export interface ClassExpression extends BaseNode {

export interface ClassDeclaration extends BaseNode {
type: "ClassDeclaration";
id: Identifier;
id?: Identifier | null;
superClass?: Expression | null;
body: ClassBody;
decorators?: Array<Decorator> | null;
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-types/src/builders/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ export function classExpression(
});
}
export function classDeclaration(
id: t.Identifier,
id: t.Identifier | null | undefined = null,
superClass: t.Expression | null | undefined = null,
body: t.ClassBody,
decorators: Array<t.Decorator> | null = null,
Expand Down
5 changes: 3 additions & 2 deletions packages/babel-types/src/definitions/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1378,8 +1378,6 @@ defineType("ClassExpression", {
fields: {
id: {
validate: assertNodeType("Identifier"),
// In declarations, this is missing if this is the
// child of an ExportDefaultDeclaration.
optional: true,
},
typeParameters: {
Expand Down Expand Up @@ -1439,6 +1437,9 @@ defineType("ClassDeclaration", {
fields: {
id: {
validate: assertNodeType("Identifier"),
// The id may be omitted if this is the child of an
// ExportDefaultDeclaration.
optional: true,
},
typeParameters: {
validate: process.env.BABEL_8_BREAKING
Expand Down