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

Improve AST node definitions in @babel/types #12510

Merged
merged 4 commits into from Dec 15, 2020
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
9 changes: 6 additions & 3 deletions packages/babel-types/src/ast-types/generated/index.ts
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
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
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
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