ast-types 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,8 +39,14 @@ function default_1(fork) {
39
39
  def("ImportAttribute")
40
40
  .bases("Node")
41
41
  .build("key", "value")
42
- .field("key", def("Identifier"))
43
- .field("value", String);
42
+ .field("key", or(def("Identifier"), def("Literal")))
43
+ .field("value", def("Expression"));
44
+ ["ImportDeclaration",
45
+ "ExportAllDeclaration",
46
+ "ExportNamedDeclaration",
47
+ ].forEach(function (decl) {
48
+ def(decl).field("assertions", [def("ImportAttribute")], defaults.emptyArray);
49
+ });
44
50
  // https://github.com/tc39/proposal-record-tuple
45
51
  // https://github.com/babel/babel/pull/10865
46
52
  def("RecordExpression")
package/def/es2022.js CHANGED
@@ -8,7 +8,7 @@ function default_1(fork) {
8
8
  var types = fork.use(types_1.default);
9
9
  var def = types.Type.def;
10
10
  def("StaticBlock")
11
- .bases("Node")
11
+ .bases("Declaration")
12
12
  .build("body")
13
13
  .field("body", [def("Statement")]);
14
14
  }
package/gen/builders.d.ts CHANGED
@@ -671,6 +671,7 @@ export interface ImportNamespaceSpecifierBuilder {
671
671
  export interface ImportDeclarationBuilder {
672
672
  (specifiers: (K.ImportSpecifierKind | K.ImportNamespaceSpecifierKind | K.ImportDefaultSpecifierKind)[] | undefined, source: K.LiteralKind, importKind?: "value" | "type" | "typeof"): namedTypes.ImportDeclaration;
673
673
  from(params: {
674
+ assertions?: K.ImportAttributeKind[];
674
675
  comments?: K.CommentKind[] | null;
675
676
  importKind?: "value" | "type" | "typeof";
676
677
  loc?: K.SourceLocationKind | null;
@@ -681,6 +682,7 @@ export interface ImportDeclarationBuilder {
681
682
  export interface ExportNamedDeclarationBuilder {
682
683
  (declaration: K.DeclarationKind | null, specifiers?: K.ExportSpecifierKind[], source?: K.LiteralKind | null): namedTypes.ExportNamedDeclaration;
683
684
  from(params: {
685
+ assertions?: K.ImportAttributeKind[];
684
686
  comments?: K.CommentKind[] | null;
685
687
  declaration: K.DeclarationKind | null;
686
688
  loc?: K.SourceLocationKind | null;
@@ -710,6 +712,7 @@ export interface ExportDefaultDeclarationBuilder {
710
712
  export interface ExportAllDeclarationBuilder {
711
713
  (source: K.LiteralKind, exported: K.IdentifierKind | null): namedTypes.ExportAllDeclaration;
712
714
  from(params: {
715
+ assertions?: K.ImportAttributeKind[];
713
716
  comments?: K.CommentKind[] | null;
714
717
  exported: K.IdentifierKind | null;
715
718
  loc?: K.SourceLocationKind | null;
@@ -860,12 +863,12 @@ export interface ClassPrivatePropertyBuilder {
860
863
  }): namedTypes.ClassPrivateProperty;
861
864
  }
862
865
  export interface ImportAttributeBuilder {
863
- (key: K.IdentifierKind, value: string): namedTypes.ImportAttribute;
866
+ (key: K.IdentifierKind | K.LiteralKind, value: K.ExpressionKind): namedTypes.ImportAttribute;
864
867
  from(params: {
865
868
  comments?: K.CommentKind[] | null;
866
- key: K.IdentifierKind;
869
+ key: K.IdentifierKind | K.LiteralKind;
867
870
  loc?: K.SourceLocationKind | null;
868
- value: string;
871
+ value: K.ExpressionKind;
869
872
  }): namedTypes.ImportAttribute;
870
873
  }
871
874
  export interface RecordExpressionBuilder {
package/gen/kinds.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare type CommentKind = namedTypes.Block | namedTypes.Line | namedType
6
6
  export declare type PositionKind = namedTypes.Position;
7
7
  export declare type FileKind = namedTypes.File;
8
8
  export declare type ProgramKind = namedTypes.Program;
9
- export declare type StatementKind = namedTypes.BlockStatement | namedTypes.EmptyStatement | namedTypes.ExpressionStatement | namedTypes.IfStatement | namedTypes.LabeledStatement | namedTypes.BreakStatement | namedTypes.ContinueStatement | namedTypes.WithStatement | namedTypes.SwitchStatement | namedTypes.ReturnStatement | namedTypes.ThrowStatement | namedTypes.TryStatement | namedTypes.WhileStatement | namedTypes.DoWhileStatement | namedTypes.ForStatement | namedTypes.VariableDeclaration | namedTypes.ForInStatement | namedTypes.DebuggerStatement | namedTypes.FunctionDeclaration | namedTypes.ForOfStatement | namedTypes.MethodDefinition | namedTypes.ClassPropertyDefinition | namedTypes.ClassProperty | namedTypes.ClassBody | namedTypes.ClassDeclaration | namedTypes.ImportDeclaration | namedTypes.ExportNamedDeclaration | namedTypes.ExportDefaultDeclaration | namedTypes.ExportAllDeclaration | namedTypes.ClassPrivateProperty | namedTypes.TSTypeParameterDeclaration | namedTypes.InterfaceDeclaration | namedTypes.DeclareInterface | namedTypes.TypeAlias | namedTypes.DeclareTypeAlias | namedTypes.OpaqueType | namedTypes.DeclareOpaqueType | namedTypes.DeclareVariable | namedTypes.DeclareFunction | namedTypes.DeclareClass | namedTypes.DeclareModule | namedTypes.DeclareModuleExports | namedTypes.DeclareExportDeclaration | namedTypes.DeclareExportAllDeclaration | namedTypes.EnumDeclaration | namedTypes.ExportDeclaration | namedTypes.Noop | namedTypes.ClassMethod | namedTypes.ClassPrivateMethod | namedTypes.ForAwaitStatement | namedTypes.TSDeclareFunction | namedTypes.TSDeclareMethod | namedTypes.TSIndexSignature | namedTypes.TSPropertySignature | namedTypes.TSMethodSignature | namedTypes.TSCallSignatureDeclaration | namedTypes.TSConstructSignatureDeclaration | namedTypes.TSEnumDeclaration | namedTypes.TSTypeAliasDeclaration | namedTypes.TSModuleDeclaration | namedTypes.TSImportEqualsDeclaration | namedTypes.TSExternalModuleReference | namedTypes.TSExportAssignment | namedTypes.TSNamespaceExportDeclaration | namedTypes.TSInterfaceDeclaration;
9
+ export declare type StatementKind = namedTypes.BlockStatement | namedTypes.EmptyStatement | namedTypes.ExpressionStatement | namedTypes.IfStatement | namedTypes.LabeledStatement | namedTypes.BreakStatement | namedTypes.ContinueStatement | namedTypes.WithStatement | namedTypes.SwitchStatement | namedTypes.ReturnStatement | namedTypes.ThrowStatement | namedTypes.TryStatement | namedTypes.WhileStatement | namedTypes.DoWhileStatement | namedTypes.ForStatement | namedTypes.VariableDeclaration | namedTypes.ForInStatement | namedTypes.DebuggerStatement | namedTypes.FunctionDeclaration | namedTypes.ForOfStatement | namedTypes.MethodDefinition | namedTypes.ClassPropertyDefinition | namedTypes.ClassProperty | namedTypes.ClassBody | namedTypes.ClassDeclaration | namedTypes.ImportDeclaration | namedTypes.ExportNamedDeclaration | namedTypes.ExportDefaultDeclaration | namedTypes.ExportAllDeclaration | namedTypes.StaticBlock | namedTypes.ClassPrivateProperty | namedTypes.TSTypeParameterDeclaration | namedTypes.InterfaceDeclaration | namedTypes.DeclareInterface | namedTypes.TypeAlias | namedTypes.DeclareTypeAlias | namedTypes.OpaqueType | namedTypes.DeclareOpaqueType | namedTypes.DeclareVariable | namedTypes.DeclareFunction | namedTypes.DeclareClass | namedTypes.DeclareModule | namedTypes.DeclareModuleExports | namedTypes.DeclareExportDeclaration | namedTypes.DeclareExportAllDeclaration | namedTypes.EnumDeclaration | namedTypes.ExportDeclaration | namedTypes.Noop | namedTypes.ClassMethod | namedTypes.ClassPrivateMethod | namedTypes.ForAwaitStatement | namedTypes.TSDeclareFunction | namedTypes.TSDeclareMethod | namedTypes.TSIndexSignature | namedTypes.TSPropertySignature | namedTypes.TSMethodSignature | namedTypes.TSCallSignatureDeclaration | namedTypes.TSConstructSignatureDeclaration | namedTypes.TSEnumDeclaration | namedTypes.TSTypeAliasDeclaration | namedTypes.TSModuleDeclaration | namedTypes.TSImportEqualsDeclaration | namedTypes.TSExternalModuleReference | namedTypes.TSExportAssignment | namedTypes.TSNamespaceExportDeclaration | namedTypes.TSInterfaceDeclaration;
10
10
  export declare type FunctionKind = namedTypes.FunctionDeclaration | namedTypes.FunctionExpression | namedTypes.ArrowFunctionExpression | namedTypes.ObjectMethod | namedTypes.ClassMethod | namedTypes.ClassPrivateMethod;
11
11
  export declare type ExpressionKind = namedTypes.Identifier | namedTypes.FunctionExpression | namedTypes.ThisExpression | namedTypes.ArrayExpression | namedTypes.ObjectExpression | namedTypes.Literal | namedTypes.SequenceExpression | namedTypes.UnaryExpression | namedTypes.BinaryExpression | namedTypes.AssignmentExpression | namedTypes.MemberExpression | namedTypes.UpdateExpression | namedTypes.LogicalExpression | namedTypes.ConditionalExpression | namedTypes.NewExpression | namedTypes.CallExpression | namedTypes.ArrowFunctionExpression | namedTypes.YieldExpression | namedTypes.GeneratorExpression | namedTypes.ComprehensionExpression | namedTypes.ClassExpression | namedTypes.Super | namedTypes.TaggedTemplateExpression | namedTypes.TemplateLiteral | namedTypes.MetaProperty | namedTypes.AwaitExpression | namedTypes.ImportExpression | namedTypes.ChainExpression | namedTypes.OptionalCallExpression | namedTypes.OptionalMemberExpression | namedTypes.PrivateName | namedTypes.RecordExpression | namedTypes.TupleExpression | namedTypes.JSXIdentifier | namedTypes.JSXExpressionContainer | namedTypes.JSXElement | namedTypes.JSXFragment | namedTypes.JSXMemberExpression | namedTypes.JSXText | namedTypes.TypeCastExpression | namedTypes.DoExpression | namedTypes.BindExpression | namedTypes.ParenthesizedExpression | namedTypes.DirectiveLiteral | namedTypes.StringLiteral | namedTypes.NumericLiteral | namedTypes.BigIntLiteral | namedTypes.DecimalLiteral | namedTypes.NullLiteral | namedTypes.BooleanLiteral | namedTypes.RegExpLiteral | namedTypes.Import | namedTypes.V8IntrinsicIdentifier | namedTypes.TopicReference | namedTypes.TSAsExpression | namedTypes.TSNonNullExpression | namedTypes.TSTypeParameter | namedTypes.TSTypeAssertion;
12
12
  export declare type PatternKind = namedTypes.Identifier | namedTypes.RestElement | namedTypes.SpreadElementPattern | namedTypes.PropertyPattern | namedTypes.ObjectPattern | namedTypes.ArrayPattern | namedTypes.AssignmentPattern | namedTypes.SpreadPropertyPattern | namedTypes.PrivateName | namedTypes.JSXIdentifier | namedTypes.TSAsExpression | namedTypes.TSNonNullExpression | namedTypes.TSTypeParameter | namedTypes.TSTypeAssertion | namedTypes.TSParameterProperty;
@@ -28,7 +28,7 @@ export declare type CatchClauseKind = namedTypes.CatchClause;
28
28
  export declare type WhileStatementKind = namedTypes.WhileStatement;
29
29
  export declare type DoWhileStatementKind = namedTypes.DoWhileStatement;
30
30
  export declare type ForStatementKind = namedTypes.ForStatement;
31
- export declare type DeclarationKind = namedTypes.VariableDeclaration | namedTypes.FunctionDeclaration | namedTypes.MethodDefinition | namedTypes.ClassPropertyDefinition | namedTypes.ClassProperty | namedTypes.ClassBody | namedTypes.ClassDeclaration | namedTypes.ImportDeclaration | namedTypes.ExportNamedDeclaration | namedTypes.ExportDefaultDeclaration | namedTypes.ExportAllDeclaration | namedTypes.ClassPrivateProperty | namedTypes.TSTypeParameterDeclaration | namedTypes.InterfaceDeclaration | namedTypes.DeclareInterface | namedTypes.TypeAlias | namedTypes.DeclareTypeAlias | namedTypes.OpaqueType | namedTypes.DeclareOpaqueType | namedTypes.DeclareClass | namedTypes.DeclareExportDeclaration | namedTypes.DeclareExportAllDeclaration | namedTypes.EnumDeclaration | namedTypes.ExportDeclaration | namedTypes.ClassMethod | namedTypes.ClassPrivateMethod | namedTypes.TSDeclareFunction | namedTypes.TSDeclareMethod | namedTypes.TSIndexSignature | namedTypes.TSPropertySignature | namedTypes.TSMethodSignature | namedTypes.TSCallSignatureDeclaration | namedTypes.TSConstructSignatureDeclaration | namedTypes.TSEnumDeclaration | namedTypes.TSTypeAliasDeclaration | namedTypes.TSModuleDeclaration | namedTypes.TSImportEqualsDeclaration | namedTypes.TSExternalModuleReference | namedTypes.TSNamespaceExportDeclaration | namedTypes.TSInterfaceDeclaration;
31
+ export declare type DeclarationKind = namedTypes.VariableDeclaration | namedTypes.FunctionDeclaration | namedTypes.MethodDefinition | namedTypes.ClassPropertyDefinition | namedTypes.ClassProperty | namedTypes.ClassBody | namedTypes.ClassDeclaration | namedTypes.ImportDeclaration | namedTypes.ExportNamedDeclaration | namedTypes.ExportDefaultDeclaration | namedTypes.ExportAllDeclaration | namedTypes.StaticBlock | namedTypes.ClassPrivateProperty | namedTypes.TSTypeParameterDeclaration | namedTypes.InterfaceDeclaration | namedTypes.DeclareInterface | namedTypes.TypeAlias | namedTypes.DeclareTypeAlias | namedTypes.OpaqueType | namedTypes.DeclareOpaqueType | namedTypes.DeclareClass | namedTypes.DeclareExportDeclaration | namedTypes.DeclareExportAllDeclaration | namedTypes.EnumDeclaration | namedTypes.ExportDeclaration | namedTypes.ClassMethod | namedTypes.ClassPrivateMethod | namedTypes.TSDeclareFunction | namedTypes.TSDeclareMethod | namedTypes.TSIndexSignature | namedTypes.TSPropertySignature | namedTypes.TSMethodSignature | namedTypes.TSCallSignatureDeclaration | namedTypes.TSConstructSignatureDeclaration | namedTypes.TSEnumDeclaration | namedTypes.TSTypeAliasDeclaration | namedTypes.TSModuleDeclaration | namedTypes.TSImportEqualsDeclaration | namedTypes.TSExternalModuleReference | namedTypes.TSNamespaceExportDeclaration | namedTypes.TSInterfaceDeclaration;
32
32
  export declare type VariableDeclarationKind = namedTypes.VariableDeclaration;
33
33
  export declare type ForInStatementKind = namedTypes.ForInStatement;
34
34
  export declare type DebuggerStatementKind = namedTypes.DebuggerStatement;
@@ -419,12 +419,14 @@ export declare namespace namedTypes {
419
419
  specifiers?: (K.ImportSpecifierKind | K.ImportNamespaceSpecifierKind | K.ImportDefaultSpecifierKind)[];
420
420
  source: K.LiteralKind;
421
421
  importKind?: "value" | "type" | "typeof";
422
+ assertions?: K.ImportAttributeKind[];
422
423
  }
423
424
  interface ExportNamedDeclaration extends Omit<Declaration, "type"> {
424
425
  type: "ExportNamedDeclaration";
425
426
  declaration: K.DeclarationKind | null;
426
427
  specifiers?: K.ExportSpecifierKind[];
427
428
  source?: K.LiteralKind | null;
429
+ assertions?: K.ImportAttributeKind[];
428
430
  }
429
431
  interface ExportSpecifier extends Omit<ModuleSpecifier, "type"> {
430
432
  type: "ExportSpecifier";
@@ -438,6 +440,7 @@ export declare namespace namedTypes {
438
440
  type: "ExportAllDeclaration";
439
441
  source: K.LiteralKind;
440
442
  exported: K.IdentifierKind | null;
443
+ assertions?: K.ImportAttributeKind[];
441
444
  }
442
445
  interface TaggedTemplateExpression extends Omit<Expression, "type"> {
443
446
  type: "TaggedTemplateExpression";
@@ -491,7 +494,7 @@ export declare namespace namedTypes {
491
494
  type: "OptionalMemberExpression";
492
495
  optional?: boolean;
493
496
  }
494
- interface StaticBlock extends Omit<Node, "type"> {
497
+ interface StaticBlock extends Omit<Declaration, "type"> {
495
498
  type: "StaticBlock";
496
499
  body: K.StatementKind[];
497
500
  }
@@ -510,8 +513,8 @@ export declare namespace namedTypes {
510
513
  }
511
514
  interface ImportAttribute extends Omit<Node, "type"> {
512
515
  type: "ImportAttribute";
513
- key: K.IdentifierKind;
514
- value: string;
516
+ key: K.IdentifierKind | K.LiteralKind;
517
+ value: K.ExpressionKind;
515
518
  }
516
519
  interface RecordExpression extends Omit<Expression, "type"> {
517
520
  type: "RecordExpression";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Ben Newman <bn@cs.stanford.edu>",
3
3
  "name": "ast-types",
4
- "version": "0.15.0",
4
+ "version": "0.15.1",
5
5
  "description": "Esprima-compatible implementation of the Mozilla JS Parser API",
6
6
  "keywords": [
7
7
  "ast",