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

Add typeParameters to tagged template visitor keys #13500

Merged
merged 4 commits into from Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
117 changes: 116 additions & 1 deletion packages/babel-types/src/definitions/core.ts
Expand Up @@ -1838,7 +1838,8 @@ defineType("Super", {
});

defineType("TaggedTemplateExpression", {
visitor: ["tag", "quasi"],
visitor: ["tag", "quasi", "typeParameters"],
JLHwung marked this conversation as resolved.
Show resolved Hide resolved
builder: ["tag", "quasi"],
aliases: ["Expression"],
fields: {
tag: {
Expand Down Expand Up @@ -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"],
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"),
},
},
});
118 changes: 0 additions & 118 deletions packages/babel-types/src/definitions/experimental.ts
Expand Up @@ -4,11 +4,6 @@ import defineType, {
assertValueType,
chain,
} from "./utils";
import {
classMethodOrPropertyCommon,
classMethodOrDeclareMethodCommon,
functionTypeAnnotationCommon,
} from "./core";

defineType("ArgumentPlaceholder", {});

Expand Down Expand Up @@ -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"],
Expand All @@ -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: {
Expand Down Expand Up @@ -211,16 +103,6 @@ defineType("ExportDefaultSpecifier", {
},
});

defineType("PrivateName", {
visitor: ["id"],
aliases: ["Private"],
fields: {
id: {
validate: assertNodeType("Identifier"),
},
},
});

defineType("RecordExpression", {
visitor: ["properties"],
aliases: ["Expression"],
Expand Down