Skip to content

Commit

Permalink
Make ClassDeclaration["id"] optional in babel-types (#15920)
Browse files Browse the repository at this point in the history
fix(types): make ClassDeclaration.id optional
  • Loading branch information
jordanbtucker committed Sep 7, 2023
1 parent 85a35ad commit 1fb3b7a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/babel-types/src/ast-types/generated/index.ts
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
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
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

0 comments on commit 1fb3b7a

Please sign in to comment.