Skip to content

Commit

Permalink
Sort node types
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Aug 16, 2021
1 parent b2bd3cd commit ef6b64a
Show file tree
Hide file tree
Showing 8 changed files with 747 additions and 801 deletions.
3 changes: 0 additions & 3 deletions packages/babel-traverse/src/path/generated/asserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,6 @@ export interface NodePathAssetions {
assertThrowStatement(
opts?: object,
): asserts this is NodePath<t.ThrowStatement>;
assertTopicReference(
opts?: object,
): asserts this is NodePath<t.TopicReference>;
assertTryStatement(opts?: object): asserts this is NodePath<t.TryStatement>;
assertTupleExpression(
opts?: object,
Expand Down
1 change: 0 additions & 1 deletion packages/babel-traverse/src/path/generated/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ export interface NodePathValidators {
isThisExpression(opts?: object): this is NodePath<t.ThisExpression>;
isThisTypeAnnotation(opts?: object): this is NodePath<t.ThisTypeAnnotation>;
isThrowStatement(opts?: object): this is NodePath<t.ThrowStatement>;
isTopicReference(opts?: object): this is NodePath<t.TopicReference>;
isTryStatement(opts?: object): this is NodePath<t.TryStatement>;
isTupleExpression(opts?: object): this is NodePath<t.TupleExpression>;
isTupleTypeAnnotation(opts?: object): this is NodePath<t.TupleTypeAnnotation>;
Expand Down
13 changes: 7 additions & 6 deletions packages/babel-types/scripts/generators/ast-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ interface BaseNode {
export type CommentTypeShorthand = "leading" | "inner" | "trailing";
export type Node = ${t.TYPES.sort().join(" | ")};\n\n`;
export type Node = ${t.TYPES.slice().sort().join(" | ")};\n\n`;

const deprecatedAlias = {};
for (const type in t.DEPRECATED_KEYS) {
Expand Down Expand Up @@ -102,22 +102,23 @@ export interface ${deprecatedAlias[type]} extends BaseNode {
}
}

for (const type in t.FLIPPED_ALIAS_KEYS) {
const aliasKeys = Object.keys(t.FLIPPED_ALIAS_KEYS).sort();
const deprecatedKeys = Object.keys(t.DEPRECATED_KEYS).sort();
for (const type of aliasKeys) {
const types = t.FLIPPED_ALIAS_KEYS[type];
code += `export type ${type} = ${types
.map(type => `${type}`)
.sort()
.join(" | ")};\n`;
}
code += "\n";

code += "export interface Aliases {\n";
for (const type in t.FLIPPED_ALIAS_KEYS) {
for (const type of aliasKeys) {
code += ` ${type}: ${type};\n`;
}
code += "}\n\n";
code += `export type DeprecatedAliases = ${Object.keys(
t.DEPRECATED_KEYS
).join(" | ")}\n\n`;
code += `export type DeprecatedAliases = ${deprecatedKeys.join(" | ")}\n\n`;

return code;
}
Expand Down
42 changes: 18 additions & 24 deletions packages/babel-types/src/asserts/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,24 @@ export function assertBindExpression(
): asserts node is t.BindExpression {
assert("BindExpression", node, opts);
}
export function assertPipelineTopicExpression(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.PipelineTopicExpression {
assert("PipelineTopicExpression", node, opts);
}
export function assertPipelineBareFunction(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.PipelineBareFunction {
assert("PipelineBareFunction", node, opts);
}
export function assertPipelinePrimaryTopicReference(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.PipelinePrimaryTopicReference {
assert("PipelinePrimaryTopicReference", node, opts);
}
export function assertImportAttribute(
node: object | null | undefined,
opts?: object | null,
Expand Down Expand Up @@ -1088,30 +1106,6 @@ export function assertModuleExpression(
): asserts node is t.ModuleExpression {
assert("ModuleExpression", node, opts);
}
export function assertTopicReference(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.TopicReference {
assert("TopicReference", node, opts);
}
export function assertPipelineTopicExpression(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.PipelineTopicExpression {
assert("PipelineTopicExpression", node, opts);
}
export function assertPipelineBareFunction(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.PipelineBareFunction {
assert("PipelineBareFunction", node, opts);
}
export function assertPipelinePrimaryTopicReference(
node: object | null | undefined,
opts?: object | null,
): asserts node is t.PipelinePrimaryTopicReference {
assert("PipelinePrimaryTopicReference", node, opts);
}
export function assertTSParameterProperty(
node: object | null | undefined,
opts?: object | null,
Expand Down

0 comments on commit ef6b64a

Please sign in to comment.