Add typeParameters to tagged template visitor keys (#13500)

* refactor: move ES2022 AST nodes to core

* fix: add typeParameters to visitor keys

* chore: update artifacts

* fix: add typeAnnotation to visitor keys
This commit is contained in:
Huáng Jùnliàng 2021-06-22 17:40:42 -04:00 committed by GitHub
parent 5ac5e3572f
commit 3840893b48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 329 additions and 332 deletions

View File

@ -500,6 +500,30 @@ export function assertOptionalCallExpression(
): asserts node is t.OptionalCallExpression { ): asserts node is t.OptionalCallExpression {
assert("OptionalCallExpression", node, opts); assert("OptionalCallExpression", node, opts);
} }
export function assertClassProperty(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.ClassProperty {
assert("ClassProperty", node, opts);
}
export function assertClassPrivateProperty(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.ClassPrivateProperty {
assert("ClassPrivateProperty", node, opts);
}
export function assertClassPrivateMethod(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.ClassPrivateMethod {
assert("ClassPrivateMethod", node, opts);
}
export function assertPrivateName(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.PrivateName {
assert("PrivateName", node, opts);
}
export function assertAnyTypeAnnotation( export function assertAnyTypeAnnotation(
node: object | null | undefined, node: object | null | undefined,
opts?: object | null, opts?: object | null,
@ -1010,12 +1034,6 @@ export function assertBindExpression(
): asserts node is t.BindExpression { ): asserts node is t.BindExpression {
assert("BindExpression", node, opts); assert("BindExpression", node, opts);
} }
export function assertClassProperty(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.ClassProperty {
assert("ClassProperty", node, opts);
}
export function assertPipelineTopicExpression( export function assertPipelineTopicExpression(
node: object | null | undefined, node: object | null | undefined,
opts?: object | null, opts?: object | null,
@ -1034,18 +1052,6 @@ export function assertPipelinePrimaryTopicReference(
): asserts node is t.PipelinePrimaryTopicReference { ): asserts node is t.PipelinePrimaryTopicReference {
assert("PipelinePrimaryTopicReference", node, opts); assert("PipelinePrimaryTopicReference", node, opts);
} }
export function assertClassPrivateProperty(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.ClassPrivateProperty {
assert("ClassPrivateProperty", node, opts);
}
export function assertClassPrivateMethod(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.ClassPrivateMethod {
assert("ClassPrivateMethod", node, opts);
}
export function assertImportAttribute( export function assertImportAttribute(
node: object | null | undefined, node: object | null | undefined,
opts?: object | null, opts?: object | null,
@ -1070,12 +1076,6 @@ export function assertExportDefaultSpecifier(
): asserts node is t.ExportDefaultSpecifier { ): asserts node is t.ExportDefaultSpecifier {
assert("ExportDefaultSpecifier", node, opts); assert("ExportDefaultSpecifier", node, opts);
} }
export function assertPrivateName(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.PrivateName {
assert("PrivateName", node, opts);
}
export function assertRecordExpression( export function assertRecordExpression(
node: object | null | undefined, node: object | null | undefined,
opts?: object | null, opts?: object | null,
@ -1682,6 +1682,12 @@ export function assertModuleSpecifier(
): asserts node is t.ModuleSpecifier { ): asserts node is t.ModuleSpecifier {
assert("ModuleSpecifier", node, opts); assert("ModuleSpecifier", node, opts);
} }
export function assertPrivate(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.Private {
assert("Private", node, opts);
}
export function assertFlow( export function assertFlow(
node: object | null | undefined, node: object | null | undefined,
opts?: object | null, opts?: object | null,
@ -1730,12 +1736,6 @@ export function assertJSX(
): asserts node is t.JSX { ): asserts node is t.JSX {
assert("JSX", node, opts); assert("JSX", node, opts);
} }
export function assertPrivate(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.Private {
assert("Private", node, opts);
}
export function assertTSTypeElement( export function assertTSTypeElement(
node: object | null | undefined, node: object | null | undefined,
opts?: object | null, opts?: object | null,

View File

@ -1009,6 +1009,61 @@ export interface OptionalCallExpression extends BaseNode {
typeParameters?: TSTypeParameterInstantiation | null; typeParameters?: TSTypeParameterInstantiation | null;
} }
export interface ClassProperty extends BaseNode {
type: "ClassProperty";
key: Identifier | StringLiteral | NumericLiteral | Expression;
value?: Expression | null;
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
decorators?: Array<Decorator> | null;
computed?: boolean;
static?: boolean;
abstract?: boolean | null;
accessibility?: "public" | "private" | "protected" | null;
declare?: boolean | null;
definite?: boolean | null;
optional?: boolean | null;
override?: boolean;
readonly?: boolean | null;
}
export interface ClassPrivateProperty extends BaseNode {
type: "ClassPrivateProperty";
key: PrivateName;
value?: Expression | null;
decorators?: Array<Decorator> | null;
static: any;
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
}
export interface ClassPrivateMethod extends BaseNode {
type: "ClassPrivateMethod";
kind?: "get" | "set" | "method" | "constructor";
key: PrivateName;
params: Array<Identifier | Pattern | RestElement | TSParameterProperty>;
body: BlockStatement;
static?: boolean;
abstract?: boolean | null;
access?: "public" | "private" | "protected" | null;
accessibility?: "public" | "private" | "protected" | null;
async?: boolean;
computed?: boolean;
decorators?: Array<Decorator> | null;
generator?: boolean;
optional?: boolean | null;
override?: boolean;
returnType?: TypeAnnotation | TSTypeAnnotation | Noop | null;
typeParameters?:
| TypeParameterDeclaration
| TSTypeParameterDeclaration
| Noop
| null;
}
export interface PrivateName extends BaseNode {
type: "PrivateName";
id: Identifier;
}
export interface AnyTypeAnnotation extends BaseNode { export interface AnyTypeAnnotation extends BaseNode {
type: "AnyTypeAnnotation"; type: "AnyTypeAnnotation";
} }
@ -1531,23 +1586,6 @@ export interface BindExpression extends BaseNode {
callee: Expression; callee: Expression;
} }
export interface ClassProperty extends BaseNode {
type: "ClassProperty";
key: Identifier | StringLiteral | NumericLiteral | Expression;
value?: Expression | null;
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
decorators?: Array<Decorator> | null;
computed?: boolean;
static?: boolean;
abstract?: boolean | null;
accessibility?: "public" | "private" | "protected" | null;
declare?: boolean | null;
definite?: boolean | null;
optional?: boolean | null;
override?: boolean;
readonly?: boolean | null;
}
export interface PipelineTopicExpression extends BaseNode { export interface PipelineTopicExpression extends BaseNode {
type: "PipelineTopicExpression"; type: "PipelineTopicExpression";
expression: Expression; expression: Expression;
@ -1562,39 +1600,6 @@ export interface PipelinePrimaryTopicReference extends BaseNode {
type: "PipelinePrimaryTopicReference"; type: "PipelinePrimaryTopicReference";
} }
export interface ClassPrivateProperty extends BaseNode {
type: "ClassPrivateProperty";
key: PrivateName;
value?: Expression | null;
decorators?: Array<Decorator> | null;
static: any;
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
}
export interface ClassPrivateMethod extends BaseNode {
type: "ClassPrivateMethod";
kind?: "get" | "set" | "method" | "constructor";
key: PrivateName;
params: Array<Identifier | Pattern | RestElement | TSParameterProperty>;
body: BlockStatement;
static?: boolean;
abstract?: boolean | null;
access?: "public" | "private" | "protected" | null;
accessibility?: "public" | "private" | "protected" | null;
async?: boolean;
computed?: boolean;
decorators?: Array<Decorator> | null;
generator?: boolean;
optional?: boolean | null;
override?: boolean;
returnType?: TypeAnnotation | TSTypeAnnotation | Noop | null;
typeParameters?:
| TypeParameterDeclaration
| TSTypeParameterDeclaration
| Noop
| null;
}
export interface ImportAttribute extends BaseNode { export interface ImportAttribute extends BaseNode {
type: "ImportAttribute"; type: "ImportAttribute";
key: Identifier | StringLiteral; key: Identifier | StringLiteral;
@ -1617,11 +1622,6 @@ export interface ExportDefaultSpecifier extends BaseNode {
exported: Identifier; exported: Identifier;
} }
export interface PrivateName extends BaseNode {
type: "PrivateName";
id: Identifier;
}
export interface RecordExpression extends BaseNode { export interface RecordExpression extends BaseNode {
type: "RecordExpression"; type: "RecordExpression";
properties: Array<ObjectProperty | SpreadElement>; properties: Array<ObjectProperty | SpreadElement>;
@ -2316,6 +2316,7 @@ export type ModuleSpecifier =
| ImportSpecifier | ImportSpecifier
| ExportNamespaceSpecifier | ExportNamespaceSpecifier
| ExportDefaultSpecifier; | ExportDefaultSpecifier;
export type Private = ClassPrivateProperty | ClassPrivateMethod | PrivateName;
export type Flow = export type Flow =
| AnyTypeAnnotation | AnyTypeAnnotation
| ArrayTypeAnnotation | ArrayTypeAnnotation
@ -2452,7 +2453,6 @@ export type JSX =
| JSXFragment | JSXFragment
| JSXOpeningFragment | JSXOpeningFragment
| JSXClosingFragment; | JSXClosingFragment;
export type Private = ClassPrivateProperty | ClassPrivateMethod | PrivateName;
export type TSTypeElement = export type TSTypeElement =
| TSCallSignatureDeclaration | TSCallSignatureDeclaration
| TSConstructSignatureDeclaration | TSConstructSignatureDeclaration
@ -2546,6 +2546,7 @@ export interface Aliases {
ModuleDeclaration: ModuleDeclaration; ModuleDeclaration: ModuleDeclaration;
ExportDeclaration: ExportDeclaration; ExportDeclaration: ExportDeclaration;
ModuleSpecifier: ModuleSpecifier; ModuleSpecifier: ModuleSpecifier;
Private: Private;
Flow: Flow; Flow: Flow;
FlowType: FlowType; FlowType: FlowType;
FlowBaseAnnotation: FlowBaseAnnotation; FlowBaseAnnotation: FlowBaseAnnotation;
@ -2554,7 +2555,6 @@ export interface Aliases {
EnumBody: EnumBody; EnumBody: EnumBody;
EnumMember: EnumMember; EnumMember: EnumMember;
JSX: JSX; JSX: JSX;
Private: Private;
TSTypeElement: TSTypeElement; TSTypeElement: TSTypeElement;
TSType: TSType; TSType: TSType;
TSBaseType: TSBaseType; TSBaseType: TSBaseType;

View File

@ -515,6 +515,38 @@ export function optionalCallExpression(
): t.OptionalCallExpression { ): t.OptionalCallExpression {
return builder("OptionalCallExpression", ...arguments); return builder("OptionalCallExpression", ...arguments);
} }
export function classProperty(
key: t.Identifier | t.StringLiteral | t.NumericLiteral | t.Expression,
value?: t.Expression | null,
typeAnnotation?: t.TypeAnnotation | t.TSTypeAnnotation | t.Noop | null,
decorators?: Array<t.Decorator> | null,
computed?: boolean,
_static?: boolean,
): t.ClassProperty {
return builder("ClassProperty", ...arguments);
}
export function classPrivateProperty(
key: t.PrivateName,
value: t.Expression | null | undefined,
decorators: Array<t.Decorator> | null | undefined,
_static: any,
): t.ClassPrivateProperty {
return builder("ClassPrivateProperty", ...arguments);
}
export function classPrivateMethod(
kind: "get" | "set" | "method" | "constructor" | undefined,
key: t.PrivateName,
params: Array<
t.Identifier | t.Pattern | t.RestElement | t.TSParameterProperty
>,
body: t.BlockStatement,
_static?: boolean,
): t.ClassPrivateMethod {
return builder("ClassPrivateMethod", ...arguments);
}
export function privateName(id: t.Identifier): t.PrivateName {
return builder("PrivateName", ...arguments);
}
export function anyTypeAnnotation(): t.AnyTypeAnnotation { export function anyTypeAnnotation(): t.AnyTypeAnnotation {
return builder("AnyTypeAnnotation", ...arguments); return builder("AnyTypeAnnotation", ...arguments);
} }
@ -992,16 +1024,6 @@ export function bindExpression(
): t.BindExpression { ): t.BindExpression {
return builder("BindExpression", ...arguments); return builder("BindExpression", ...arguments);
} }
export function classProperty(
key: t.Identifier | t.StringLiteral | t.NumericLiteral | t.Expression,
value?: t.Expression | null,
typeAnnotation?: t.TypeAnnotation | t.TSTypeAnnotation | t.Noop | null,
decorators?: Array<t.Decorator> | null,
computed?: boolean,
_static?: boolean,
): t.ClassProperty {
return builder("ClassProperty", ...arguments);
}
export function pipelineTopicExpression( export function pipelineTopicExpression(
expression: t.Expression, expression: t.Expression,
): t.PipelineTopicExpression { ): t.PipelineTopicExpression {
@ -1015,25 +1037,6 @@ export function pipelineBareFunction(
export function pipelinePrimaryTopicReference(): t.PipelinePrimaryTopicReference { export function pipelinePrimaryTopicReference(): t.PipelinePrimaryTopicReference {
return builder("PipelinePrimaryTopicReference", ...arguments); return builder("PipelinePrimaryTopicReference", ...arguments);
} }
export function classPrivateProperty(
key: t.PrivateName,
value: t.Expression | null | undefined,
decorators: Array<t.Decorator> | null | undefined,
_static: any,
): t.ClassPrivateProperty {
return builder("ClassPrivateProperty", ...arguments);
}
export function classPrivateMethod(
kind: "get" | "set" | "method" | "constructor" | undefined,
key: t.PrivateName,
params: Array<
t.Identifier | t.Pattern | t.RestElement | t.TSParameterProperty
>,
body: t.BlockStatement,
_static?: boolean,
): t.ClassPrivateMethod {
return builder("ClassPrivateMethod", ...arguments);
}
export function importAttribute( export function importAttribute(
key: t.Identifier | t.StringLiteral, key: t.Identifier | t.StringLiteral,
value: t.StringLiteral, value: t.StringLiteral,
@ -1054,9 +1057,6 @@ export function exportDefaultSpecifier(
): t.ExportDefaultSpecifier { ): t.ExportDefaultSpecifier {
return builder("ExportDefaultSpecifier", ...arguments); return builder("ExportDefaultSpecifier", ...arguments);
} }
export function privateName(id: t.Identifier): t.PrivateName {
return builder("PrivateName", ...arguments);
}
export function recordExpression( export function recordExpression(
properties: Array<t.ObjectProperty | t.SpreadElement>, properties: Array<t.ObjectProperty | t.SpreadElement>,
): t.RecordExpression { ): t.RecordExpression {

View File

@ -90,6 +90,10 @@ export {
exportNamespaceSpecifier as ExportNamespaceSpecifier, exportNamespaceSpecifier as ExportNamespaceSpecifier,
optionalMemberExpression as OptionalMemberExpression, optionalMemberExpression as OptionalMemberExpression,
optionalCallExpression as OptionalCallExpression, optionalCallExpression as OptionalCallExpression,
classProperty as ClassProperty,
classPrivateProperty as ClassPrivateProperty,
classPrivateMethod as ClassPrivateMethod,
privateName as PrivateName,
anyTypeAnnotation as AnyTypeAnnotation, anyTypeAnnotation as AnyTypeAnnotation,
arrayTypeAnnotation as ArrayTypeAnnotation, arrayTypeAnnotation as ArrayTypeAnnotation,
booleanTypeAnnotation as BooleanTypeAnnotation, booleanTypeAnnotation as BooleanTypeAnnotation,
@ -175,17 +179,13 @@ export {
v8IntrinsicIdentifier as V8IntrinsicIdentifier, v8IntrinsicIdentifier as V8IntrinsicIdentifier,
argumentPlaceholder as ArgumentPlaceholder, argumentPlaceholder as ArgumentPlaceholder,
bindExpression as BindExpression, bindExpression as BindExpression,
classProperty as ClassProperty,
pipelineTopicExpression as PipelineTopicExpression, pipelineTopicExpression as PipelineTopicExpression,
pipelineBareFunction as PipelineBareFunction, pipelineBareFunction as PipelineBareFunction,
pipelinePrimaryTopicReference as PipelinePrimaryTopicReference, pipelinePrimaryTopicReference as PipelinePrimaryTopicReference,
classPrivateProperty as ClassPrivateProperty,
classPrivateMethod as ClassPrivateMethod,
importAttribute as ImportAttribute, importAttribute as ImportAttribute,
decorator as Decorator, decorator as Decorator,
doExpression as DoExpression, doExpression as DoExpression,
exportDefaultSpecifier as ExportDefaultSpecifier, exportDefaultSpecifier as ExportDefaultSpecifier,
privateName as PrivateName,
recordExpression as RecordExpression, recordExpression as RecordExpression,
tupleExpression as TupleExpression, tupleExpression as TupleExpression,
decimalLiteral as DecimalLiteral, decimalLiteral as DecimalLiteral,

View File

@ -38,6 +38,7 @@ export const CLASS_TYPES = FLIPPED_ALIAS_KEYS["Class"];
export const MODULEDECLARATION_TYPES = FLIPPED_ALIAS_KEYS["ModuleDeclaration"]; export const MODULEDECLARATION_TYPES = FLIPPED_ALIAS_KEYS["ModuleDeclaration"];
export const EXPORTDECLARATION_TYPES = FLIPPED_ALIAS_KEYS["ExportDeclaration"]; export const EXPORTDECLARATION_TYPES = FLIPPED_ALIAS_KEYS["ExportDeclaration"];
export const MODULESPECIFIER_TYPES = FLIPPED_ALIAS_KEYS["ModuleSpecifier"]; export const MODULESPECIFIER_TYPES = FLIPPED_ALIAS_KEYS["ModuleSpecifier"];
export const PRIVATE_TYPES = FLIPPED_ALIAS_KEYS["Private"];
export const FLOW_TYPES = FLIPPED_ALIAS_KEYS["Flow"]; export const FLOW_TYPES = FLIPPED_ALIAS_KEYS["Flow"];
export const FLOWTYPE_TYPES = FLIPPED_ALIAS_KEYS["FlowType"]; export const FLOWTYPE_TYPES = FLIPPED_ALIAS_KEYS["FlowType"];
export const FLOWBASEANNOTATION_TYPES = export const FLOWBASEANNOTATION_TYPES =
@ -47,7 +48,6 @@ export const FLOWPREDICATE_TYPES = FLIPPED_ALIAS_KEYS["FlowPredicate"];
export const ENUMBODY_TYPES = FLIPPED_ALIAS_KEYS["EnumBody"]; export const ENUMBODY_TYPES = FLIPPED_ALIAS_KEYS["EnumBody"];
export const ENUMMEMBER_TYPES = FLIPPED_ALIAS_KEYS["EnumMember"]; export const ENUMMEMBER_TYPES = FLIPPED_ALIAS_KEYS["EnumMember"];
export const JSX_TYPES = FLIPPED_ALIAS_KEYS["JSX"]; export const JSX_TYPES = FLIPPED_ALIAS_KEYS["JSX"];
export const PRIVATE_TYPES = FLIPPED_ALIAS_KEYS["Private"];
export const TSTYPEELEMENT_TYPES = FLIPPED_ALIAS_KEYS["TSTypeElement"]; export const TSTYPEELEMENT_TYPES = FLIPPED_ALIAS_KEYS["TSTypeElement"];
export const TSTYPE_TYPES = FLIPPED_ALIAS_KEYS["TSType"]; export const TSTYPE_TYPES = FLIPPED_ALIAS_KEYS["TSType"];
export const TSBASETYPE_TYPES = FLIPPED_ALIAS_KEYS["TSBaseType"]; export const TSBASETYPE_TYPES = FLIPPED_ALIAS_KEYS["TSBaseType"];

View File

@ -1838,7 +1838,8 @@ defineType("Super", {
}); });
defineType("TaggedTemplateExpression", { defineType("TaggedTemplateExpression", {
visitor: ["tag", "quasi"], visitor: ["tag", "quasi", "typeParameters"],
builder: ["tag", "quasi"],
aliases: ["Expression"], aliases: ["Expression"],
fields: { fields: {
tag: { tag: {
@ -2050,3 +2051,117 @@ defineType("OptionalCallExpression", {
}, },
}, },
}); });
// --- ES2022 ---
defineType("ClassProperty", {
visitor: ["key", "value", "typeAnnotation", "decorators"],
builder: [
"key",
"value",
"typeAnnotation",
"decorators",
"computed",
"static",
],
aliases: ["Property"],
fields: {
...classMethodOrPropertyCommon,
value: {
validate: assertNodeType("Expression"),
optional: true,
},
definite: {
validate: assertValueType("boolean"),
optional: true,
},
typeAnnotation: {
validate: process.env.BABEL_8_BREAKING
? assertNodeType("TypeAnnotation", "TSTypeAnnotation")
: assertNodeType("TypeAnnotation", "TSTypeAnnotation", "Noop"),
optional: true,
},
decorators: {
validate: chain(
assertValueType("array"),
assertEach(assertNodeType("Decorator")),
),
optional: true,
},
readonly: {
validate: assertValueType("boolean"),
optional: true,
},
declare: {
validate: assertValueType("boolean"),
optional: true,
},
},
});
defineType("ClassPrivateProperty", {
visitor: ["key", "value", "decorators", "typeAnnotation"],
builder: ["key", "value", "decorators", "static"],
aliases: ["Property", "Private"],
fields: {
key: {
validate: assertNodeType("PrivateName"),
},
value: {
validate: assertNodeType("Expression"),
optional: true,
},
typeAnnotation: {
validate: process.env.BABEL_8_BREAKING
? assertNodeType("TypeAnnotation", "TSTypeAnnotation")
: assertNodeType("TypeAnnotation", "TSTypeAnnotation", "Noop"),
optional: true,
},
decorators: {
validate: chain(
assertValueType("array"),
assertEach(assertNodeType("Decorator")),
),
optional: true,
},
},
});
defineType("ClassPrivateMethod", {
builder: ["kind", "key", "params", "body", "static"],
visitor: [
"key",
"params",
"body",
"decorators",
"returnType",
"typeParameters",
],
aliases: [
"Function",
"Scopable",
"BlockParent",
"FunctionParent",
"Method",
"Private",
],
fields: {
...classMethodOrDeclareMethodCommon,
...functionTypeAnnotationCommon,
key: {
validate: assertNodeType("PrivateName"),
},
body: {
validate: assertNodeType("BlockStatement"),
},
},
});
defineType("PrivateName", {
visitor: ["id"],
aliases: ["Private"],
fields: {
id: {
validate: assertNodeType("Identifier"),
},
},
});

View File

@ -4,11 +4,6 @@ import defineType, {
assertValueType, assertValueType,
chain, chain,
} from "./utils"; } from "./utils";
import {
classMethodOrPropertyCommon,
classMethodOrDeclareMethodCommon,
functionTypeAnnotationCommon,
} from "./core";
defineType("ArgumentPlaceholder", {}); defineType("ArgumentPlaceholder", {});
@ -38,51 +33,6 @@ defineType("BindExpression", {
}, },
}); });
defineType("ClassProperty", {
visitor: ["key", "value", "typeAnnotation", "decorators"],
builder: [
"key",
"value",
"typeAnnotation",
"decorators",
"computed",
"static",
],
aliases: ["Property"],
fields: {
...classMethodOrPropertyCommon,
value: {
validate: assertNodeType("Expression"),
optional: true,
},
definite: {
validate: assertValueType("boolean"),
optional: true,
},
typeAnnotation: {
validate: process.env.BABEL_8_BREAKING
? assertNodeType("TypeAnnotation", "TSTypeAnnotation")
: assertNodeType("TypeAnnotation", "TSTypeAnnotation", "Noop"),
optional: true,
},
decorators: {
validate: chain(
assertValueType("array"),
assertEach(assertNodeType("Decorator")),
),
optional: true,
},
readonly: {
validate: assertValueType("boolean"),
optional: true,
},
declare: {
validate: assertValueType("boolean"),
optional: true,
},
},
});
defineType("PipelineTopicExpression", { defineType("PipelineTopicExpression", {
builder: ["expression"], builder: ["expression"],
visitor: ["expression"], visitor: ["expression"],
@ -107,64 +57,6 @@ defineType("PipelinePrimaryTopicReference", {
aliases: ["Expression"], aliases: ["Expression"],
}); });
defineType("ClassPrivateProperty", {
visitor: ["key", "value", "decorators"],
builder: ["key", "value", "decorators", "static"],
aliases: ["Property", "Private"],
fields: {
key: {
validate: assertNodeType("PrivateName"),
},
value: {
validate: assertNodeType("Expression"),
optional: true,
},
typeAnnotation: {
validate: process.env.BABEL_8_BREAKING
? assertNodeType("TypeAnnotation", "TSTypeAnnotation")
: assertNodeType("TypeAnnotation", "TSTypeAnnotation", "Noop"),
optional: true,
},
decorators: {
validate: chain(
assertValueType("array"),
assertEach(assertNodeType("Decorator")),
),
optional: true,
},
},
});
defineType("ClassPrivateMethod", {
builder: ["kind", "key", "params", "body", "static"],
visitor: [
"key",
"params",
"body",
"decorators",
"returnType",
"typeParameters",
],
aliases: [
"Function",
"Scopable",
"BlockParent",
"FunctionParent",
"Method",
"Private",
],
fields: {
...classMethodOrDeclareMethodCommon,
...functionTypeAnnotationCommon,
key: {
validate: assertNodeType("PrivateName"),
},
body: {
validate: assertNodeType("BlockStatement"),
},
},
});
defineType("ImportAttribute", { defineType("ImportAttribute", {
visitor: ["key", "value"], visitor: ["key", "value"],
fields: { fields: {
@ -211,16 +103,6 @@ defineType("ExportDefaultSpecifier", {
}, },
}); });
defineType("PrivateName", {
visitor: ["id"],
aliases: ["Private"],
fields: {
id: {
validate: assertNodeType("Identifier"),
},
},
});
defineType("RecordExpression", { defineType("RecordExpression", {
visitor: ["properties"], visitor: ["properties"],
aliases: ["Expression"], aliases: ["Expression"],

View File

@ -1382,6 +1382,74 @@ export function isOptionalCallExpression(
return false; return false;
} }
export function isClassProperty(
node: object | null | undefined,
opts?: object | null,
): node is t.ClassProperty {
if (!node) return false;
const nodeType = (node as t.Node).type;
if (nodeType === "ClassProperty") {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}
return false;
}
export function isClassPrivateProperty(
node: object | null | undefined,
opts?: object | null,
): node is t.ClassPrivateProperty {
if (!node) return false;
const nodeType = (node as t.Node).type;
if (nodeType === "ClassPrivateProperty") {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}
return false;
}
export function isClassPrivateMethod(
node: object | null | undefined,
opts?: object | null,
): node is t.ClassPrivateMethod {
if (!node) return false;
const nodeType = (node as t.Node).type;
if (nodeType === "ClassPrivateMethod") {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}
return false;
}
export function isPrivateName(
node: object | null | undefined,
opts?: object | null,
): node is t.PrivateName {
if (!node) return false;
const nodeType = (node as t.Node).type;
if (nodeType === "PrivateName") {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}
return false;
}
export function isAnyTypeAnnotation( export function isAnyTypeAnnotation(
node: object | null | undefined, node: object | null | undefined,
opts?: object | null, opts?: object | null,
@ -2827,23 +2895,6 @@ export function isBindExpression(
return false; return false;
} }
export function isClassProperty(
node: object | null | undefined,
opts?: object | null,
): node is t.ClassProperty {
if (!node) return false;
const nodeType = (node as t.Node).type;
if (nodeType === "ClassProperty") {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}
return false;
}
export function isPipelineTopicExpression( export function isPipelineTopicExpression(
node: object | null | undefined, node: object | null | undefined,
opts?: object | null, opts?: object | null,
@ -2895,40 +2946,6 @@ export function isPipelinePrimaryTopicReference(
return false; return false;
} }
export function isClassPrivateProperty(
node: object | null | undefined,
opts?: object | null,
): node is t.ClassPrivateProperty {
if (!node) return false;
const nodeType = (node as t.Node).type;
if (nodeType === "ClassPrivateProperty") {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}
return false;
}
export function isClassPrivateMethod(
node: object | null | undefined,
opts?: object | null,
): node is t.ClassPrivateMethod {
if (!node) return false;
const nodeType = (node as t.Node).type;
if (nodeType === "ClassPrivateMethod") {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}
return false;
}
export function isImportAttribute( export function isImportAttribute(
node: object | null | undefined, node: object | null | undefined,
opts?: object | null, opts?: object | null,
@ -2997,23 +3014,6 @@ export function isExportDefaultSpecifier(
return false; return false;
} }
export function isPrivateName(
node: object | null | undefined,
opts?: object | null,
): node is t.PrivateName {
if (!node) return false;
const nodeType = (node as t.Node).type;
if (nodeType === "PrivateName") {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}
return false;
}
export function isRecordExpression( export function isRecordExpression(
node: object | null | undefined, node: object | null | undefined,
opts?: object | null, opts?: object | null,
@ -5057,6 +5057,27 @@ export function isModuleSpecifier(
return false; return false;
} }
export function isPrivate(
node: object | null | undefined,
opts?: object | null,
): node is t.Private {
if (!node) return false;
const nodeType = (node as t.Node).type;
if (
"ClassPrivateProperty" === nodeType ||
"ClassPrivateMethod" === nodeType ||
"PrivateName" === nodeType
) {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}
return false;
}
export function isFlow( export function isFlow(
node: object | null | undefined, node: object | null | undefined,
opts?: object | null, opts?: object | null,
@ -5328,27 +5349,6 @@ export function isJSX(
return false; return false;
} }
export function isPrivate(
node: object | null | undefined,
opts?: object | null,
): node is t.Private {
if (!node) return false;
const nodeType = (node as t.Node).type;
if (
"ClassPrivateProperty" === nodeType ||
"ClassPrivateMethod" === nodeType ||
"PrivateName" === nodeType
) {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}
return false;
}
export function isTSTypeElement( export function isTSTypeElement(
node: object | null | undefined, node: object | null | undefined,
opts?: object | null, opts?: object | null,