Skip to content

Commit

Permalink
Improve AST node definitions in @babel/types (#12510)
Browse files Browse the repository at this point in the history
  • Loading branch information
zxbodya authored Dec 15, 2020
1 parent 4f1df9a commit 2f6de2f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
9 changes: 6 additions & 3 deletions packages/babel-types/src/ast-types/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ export interface ExportAllDeclaration extends BaseNode {
type: "ExportAllDeclaration";
source: StringLiteral;
assertions?: ImportAttribute | null;
exportKind?: "type" | "value" | null;
}

export interface ExportDefaultDeclaration extends BaseNode {
Expand Down Expand Up @@ -1225,6 +1226,7 @@ export interface ObjectTypeProperty extends BaseNode {
value: FlowType;
variance?: Variance | null;
kind: "init" | "get" | "set";
method: boolean;
optional: boolean;
proto: boolean;
static: boolean;
Expand Down Expand Up @@ -1335,19 +1337,19 @@ export interface EnumDeclaration extends BaseNode {
export interface EnumBooleanBody extends BaseNode {
type: "EnumBooleanBody";
members: Array<EnumBooleanMember>;
explicit: boolean;
explicitType: boolean;
}

export interface EnumNumberBody extends BaseNode {
type: "EnumNumberBody";
members: Array<EnumNumberMember>;
explicit: boolean;
explicitType: boolean;
}

export interface EnumStringBody extends BaseNode {
type: "EnumStringBody";
members: Array<EnumStringMember | EnumDefaultedMember>;
explicit: boolean;
explicitType: boolean;
}

export interface EnumSymbolBody extends BaseNode {
Expand Down Expand Up @@ -1542,6 +1544,7 @@ export interface ClassPrivateProperty extends BaseNode {
value?: Expression | null;
decorators?: Array<Decorator> | null;
static: any;
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
}

export interface ClassPrivateMethod extends BaseNode {
Expand Down
1 change: 1 addition & 0 deletions packages/babel-types/src/definitions/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,7 @@ defineType("ExportAllDeclaration", {
source: {
validate: assertNodeType("StringLiteral"),
},
exportKind: validateOptional(assertOneOf("type", "value")),
assertions: {
optional: true,
validate: chain(
Expand Down
4 changes: 4 additions & 0 deletions packages/babel-types/src/definitions/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ defineType("ClassPrivateProperty", {
validate: assertNodeType("Expression"),
optional: true,
},
typeAnnotation: {
validate: assertNodeType("TypeAnnotation", "TSTypeAnnotation", "Noop"),
optional: true,
},
decorators: {
validate: chain(
assertValueType("array"),
Expand Down
7 changes: 4 additions & 3 deletions packages/babel-types/src/definitions/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ defineType("ObjectTypeProperty", {
proto: validate(assertValueType("boolean")),
optional: validate(assertValueType("boolean")),
variance: validateOptionalType("Variance"),
method: validate(assertValueType("boolean")),
},
});

Expand Down Expand Up @@ -488,7 +489,7 @@ defineType("EnumBooleanBody", {
aliases: ["EnumBody"],
visitor: ["members"],
fields: {
explicit: validate(assertValueType("boolean")),
explicitType: validate(assertValueType("boolean")),
members: validateArrayOfType("EnumBooleanMember"),
},
});
Expand All @@ -497,7 +498,7 @@ defineType("EnumNumberBody", {
aliases: ["EnumBody"],
visitor: ["members"],
fields: {
explicit: validate(assertValueType("boolean")),
explicitType: validate(assertValueType("boolean")),
members: validateArrayOfType("EnumNumberMember"),
},
});
Expand All @@ -506,7 +507,7 @@ defineType("EnumStringBody", {
aliases: ["EnumBody"],
visitor: ["members"],
fields: {
explicit: validate(assertValueType("boolean")),
explicitType: validate(assertValueType("boolean")),
members: validateArrayOfType(["EnumStringMember", "EnumDefaultedMember"]),
},
});
Expand Down

0 comments on commit 2f6de2f

Please sign in to comment.