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:
parent
5ac5e3572f
commit
3840893b48
@ -500,6 +500,30 @@ export function assertOptionalCallExpression(
|
||||
): asserts node is t.OptionalCallExpression {
|
||||
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(
|
||||
node: object | null | undefined,
|
||||
opts?: object | null,
|
||||
@ -1010,12 +1034,6 @@ export function assertBindExpression(
|
||||
): asserts node is t.BindExpression {
|
||||
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(
|
||||
node: object | null | undefined,
|
||||
opts?: object | null,
|
||||
@ -1034,18 +1052,6 @@ export function assertPipelinePrimaryTopicReference(
|
||||
): asserts node is t.PipelinePrimaryTopicReference {
|
||||
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(
|
||||
node: object | null | undefined,
|
||||
opts?: object | null,
|
||||
@ -1070,12 +1076,6 @@ export function assertExportDefaultSpecifier(
|
||||
): asserts node is t.ExportDefaultSpecifier {
|
||||
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(
|
||||
node: object | null | undefined,
|
||||
opts?: object | null,
|
||||
@ -1682,6 +1682,12 @@ export function assertModuleSpecifier(
|
||||
): asserts node is t.ModuleSpecifier {
|
||||
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(
|
||||
node: object | null | undefined,
|
||||
opts?: object | null,
|
||||
@ -1730,12 +1736,6 @@ export function assertJSX(
|
||||
): asserts node is t.JSX {
|
||||
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(
|
||||
node: object | null | undefined,
|
||||
opts?: object | null,
|
||||
|
||||
@ -1009,6 +1009,61 @@ export interface OptionalCallExpression extends BaseNode {
|
||||
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 {
|
||||
type: "AnyTypeAnnotation";
|
||||
}
|
||||
@ -1531,23 +1586,6 @@ export interface BindExpression extends BaseNode {
|
||||
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 {
|
||||
type: "PipelineTopicExpression";
|
||||
expression: Expression;
|
||||
@ -1562,39 +1600,6 @@ export interface PipelinePrimaryTopicReference extends BaseNode {
|
||||
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 {
|
||||
type: "ImportAttribute";
|
||||
key: Identifier | StringLiteral;
|
||||
@ -1617,11 +1622,6 @@ export interface ExportDefaultSpecifier extends BaseNode {
|
||||
exported: Identifier;
|
||||
}
|
||||
|
||||
export interface PrivateName extends BaseNode {
|
||||
type: "PrivateName";
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
export interface RecordExpression extends BaseNode {
|
||||
type: "RecordExpression";
|
||||
properties: Array<ObjectProperty | SpreadElement>;
|
||||
@ -2316,6 +2316,7 @@ export type ModuleSpecifier =
|
||||
| ImportSpecifier
|
||||
| ExportNamespaceSpecifier
|
||||
| ExportDefaultSpecifier;
|
||||
export type Private = ClassPrivateProperty | ClassPrivateMethod | PrivateName;
|
||||
export type Flow =
|
||||
| AnyTypeAnnotation
|
||||
| ArrayTypeAnnotation
|
||||
@ -2452,7 +2453,6 @@ export type JSX =
|
||||
| JSXFragment
|
||||
| JSXOpeningFragment
|
||||
| JSXClosingFragment;
|
||||
export type Private = ClassPrivateProperty | ClassPrivateMethod | PrivateName;
|
||||
export type TSTypeElement =
|
||||
| TSCallSignatureDeclaration
|
||||
| TSConstructSignatureDeclaration
|
||||
@ -2546,6 +2546,7 @@ export interface Aliases {
|
||||
ModuleDeclaration: ModuleDeclaration;
|
||||
ExportDeclaration: ExportDeclaration;
|
||||
ModuleSpecifier: ModuleSpecifier;
|
||||
Private: Private;
|
||||
Flow: Flow;
|
||||
FlowType: FlowType;
|
||||
FlowBaseAnnotation: FlowBaseAnnotation;
|
||||
@ -2554,7 +2555,6 @@ export interface Aliases {
|
||||
EnumBody: EnumBody;
|
||||
EnumMember: EnumMember;
|
||||
JSX: JSX;
|
||||
Private: Private;
|
||||
TSTypeElement: TSTypeElement;
|
||||
TSType: TSType;
|
||||
TSBaseType: TSBaseType;
|
||||
|
||||
@ -515,6 +515,38 @@ export function optionalCallExpression(
|
||||
): t.OptionalCallExpression {
|
||||
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 {
|
||||
return builder("AnyTypeAnnotation", ...arguments);
|
||||
}
|
||||
@ -992,16 +1024,6 @@ export function bindExpression(
|
||||
): t.BindExpression {
|
||||
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(
|
||||
expression: t.Expression,
|
||||
): t.PipelineTopicExpression {
|
||||
@ -1015,25 +1037,6 @@ export function pipelineBareFunction(
|
||||
export function pipelinePrimaryTopicReference(): t.PipelinePrimaryTopicReference {
|
||||
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(
|
||||
key: t.Identifier | t.StringLiteral,
|
||||
value: t.StringLiteral,
|
||||
@ -1054,9 +1057,6 @@ export function exportDefaultSpecifier(
|
||||
): t.ExportDefaultSpecifier {
|
||||
return builder("ExportDefaultSpecifier", ...arguments);
|
||||
}
|
||||
export function privateName(id: t.Identifier): t.PrivateName {
|
||||
return builder("PrivateName", ...arguments);
|
||||
}
|
||||
export function recordExpression(
|
||||
properties: Array<t.ObjectProperty | t.SpreadElement>,
|
||||
): t.RecordExpression {
|
||||
|
||||
@ -90,6 +90,10 @@ export {
|
||||
exportNamespaceSpecifier as ExportNamespaceSpecifier,
|
||||
optionalMemberExpression as OptionalMemberExpression,
|
||||
optionalCallExpression as OptionalCallExpression,
|
||||
classProperty as ClassProperty,
|
||||
classPrivateProperty as ClassPrivateProperty,
|
||||
classPrivateMethod as ClassPrivateMethod,
|
||||
privateName as PrivateName,
|
||||
anyTypeAnnotation as AnyTypeAnnotation,
|
||||
arrayTypeAnnotation as ArrayTypeAnnotation,
|
||||
booleanTypeAnnotation as BooleanTypeAnnotation,
|
||||
@ -175,17 +179,13 @@ export {
|
||||
v8IntrinsicIdentifier as V8IntrinsicIdentifier,
|
||||
argumentPlaceholder as ArgumentPlaceholder,
|
||||
bindExpression as BindExpression,
|
||||
classProperty as ClassProperty,
|
||||
pipelineTopicExpression as PipelineTopicExpression,
|
||||
pipelineBareFunction as PipelineBareFunction,
|
||||
pipelinePrimaryTopicReference as PipelinePrimaryTopicReference,
|
||||
classPrivateProperty as ClassPrivateProperty,
|
||||
classPrivateMethod as ClassPrivateMethod,
|
||||
importAttribute as ImportAttribute,
|
||||
decorator as Decorator,
|
||||
doExpression as DoExpression,
|
||||
exportDefaultSpecifier as ExportDefaultSpecifier,
|
||||
privateName as PrivateName,
|
||||
recordExpression as RecordExpression,
|
||||
tupleExpression as TupleExpression,
|
||||
decimalLiteral as DecimalLiteral,
|
||||
|
||||
@ -38,6 +38,7 @@ export const CLASS_TYPES = FLIPPED_ALIAS_KEYS["Class"];
|
||||
export const MODULEDECLARATION_TYPES = FLIPPED_ALIAS_KEYS["ModuleDeclaration"];
|
||||
export const EXPORTDECLARATION_TYPES = FLIPPED_ALIAS_KEYS["ExportDeclaration"];
|
||||
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 FLOWTYPE_TYPES = FLIPPED_ALIAS_KEYS["FlowType"];
|
||||
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 ENUMMEMBER_TYPES = FLIPPED_ALIAS_KEYS["EnumMember"];
|
||||
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 TSTYPE_TYPES = FLIPPED_ALIAS_KEYS["TSType"];
|
||||
export const TSBASETYPE_TYPES = FLIPPED_ALIAS_KEYS["TSBaseType"];
|
||||
|
||||
@ -1838,7 +1838,8 @@ defineType("Super", {
|
||||
});
|
||||
|
||||
defineType("TaggedTemplateExpression", {
|
||||
visitor: ["tag", "quasi"],
|
||||
visitor: ["tag", "quasi", "typeParameters"],
|
||||
builder: ["tag", "quasi"],
|
||||
aliases: ["Expression"],
|
||||
fields: {
|
||||
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"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -4,11 +4,6 @@ import defineType, {
|
||||
assertValueType,
|
||||
chain,
|
||||
} from "./utils";
|
||||
import {
|
||||
classMethodOrPropertyCommon,
|
||||
classMethodOrDeclareMethodCommon,
|
||||
functionTypeAnnotationCommon,
|
||||
} from "./core";
|
||||
|
||||
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", {
|
||||
builder: ["expression"],
|
||||
visitor: ["expression"],
|
||||
@ -107,64 +57,6 @@ defineType("PipelinePrimaryTopicReference", {
|
||||
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", {
|
||||
visitor: ["key", "value"],
|
||||
fields: {
|
||||
@ -211,16 +103,6 @@ defineType("ExportDefaultSpecifier", {
|
||||
},
|
||||
});
|
||||
|
||||
defineType("PrivateName", {
|
||||
visitor: ["id"],
|
||||
aliases: ["Private"],
|
||||
fields: {
|
||||
id: {
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("RecordExpression", {
|
||||
visitor: ["properties"],
|
||||
aliases: ["Expression"],
|
||||
|
||||
@ -1382,6 +1382,74 @@ export function isOptionalCallExpression(
|
||||
|
||||
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(
|
||||
node: object | null | undefined,
|
||||
opts?: object | null,
|
||||
@ -2827,23 +2895,6 @@ export function isBindExpression(
|
||||
|
||||
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(
|
||||
node: object | null | undefined,
|
||||
opts?: object | null,
|
||||
@ -2895,40 +2946,6 @@ export function isPipelinePrimaryTopicReference(
|
||||
|
||||
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(
|
||||
node: object | null | undefined,
|
||||
opts?: object | null,
|
||||
@ -2997,23 +3014,6 @@ export function isExportDefaultSpecifier(
|
||||
|
||||
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(
|
||||
node: object | null | undefined,
|
||||
opts?: object | null,
|
||||
@ -5057,6 +5057,27 @@ export function isModuleSpecifier(
|
||||
|
||||
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(
|
||||
node: object | null | undefined,
|
||||
opts?: object | null,
|
||||
@ -5328,27 +5349,6 @@ export function isJSX(
|
||||
|
||||
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(
|
||||
node: object | null | undefined,
|
||||
opts?: object | null,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user