Skip to content

Commit

Permalink
Fix inherits aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Aug 16, 2021
1 parent b2bd3cd commit 517edbc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
19 changes: 11 additions & 8 deletions packages/babel-types/src/ast-types/generated/index.ts
Expand Up @@ -2234,9 +2234,6 @@ export type StandardizedOrProposal =
| PrivateName
| ArgumentPlaceholder
| BindExpression
| PipelineTopicExpression
| PipelineBareFunction
| PipelinePrimaryTopicReference
| ImportAttribute
| Decorator
| DoExpression
Expand All @@ -2245,7 +2242,11 @@ export type StandardizedOrProposal =
| TupleExpression
| DecimalLiteral
| StaticBlock
| ModuleExpression;
| ModuleExpression
| TopicReference
| PipelineTopicExpression
| PipelineBareFunction
| PipelinePrimaryTopicReference;
export type Expression =
| ArrayExpression
| AssignmentExpression
Expand All @@ -2261,6 +2262,7 @@ export type Expression =
| RegExpLiteral
| LogicalExpression
| MemberExpression
| NewExpression
| ObjectExpression
| SequenceExpression
| ParenthesizedExpression
Expand Down Expand Up @@ -2682,9 +2684,6 @@ export type Miscellaneous = Noop | Placeholder | V8IntrinsicIdentifier;
export type Proposal =
| ArgumentPlaceholder
| BindExpression
| PipelineTopicExpression
| PipelineBareFunction
| PipelinePrimaryTopicReference
| ImportAttribute
| Decorator
| DoExpression
Expand All @@ -2693,7 +2692,11 @@ export type Proposal =
| TupleExpression
| DecimalLiteral
| StaticBlock
| ModuleExpression;
| ModuleExpression
| TopicReference
| PipelineTopicExpression
| PipelineBareFunction
| PipelinePrimaryTopicReference;
export type TypeScript =
| TSParameterProperty
| TSDeclareFunction
Expand Down
7 changes: 6 additions & 1 deletion packages/babel-types/src/definitions/utils.ts
Expand Up @@ -271,7 +271,12 @@ const validFieldKeys = ["default", "optional", "validate"];
// Wraps defineType to ensure these aliases are included.
export function defineAliasedType(...aliases: string[]) {
return (type: string, opts: DefineTypeOpts = {}) => {
const defined = (opts.aliases ??= []);
let defined = opts.aliases;
if (!defined) {
if (opts.inherits) defined = store[opts.inherits].aliases?.slice();
defined ??= [];
opts.aliases = defined;
}
const additional = aliases.filter(a => !defined.includes(a));
defined.unshift(...additional);
return defineType(type, opts);
Expand Down
17 changes: 10 additions & 7 deletions packages/babel-types/src/validators/generated/index.ts
Expand Up @@ -4390,9 +4390,6 @@ export function isStandardizedOrProposal(
"PrivateName" === nodeType ||
"ArgumentPlaceholder" === nodeType ||
"BindExpression" === nodeType ||
"PipelineTopicExpression" === nodeType ||
"PipelineBareFunction" === nodeType ||
"PipelinePrimaryTopicReference" === nodeType ||
"ImportAttribute" === nodeType ||
"Decorator" === nodeType ||
"DoExpression" === nodeType ||
Expand All @@ -4402,6 +4399,10 @@ export function isStandardizedOrProposal(
"DecimalLiteral" === nodeType ||
"StaticBlock" === nodeType ||
"ModuleExpression" === nodeType ||
"TopicReference" === nodeType ||
"PipelineTopicExpression" === nodeType ||
"PipelineBareFunction" === nodeType ||
"PipelinePrimaryTopicReference" === nodeType ||
(nodeType === "Placeholder" &&
("Identifier" === (node as t.Placeholder).expectedNode ||
"StringLiteral" === (node as t.Placeholder).expectedNode ||
Expand Down Expand Up @@ -4439,6 +4440,7 @@ export function isExpression(
"RegExpLiteral" === nodeType ||
"LogicalExpression" === nodeType ||
"MemberExpression" === nodeType ||
"NewExpression" === nodeType ||
"ObjectExpression" === nodeType ||
"SequenceExpression" === nodeType ||
"ParenthesizedExpression" === nodeType ||
Expand Down Expand Up @@ -5638,9 +5640,6 @@ export function isProposal(
if (
"ArgumentPlaceholder" === nodeType ||
"BindExpression" === nodeType ||
"PipelineTopicExpression" === nodeType ||
"PipelineBareFunction" === nodeType ||
"PipelinePrimaryTopicReference" === nodeType ||
"ImportAttribute" === nodeType ||
"Decorator" === nodeType ||
"DoExpression" === nodeType ||
Expand All @@ -5649,7 +5648,11 @@ export function isProposal(
"TupleExpression" === nodeType ||
"DecimalLiteral" === nodeType ||
"StaticBlock" === nodeType ||
"ModuleExpression" === nodeType
"ModuleExpression" === nodeType ||
"TopicReference" === nodeType ||
"PipelineTopicExpression" === nodeType ||
"PipelineBareFunction" === nodeType ||
"PipelinePrimaryTopicReference" === nodeType
) {
if (typeof opts === "undefined") {
return true;
Expand Down

0 comments on commit 517edbc

Please sign in to comment.