ast-types 0.14.2 → 0.15.0

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.
Files changed (47) hide show
  1. package/.github/workflows/main.yml +1 -1
  2. package/README.md +1 -1
  3. package/def/babel-core.js +19 -4
  4. package/def/babel.js +15 -2
  5. package/def/core.js +7 -6
  6. package/def/es-proposals.js +26 -4
  7. package/def/es2016.js +6 -12
  8. package/def/es2017.js +3 -3
  9. package/def/es2018.js +3 -3
  10. package/def/es2019.js +3 -3
  11. package/def/es2020.js +7 -8
  12. package/def/es2021.d.ts +2 -0
  13. package/def/es2021.js +13 -0
  14. package/def/es2022.d.ts +2 -0
  15. package/def/es2022.js +16 -0
  16. package/def/es6.js +3 -3
  17. package/def/esprima.js +4 -4
  18. package/def/flow.js +15 -4
  19. package/def/jsx.js +4 -4
  20. package/def/operators/core.d.ts +5 -0
  21. package/def/operators/core.js +25 -0
  22. package/def/operators/es2016.d.ts +5 -0
  23. package/def/operators/es2016.js +19 -0
  24. package/def/operators/es2020.d.ts +5 -0
  25. package/def/operators/es2020.js +15 -0
  26. package/def/operators/es2021.d.ts +5 -0
  27. package/def/operators/es2021.js +18 -0
  28. package/def/type-annotations.js +2 -2
  29. package/def/typescript.js +11 -4
  30. package/fork.js +5 -5
  31. package/gen/builders.d.ts +170 -61
  32. package/gen/kinds.d.ts +23 -12
  33. package/gen/namedTypes.d.ts +108 -36
  34. package/gen/visitor.d.ts +15 -4
  35. package/lib/equiv.js +1 -1
  36. package/lib/node-path.js +3 -3
  37. package/lib/path-visitor.js +2 -2
  38. package/lib/path.d.ts +3 -3
  39. package/lib/path.js +1 -1
  40. package/lib/scope.d.ts +3 -2
  41. package/lib/scope.js +61 -26
  42. package/lib/shared.js +1 -1
  43. package/lib/types.js +6 -6
  44. package/main.js +9 -25
  45. package/package.json +15 -15
  46. package/def/core-operators.d.ts +0 -3
  47. package/def/core-operators.js +0 -20
@@ -220,7 +220,7 @@ export declare namespace namedTypes {
220
220
  }
221
221
  interface AssignmentExpression extends Omit<Expression, "type"> {
222
222
  type: "AssignmentExpression";
223
- operator: "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "**=";
223
+ operator: "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "**=" | "||=" | "&&=" | "??=";
224
224
  left: K.PatternKind | K.MemberExpressionKind;
225
225
  right: K.ExpressionKind;
226
226
  }
@@ -447,7 +447,7 @@ export declare namespace namedTypes {
447
447
  interface TemplateLiteral extends Omit<Expression, "type"> {
448
448
  type: "TemplateLiteral";
449
449
  quasis: K.TemplateElementKind[];
450
- expressions: K.ExpressionKind[];
450
+ expressions: K.ExpressionKind[] | K.TSTypeKind[];
451
451
  }
452
452
  interface TemplateElement extends Omit<Node, "type"> {
453
453
  type: "TemplateElement";
@@ -491,6 +491,52 @@ export declare namespace namedTypes {
491
491
  type: "OptionalMemberExpression";
492
492
  optional?: boolean;
493
493
  }
494
+ interface StaticBlock extends Omit<Node, "type"> {
495
+ type: "StaticBlock";
496
+ body: K.StatementKind[];
497
+ }
498
+ interface Decorator extends Omit<Node, "type"> {
499
+ type: "Decorator";
500
+ expression: K.ExpressionKind;
501
+ }
502
+ interface PrivateName extends Omit<Expression, "type">, Omit<Pattern, "type"> {
503
+ type: "PrivateName";
504
+ id: K.IdentifierKind;
505
+ }
506
+ interface ClassPrivateProperty extends Omit<ClassProperty, "type" | "key" | "value"> {
507
+ type: "ClassPrivateProperty";
508
+ key: K.PrivateNameKind;
509
+ value?: K.ExpressionKind | null;
510
+ }
511
+ interface ImportAttribute extends Omit<Node, "type"> {
512
+ type: "ImportAttribute";
513
+ key: K.IdentifierKind;
514
+ value: string;
515
+ }
516
+ interface RecordExpression extends Omit<Expression, "type"> {
517
+ type: "RecordExpression";
518
+ properties: (K.ObjectPropertyKind | K.ObjectMethodKind | K.SpreadElementKind)[];
519
+ }
520
+ interface ObjectMethod extends Omit<Node, "type">, Omit<Function, "type" | "params" | "body" | "generator" | "async"> {
521
+ type: "ObjectMethod";
522
+ kind: "method" | "get" | "set";
523
+ key: K.LiteralKind | K.IdentifierKind | K.ExpressionKind;
524
+ params: K.PatternKind[];
525
+ body: K.BlockStatementKind;
526
+ computed?: boolean;
527
+ generator?: boolean;
528
+ async?: boolean;
529
+ accessibility?: K.LiteralKind | null;
530
+ decorators?: K.DecoratorKind[] | null;
531
+ }
532
+ interface TupleExpression extends Omit<Expression, "type"> {
533
+ type: "TupleExpression";
534
+ elements: (K.ExpressionKind | K.SpreadElementKind | null)[];
535
+ }
536
+ interface ModuleExpression extends Omit<Node, "type"> {
537
+ type: "ModuleExpression";
538
+ body: K.ProgramKind;
539
+ }
494
540
  interface JSXAttribute extends Omit<Node, "type"> {
495
541
  type: "JSXAttribute";
496
542
  name: K.JSXIdentifierKind | K.JSXNamespacedNameKind;
@@ -562,19 +608,6 @@ export declare namespace namedTypes {
562
608
  interface JSXClosingFragment extends Omit<Node, "type"> {
563
609
  type: "JSXClosingFragment";
564
610
  }
565
- interface Decorator extends Omit<Node, "type"> {
566
- type: "Decorator";
567
- expression: K.ExpressionKind;
568
- }
569
- interface PrivateName extends Omit<Expression, "type">, Omit<Pattern, "type"> {
570
- type: "PrivateName";
571
- id: K.IdentifierKind;
572
- }
573
- interface ClassPrivateProperty extends Omit<ClassProperty, "type" | "key" | "value"> {
574
- type: "ClassPrivateProperty";
575
- key: K.PrivateNameKind;
576
- value?: K.ExpressionKind | null;
577
- }
578
611
  interface TypeParameterDeclaration extends Omit<Node, "type"> {
579
612
  type: "TypeParameterDeclaration";
580
613
  params: K.TypeParameterKind[];
@@ -758,6 +791,17 @@ export declare namespace namedTypes {
758
791
  object: K.IdentifierKind;
759
792
  property: K.MemberTypeAnnotationKind | K.GenericTypeAnnotationKind;
760
793
  }
794
+ interface IndexedAccessType extends Omit<FlowType, "type"> {
795
+ type: "IndexedAccessType";
796
+ objectType: K.FlowTypeKind;
797
+ indexType: K.FlowTypeKind;
798
+ }
799
+ interface OptionalIndexedAccessType extends Omit<FlowType, "type"> {
800
+ type: "OptionalIndexedAccessType";
801
+ objectType: K.FlowTypeKind;
802
+ indexType: K.FlowTypeKind;
803
+ optional: boolean;
804
+ }
761
805
  interface UnionTypeAnnotation extends Omit<FlowType, "type"> {
762
806
  type: "UnionTypeAnnotation";
763
807
  types: K.FlowTypeKind[];
@@ -989,6 +1033,14 @@ export declare namespace namedTypes {
989
1033
  raw: string;
990
1034
  };
991
1035
  }
1036
+ interface DecimalLiteral extends Omit<Literal, "type" | "value"> {
1037
+ type: "DecimalLiteral";
1038
+ value: string;
1039
+ extra?: {
1040
+ rawValue: string;
1041
+ raw: string;
1042
+ };
1043
+ }
992
1044
  interface NullLiteral extends Omit<Literal, "type" | "value"> {
993
1045
  type: "NullLiteral";
994
1046
  value?: null;
@@ -1003,18 +1055,6 @@ export declare namespace namedTypes {
1003
1055
  flags: string;
1004
1056
  value?: RegExp;
1005
1057
  }
1006
- interface ObjectMethod extends Omit<Node, "type">, Omit<Function, "type" | "params" | "body" | "generator" | "async"> {
1007
- type: "ObjectMethod";
1008
- kind: "method" | "get" | "set";
1009
- key: K.LiteralKind | K.IdentifierKind | K.ExpressionKind;
1010
- params: K.PatternKind[];
1011
- body: K.BlockStatementKind;
1012
- computed?: boolean;
1013
- generator?: boolean;
1014
- async?: boolean;
1015
- accessibility?: K.LiteralKind | null;
1016
- decorators?: K.DecoratorKind[] | null;
1017
- }
1018
1058
  interface ClassMethod extends Omit<Declaration, "type">, Omit<Function, "type" | "body"> {
1019
1059
  type: "ClassMethod";
1020
1060
  key: K.LiteralKind | K.IdentifierKind | K.ExpressionKind;
@@ -1054,6 +1094,13 @@ export declare namespace namedTypes {
1054
1094
  interface Import extends Omit<Expression, "type"> {
1055
1095
  type: "Import";
1056
1096
  }
1097
+ interface V8IntrinsicIdentifier extends Omit<Expression, "type"> {
1098
+ type: "V8IntrinsicIdentifier";
1099
+ name: string;
1100
+ }
1101
+ interface TopicReference extends Omit<Expression, "type"> {
1102
+ type: "TopicReference";
1103
+ }
1057
1104
  interface TSQualifiedName extends Omit<Node, "type"> {
1058
1105
  type: "TSQualifiedName";
1059
1106
  left: K.IdentifierKind | K.TSQualifiedNameKind;
@@ -1117,6 +1164,9 @@ export declare namespace namedTypes {
1117
1164
  interface TSVoidKeyword extends Omit<TSType, "type"> {
1118
1165
  type: "TSVoidKeyword";
1119
1166
  }
1167
+ interface TSIntrinsicKeyword extends Omit<TSType, "type"> {
1168
+ type: "TSIntrinsicKeyword";
1169
+ }
1120
1170
  interface TSThisType extends Omit<TSType, "type"> {
1121
1171
  type: "TSThisType";
1122
1172
  }
@@ -1345,7 +1395,7 @@ export declare namespace namedTypes {
1345
1395
  readonly?: boolean;
1346
1396
  parameter: K.IdentifierKind | K.AssignmentPatternKind;
1347
1397
  }
1348
- type ASTNode = File | Program | Identifier | BlockStatement | EmptyStatement | ExpressionStatement | IfStatement | LabeledStatement | BreakStatement | ContinueStatement | WithStatement | SwitchStatement | SwitchCase | ReturnStatement | ThrowStatement | TryStatement | CatchClause | WhileStatement | DoWhileStatement | ForStatement | VariableDeclaration | ForInStatement | DebuggerStatement | FunctionDeclaration | FunctionExpression | VariableDeclarator | ThisExpression | ArrayExpression | ObjectExpression | Property | Literal | SequenceExpression | UnaryExpression | BinaryExpression | AssignmentExpression | MemberExpression | UpdateExpression | LogicalExpression | ConditionalExpression | NewExpression | CallExpression | RestElement | TypeAnnotation | TSTypeAnnotation | SpreadElementPattern | ArrowFunctionExpression | ForOfStatement | YieldExpression | GeneratorExpression | ComprehensionBlock | ComprehensionExpression | ObjectProperty | PropertyPattern | ObjectPattern | ArrayPattern | SpreadElement | AssignmentPattern | MethodDefinition | ClassPropertyDefinition | ClassProperty | ClassBody | ClassDeclaration | ClassExpression | Super | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ImportDeclaration | ExportNamedDeclaration | ExportSpecifier | ExportDefaultDeclaration | ExportAllDeclaration | TaggedTemplateExpression | TemplateLiteral | TemplateElement | MetaProperty | AwaitExpression | SpreadProperty | SpreadPropertyPattern | ImportExpression | ChainExpression | OptionalCallExpression | OptionalMemberExpression | JSXAttribute | JSXIdentifier | JSXNamespacedName | JSXExpressionContainer | JSXElement | JSXFragment | JSXMemberExpression | JSXSpreadAttribute | JSXEmptyExpression | JSXText | JSXSpreadChild | JSXOpeningElement | JSXClosingElement | JSXOpeningFragment | JSXClosingFragment | Decorator | PrivateName | ClassPrivateProperty | TypeParameterDeclaration | TSTypeParameterDeclaration | TypeParameterInstantiation | TSTypeParameterInstantiation | ClassImplements | TSExpressionWithTypeArguments | AnyTypeAnnotation | EmptyTypeAnnotation | MixedTypeAnnotation | VoidTypeAnnotation | SymbolTypeAnnotation | NumberTypeAnnotation | BigIntTypeAnnotation | NumberLiteralTypeAnnotation | NumericLiteralTypeAnnotation | BigIntLiteralTypeAnnotation | StringTypeAnnotation | StringLiteralTypeAnnotation | BooleanTypeAnnotation | BooleanLiteralTypeAnnotation | NullableTypeAnnotation | NullLiteralTypeAnnotation | NullTypeAnnotation | ThisTypeAnnotation | ExistsTypeAnnotation | ExistentialTypeParam | FunctionTypeAnnotation | FunctionTypeParam | ArrayTypeAnnotation | ObjectTypeAnnotation | ObjectTypeProperty | ObjectTypeSpreadProperty | ObjectTypeIndexer | ObjectTypeCallProperty | ObjectTypeInternalSlot | Variance | QualifiedTypeIdentifier | GenericTypeAnnotation | MemberTypeAnnotation | UnionTypeAnnotation | IntersectionTypeAnnotation | TypeofTypeAnnotation | TypeParameter | InterfaceTypeAnnotation | InterfaceExtends | InterfaceDeclaration | DeclareInterface | TypeAlias | DeclareTypeAlias | OpaqueType | DeclareOpaqueType | TypeCastExpression | TupleTypeAnnotation | DeclareVariable | DeclareFunction | DeclareClass | DeclareModule | DeclareModuleExports | DeclareExportDeclaration | ExportBatchSpecifier | DeclareExportAllDeclaration | InferredPredicate | DeclaredPredicate | EnumDeclaration | EnumBooleanBody | EnumNumberBody | EnumStringBody | EnumSymbolBody | EnumBooleanMember | EnumNumberMember | EnumStringMember | EnumDefaultedMember | ExportDeclaration | Block | Line | Noop | DoExpression | BindExpression | ParenthesizedExpression | ExportNamespaceSpecifier | ExportDefaultSpecifier | CommentBlock | CommentLine | Directive | DirectiveLiteral | InterpreterDirective | StringLiteral | NumericLiteral | BigIntLiteral | NullLiteral | BooleanLiteral | RegExpLiteral | ObjectMethod | ClassMethod | ClassPrivateMethod | RestProperty | ForAwaitStatement | Import | TSQualifiedName | TSTypeReference | TSAsExpression | TSNonNullExpression | TSAnyKeyword | TSBigIntKeyword | TSBooleanKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSThisType | TSArrayType | TSLiteralType | TSUnionType | TSIntersectionType | TSConditionalType | TSInferType | TSTypeParameter | TSParenthesizedType | TSFunctionType | TSConstructorType | TSDeclareFunction | TSDeclareMethod | TSMappedType | TSTupleType | TSNamedTupleMember | TSRestType | TSOptionalType | TSIndexedAccessType | TSTypeOperator | TSIndexSignature | TSPropertySignature | TSMethodSignature | TSTypePredicate | TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSEnumMember | TSTypeQuery | TSImportType | TSTypeLiteral | TSTypeAssertion | TSEnumDeclaration | TSTypeAliasDeclaration | TSModuleBlock | TSModuleDeclaration | TSImportEqualsDeclaration | TSExternalModuleReference | TSExportAssignment | TSNamespaceExportDeclaration | TSInterfaceBody | TSInterfaceDeclaration | TSParameterProperty;
1398
+ type ASTNode = File | Program | Identifier | BlockStatement | EmptyStatement | ExpressionStatement | IfStatement | LabeledStatement | BreakStatement | ContinueStatement | WithStatement | SwitchStatement | SwitchCase | ReturnStatement | ThrowStatement | TryStatement | CatchClause | WhileStatement | DoWhileStatement | ForStatement | VariableDeclaration | ForInStatement | DebuggerStatement | FunctionDeclaration | FunctionExpression | VariableDeclarator | ThisExpression | ArrayExpression | ObjectExpression | Property | Literal | SequenceExpression | UnaryExpression | BinaryExpression | AssignmentExpression | MemberExpression | UpdateExpression | LogicalExpression | ConditionalExpression | NewExpression | CallExpression | RestElement | TypeAnnotation | TSTypeAnnotation | SpreadElementPattern | ArrowFunctionExpression | ForOfStatement | YieldExpression | GeneratorExpression | ComprehensionBlock | ComprehensionExpression | ObjectProperty | PropertyPattern | ObjectPattern | ArrayPattern | SpreadElement | AssignmentPattern | MethodDefinition | ClassPropertyDefinition | ClassProperty | ClassBody | ClassDeclaration | ClassExpression | Super | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ImportDeclaration | ExportNamedDeclaration | ExportSpecifier | ExportDefaultDeclaration | ExportAllDeclaration | TaggedTemplateExpression | TemplateLiteral | TemplateElement | MetaProperty | AwaitExpression | SpreadProperty | SpreadPropertyPattern | ImportExpression | ChainExpression | OptionalCallExpression | OptionalMemberExpression | StaticBlock | Decorator | PrivateName | ClassPrivateProperty | ImportAttribute | RecordExpression | ObjectMethod | TupleExpression | ModuleExpression | JSXAttribute | JSXIdentifier | JSXNamespacedName | JSXExpressionContainer | JSXElement | JSXFragment | JSXMemberExpression | JSXSpreadAttribute | JSXEmptyExpression | JSXText | JSXSpreadChild | JSXOpeningElement | JSXClosingElement | JSXOpeningFragment | JSXClosingFragment | TypeParameterDeclaration | TSTypeParameterDeclaration | TypeParameterInstantiation | TSTypeParameterInstantiation | ClassImplements | TSExpressionWithTypeArguments | AnyTypeAnnotation | EmptyTypeAnnotation | MixedTypeAnnotation | VoidTypeAnnotation | SymbolTypeAnnotation | NumberTypeAnnotation | BigIntTypeAnnotation | NumberLiteralTypeAnnotation | NumericLiteralTypeAnnotation | BigIntLiteralTypeAnnotation | StringTypeAnnotation | StringLiteralTypeAnnotation | BooleanTypeAnnotation | BooleanLiteralTypeAnnotation | NullableTypeAnnotation | NullLiteralTypeAnnotation | NullTypeAnnotation | ThisTypeAnnotation | ExistsTypeAnnotation | ExistentialTypeParam | FunctionTypeAnnotation | FunctionTypeParam | ArrayTypeAnnotation | ObjectTypeAnnotation | ObjectTypeProperty | ObjectTypeSpreadProperty | ObjectTypeIndexer | ObjectTypeCallProperty | ObjectTypeInternalSlot | Variance | QualifiedTypeIdentifier | GenericTypeAnnotation | MemberTypeAnnotation | IndexedAccessType | OptionalIndexedAccessType | UnionTypeAnnotation | IntersectionTypeAnnotation | TypeofTypeAnnotation | TypeParameter | InterfaceTypeAnnotation | InterfaceExtends | InterfaceDeclaration | DeclareInterface | TypeAlias | DeclareTypeAlias | OpaqueType | DeclareOpaqueType | TypeCastExpression | TupleTypeAnnotation | DeclareVariable | DeclareFunction | DeclareClass | DeclareModule | DeclareModuleExports | DeclareExportDeclaration | ExportBatchSpecifier | DeclareExportAllDeclaration | InferredPredicate | DeclaredPredicate | EnumDeclaration | EnumBooleanBody | EnumNumberBody | EnumStringBody | EnumSymbolBody | EnumBooleanMember | EnumNumberMember | EnumStringMember | EnumDefaultedMember | ExportDeclaration | Block | Line | Noop | DoExpression | BindExpression | ParenthesizedExpression | ExportNamespaceSpecifier | ExportDefaultSpecifier | CommentBlock | CommentLine | Directive | DirectiveLiteral | InterpreterDirective | StringLiteral | NumericLiteral | BigIntLiteral | DecimalLiteral | NullLiteral | BooleanLiteral | RegExpLiteral | ClassMethod | ClassPrivateMethod | RestProperty | ForAwaitStatement | Import | V8IntrinsicIdentifier | TopicReference | TSQualifiedName | TSTypeReference | TSAsExpression | TSNonNullExpression | TSAnyKeyword | TSBigIntKeyword | TSBooleanKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSIntrinsicKeyword | TSThisType | TSArrayType | TSLiteralType | TSUnionType | TSIntersectionType | TSConditionalType | TSInferType | TSTypeParameter | TSParenthesizedType | TSFunctionType | TSConstructorType | TSDeclareFunction | TSDeclareMethod | TSMappedType | TSTupleType | TSNamedTupleMember | TSRestType | TSOptionalType | TSIndexedAccessType | TSTypeOperator | TSIndexSignature | TSPropertySignature | TSMethodSignature | TSTypePredicate | TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSEnumMember | TSTypeQuery | TSImportType | TSTypeLiteral | TSTypeAssertion | TSEnumDeclaration | TSTypeAliasDeclaration | TSModuleBlock | TSModuleDeclaration | TSImportEqualsDeclaration | TSExternalModuleReference | TSExportAssignment | TSNamespaceExportDeclaration | TSInterfaceBody | TSInterfaceDeclaration | TSParameterProperty;
1349
1399
  let Printable: Type<Printable>;
1350
1400
  let SourceLocation: Type<SourceLocation>;
1351
1401
  let Node: Type<Node>;
@@ -1442,6 +1492,15 @@ export declare namespace namedTypes {
1442
1492
  let ChainExpression: Type<ChainExpression>;
1443
1493
  let OptionalCallExpression: Type<OptionalCallExpression>;
1444
1494
  let OptionalMemberExpression: Type<OptionalMemberExpression>;
1495
+ let StaticBlock: Type<StaticBlock>;
1496
+ let Decorator: Type<Decorator>;
1497
+ let PrivateName: Type<PrivateName>;
1498
+ let ClassPrivateProperty: Type<ClassPrivateProperty>;
1499
+ let ImportAttribute: Type<ImportAttribute>;
1500
+ let RecordExpression: Type<RecordExpression>;
1501
+ let ObjectMethod: Type<ObjectMethod>;
1502
+ let TupleExpression: Type<TupleExpression>;
1503
+ let ModuleExpression: Type<ModuleExpression>;
1445
1504
  let JSXAttribute: Type<JSXAttribute>;
1446
1505
  let JSXIdentifier: Type<JSXIdentifier>;
1447
1506
  let JSXNamespacedName: Type<JSXNamespacedName>;
@@ -1457,9 +1516,6 @@ export declare namespace namedTypes {
1457
1516
  let JSXClosingElement: Type<JSXClosingElement>;
1458
1517
  let JSXOpeningFragment: Type<JSXOpeningFragment>;
1459
1518
  let JSXClosingFragment: Type<JSXClosingFragment>;
1460
- let Decorator: Type<Decorator>;
1461
- let PrivateName: Type<PrivateName>;
1462
- let ClassPrivateProperty: Type<ClassPrivateProperty>;
1463
1519
  let TypeParameterDeclaration: Type<TypeParameterDeclaration>;
1464
1520
  let TSTypeParameterDeclaration: Type<TSTypeParameterDeclaration>;
1465
1521
  let TypeParameterInstantiation: Type<TypeParameterInstantiation>;
@@ -1503,6 +1559,8 @@ export declare namespace namedTypes {
1503
1559
  let QualifiedTypeIdentifier: Type<QualifiedTypeIdentifier>;
1504
1560
  let GenericTypeAnnotation: Type<GenericTypeAnnotation>;
1505
1561
  let MemberTypeAnnotation: Type<MemberTypeAnnotation>;
1562
+ let IndexedAccessType: Type<IndexedAccessType>;
1563
+ let OptionalIndexedAccessType: Type<OptionalIndexedAccessType>;
1506
1564
  let UnionTypeAnnotation: Type<UnionTypeAnnotation>;
1507
1565
  let IntersectionTypeAnnotation: Type<IntersectionTypeAnnotation>;
1508
1566
  let TypeofTypeAnnotation: Type<TypeofTypeAnnotation>;
@@ -1554,15 +1612,17 @@ export declare namespace namedTypes {
1554
1612
  let StringLiteral: Type<StringLiteral>;
1555
1613
  let NumericLiteral: Type<NumericLiteral>;
1556
1614
  let BigIntLiteral: Type<BigIntLiteral>;
1615
+ let DecimalLiteral: Type<DecimalLiteral>;
1557
1616
  let NullLiteral: Type<NullLiteral>;
1558
1617
  let BooleanLiteral: Type<BooleanLiteral>;
1559
1618
  let RegExpLiteral: Type<RegExpLiteral>;
1560
- let ObjectMethod: Type<ObjectMethod>;
1561
1619
  let ClassMethod: Type<ClassMethod>;
1562
1620
  let ClassPrivateMethod: Type<ClassPrivateMethod>;
1563
1621
  let RestProperty: Type<RestProperty>;
1564
1622
  let ForAwaitStatement: Type<ForAwaitStatement>;
1565
1623
  let Import: Type<Import>;
1624
+ let V8IntrinsicIdentifier: Type<V8IntrinsicIdentifier>;
1625
+ let TopicReference: Type<TopicReference>;
1566
1626
  let TSQualifiedName: Type<TSQualifiedName>;
1567
1627
  let TSTypeReference: Type<TSTypeReference>;
1568
1628
  let TSHasOptionalTypeParameters: Type<TSHasOptionalTypeParameters>;
@@ -1581,6 +1641,7 @@ export declare namespace namedTypes {
1581
1641
  let TSUndefinedKeyword: Type<TSUndefinedKeyword>;
1582
1642
  let TSUnknownKeyword: Type<TSUnknownKeyword>;
1583
1643
  let TSVoidKeyword: Type<TSVoidKeyword>;
1644
+ let TSIntrinsicKeyword: Type<TSIntrinsicKeyword>;
1584
1645
  let TSThisType: Type<TSThisType>;
1585
1646
  let TSArrayType: Type<TSArrayType>;
1586
1647
  let TSLiteralType: Type<TSLiteralType>;
@@ -1721,6 +1782,15 @@ export interface NamedTypes {
1721
1782
  ChainExpression: Type<namedTypes.ChainExpression>;
1722
1783
  OptionalCallExpression: Type<namedTypes.OptionalCallExpression>;
1723
1784
  OptionalMemberExpression: Type<namedTypes.OptionalMemberExpression>;
1785
+ StaticBlock: Type<namedTypes.StaticBlock>;
1786
+ Decorator: Type<namedTypes.Decorator>;
1787
+ PrivateName: Type<namedTypes.PrivateName>;
1788
+ ClassPrivateProperty: Type<namedTypes.ClassPrivateProperty>;
1789
+ ImportAttribute: Type<namedTypes.ImportAttribute>;
1790
+ RecordExpression: Type<namedTypes.RecordExpression>;
1791
+ ObjectMethod: Type<namedTypes.ObjectMethod>;
1792
+ TupleExpression: Type<namedTypes.TupleExpression>;
1793
+ ModuleExpression: Type<namedTypes.ModuleExpression>;
1724
1794
  JSXAttribute: Type<namedTypes.JSXAttribute>;
1725
1795
  JSXIdentifier: Type<namedTypes.JSXIdentifier>;
1726
1796
  JSXNamespacedName: Type<namedTypes.JSXNamespacedName>;
@@ -1736,9 +1806,6 @@ export interface NamedTypes {
1736
1806
  JSXClosingElement: Type<namedTypes.JSXClosingElement>;
1737
1807
  JSXOpeningFragment: Type<namedTypes.JSXOpeningFragment>;
1738
1808
  JSXClosingFragment: Type<namedTypes.JSXClosingFragment>;
1739
- Decorator: Type<namedTypes.Decorator>;
1740
- PrivateName: Type<namedTypes.PrivateName>;
1741
- ClassPrivateProperty: Type<namedTypes.ClassPrivateProperty>;
1742
1809
  TypeParameterDeclaration: Type<namedTypes.TypeParameterDeclaration>;
1743
1810
  TSTypeParameterDeclaration: Type<namedTypes.TSTypeParameterDeclaration>;
1744
1811
  TypeParameterInstantiation: Type<namedTypes.TypeParameterInstantiation>;
@@ -1782,6 +1849,8 @@ export interface NamedTypes {
1782
1849
  QualifiedTypeIdentifier: Type<namedTypes.QualifiedTypeIdentifier>;
1783
1850
  GenericTypeAnnotation: Type<namedTypes.GenericTypeAnnotation>;
1784
1851
  MemberTypeAnnotation: Type<namedTypes.MemberTypeAnnotation>;
1852
+ IndexedAccessType: Type<namedTypes.IndexedAccessType>;
1853
+ OptionalIndexedAccessType: Type<namedTypes.OptionalIndexedAccessType>;
1785
1854
  UnionTypeAnnotation: Type<namedTypes.UnionTypeAnnotation>;
1786
1855
  IntersectionTypeAnnotation: Type<namedTypes.IntersectionTypeAnnotation>;
1787
1856
  TypeofTypeAnnotation: Type<namedTypes.TypeofTypeAnnotation>;
@@ -1833,15 +1902,17 @@ export interface NamedTypes {
1833
1902
  StringLiteral: Type<namedTypes.StringLiteral>;
1834
1903
  NumericLiteral: Type<namedTypes.NumericLiteral>;
1835
1904
  BigIntLiteral: Type<namedTypes.BigIntLiteral>;
1905
+ DecimalLiteral: Type<namedTypes.DecimalLiteral>;
1836
1906
  NullLiteral: Type<namedTypes.NullLiteral>;
1837
1907
  BooleanLiteral: Type<namedTypes.BooleanLiteral>;
1838
1908
  RegExpLiteral: Type<namedTypes.RegExpLiteral>;
1839
- ObjectMethod: Type<namedTypes.ObjectMethod>;
1840
1909
  ClassMethod: Type<namedTypes.ClassMethod>;
1841
1910
  ClassPrivateMethod: Type<namedTypes.ClassPrivateMethod>;
1842
1911
  RestProperty: Type<namedTypes.RestProperty>;
1843
1912
  ForAwaitStatement: Type<namedTypes.ForAwaitStatement>;
1844
1913
  Import: Type<namedTypes.Import>;
1914
+ V8IntrinsicIdentifier: Type<namedTypes.V8IntrinsicIdentifier>;
1915
+ TopicReference: Type<namedTypes.TopicReference>;
1845
1916
  TSQualifiedName: Type<namedTypes.TSQualifiedName>;
1846
1917
  TSTypeReference: Type<namedTypes.TSTypeReference>;
1847
1918
  TSHasOptionalTypeParameters: Type<namedTypes.TSHasOptionalTypeParameters>;
@@ -1860,6 +1931,7 @@ export interface NamedTypes {
1860
1931
  TSUndefinedKeyword: Type<namedTypes.TSUndefinedKeyword>;
1861
1932
  TSUnknownKeyword: Type<namedTypes.TSUnknownKeyword>;
1862
1933
  TSVoidKeyword: Type<namedTypes.TSVoidKeyword>;
1934
+ TSIntrinsicKeyword: Type<namedTypes.TSIntrinsicKeyword>;
1863
1935
  TSThisType: Type<namedTypes.TSThisType>;
1864
1936
  TSArrayType: Type<namedTypes.TSArrayType>;
1865
1937
  TSLiteralType: Type<namedTypes.TSLiteralType>;
package/gen/visitor.d.ts CHANGED
@@ -98,6 +98,15 @@ export interface Visitor<M = {}> {
98
98
  visitChainExpression?(this: Context & M, path: NodePath<namedTypes.ChainExpression>): any;
99
99
  visitOptionalCallExpression?(this: Context & M, path: NodePath<namedTypes.OptionalCallExpression>): any;
100
100
  visitOptionalMemberExpression?(this: Context & M, path: NodePath<namedTypes.OptionalMemberExpression>): any;
101
+ visitStaticBlock?(this: Context & M, path: NodePath<namedTypes.StaticBlock>): any;
102
+ visitDecorator?(this: Context & M, path: NodePath<namedTypes.Decorator>): any;
103
+ visitPrivateName?(this: Context & M, path: NodePath<namedTypes.PrivateName>): any;
104
+ visitClassPrivateProperty?(this: Context & M, path: NodePath<namedTypes.ClassPrivateProperty>): any;
105
+ visitImportAttribute?(this: Context & M, path: NodePath<namedTypes.ImportAttribute>): any;
106
+ visitRecordExpression?(this: Context & M, path: NodePath<namedTypes.RecordExpression>): any;
107
+ visitObjectMethod?(this: Context & M, path: NodePath<namedTypes.ObjectMethod>): any;
108
+ visitTupleExpression?(this: Context & M, path: NodePath<namedTypes.TupleExpression>): any;
109
+ visitModuleExpression?(this: Context & M, path: NodePath<namedTypes.ModuleExpression>): any;
101
110
  visitJSXAttribute?(this: Context & M, path: NodePath<namedTypes.JSXAttribute>): any;
102
111
  visitJSXIdentifier?(this: Context & M, path: NodePath<namedTypes.JSXIdentifier>): any;
103
112
  visitJSXNamespacedName?(this: Context & M, path: NodePath<namedTypes.JSXNamespacedName>): any;
@@ -113,9 +122,6 @@ export interface Visitor<M = {}> {
113
122
  visitJSXClosingElement?(this: Context & M, path: NodePath<namedTypes.JSXClosingElement>): any;
114
123
  visitJSXOpeningFragment?(this: Context & M, path: NodePath<namedTypes.JSXOpeningFragment>): any;
115
124
  visitJSXClosingFragment?(this: Context & M, path: NodePath<namedTypes.JSXClosingFragment>): any;
116
- visitDecorator?(this: Context & M, path: NodePath<namedTypes.Decorator>): any;
117
- visitPrivateName?(this: Context & M, path: NodePath<namedTypes.PrivateName>): any;
118
- visitClassPrivateProperty?(this: Context & M, path: NodePath<namedTypes.ClassPrivateProperty>): any;
119
125
  visitTypeParameterDeclaration?(this: Context & M, path: NodePath<namedTypes.TypeParameterDeclaration>): any;
120
126
  visitTSTypeParameterDeclaration?(this: Context & M, path: NodePath<namedTypes.TSTypeParameterDeclaration>): any;
121
127
  visitTypeParameterInstantiation?(this: Context & M, path: NodePath<namedTypes.TypeParameterInstantiation>): any;
@@ -159,6 +165,8 @@ export interface Visitor<M = {}> {
159
165
  visitQualifiedTypeIdentifier?(this: Context & M, path: NodePath<namedTypes.QualifiedTypeIdentifier>): any;
160
166
  visitGenericTypeAnnotation?(this: Context & M, path: NodePath<namedTypes.GenericTypeAnnotation>): any;
161
167
  visitMemberTypeAnnotation?(this: Context & M, path: NodePath<namedTypes.MemberTypeAnnotation>): any;
168
+ visitIndexedAccessType?(this: Context & M, path: NodePath<namedTypes.IndexedAccessType>): any;
169
+ visitOptionalIndexedAccessType?(this: Context & M, path: NodePath<namedTypes.OptionalIndexedAccessType>): any;
162
170
  visitUnionTypeAnnotation?(this: Context & M, path: NodePath<namedTypes.UnionTypeAnnotation>): any;
163
171
  visitIntersectionTypeAnnotation?(this: Context & M, path: NodePath<namedTypes.IntersectionTypeAnnotation>): any;
164
172
  visitTypeofTypeAnnotation?(this: Context & M, path: NodePath<namedTypes.TypeofTypeAnnotation>): any;
@@ -210,15 +218,17 @@ export interface Visitor<M = {}> {
210
218
  visitStringLiteral?(this: Context & M, path: NodePath<namedTypes.StringLiteral>): any;
211
219
  visitNumericLiteral?(this: Context & M, path: NodePath<namedTypes.NumericLiteral>): any;
212
220
  visitBigIntLiteral?(this: Context & M, path: NodePath<namedTypes.BigIntLiteral>): any;
221
+ visitDecimalLiteral?(this: Context & M, path: NodePath<namedTypes.DecimalLiteral>): any;
213
222
  visitNullLiteral?(this: Context & M, path: NodePath<namedTypes.NullLiteral>): any;
214
223
  visitBooleanLiteral?(this: Context & M, path: NodePath<namedTypes.BooleanLiteral>): any;
215
224
  visitRegExpLiteral?(this: Context & M, path: NodePath<namedTypes.RegExpLiteral>): any;
216
- visitObjectMethod?(this: Context & M, path: NodePath<namedTypes.ObjectMethod>): any;
217
225
  visitClassMethod?(this: Context & M, path: NodePath<namedTypes.ClassMethod>): any;
218
226
  visitClassPrivateMethod?(this: Context & M, path: NodePath<namedTypes.ClassPrivateMethod>): any;
219
227
  visitRestProperty?(this: Context & M, path: NodePath<namedTypes.RestProperty>): any;
220
228
  visitForAwaitStatement?(this: Context & M, path: NodePath<namedTypes.ForAwaitStatement>): any;
221
229
  visitImport?(this: Context & M, path: NodePath<namedTypes.Import>): any;
230
+ visitV8IntrinsicIdentifier?(this: Context & M, path: NodePath<namedTypes.V8IntrinsicIdentifier>): any;
231
+ visitTopicReference?(this: Context & M, path: NodePath<namedTypes.TopicReference>): any;
222
232
  visitTSQualifiedName?(this: Context & M, path: NodePath<namedTypes.TSQualifiedName>): any;
223
233
  visitTSTypeReference?(this: Context & M, path: NodePath<namedTypes.TSTypeReference>): any;
224
234
  visitTSHasOptionalTypeParameters?(this: Context & M, path: NodePath<namedTypes.TSHasOptionalTypeParameters>): any;
@@ -237,6 +247,7 @@ export interface Visitor<M = {}> {
237
247
  visitTSUndefinedKeyword?(this: Context & M, path: NodePath<namedTypes.TSUndefinedKeyword>): any;
238
248
  visitTSUnknownKeyword?(this: Context & M, path: NodePath<namedTypes.TSUnknownKeyword>): any;
239
249
  visitTSVoidKeyword?(this: Context & M, path: NodePath<namedTypes.TSVoidKeyword>): any;
250
+ visitTSIntrinsicKeyword?(this: Context & M, path: NodePath<namedTypes.TSIntrinsicKeyword>): any;
240
251
  visitTSThisType?(this: Context & M, path: NodePath<namedTypes.TSThisType>): any;
241
252
  visitTSArrayType?(this: Context & M, path: NodePath<namedTypes.TSArrayType>): any;
242
253
  visitTSLiteralType?(this: Context & M, path: NodePath<namedTypes.TSLiteralType>): any;
package/lib/equiv.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";;
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
- var types_1 = tslib_1.__importDefault(require("./types"));
4
+ var types_1 = (0, tslib_1.__importDefault)(require("./types"));
5
5
  function default_1(fork) {
6
6
  var types = fork.use(types_1.default);
7
7
  var getFieldNames = types.getFieldNames;
package/lib/node-path.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";;
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
- var types_1 = tslib_1.__importDefault(require("./types"));
5
- var path_1 = tslib_1.__importDefault(require("./path"));
6
- var scope_1 = tslib_1.__importDefault(require("./scope"));
4
+ var types_1 = (0, tslib_1.__importDefault)(require("./types"));
5
+ var path_1 = (0, tslib_1.__importDefault)(require("./path"));
6
+ var scope_1 = (0, tslib_1.__importDefault)(require("./scope"));
7
7
  function nodePathPlugin(fork) {
8
8
  var types = fork.use(types_1.default);
9
9
  var n = types.namedTypes;
@@ -1,8 +1,8 @@
1
1
  "use strict";;
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
- var types_1 = tslib_1.__importDefault(require("./types"));
5
- var node_path_1 = tslib_1.__importDefault(require("./node-path"));
4
+ var types_1 = (0, tslib_1.__importDefault)(require("./types"));
5
+ var node_path_1 = (0, tslib_1.__importDefault)(require("./node-path"));
6
6
  var hasOwn = Object.prototype.hasOwnProperty;
7
7
  function pathVisitorPlugin(fork) {
8
8
  var types = fork.use(types_1.default);
package/lib/path.d.ts CHANGED
@@ -7,9 +7,9 @@ export interface Path<V = any> {
7
7
  __childCache: object | null;
8
8
  getValueProperty(name: any): any;
9
9
  get(...names: any[]): any;
10
- each(callback: any, context: any): any;
11
- map(callback: any, context: any): any;
12
- filter(callback: any, context: any): any;
10
+ each(callback: any, context?: any): any;
11
+ map(callback: any, context?: any): any;
12
+ filter(callback: any, context?: any): any;
13
13
  shift(): any;
14
14
  unshift(...args: any[]): any;
15
15
  push(...args: any[]): any;
package/lib/path.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";;
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
- var types_1 = tslib_1.__importDefault(require("./types"));
4
+ var types_1 = (0, tslib_1.__importDefault)(require("./types"));
5
5
  var Op = Object.prototype;
6
6
  var hasOwn = Op.hasOwnProperty;
7
7
  function pathPlugin(fork) {
package/lib/scope.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Fork } from "../types";
2
+ import { NodePath } from "./node-path";
2
3
  export interface Scope {
3
- path: any;
4
+ path: NodePath;
4
5
  node: any;
5
6
  isGlobal: boolean;
6
7
  depth: number;
@@ -20,7 +21,7 @@ export interface Scope {
20
21
  getGlobalScope(): Scope;
21
22
  }
22
23
  export interface ScopeConstructor {
23
- new (path: any, parentScope: any): Scope;
24
+ new (path: NodePath, parentScope: any): Scope;
24
25
  isEstablishedBy(node: any): any;
25
26
  }
26
27
  export default function scopePlugin(fork: Fork): ScopeConstructor;
package/lib/scope.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";;
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
- var types_1 = tslib_1.__importDefault(require("./types"));
4
+ var types_1 = (0, tslib_1.__importDefault)(require("./types"));
5
5
  var hasOwn = Object.prototype.hasOwnProperty;
6
6
  function scopePlugin(fork) {
7
7
  var types = fork.use(types_1.default);
@@ -15,7 +15,9 @@ function scopePlugin(fork) {
15
15
  if (!(this instanceof Scope)) {
16
16
  throw new Error("Scope constructor cannot be invoked without 'new'");
17
17
  }
18
- ScopeType.assert(path.value);
18
+ if (!TypeParameterScopeType.check(path.value)) {
19
+ ScopeType.assert(path.value);
20
+ }
19
21
  var depth;
20
22
  if (parentScope) {
21
23
  if (!(parentScope instanceof Scope)) {
@@ -37,19 +39,21 @@ function scopePlugin(fork) {
37
39
  types: { value: {} },
38
40
  });
39
41
  };
40
- var scopeTypes = [
41
- // Program nodes introduce global scopes.
42
- namedTypes.Program,
43
- // Function is the supertype of FunctionExpression,
44
- // FunctionDeclaration, ArrowExpression, etc.
45
- namedTypes.Function,
46
- // In case you didn't know, the caught parameter shadows any variable
47
- // of the same name in an outer scope.
48
- namedTypes.CatchClause
49
- ];
50
- var ScopeType = Type.or.apply(Type, scopeTypes);
42
+ var ScopeType = Type.or(
43
+ // Program nodes introduce global scopes.
44
+ namedTypes.Program,
45
+ // Function is the supertype of FunctionExpression,
46
+ // FunctionDeclaration, ArrowExpression, etc.
47
+ namedTypes.Function,
48
+ // In case you didn't know, the caught parameter shadows any variable
49
+ // of the same name in an outer scope.
50
+ namedTypes.CatchClause);
51
+ // These types introduce scopes that are restricted to type parameters in
52
+ // Flow (this doesn't apply to ECMAScript).
53
+ var TypeParameterScopeType = Type.or(namedTypes.Function, namedTypes.ClassDeclaration, namedTypes.ClassExpression, namedTypes.InterfaceDeclaration, namedTypes.TSInterfaceDeclaration, namedTypes.TypeAlias, namedTypes.TSTypeAliasDeclaration);
54
+ var FlowOrTSTypeParameterType = Type.or(namedTypes.TypeParameter, namedTypes.TSTypeParameter);
51
55
  Scope.isEstablishedBy = function (node) {
52
- return ScopeType.check(node);
56
+ return ScopeType.check(node) || TypeParameterScopeType.check(node);
53
57
  };
54
58
  var Sp = Scope.prototype;
55
59
  // Will be overridden after an instance lazily calls scanScope.
@@ -97,6 +101,10 @@ function scopePlugin(fork) {
97
101
  // Empty out this.bindings, just in cases.
98
102
  delete this.bindings[name];
99
103
  }
104
+ for (var name in this.types) {
105
+ // Empty out this.types, just in cases.
106
+ delete this.types[name];
107
+ }
100
108
  scanScope(this.path, this.bindings, this.types);
101
109
  this.didScan = true;
102
110
  }
@@ -111,18 +119,24 @@ function scopePlugin(fork) {
111
119
  };
112
120
  function scanScope(path, bindings, scopeTypes) {
113
121
  var node = path.value;
114
- ScopeType.assert(node);
115
- if (namedTypes.CatchClause.check(node)) {
116
- // A catch clause establishes a new scope but the only variable
117
- // bound in that scope is the catch parameter. Any other
118
- // declarations create bindings in the outer scope.
119
- var param = path.get("param");
120
- if (param.value) {
121
- addPattern(param, bindings);
122
+ if (TypeParameterScopeType.check(node)) {
123
+ var params = path.get('typeParameters', 'params');
124
+ if (isArray.check(params.value)) {
125
+ params.each(function (childPath) {
126
+ addTypeParameter(childPath, scopeTypes);
127
+ });
122
128
  }
123
129
  }
124
- else {
125
- recursiveScanScope(path, bindings, scopeTypes);
130
+ if (ScopeType.check(node)) {
131
+ if (namedTypes.CatchClause.check(node)) {
132
+ // A catch clause establishes a new scope but the only variable
133
+ // bound in that scope is the catch parameter. Any other
134
+ // declarations create bindings in the outer scope.
135
+ addPattern(path.get("param"), bindings);
136
+ }
137
+ else {
138
+ recursiveScanScope(path, bindings, scopeTypes);
139
+ }
126
140
  }
127
141
  }
128
142
  function recursiveScanScope(path, bindings, scopeTypes) {
@@ -145,6 +159,7 @@ function scopePlugin(fork) {
145
159
  addPattern(paramPath, bindings);
146
160
  });
147
161
  recursiveScanChild(path.get("body"), bindings, scopeTypes);
162
+ recursiveScanScope(path.get("typeParameters"), bindings, scopeTypes);
148
163
  }
149
164
  else if ((namedTypes.TypeAlias && namedTypes.TypeAlias.check(node)) ||
150
165
  (namedTypes.InterfaceDeclaration && namedTypes.InterfaceDeclaration.check(node)) ||
@@ -201,8 +216,16 @@ function scopePlugin(fork) {
201
216
  addPattern(path.get("id"), bindings);
202
217
  }
203
218
  else if (namedTypes.ClassDeclaration &&
204
- namedTypes.ClassDeclaration.check(node)) {
219
+ namedTypes.ClassDeclaration.check(node) &&
220
+ node.id !== null) {
205
221
  addPattern(path.get("id"), bindings);
222
+ recursiveScanScope(path.get("typeParameters"), bindings, scopeTypes);
223
+ }
224
+ else if ((namedTypes.InterfaceDeclaration &&
225
+ namedTypes.InterfaceDeclaration.check(node)) ||
226
+ (namedTypes.TSInterfaceDeclaration &&
227
+ namedTypes.TSInterfaceDeclaration.check(node))) {
228
+ addTypePattern(path.get("id"), scopeTypes);
206
229
  }
207
230
  else if (ScopeType.check(node)) {
208
231
  if (namedTypes.CatchClause.check(node) &&
@@ -249,7 +272,9 @@ function scopePlugin(fork) {
249
272
  if (namedTypes.Pattern.check(property)) {
250
273
  addPattern(propertyPath, bindings);
251
274
  }
252
- else if (namedTypes.Property.check(property)) {
275
+ else if (namedTypes.Property.check(property) ||
276
+ (namedTypes.ObjectProperty &&
277
+ namedTypes.ObjectProperty.check(property))) {
253
278
  addPattern(propertyPath.get('value'), bindings);
254
279
  }
255
280
  else if (namedTypes.SpreadProperty &&
@@ -296,6 +321,16 @@ function scopePlugin(fork) {
296
321
  }
297
322
  }
298
323
  }
324
+ function addTypeParameter(parameterPath, types) {
325
+ var parameter = parameterPath.value;
326
+ FlowOrTSTypeParameterType.assert(parameter);
327
+ if (hasOwn.call(types, parameter.name)) {
328
+ types[parameter.name].push(parameterPath);
329
+ }
330
+ else {
331
+ types[parameter.name] = [parameterPath];
332
+ }
333
+ }
299
334
  Sp.lookup = function (name) {
300
335
  for (var scope = this; scope; scope = scope.parent)
301
336
  if (scope.declares(name))
package/lib/shared.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";;
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
- var types_1 = tslib_1.__importDefault(require("./types"));
4
+ var types_1 = (0, tslib_1.__importDefault)(require("./types"));
5
5
  function default_1(fork) {
6
6
  var types = fork.use(types_1.default);
7
7
  var Type = types.Type;