ast-types 0.11.5 → 0.12.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.
Files changed (57) hide show
  1. package/.travis.yml +2 -2
  2. package/def/babel-core.d.ts +2 -0
  3. package/def/babel-core.js +250 -290
  4. package/def/babel.d.ts +2 -0
  5. package/def/babel.js +12 -3
  6. package/def/core.d.ts +2 -0
  7. package/def/core.js +57 -126
  8. package/def/es-proposals.d.ts +2 -0
  9. package/def/es-proposals.js +34 -32
  10. package/def/es6.d.ts +2 -0
  11. package/def/es6.js +210 -253
  12. package/def/es7.d.ts +2 -0
  13. package/def/es7.js +35 -41
  14. package/def/esprima.d.ts +2 -0
  15. package/def/esprima.js +50 -71
  16. package/def/flow.d.ts +2 -0
  17. package/def/flow.js +289 -393
  18. package/def/jsx.d.ts +2 -0
  19. package/def/jsx.js +99 -125
  20. package/def/type-annotations.d.ts +7 -0
  21. package/def/type-annotations.js +42 -0
  22. package/def/typescript.d.ts +2 -0
  23. package/def/typescript.js +326 -444
  24. package/fork.d.ts +46 -0
  25. package/fork.js +40 -31
  26. package/gen/builders.d.ts +2539 -0
  27. package/gen/builders.js +2 -0
  28. package/gen/kinds.d.ts +259 -0
  29. package/gen/kinds.js +2 -0
  30. package/gen/namedTypes.d.ts +262 -0
  31. package/gen/namedTypes.js +2 -0
  32. package/gen/nodes.d.ts +1255 -0
  33. package/gen/nodes.js +2 -0
  34. package/gen/visitor.d.ts +263 -0
  35. package/gen/visitor.js +2 -0
  36. package/lib/equiv.d.ts +5 -0
  37. package/lib/equiv.js +19 -49
  38. package/lib/node-path.d.ts +22 -0
  39. package/lib/node-path.js +60 -125
  40. package/lib/path-visitor.d.ts +52 -0
  41. package/lib/path-visitor.js +117 -194
  42. package/lib/path.d.ts +25 -0
  43. package/lib/path.js +71 -107
  44. package/lib/scope.d.ts +26 -0
  45. package/lib/scope.js +100 -143
  46. package/lib/shared.d.ts +13 -0
  47. package/lib/shared.js +34 -31
  48. package/lib/types.d.ts +140 -0
  49. package/lib/types.js +584 -676
  50. package/main.d.ts +16 -0
  51. package/main.js +33 -18
  52. package/package.json +24 -7
  53. package/tsconfig.json +20 -0
  54. package/types.d.ts +6 -0
  55. package/types.js +2 -0
  56. package/def/e4x.js +0 -86
  57. package/def/mozilla.js +0 -42
package/gen/nodes.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,263 @@
1
+ import { NodePath } from "../lib/node-path";
2
+ import { Context } from "../lib/path-visitor";
3
+ import * as N from "./nodes";
4
+ export interface Visitor<M = {}> {
5
+ visitPrintable?(this: Context & M, path: NodePath<N.Printable>): any;
6
+ visitSourceLocation?(this: Context & M, path: NodePath<N.SourceLocation>): any;
7
+ visitNode?(this: Context & M, path: NodePath<N.Node>): any;
8
+ visitComment?(this: Context & M, path: NodePath<N.Comment>): any;
9
+ visitPosition?(this: Context & M, path: NodePath<N.Position>): any;
10
+ visitFile?(this: Context & M, path: NodePath<N.File>): any;
11
+ visitProgram?(this: Context & M, path: NodePath<N.Program>): any;
12
+ visitStatement?(this: Context & M, path: NodePath<N.Statement>): any;
13
+ visitFunction?(this: Context & M, path: NodePath<N.Function>): any;
14
+ visitPattern?(this: Context & M, path: NodePath<N.Pattern>): any;
15
+ visitExpression?(this: Context & M, path: NodePath<N.Expression>): any;
16
+ visitIdentifier?(this: Context & M, path: NodePath<N.Identifier>): any;
17
+ visitBlockStatement?(this: Context & M, path: NodePath<N.BlockStatement>): any;
18
+ visitEmptyStatement?(this: Context & M, path: NodePath<N.EmptyStatement>): any;
19
+ visitExpressionStatement?(this: Context & M, path: NodePath<N.ExpressionStatement>): any;
20
+ visitIfStatement?(this: Context & M, path: NodePath<N.IfStatement>): any;
21
+ visitLabeledStatement?(this: Context & M, path: NodePath<N.LabeledStatement>): any;
22
+ visitBreakStatement?(this: Context & M, path: NodePath<N.BreakStatement>): any;
23
+ visitContinueStatement?(this: Context & M, path: NodePath<N.ContinueStatement>): any;
24
+ visitWithStatement?(this: Context & M, path: NodePath<N.WithStatement>): any;
25
+ visitSwitchStatement?(this: Context & M, path: NodePath<N.SwitchStatement>): any;
26
+ visitSwitchCase?(this: Context & M, path: NodePath<N.SwitchCase>): any;
27
+ visitReturnStatement?(this: Context & M, path: NodePath<N.ReturnStatement>): any;
28
+ visitThrowStatement?(this: Context & M, path: NodePath<N.ThrowStatement>): any;
29
+ visitTryStatement?(this: Context & M, path: NodePath<N.TryStatement>): any;
30
+ visitCatchClause?(this: Context & M, path: NodePath<N.CatchClause>): any;
31
+ visitWhileStatement?(this: Context & M, path: NodePath<N.WhileStatement>): any;
32
+ visitDoWhileStatement?(this: Context & M, path: NodePath<N.DoWhileStatement>): any;
33
+ visitForStatement?(this: Context & M, path: NodePath<N.ForStatement>): any;
34
+ visitDeclaration?(this: Context & M, path: NodePath<N.Declaration>): any;
35
+ visitVariableDeclaration?(this: Context & M, path: NodePath<N.VariableDeclaration>): any;
36
+ visitForInStatement?(this: Context & M, path: NodePath<N.ForInStatement>): any;
37
+ visitDebuggerStatement?(this: Context & M, path: NodePath<N.DebuggerStatement>): any;
38
+ visitFunctionDeclaration?(this: Context & M, path: NodePath<N.FunctionDeclaration>): any;
39
+ visitFunctionExpression?(this: Context & M, path: NodePath<N.FunctionExpression>): any;
40
+ visitVariableDeclarator?(this: Context & M, path: NodePath<N.VariableDeclarator>): any;
41
+ visitThisExpression?(this: Context & M, path: NodePath<N.ThisExpression>): any;
42
+ visitArrayExpression?(this: Context & M, path: NodePath<N.ArrayExpression>): any;
43
+ visitObjectExpression?(this: Context & M, path: NodePath<N.ObjectExpression>): any;
44
+ visitProperty?(this: Context & M, path: NodePath<N.Property>): any;
45
+ visitLiteral?(this: Context & M, path: NodePath<N.Literal>): any;
46
+ visitSequenceExpression?(this: Context & M, path: NodePath<N.SequenceExpression>): any;
47
+ visitUnaryExpression?(this: Context & M, path: NodePath<N.UnaryExpression>): any;
48
+ visitBinaryExpression?(this: Context & M, path: NodePath<N.BinaryExpression>): any;
49
+ visitAssignmentExpression?(this: Context & M, path: NodePath<N.AssignmentExpression>): any;
50
+ visitUpdateExpression?(this: Context & M, path: NodePath<N.UpdateExpression>): any;
51
+ visitLogicalExpression?(this: Context & M, path: NodePath<N.LogicalExpression>): any;
52
+ visitConditionalExpression?(this: Context & M, path: NodePath<N.ConditionalExpression>): any;
53
+ visitNewExpression?(this: Context & M, path: NodePath<N.NewExpression>): any;
54
+ visitCallExpression?(this: Context & M, path: NodePath<N.CallExpression>): any;
55
+ visitMemberExpression?(this: Context & M, path: NodePath<N.MemberExpression>): any;
56
+ visitRestElement?(this: Context & M, path: NodePath<N.RestElement>): any;
57
+ visitTypeAnnotation?(this: Context & M, path: NodePath<N.TypeAnnotation>): any;
58
+ visitTSTypeAnnotation?(this: Context & M, path: NodePath<N.TSTypeAnnotation>): any;
59
+ visitSpreadElementPattern?(this: Context & M, path: NodePath<N.SpreadElementPattern>): any;
60
+ visitArrowFunctionExpression?(this: Context & M, path: NodePath<N.ArrowFunctionExpression>): any;
61
+ visitForOfStatement?(this: Context & M, path: NodePath<N.ForOfStatement>): any;
62
+ visitYieldExpression?(this: Context & M, path: NodePath<N.YieldExpression>): any;
63
+ visitGeneratorExpression?(this: Context & M, path: NodePath<N.GeneratorExpression>): any;
64
+ visitComprehensionBlock?(this: Context & M, path: NodePath<N.ComprehensionBlock>): any;
65
+ visitComprehensionExpression?(this: Context & M, path: NodePath<N.ComprehensionExpression>): any;
66
+ visitObjectProperty?(this: Context & M, path: NodePath<N.ObjectProperty>): any;
67
+ visitPropertyPattern?(this: Context & M, path: NodePath<N.PropertyPattern>): any;
68
+ visitObjectPattern?(this: Context & M, path: NodePath<N.ObjectPattern>): any;
69
+ visitArrayPattern?(this: Context & M, path: NodePath<N.ArrayPattern>): any;
70
+ visitMethodDefinition?(this: Context & M, path: NodePath<N.MethodDefinition>): any;
71
+ visitSpreadElement?(this: Context & M, path: NodePath<N.SpreadElement>): any;
72
+ visitAssignmentPattern?(this: Context & M, path: NodePath<N.AssignmentPattern>): any;
73
+ visitClassPropertyDefinition?(this: Context & M, path: NodePath<N.ClassPropertyDefinition>): any;
74
+ visitClassProperty?(this: Context & M, path: NodePath<N.ClassProperty>): any;
75
+ visitClassBody?(this: Context & M, path: NodePath<N.ClassBody>): any;
76
+ visitClassDeclaration?(this: Context & M, path: NodePath<N.ClassDeclaration>): any;
77
+ visitClassExpression?(this: Context & M, path: NodePath<N.ClassExpression>): any;
78
+ visitSpecifier?(this: Context & M, path: NodePath<N.Specifier>): any;
79
+ visitModuleSpecifier?(this: Context & M, path: NodePath<N.ModuleSpecifier>): any;
80
+ visitImportSpecifier?(this: Context & M, path: NodePath<N.ImportSpecifier>): any;
81
+ visitImportNamespaceSpecifier?(this: Context & M, path: NodePath<N.ImportNamespaceSpecifier>): any;
82
+ visitImportDefaultSpecifier?(this: Context & M, path: NodePath<N.ImportDefaultSpecifier>): any;
83
+ visitImportDeclaration?(this: Context & M, path: NodePath<N.ImportDeclaration>): any;
84
+ visitTaggedTemplateExpression?(this: Context & M, path: NodePath<N.TaggedTemplateExpression>): any;
85
+ visitTemplateLiteral?(this: Context & M, path: NodePath<N.TemplateLiteral>): any;
86
+ visitTemplateElement?(this: Context & M, path: NodePath<N.TemplateElement>): any;
87
+ visitSpreadProperty?(this: Context & M, path: NodePath<N.SpreadProperty>): any;
88
+ visitSpreadPropertyPattern?(this: Context & M, path: NodePath<N.SpreadPropertyPattern>): any;
89
+ visitAwaitExpression?(this: Context & M, path: NodePath<N.AwaitExpression>): any;
90
+ visitJSXAttribute?(this: Context & M, path: NodePath<N.JSXAttribute>): any;
91
+ visitJSXIdentifier?(this: Context & M, path: NodePath<N.JSXIdentifier>): any;
92
+ visitJSXNamespacedName?(this: Context & M, path: NodePath<N.JSXNamespacedName>): any;
93
+ visitJSXExpressionContainer?(this: Context & M, path: NodePath<N.JSXExpressionContainer>): any;
94
+ visitJSXMemberExpression?(this: Context & M, path: NodePath<N.JSXMemberExpression>): any;
95
+ visitJSXSpreadAttribute?(this: Context & M, path: NodePath<N.JSXSpreadAttribute>): any;
96
+ visitJSXElement?(this: Context & M, path: NodePath<N.JSXElement>): any;
97
+ visitJSXOpeningElement?(this: Context & M, path: NodePath<N.JSXOpeningElement>): any;
98
+ visitJSXClosingElement?(this: Context & M, path: NodePath<N.JSXClosingElement>): any;
99
+ visitJSXFragment?(this: Context & M, path: NodePath<N.JSXFragment>): any;
100
+ visitJSXText?(this: Context & M, path: NodePath<N.JSXText>): any;
101
+ visitJSXOpeningFragment?(this: Context & M, path: NodePath<N.JSXOpeningFragment>): any;
102
+ visitJSXClosingFragment?(this: Context & M, path: NodePath<N.JSXClosingFragment>): any;
103
+ visitJSXEmptyExpression?(this: Context & M, path: NodePath<N.JSXEmptyExpression>): any;
104
+ visitJSXSpreadChild?(this: Context & M, path: NodePath<N.JSXSpreadChild>): any;
105
+ visitTypeParameterDeclaration?(this: Context & M, path: NodePath<N.TypeParameterDeclaration>): any;
106
+ visitTSTypeParameterDeclaration?(this: Context & M, path: NodePath<N.TSTypeParameterDeclaration>): any;
107
+ visitTypeParameterInstantiation?(this: Context & M, path: NodePath<N.TypeParameterInstantiation>): any;
108
+ visitTSTypeParameterInstantiation?(this: Context & M, path: NodePath<N.TSTypeParameterInstantiation>): any;
109
+ visitClassImplements?(this: Context & M, path: NodePath<N.ClassImplements>): any;
110
+ visitTSType?(this: Context & M, path: NodePath<N.TSType>): any;
111
+ visitTSExpressionWithTypeArguments?(this: Context & M, path: NodePath<N.TSExpressionWithTypeArguments>): any;
112
+ visitFlow?(this: Context & M, path: NodePath<N.Flow>): any;
113
+ visitFlowType?(this: Context & M, path: NodePath<N.FlowType>): any;
114
+ visitAnyTypeAnnotation?(this: Context & M, path: NodePath<N.AnyTypeAnnotation>): any;
115
+ visitEmptyTypeAnnotation?(this: Context & M, path: NodePath<N.EmptyTypeAnnotation>): any;
116
+ visitMixedTypeAnnotation?(this: Context & M, path: NodePath<N.MixedTypeAnnotation>): any;
117
+ visitVoidTypeAnnotation?(this: Context & M, path: NodePath<N.VoidTypeAnnotation>): any;
118
+ visitNumberTypeAnnotation?(this: Context & M, path: NodePath<N.NumberTypeAnnotation>): any;
119
+ visitNumberLiteralTypeAnnotation?(this: Context & M, path: NodePath<N.NumberLiteralTypeAnnotation>): any;
120
+ visitNumericLiteralTypeAnnotation?(this: Context & M, path: NodePath<N.NumericLiteralTypeAnnotation>): any;
121
+ visitStringTypeAnnotation?(this: Context & M, path: NodePath<N.StringTypeAnnotation>): any;
122
+ visitStringLiteralTypeAnnotation?(this: Context & M, path: NodePath<N.StringLiteralTypeAnnotation>): any;
123
+ visitBooleanTypeAnnotation?(this: Context & M, path: NodePath<N.BooleanTypeAnnotation>): any;
124
+ visitBooleanLiteralTypeAnnotation?(this: Context & M, path: NodePath<N.BooleanLiteralTypeAnnotation>): any;
125
+ visitNullableTypeAnnotation?(this: Context & M, path: NodePath<N.NullableTypeAnnotation>): any;
126
+ visitNullLiteralTypeAnnotation?(this: Context & M, path: NodePath<N.NullLiteralTypeAnnotation>): any;
127
+ visitNullTypeAnnotation?(this: Context & M, path: NodePath<N.NullTypeAnnotation>): any;
128
+ visitThisTypeAnnotation?(this: Context & M, path: NodePath<N.ThisTypeAnnotation>): any;
129
+ visitExistsTypeAnnotation?(this: Context & M, path: NodePath<N.ExistsTypeAnnotation>): any;
130
+ visitExistentialTypeParam?(this: Context & M, path: NodePath<N.ExistentialTypeParam>): any;
131
+ visitFunctionTypeAnnotation?(this: Context & M, path: NodePath<N.FunctionTypeAnnotation>): any;
132
+ visitFunctionTypeParam?(this: Context & M, path: NodePath<N.FunctionTypeParam>): any;
133
+ visitArrayTypeAnnotation?(this: Context & M, path: NodePath<N.ArrayTypeAnnotation>): any;
134
+ visitObjectTypeAnnotation?(this: Context & M, path: NodePath<N.ObjectTypeAnnotation>): any;
135
+ visitObjectTypeProperty?(this: Context & M, path: NodePath<N.ObjectTypeProperty>): any;
136
+ visitObjectTypeSpreadProperty?(this: Context & M, path: NodePath<N.ObjectTypeSpreadProperty>): any;
137
+ visitObjectTypeIndexer?(this: Context & M, path: NodePath<N.ObjectTypeIndexer>): any;
138
+ visitObjectTypeCallProperty?(this: Context & M, path: NodePath<N.ObjectTypeCallProperty>): any;
139
+ visitObjectTypeInternalSlot?(this: Context & M, path: NodePath<N.ObjectTypeInternalSlot>): any;
140
+ visitVariance?(this: Context & M, path: NodePath<N.Variance>): any;
141
+ visitQualifiedTypeIdentifier?(this: Context & M, path: NodePath<N.QualifiedTypeIdentifier>): any;
142
+ visitGenericTypeAnnotation?(this: Context & M, path: NodePath<N.GenericTypeAnnotation>): any;
143
+ visitMemberTypeAnnotation?(this: Context & M, path: NodePath<N.MemberTypeAnnotation>): any;
144
+ visitUnionTypeAnnotation?(this: Context & M, path: NodePath<N.UnionTypeAnnotation>): any;
145
+ visitIntersectionTypeAnnotation?(this: Context & M, path: NodePath<N.IntersectionTypeAnnotation>): any;
146
+ visitTypeofTypeAnnotation?(this: Context & M, path: NodePath<N.TypeofTypeAnnotation>): any;
147
+ visitTypeParameter?(this: Context & M, path: NodePath<N.TypeParameter>): any;
148
+ visitInterfaceTypeAnnotation?(this: Context & M, path: NodePath<N.InterfaceTypeAnnotation>): any;
149
+ visitInterfaceExtends?(this: Context & M, path: NodePath<N.InterfaceExtends>): any;
150
+ visitInterfaceDeclaration?(this: Context & M, path: NodePath<N.InterfaceDeclaration>): any;
151
+ visitDeclareInterface?(this: Context & M, path: NodePath<N.DeclareInterface>): any;
152
+ visitTypeAlias?(this: Context & M, path: NodePath<N.TypeAlias>): any;
153
+ visitOpaqueType?(this: Context & M, path: NodePath<N.OpaqueType>): any;
154
+ visitDeclareTypeAlias?(this: Context & M, path: NodePath<N.DeclareTypeAlias>): any;
155
+ visitDeclareOpaqueType?(this: Context & M, path: NodePath<N.DeclareOpaqueType>): any;
156
+ visitTypeCastExpression?(this: Context & M, path: NodePath<N.TypeCastExpression>): any;
157
+ visitTupleTypeAnnotation?(this: Context & M, path: NodePath<N.TupleTypeAnnotation>): any;
158
+ visitDeclareVariable?(this: Context & M, path: NodePath<N.DeclareVariable>): any;
159
+ visitDeclareFunction?(this: Context & M, path: NodePath<N.DeclareFunction>): any;
160
+ visitDeclareClass?(this: Context & M, path: NodePath<N.DeclareClass>): any;
161
+ visitDeclareModule?(this: Context & M, path: NodePath<N.DeclareModule>): any;
162
+ visitDeclareModuleExports?(this: Context & M, path: NodePath<N.DeclareModuleExports>): any;
163
+ visitDeclareExportDeclaration?(this: Context & M, path: NodePath<N.DeclareExportDeclaration>): any;
164
+ visitExportSpecifier?(this: Context & M, path: NodePath<N.ExportSpecifier>): any;
165
+ visitExportBatchSpecifier?(this: Context & M, path: NodePath<N.ExportBatchSpecifier>): any;
166
+ visitDeclareExportAllDeclaration?(this: Context & M, path: NodePath<N.DeclareExportAllDeclaration>): any;
167
+ visitFlowPredicate?(this: Context & M, path: NodePath<N.FlowPredicate>): any;
168
+ visitInferredPredicate?(this: Context & M, path: NodePath<N.InferredPredicate>): any;
169
+ visitDeclaredPredicate?(this: Context & M, path: NodePath<N.DeclaredPredicate>): any;
170
+ visitExportDeclaration?(this: Context & M, path: NodePath<N.ExportDeclaration>): any;
171
+ visitBlock?(this: Context & M, path: NodePath<N.Block>): any;
172
+ visitLine?(this: Context & M, path: NodePath<N.Line>): any;
173
+ visitNoop?(this: Context & M, path: NodePath<N.Noop>): any;
174
+ visitDoExpression?(this: Context & M, path: NodePath<N.DoExpression>): any;
175
+ visitSuper?(this: Context & M, path: NodePath<N.Super>): any;
176
+ visitBindExpression?(this: Context & M, path: NodePath<N.BindExpression>): any;
177
+ visitDecorator?(this: Context & M, path: NodePath<N.Decorator>): any;
178
+ visitMetaProperty?(this: Context & M, path: NodePath<N.MetaProperty>): any;
179
+ visitParenthesizedExpression?(this: Context & M, path: NodePath<N.ParenthesizedExpression>): any;
180
+ visitExportDefaultDeclaration?(this: Context & M, path: NodePath<N.ExportDefaultDeclaration>): any;
181
+ visitExportNamedDeclaration?(this: Context & M, path: NodePath<N.ExportNamedDeclaration>): any;
182
+ visitExportNamespaceSpecifier?(this: Context & M, path: NodePath<N.ExportNamespaceSpecifier>): any;
183
+ visitExportDefaultSpecifier?(this: Context & M, path: NodePath<N.ExportDefaultSpecifier>): any;
184
+ visitExportAllDeclaration?(this: Context & M, path: NodePath<N.ExportAllDeclaration>): any;
185
+ visitCommentBlock?(this: Context & M, path: NodePath<N.CommentBlock>): any;
186
+ visitCommentLine?(this: Context & M, path: NodePath<N.CommentLine>): any;
187
+ visitDirective?(this: Context & M, path: NodePath<N.Directive>): any;
188
+ visitDirectiveLiteral?(this: Context & M, path: NodePath<N.DirectiveLiteral>): any;
189
+ visitInterpreterDirective?(this: Context & M, path: NodePath<N.InterpreterDirective>): any;
190
+ visitStringLiteral?(this: Context & M, path: NodePath<N.StringLiteral>): any;
191
+ visitNumericLiteral?(this: Context & M, path: NodePath<N.NumericLiteral>): any;
192
+ visitBigIntLiteral?(this: Context & M, path: NodePath<N.BigIntLiteral>): any;
193
+ visitNullLiteral?(this: Context & M, path: NodePath<N.NullLiteral>): any;
194
+ visitBooleanLiteral?(this: Context & M, path: NodePath<N.BooleanLiteral>): any;
195
+ visitRegExpLiteral?(this: Context & M, path: NodePath<N.RegExpLiteral>): any;
196
+ visitObjectMethod?(this: Context & M, path: NodePath<N.ObjectMethod>): any;
197
+ visitClassPrivateProperty?(this: Context & M, path: NodePath<N.ClassPrivateProperty>): any;
198
+ visitClassMethod?(this: Context & M, path: NodePath<N.ClassMethod>): any;
199
+ visitClassPrivateMethod?(this: Context & M, path: NodePath<N.ClassPrivateMethod>): any;
200
+ visitPrivateName?(this: Context & M, path: NodePath<N.PrivateName>): any;
201
+ visitRestProperty?(this: Context & M, path: NodePath<N.RestProperty>): any;
202
+ visitForAwaitStatement?(this: Context & M, path: NodePath<N.ForAwaitStatement>): any;
203
+ visitImport?(this: Context & M, path: NodePath<N.Import>): any;
204
+ visitTSQualifiedName?(this: Context & M, path: NodePath<N.TSQualifiedName>): any;
205
+ visitTSTypeReference?(this: Context & M, path: NodePath<N.TSTypeReference>): any;
206
+ visitTSHasOptionalTypeParameters?(this: Context & M, path: NodePath<N.TSHasOptionalTypeParameters>): any;
207
+ visitTSHasOptionalTypeAnnotation?(this: Context & M, path: NodePath<N.TSHasOptionalTypeAnnotation>): any;
208
+ visitTSAsExpression?(this: Context & M, path: NodePath<N.TSAsExpression>): any;
209
+ visitTSNonNullExpression?(this: Context & M, path: NodePath<N.TSNonNullExpression>): any;
210
+ visitTSAnyKeyword?(this: Context & M, path: NodePath<N.TSAnyKeyword>): any;
211
+ visitTSBooleanKeyword?(this: Context & M, path: NodePath<N.TSBooleanKeyword>): any;
212
+ visitTSNeverKeyword?(this: Context & M, path: NodePath<N.TSNeverKeyword>): any;
213
+ visitTSNullKeyword?(this: Context & M, path: NodePath<N.TSNullKeyword>): any;
214
+ visitTSNumberKeyword?(this: Context & M, path: NodePath<N.TSNumberKeyword>): any;
215
+ visitTSObjectKeyword?(this: Context & M, path: NodePath<N.TSObjectKeyword>): any;
216
+ visitTSStringKeyword?(this: Context & M, path: NodePath<N.TSStringKeyword>): any;
217
+ visitTSSymbolKeyword?(this: Context & M, path: NodePath<N.TSSymbolKeyword>): any;
218
+ visitTSUndefinedKeyword?(this: Context & M, path: NodePath<N.TSUndefinedKeyword>): any;
219
+ visitTSUnknownKeyword?(this: Context & M, path: NodePath<N.TSUnknownKeyword>): any;
220
+ visitTSVoidKeyword?(this: Context & M, path: NodePath<N.TSVoidKeyword>): any;
221
+ visitTSThisType?(this: Context & M, path: NodePath<N.TSThisType>): any;
222
+ visitTSArrayType?(this: Context & M, path: NodePath<N.TSArrayType>): any;
223
+ visitTSLiteralType?(this: Context & M, path: NodePath<N.TSLiteralType>): any;
224
+ visitTSUnionType?(this: Context & M, path: NodePath<N.TSUnionType>): any;
225
+ visitTSIntersectionType?(this: Context & M, path: NodePath<N.TSIntersectionType>): any;
226
+ visitTSConditionalType?(this: Context & M, path: NodePath<N.TSConditionalType>): any;
227
+ visitTSInferType?(this: Context & M, path: NodePath<N.TSInferType>): any;
228
+ visitTSTypeParameter?(this: Context & M, path: NodePath<N.TSTypeParameter>): any;
229
+ visitTSParenthesizedType?(this: Context & M, path: NodePath<N.TSParenthesizedType>): any;
230
+ visitTSFunctionType?(this: Context & M, path: NodePath<N.TSFunctionType>): any;
231
+ visitTSConstructorType?(this: Context & M, path: NodePath<N.TSConstructorType>): any;
232
+ visitTSDeclareFunction?(this: Context & M, path: NodePath<N.TSDeclareFunction>): any;
233
+ visitTSDeclareMethod?(this: Context & M, path: NodePath<N.TSDeclareMethod>): any;
234
+ visitTSMappedType?(this: Context & M, path: NodePath<N.TSMappedType>): any;
235
+ visitTSTupleType?(this: Context & M, path: NodePath<N.TSTupleType>): any;
236
+ visitTSRestType?(this: Context & M, path: NodePath<N.TSRestType>): any;
237
+ visitTSOptionalType?(this: Context & M, path: NodePath<N.TSOptionalType>): any;
238
+ visitTSIndexedAccessType?(this: Context & M, path: NodePath<N.TSIndexedAccessType>): any;
239
+ visitTSTypeOperator?(this: Context & M, path: NodePath<N.TSTypeOperator>): any;
240
+ visitTSIndexSignature?(this: Context & M, path: NodePath<N.TSIndexSignature>): any;
241
+ visitTSPropertySignature?(this: Context & M, path: NodePath<N.TSPropertySignature>): any;
242
+ visitTSMethodSignature?(this: Context & M, path: NodePath<N.TSMethodSignature>): any;
243
+ visitTSTypePredicate?(this: Context & M, path: NodePath<N.TSTypePredicate>): any;
244
+ visitTSCallSignatureDeclaration?(this: Context & M, path: NodePath<N.TSCallSignatureDeclaration>): any;
245
+ visitTSConstructSignatureDeclaration?(this: Context & M, path: NodePath<N.TSConstructSignatureDeclaration>): any;
246
+ visitTSEnumMember?(this: Context & M, path: NodePath<N.TSEnumMember>): any;
247
+ visitTSTypeQuery?(this: Context & M, path: NodePath<N.TSTypeQuery>): any;
248
+ visitTSTypeLiteral?(this: Context & M, path: NodePath<N.TSTypeLiteral>): any;
249
+ visitTSTypeAssertion?(this: Context & M, path: NodePath<N.TSTypeAssertion>): any;
250
+ visitTSEnumDeclaration?(this: Context & M, path: NodePath<N.TSEnumDeclaration>): any;
251
+ visitTSTypeAliasDeclaration?(this: Context & M, path: NodePath<N.TSTypeAliasDeclaration>): any;
252
+ visitTSModuleBlock?(this: Context & M, path: NodePath<N.TSModuleBlock>): any;
253
+ visitTSModuleDeclaration?(this: Context & M, path: NodePath<N.TSModuleDeclaration>): any;
254
+ visitTSImportEqualsDeclaration?(this: Context & M, path: NodePath<N.TSImportEqualsDeclaration>): any;
255
+ visitTSExternalModuleReference?(this: Context & M, path: NodePath<N.TSExternalModuleReference>): any;
256
+ visitTSExportAssignment?(this: Context & M, path: NodePath<N.TSExportAssignment>): any;
257
+ visitTSNamespaceExportDeclaration?(this: Context & M, path: NodePath<N.TSNamespaceExportDeclaration>): any;
258
+ visitTSInterfaceBody?(this: Context & M, path: NodePath<N.TSInterfaceBody>): any;
259
+ visitTSInterfaceDeclaration?(this: Context & M, path: NodePath<N.TSInterfaceDeclaration>): any;
260
+ visitTSParameterProperty?(this: Context & M, path: NodePath<N.TSParameterProperty>): any;
261
+ visitOptionalMemberExpression?(this: Context & M, path: NodePath<N.OptionalMemberExpression>): any;
262
+ visitOptionalCallExpression?(this: Context & M, path: NodePath<N.OptionalCallExpression>): any;
263
+ }
package/gen/visitor.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/equiv.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { Fork } from "../types";
2
+ export default function (fork: Fork): {
3
+ (a: any, b: any, problemPath?: any): boolean;
4
+ assert(a: any, b: any): void;
5
+ };
package/lib/equiv.js CHANGED
@@ -1,5 +1,11 @@
1
- module.exports = function (fork) {
2
- var types = fork.use(require('../lib/types'));
1
+ "use strict";;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var types_1 = __importDefault(require("./types"));
7
+ function default_1(fork) {
8
+ var types = fork.use(types_1.default);
3
9
  var getFieldNames = types.getFieldNames;
4
10
  var getFieldValue = types.getFieldValue;
5
11
  var isArray = types.builtInTypes.array;
@@ -7,17 +13,15 @@ module.exports = function (fork) {
7
13
  var isDate = types.builtInTypes.Date;
8
14
  var isRegExp = types.builtInTypes.RegExp;
9
15
  var hasOwn = Object.prototype.hasOwnProperty;
10
-
11
16
  function astNodesAreEquivalent(a, b, problemPath) {
12
17
  if (isArray.check(problemPath)) {
13
18
  problemPath.length = 0;
14
- } else {
19
+ }
20
+ else {
15
21
  problemPath = null;
16
22
  }
17
-
18
23
  return areEquivalent(a, b, problemPath);
19
24
  }
20
-
21
25
  astNodesAreEquivalent.assert = function (a, b) {
22
26
  var problemPath = [];
23
27
  if (!astNodesAreEquivalent(a, b, problemPath)) {
@@ -25,75 +29,59 @@ module.exports = function (fork) {
25
29
  if (a !== b) {
26
30
  throw new Error("Nodes must be equal");
27
31
  }
28
- } else {
29
- throw new Error(
30
- "Nodes differ in the following path: " +
31
- problemPath.map(subscriptForProperty).join("")
32
- );
32
+ }
33
+ else {
34
+ throw new Error("Nodes differ in the following path: " +
35
+ problemPath.map(subscriptForProperty).join(""));
33
36
  }
34
37
  }
35
38
  };
36
-
37
39
  function subscriptForProperty(property) {
38
40
  if (/[_$a-z][_$a-z0-9]*/i.test(property)) {
39
41
  return "." + property;
40
42
  }
41
43
  return "[" + JSON.stringify(property) + "]";
42
44
  }
43
-
44
45
  function areEquivalent(a, b, problemPath) {
45
46
  if (a === b) {
46
47
  return true;
47
48
  }
48
-
49
49
  if (isArray.check(a)) {
50
50
  return arraysAreEquivalent(a, b, problemPath);
51
51
  }
52
-
53
52
  if (isObject.check(a)) {
54
53
  return objectsAreEquivalent(a, b, problemPath);
55
54
  }
56
-
57
55
  if (isDate.check(a)) {
58
56
  return isDate.check(b) && (+a === +b);
59
57
  }
60
-
61
58
  if (isRegExp.check(a)) {
62
- return isRegExp.check(b) && (
63
- a.source === b.source &&
59
+ return isRegExp.check(b) && (a.source === b.source &&
64
60
  a.global === b.global &&
65
61
  a.multiline === b.multiline &&
66
- a.ignoreCase === b.ignoreCase
67
- );
62
+ a.ignoreCase === b.ignoreCase);
68
63
  }
69
-
70
64
  return a == b;
71
65
  }
72
-
73
66
  function arraysAreEquivalent(a, b, problemPath) {
74
67
  isArray.assert(a);
75
68
  var aLength = a.length;
76
-
77
69
  if (!isArray.check(b) || b.length !== aLength) {
78
70
  if (problemPath) {
79
71
  problemPath.push("length");
80
72
  }
81
73
  return false;
82
74
  }
83
-
84
75
  for (var i = 0; i < aLength; ++i) {
85
76
  if (problemPath) {
86
77
  problemPath.push(i);
87
78
  }
88
-
89
79
  if (i in a !== i in b) {
90
80
  return false;
91
81
  }
92
-
93
82
  if (!areEquivalent(a[i], b[i], problemPath)) {
94
83
  return false;
95
84
  }
96
-
97
85
  if (problemPath) {
98
86
  var problemPathTail = problemPath.pop();
99
87
  if (problemPathTail !== i) {
@@ -101,16 +89,13 @@ module.exports = function (fork) {
101
89
  }
102
90
  }
103
91
  }
104
-
105
92
  return true;
106
93
  }
107
-
108
94
  function objectsAreEquivalent(a, b, problemPath) {
109
95
  isObject.assert(a);
110
96
  if (!isObject.check(b)) {
111
97
  return false;
112
98
  }
113
-
114
99
  // Fast path for a common property of AST nodes.
115
100
  if (a.type !== b.type) {
116
101
  if (problemPath) {
@@ -118,27 +103,21 @@ module.exports = function (fork) {
118
103
  }
119
104
  return false;
120
105
  }
121
-
122
106
  var aNames = getFieldNames(a);
123
107
  var aNameCount = aNames.length;
124
-
125
108
  var bNames = getFieldNames(b);
126
109
  var bNameCount = bNames.length;
127
-
128
110
  if (aNameCount === bNameCount) {
129
111
  for (var i = 0; i < aNameCount; ++i) {
130
112
  var name = aNames[i];
131
113
  var aChild = getFieldValue(a, name);
132
114
  var bChild = getFieldValue(b, name);
133
-
134
115
  if (problemPath) {
135
116
  problemPath.push(name);
136
117
  }
137
-
138
118
  if (!areEquivalent(aChild, bChild, problemPath)) {
139
119
  return false;
140
120
  }
141
-
142
121
  if (problemPath) {
143
122
  var problemPathTail = problemPath.pop();
144
123
  if (problemPathTail !== name) {
@@ -146,41 +125,32 @@ module.exports = function (fork) {
146
125
  }
147
126
  }
148
127
  }
149
-
150
128
  return true;
151
129
  }
152
-
153
130
  if (!problemPath) {
154
131
  return false;
155
132
  }
156
-
157
133
  // Since aNameCount !== bNameCount, we need to find some name that's
158
134
  // missing in aNames but present in bNames, or vice-versa.
159
-
160
135
  var seenNames = Object.create(null);
161
-
162
136
  for (i = 0; i < aNameCount; ++i) {
163
137
  seenNames[aNames[i]] = true;
164
138
  }
165
-
166
139
  for (i = 0; i < bNameCount; ++i) {
167
140
  name = bNames[i];
168
-
169
141
  if (!hasOwn.call(seenNames, name)) {
170
142
  problemPath.push(name);
171
143
  return false;
172
144
  }
173
-
174
145
  delete seenNames[name];
175
146
  }
176
-
177
147
  for (name in seenNames) {
178
148
  problemPath.push(name);
179
149
  break;
180
150
  }
181
-
182
151
  return false;
183
152
  }
184
-
185
153
  return astNodesAreEquivalent;
186
- };
154
+ }
155
+ exports.default = default_1;
156
+ module.exports = exports["default"];
@@ -0,0 +1,22 @@
1
+ import { Fork } from "../types";
2
+ import { ASTNode } from "./types";
3
+ import { Path } from "./path";
4
+ import { Scope } from "./scope";
5
+ export interface NodePath<N = any, V = any> extends Path<V> {
6
+ node: N;
7
+ parent: any;
8
+ scope: any;
9
+ replace: Path['replace'];
10
+ prune(...args: any[]): any;
11
+ _computeNode(): any;
12
+ _computeParent(): any;
13
+ _computeScope(): Scope | null;
14
+ getValueProperty(name: any): any;
15
+ needsParens(assumeExpressionContext?: boolean): boolean;
16
+ canBeFirstInStatement(): boolean;
17
+ firstInStatement(): boolean;
18
+ }
19
+ export interface NodePathConstructor {
20
+ new <N extends ASTNode = any, V = any>(value: any, parentPath?: any, name?: any): NodePath<N, V>;
21
+ }
22
+ export default function nodePathPlugin(fork: Fork): NodePathConstructor;