ast-types 0.13.0 → 0.13.4
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.
- package/.github/dependabot.yml +9 -0
- package/.github/workflows/main.yml +29 -0
- package/README.md +2 -1
- package/def/babel-core.js +4 -6
- package/def/babel.js +3 -5
- package/def/core.js +3 -5
- package/def/es-proposals.js +4 -6
- package/def/es2020.d.ts +2 -0
- package/def/es2020.js +16 -0
- package/def/es6.js +4 -6
- package/def/es7.js +4 -6
- package/def/esprima.js +4 -6
- package/def/flow.js +9 -7
- package/def/jsx.js +4 -6
- package/def/type-annotations.js +3 -5
- package/def/typescript.js +17 -12
- package/fork.d.ts +1 -1
- package/fork.js +6 -8
- package/gen/builders.d.ts +29 -5
- package/gen/kinds.d.ts +6 -4
- package/gen/namedTypes.d.ts +21 -4
- package/gen/namedTypes.js +1 -0
- package/gen/visitor.d.ts +2 -0
- package/lib/equiv.js +2 -4
- package/lib/node-path.js +4 -6
- package/lib/path-visitor.js +3 -5
- package/lib/path.js +2 -4
- package/lib/scope.js +6 -5
- package/lib/shared.d.ts +7 -7
- package/lib/shared.js +2 -4
- package/lib/types.d.ts +1 -1
- package/lib/types.js +31 -32
- package/main.js +15 -14
- package/package.json +11 -9
- package/tsconfig.json +1 -0
- package/.travis.yml +0 -11
- package/gen/nodes.d.ts +0 -1265
- package/gen/nodes.js +0 -2
package/gen/namedTypes.d.ts
CHANGED
|
@@ -251,11 +251,13 @@ export declare namespace namedTypes {
|
|
|
251
251
|
type: "NewExpression";
|
|
252
252
|
callee: K.ExpressionKind;
|
|
253
253
|
arguments: (K.ExpressionKind | K.SpreadElementKind)[];
|
|
254
|
+
typeArguments?: null | K.TypeParameterInstantiationKind;
|
|
254
255
|
}
|
|
255
256
|
interface CallExpression extends Omit<Expression, "type"> {
|
|
256
257
|
type: "CallExpression";
|
|
257
258
|
callee: K.ExpressionKind;
|
|
258
259
|
arguments: (K.ExpressionKind | K.SpreadElementKind)[];
|
|
260
|
+
typeArguments?: null | K.TypeParameterInstantiationKind;
|
|
259
261
|
}
|
|
260
262
|
interface RestElement extends Omit<Pattern, "type"> {
|
|
261
263
|
type: "RestElement";
|
|
@@ -441,6 +443,10 @@ export declare namespace namedTypes {
|
|
|
441
443
|
argument: K.ExpressionKind | null;
|
|
442
444
|
all?: boolean;
|
|
443
445
|
}
|
|
446
|
+
interface ImportExpression extends Omit<Expression, "type"> {
|
|
447
|
+
type: "ImportExpression";
|
|
448
|
+
source: K.ExpressionKind;
|
|
449
|
+
}
|
|
444
450
|
interface JSXAttribute extends Omit<Node, "type"> {
|
|
445
451
|
type: "JSXAttribute";
|
|
446
452
|
name: K.JSXIdentifierKind | K.JSXNamespacedNameKind;
|
|
@@ -1117,7 +1123,13 @@ export declare namespace namedTypes {
|
|
|
1117
1123
|
}
|
|
1118
1124
|
interface TSTupleType extends Omit<TSType, "type"> {
|
|
1119
1125
|
type: "TSTupleType";
|
|
1120
|
-
elementTypes: K.TSTypeKind[];
|
|
1126
|
+
elementTypes: (K.TSTypeKind | K.TSNamedTupleMemberKind)[];
|
|
1127
|
+
}
|
|
1128
|
+
interface TSNamedTupleMember extends Omit<TSType, "type"> {
|
|
1129
|
+
type: "TSNamedTupleMember";
|
|
1130
|
+
label: K.IdentifierKind;
|
|
1131
|
+
optional?: boolean;
|
|
1132
|
+
elementType: K.TSTypeKind;
|
|
1121
1133
|
}
|
|
1122
1134
|
interface TSRestType extends Omit<TSType, "type"> {
|
|
1123
1135
|
type: "TSRestType";
|
|
@@ -1157,10 +1169,11 @@ export declare namespace namedTypes {
|
|
|
1157
1169
|
optional?: boolean;
|
|
1158
1170
|
parameters: (K.IdentifierKind | K.RestElementKind | K.ArrayPatternKind | K.ObjectPatternKind)[];
|
|
1159
1171
|
}
|
|
1160
|
-
interface TSTypePredicate extends Omit<TSTypeAnnotation, "type" | "typeAnnotation"> {
|
|
1172
|
+
interface TSTypePredicate extends Omit<TSTypeAnnotation, "type" | "typeAnnotation">, Omit<TSType, "type"> {
|
|
1161
1173
|
type: "TSTypePredicate";
|
|
1162
1174
|
parameterName: K.IdentifierKind | K.TSThisTypeKind;
|
|
1163
|
-
typeAnnotation
|
|
1175
|
+
typeAnnotation?: K.TSTypeAnnotationKind | null;
|
|
1176
|
+
asserts?: boolean;
|
|
1164
1177
|
}
|
|
1165
1178
|
interface TSCallSignatureDeclaration extends Omit<Declaration, "type">, TSHasOptionalTypeParameters, TSHasOptionalTypeAnnotation {
|
|
1166
1179
|
type: "TSCallSignatureDeclaration";
|
|
@@ -1264,7 +1277,7 @@ export declare namespace namedTypes {
|
|
|
1264
1277
|
type: "OptionalCallExpression";
|
|
1265
1278
|
optional?: boolean;
|
|
1266
1279
|
}
|
|
1267
|
-
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 | MethodDefinition | SpreadElement | AssignmentPattern | ClassPropertyDefinition | ClassProperty | ClassBody | ClassDeclaration | ClassExpression | ImportSpecifier | ImportNamespaceSpecifier | ImportDefaultSpecifier | ImportDeclaration | TaggedTemplateExpression | TemplateLiteral | TemplateElement | SpreadProperty | SpreadPropertyPattern | AwaitExpression | JSXAttribute | JSXIdentifier | JSXNamespacedName | JSXExpressionContainer | JSXMemberExpression | JSXSpreadAttribute | JSXElement | JSXOpeningElement | JSXClosingElement | JSXFragment | JSXText | JSXOpeningFragment | JSXClosingFragment | JSXEmptyExpression | JSXSpreadChild | TypeParameterDeclaration | TSTypeParameterDeclaration | TypeParameterInstantiation | TSTypeParameterInstantiation | ClassImplements | TSExpressionWithTypeArguments | AnyTypeAnnotation | EmptyTypeAnnotation | MixedTypeAnnotation | VoidTypeAnnotation | NumberTypeAnnotation | NumberLiteralTypeAnnotation | NumericLiteralTypeAnnotation | 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 | OpaqueType | DeclareTypeAlias | DeclareOpaqueType | TypeCastExpression | TupleTypeAnnotation | DeclareVariable | DeclareFunction | DeclareClass | DeclareModule | DeclareModuleExports | DeclareExportDeclaration | ExportSpecifier | ExportBatchSpecifier | DeclareExportAllDeclaration | InferredPredicate | DeclaredPredicate | ExportDeclaration | Block | Line | Noop | DoExpression | Super | BindExpression | Decorator | MetaProperty | ParenthesizedExpression | ExportDefaultDeclaration | ExportNamedDeclaration | ExportNamespaceSpecifier | ExportDefaultSpecifier | ExportAllDeclaration | CommentBlock | CommentLine | Directive | DirectiveLiteral | InterpreterDirective | StringLiteral | NumericLiteral | BigIntLiteral | NullLiteral | BooleanLiteral | RegExpLiteral | ObjectMethod | ClassPrivateProperty | ClassMethod | ClassPrivateMethod | PrivateName | 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 | 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 | OptionalMemberExpression | OptionalCallExpression;
|
|
1280
|
+
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 | MethodDefinition | SpreadElement | AssignmentPattern | ClassPropertyDefinition | ClassProperty | ClassBody | ClassDeclaration | ClassExpression | ImportSpecifier | ImportNamespaceSpecifier | ImportDefaultSpecifier | ImportDeclaration | TaggedTemplateExpression | TemplateLiteral | TemplateElement | SpreadProperty | SpreadPropertyPattern | AwaitExpression | ImportExpression | JSXAttribute | JSXIdentifier | JSXNamespacedName | JSXExpressionContainer | JSXMemberExpression | JSXSpreadAttribute | JSXElement | JSXOpeningElement | JSXClosingElement | JSXFragment | JSXText | JSXOpeningFragment | JSXClosingFragment | JSXEmptyExpression | JSXSpreadChild | TypeParameterDeclaration | TSTypeParameterDeclaration | TypeParameterInstantiation | TSTypeParameterInstantiation | ClassImplements | TSExpressionWithTypeArguments | AnyTypeAnnotation | EmptyTypeAnnotation | MixedTypeAnnotation | VoidTypeAnnotation | NumberTypeAnnotation | NumberLiteralTypeAnnotation | NumericLiteralTypeAnnotation | 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 | OpaqueType | DeclareTypeAlias | DeclareOpaqueType | TypeCastExpression | TupleTypeAnnotation | DeclareVariable | DeclareFunction | DeclareClass | DeclareModule | DeclareModuleExports | DeclareExportDeclaration | ExportSpecifier | ExportBatchSpecifier | DeclareExportAllDeclaration | InferredPredicate | DeclaredPredicate | ExportDeclaration | Block | Line | Noop | DoExpression | Super | BindExpression | Decorator | MetaProperty | ParenthesizedExpression | ExportDefaultDeclaration | ExportNamedDeclaration | ExportNamespaceSpecifier | ExportDefaultSpecifier | ExportAllDeclaration | CommentBlock | CommentLine | Directive | DirectiveLiteral | InterpreterDirective | StringLiteral | NumericLiteral | BigIntLiteral | NullLiteral | BooleanLiteral | RegExpLiteral | ObjectMethod | ClassPrivateProperty | ClassMethod | ClassPrivateMethod | PrivateName | 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 | OptionalMemberExpression | OptionalCallExpression;
|
|
1268
1281
|
let Printable: Type<Printable>;
|
|
1269
1282
|
let SourceLocation: Type<SourceLocation>;
|
|
1270
1283
|
let Node: Type<Node>;
|
|
@@ -1350,6 +1363,7 @@ export declare namespace namedTypes {
|
|
|
1350
1363
|
let SpreadProperty: Type<SpreadProperty>;
|
|
1351
1364
|
let SpreadPropertyPattern: Type<SpreadPropertyPattern>;
|
|
1352
1365
|
let AwaitExpression: Type<AwaitExpression>;
|
|
1366
|
+
let ImportExpression: Type<ImportExpression>;
|
|
1353
1367
|
let JSXAttribute: Type<JSXAttribute>;
|
|
1354
1368
|
let JSXIdentifier: Type<JSXIdentifier>;
|
|
1355
1369
|
let JSXNamespacedName: Type<JSXNamespacedName>;
|
|
@@ -1498,6 +1512,7 @@ export declare namespace namedTypes {
|
|
|
1498
1512
|
let TSDeclareMethod: Type<TSDeclareMethod>;
|
|
1499
1513
|
let TSMappedType: Type<TSMappedType>;
|
|
1500
1514
|
let TSTupleType: Type<TSTupleType>;
|
|
1515
|
+
let TSNamedTupleMember: Type<TSNamedTupleMember>;
|
|
1501
1516
|
let TSRestType: Type<TSRestType>;
|
|
1502
1517
|
let TSOptionalType: Type<TSOptionalType>;
|
|
1503
1518
|
let TSIndexedAccessType: Type<TSIndexedAccessType>;
|
|
@@ -1613,6 +1628,7 @@ export interface NamedTypes {
|
|
|
1613
1628
|
SpreadProperty: Type<namedTypes.SpreadProperty>;
|
|
1614
1629
|
SpreadPropertyPattern: Type<namedTypes.SpreadPropertyPattern>;
|
|
1615
1630
|
AwaitExpression: Type<namedTypes.AwaitExpression>;
|
|
1631
|
+
ImportExpression: Type<namedTypes.ImportExpression>;
|
|
1616
1632
|
JSXAttribute: Type<namedTypes.JSXAttribute>;
|
|
1617
1633
|
JSXIdentifier: Type<namedTypes.JSXIdentifier>;
|
|
1618
1634
|
JSXNamespacedName: Type<namedTypes.JSXNamespacedName>;
|
|
@@ -1761,6 +1777,7 @@ export interface NamedTypes {
|
|
|
1761
1777
|
TSDeclareMethod: Type<namedTypes.TSDeclareMethod>;
|
|
1762
1778
|
TSMappedType: Type<namedTypes.TSMappedType>;
|
|
1763
1779
|
TSTupleType: Type<namedTypes.TSTupleType>;
|
|
1780
|
+
TSNamedTupleMember: Type<namedTypes.TSNamedTupleMember>;
|
|
1764
1781
|
TSRestType: Type<namedTypes.TSRestType>;
|
|
1765
1782
|
TSOptionalType: Type<namedTypes.TSOptionalType>;
|
|
1766
1783
|
TSIndexedAccessType: Type<namedTypes.TSIndexedAccessType>;
|
package/gen/namedTypes.js
CHANGED
package/gen/visitor.d.ts
CHANGED
|
@@ -87,6 +87,7 @@ export interface Visitor<M = {}> {
|
|
|
87
87
|
visitSpreadProperty?(this: Context & M, path: NodePath<namedTypes.SpreadProperty>): any;
|
|
88
88
|
visitSpreadPropertyPattern?(this: Context & M, path: NodePath<namedTypes.SpreadPropertyPattern>): any;
|
|
89
89
|
visitAwaitExpression?(this: Context & M, path: NodePath<namedTypes.AwaitExpression>): any;
|
|
90
|
+
visitImportExpression?(this: Context & M, path: NodePath<namedTypes.ImportExpression>): any;
|
|
90
91
|
visitJSXAttribute?(this: Context & M, path: NodePath<namedTypes.JSXAttribute>): any;
|
|
91
92
|
visitJSXIdentifier?(this: Context & M, path: NodePath<namedTypes.JSXIdentifier>): any;
|
|
92
93
|
visitJSXNamespacedName?(this: Context & M, path: NodePath<namedTypes.JSXNamespacedName>): any;
|
|
@@ -235,6 +236,7 @@ export interface Visitor<M = {}> {
|
|
|
235
236
|
visitTSDeclareMethod?(this: Context & M, path: NodePath<namedTypes.TSDeclareMethod>): any;
|
|
236
237
|
visitTSMappedType?(this: Context & M, path: NodePath<namedTypes.TSMappedType>): any;
|
|
237
238
|
visitTSTupleType?(this: Context & M, path: NodePath<namedTypes.TSTupleType>): any;
|
|
239
|
+
visitTSNamedTupleMember?(this: Context & M, path: NodePath<namedTypes.TSNamedTupleMember>): any;
|
|
238
240
|
visitTSRestType?(this: Context & M, path: NodePath<namedTypes.TSRestType>): any;
|
|
239
241
|
visitTSOptionalType?(this: Context & M, path: NodePath<namedTypes.TSOptionalType>): any;
|
|
240
242
|
visitTSIndexedAccessType?(this: Context & M, path: NodePath<namedTypes.TSIndexedAccessType>): any;
|
package/lib/equiv.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";;
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var types_1 = tslib_1.__importDefault(require("./types"));
|
|
7
5
|
function default_1(fork) {
|
|
8
6
|
var types = fork.use(types_1.default);
|
|
9
7
|
var getFieldNames = types.getFieldNames;
|
package/lib/node-path.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";;
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
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"));
|
|
9
7
|
function nodePathPlugin(fork) {
|
|
10
8
|
var types = fork.use(types_1.default);
|
|
11
9
|
var n = types.namedTypes;
|
package/lib/path-visitor.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";;
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var
|
|
7
|
-
var
|
|
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"));
|
|
8
6
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
9
7
|
function pathVisitorPlugin(fork) {
|
|
10
8
|
var types = fork.use(types_1.default);
|
package/lib/path.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";;
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var types_1 = tslib_1.__importDefault(require("./types"));
|
|
7
5
|
var Op = Object.prototype;
|
|
8
6
|
var hasOwn = Op.hasOwnProperty;
|
|
9
7
|
function pathPlugin(fork) {
|
package/lib/scope.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";;
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var types_1 = tslib_1.__importDefault(require("./types"));
|
|
7
5
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
8
6
|
function scopePlugin(fork) {
|
|
9
7
|
var types = fork.use(types_1.default);
|
|
@@ -118,7 +116,10 @@ function scopePlugin(fork) {
|
|
|
118
116
|
// A catch clause establishes a new scope but the only variable
|
|
119
117
|
// bound in that scope is the catch parameter. Any other
|
|
120
118
|
// declarations create bindings in the outer scope.
|
|
121
|
-
|
|
119
|
+
var param = path.get("param");
|
|
120
|
+
if (param.value) {
|
|
121
|
+
addPattern(param, bindings);
|
|
122
|
+
}
|
|
122
123
|
}
|
|
123
124
|
else {
|
|
124
125
|
recursiveScanScope(path, bindings, scopeTypes);
|
package/lib/shared.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Fork } from "../types";
|
|
2
2
|
export default function (fork: Fork): {
|
|
3
|
-
geq: (than: any) => import("./types").Type<
|
|
3
|
+
geq: (than: any) => import("./types").Type<unknown>;
|
|
4
4
|
defaults: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
null: () => null;
|
|
6
|
+
emptyArray: () => never[];
|
|
7
|
+
false: () => boolean;
|
|
8
|
+
true: () => boolean;
|
|
9
|
+
undefined: () => void;
|
|
10
10
|
"use strict": () => string;
|
|
11
11
|
};
|
|
12
|
-
isPrimitive: import("./types").Type<
|
|
12
|
+
isPrimitive: import("./types").Type<unknown>;
|
|
13
13
|
};
|
package/lib/shared.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";;
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var types_1 = tslib_1.__importDefault(require("./types"));
|
|
7
5
|
function default_1(fork) {
|
|
8
6
|
var types = fork.use(types_1.default);
|
|
9
7
|
var Type = types.Type;
|
package/lib/types.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ export default function typesPlugin(_fork: Fork): {
|
|
|
102
102
|
Type: {
|
|
103
103
|
or(...types: any[]): Type<any>;
|
|
104
104
|
from<T>(value: any, name?: string | undefined): Type<T>;
|
|
105
|
-
def(typeName: string): Def
|
|
105
|
+
def(typeName: string): Def;
|
|
106
106
|
hasDef(typeName: string): boolean;
|
|
107
107
|
};
|
|
108
108
|
builtInTypes: {
|
package/lib/types.js
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Def = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
16
5
|
var Op = Object.prototype;
|
|
17
6
|
var objToStr = Op.toString;
|
|
18
7
|
var hasOwn = Op.hasOwnProperty;
|
|
@@ -33,7 +22,7 @@ var BaseType = /** @class */ (function () {
|
|
|
33
22
|
return BaseType;
|
|
34
23
|
}());
|
|
35
24
|
var ArrayType = /** @class */ (function (_super) {
|
|
36
|
-
__extends(ArrayType, _super);
|
|
25
|
+
tslib_1.__extends(ArrayType, _super);
|
|
37
26
|
function ArrayType(elemType) {
|
|
38
27
|
var _this = _super.call(this) || this;
|
|
39
28
|
_this.elemType = elemType;
|
|
@@ -50,7 +39,7 @@ var ArrayType = /** @class */ (function (_super) {
|
|
|
50
39
|
return ArrayType;
|
|
51
40
|
}(BaseType));
|
|
52
41
|
var IdentityType = /** @class */ (function (_super) {
|
|
53
|
-
__extends(IdentityType, _super);
|
|
42
|
+
tslib_1.__extends(IdentityType, _super);
|
|
54
43
|
function IdentityType(value) {
|
|
55
44
|
var _this = _super.call(this) || this;
|
|
56
45
|
_this.value = value;
|
|
@@ -70,7 +59,7 @@ var IdentityType = /** @class */ (function (_super) {
|
|
|
70
59
|
return IdentityType;
|
|
71
60
|
}(BaseType));
|
|
72
61
|
var ObjectType = /** @class */ (function (_super) {
|
|
73
|
-
__extends(ObjectType, _super);
|
|
62
|
+
tslib_1.__extends(ObjectType, _super);
|
|
74
63
|
function ObjectType(fields) {
|
|
75
64
|
var _this = _super.call(this) || this;
|
|
76
65
|
_this.fields = fields;
|
|
@@ -89,7 +78,7 @@ var ObjectType = /** @class */ (function (_super) {
|
|
|
89
78
|
return ObjectType;
|
|
90
79
|
}(BaseType));
|
|
91
80
|
var OrType = /** @class */ (function (_super) {
|
|
92
|
-
__extends(OrType, _super);
|
|
81
|
+
tslib_1.__extends(OrType, _super);
|
|
93
82
|
function OrType(types) {
|
|
94
83
|
var _this = _super.call(this) || this;
|
|
95
84
|
_this.types = types;
|
|
@@ -107,7 +96,7 @@ var OrType = /** @class */ (function (_super) {
|
|
|
107
96
|
return OrType;
|
|
108
97
|
}(BaseType));
|
|
109
98
|
var PredicateType = /** @class */ (function (_super) {
|
|
110
|
-
__extends(PredicateType, _super);
|
|
99
|
+
tslib_1.__extends(PredicateType, _super);
|
|
111
100
|
function PredicateType(name, predicate) {
|
|
112
101
|
var _this = _super.call(this) || this;
|
|
113
102
|
_this.name = name;
|
|
@@ -304,11 +293,9 @@ function typesPlugin(_fork) {
|
|
|
304
293
|
};
|
|
305
294
|
var builtInCtorFns = [];
|
|
306
295
|
var builtInCtorTypes = [];
|
|
307
|
-
|
|
308
|
-
function defBuiltInType(example, name) {
|
|
296
|
+
function defBuiltInType(name, example) {
|
|
309
297
|
var objStr = objToStr.call(example);
|
|
310
298
|
var type = new PredicateType(name, function (value) { return objToStr.call(value) === objStr; });
|
|
311
|
-
builtInTypes[name] = type;
|
|
312
299
|
if (example && typeof example.constructor === "function") {
|
|
313
300
|
builtInCtorFns.push(example.constructor);
|
|
314
301
|
builtInCtorTypes.push(type);
|
|
@@ -319,16 +306,28 @@ function typesPlugin(_fork) {
|
|
|
319
306
|
// value, rather than using the problematic typeof operator. Note however
|
|
320
307
|
// that no subtyping is considered; so, for instance, isObject.check
|
|
321
308
|
// returns false for [], /./, new Date, and null.
|
|
322
|
-
var isString = defBuiltInType("
|
|
323
|
-
var isFunction = defBuiltInType(function () { }
|
|
324
|
-
var isArray = defBuiltInType(
|
|
325
|
-
var isObject = defBuiltInType(
|
|
326
|
-
var isRegExp = defBuiltInType(
|
|
327
|
-
var isDate = defBuiltInType(
|
|
328
|
-
var isNumber = defBuiltInType(
|
|
329
|
-
var isBoolean = defBuiltInType(
|
|
330
|
-
var isNull = defBuiltInType(null,
|
|
331
|
-
var isUndefined = defBuiltInType(
|
|
309
|
+
var isString = defBuiltInType("string", "truthy");
|
|
310
|
+
var isFunction = defBuiltInType("function", function () { });
|
|
311
|
+
var isArray = defBuiltInType("array", []);
|
|
312
|
+
var isObject = defBuiltInType("object", {});
|
|
313
|
+
var isRegExp = defBuiltInType("RegExp", /./);
|
|
314
|
+
var isDate = defBuiltInType("Date", new Date());
|
|
315
|
+
var isNumber = defBuiltInType("number", 3);
|
|
316
|
+
var isBoolean = defBuiltInType("boolean", true);
|
|
317
|
+
var isNull = defBuiltInType("null", null);
|
|
318
|
+
var isUndefined = defBuiltInType("undefined", undefined);
|
|
319
|
+
var builtInTypes = {
|
|
320
|
+
string: isString,
|
|
321
|
+
function: isFunction,
|
|
322
|
+
array: isArray,
|
|
323
|
+
object: isObject,
|
|
324
|
+
RegExp: isRegExp,
|
|
325
|
+
Date: isDate,
|
|
326
|
+
number: isNumber,
|
|
327
|
+
boolean: isBoolean,
|
|
328
|
+
null: isNull,
|
|
329
|
+
undefined: isUndefined,
|
|
330
|
+
};
|
|
332
331
|
// In order to return the same Def instance every time Type.def is called
|
|
333
332
|
// with a particular name, those instances need to be stored in a cache.
|
|
334
333
|
var defCache = Object.create(null);
|
|
@@ -346,7 +345,7 @@ function typesPlugin(_fork) {
|
|
|
346
345
|
return null;
|
|
347
346
|
}
|
|
348
347
|
var DefImpl = /** @class */ (function (_super) {
|
|
349
|
-
__extends(DefImpl, _super);
|
|
348
|
+
tslib_1.__extends(DefImpl, _super);
|
|
350
349
|
function DefImpl(typeName) {
|
|
351
350
|
var _this = _super.call(this, new PredicateType(typeName, function (value, deep) { return _this.check(value, deep); }), typeName) || this;
|
|
352
351
|
return _this;
|
package/main.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
3
|
+
exports.visit = exports.use = exports.Type = exports.someField = exports.PathVisitor = exports.Path = exports.NodePath = exports.namedTypes = exports.getSupertypeNames = exports.getFieldValue = exports.getFieldNames = exports.getBuilderName = exports.finalize = exports.eachField = exports.defineMethod = exports.builtInTypes = exports.builders = exports.astNodesAreEquivalent = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var fork_1 = tslib_1.__importDefault(require("./fork"));
|
|
6
|
+
var core_1 = tslib_1.__importDefault(require("./def/core"));
|
|
7
|
+
var es6_1 = tslib_1.__importDefault(require("./def/es6"));
|
|
8
|
+
var es7_1 = tslib_1.__importDefault(require("./def/es7"));
|
|
9
|
+
var es2020_1 = tslib_1.__importDefault(require("./def/es2020"));
|
|
10
|
+
var jsx_1 = tslib_1.__importDefault(require("./def/jsx"));
|
|
11
|
+
var flow_1 = tslib_1.__importDefault(require("./def/flow"));
|
|
12
|
+
var esprima_1 = tslib_1.__importDefault(require("./def/esprima"));
|
|
13
|
+
var babel_1 = tslib_1.__importDefault(require("./def/babel"));
|
|
14
|
+
var typescript_1 = tslib_1.__importDefault(require("./def/typescript"));
|
|
15
|
+
var es_proposals_1 = tslib_1.__importDefault(require("./def/es-proposals"));
|
|
16
16
|
var namedTypes_1 = require("./gen/namedTypes");
|
|
17
|
-
exports
|
|
17
|
+
Object.defineProperty(exports, "namedTypes", { enumerable: true, get: function () { return namedTypes_1.namedTypes; } });
|
|
18
18
|
var _a = fork_1.default([
|
|
19
19
|
// This core module of AST types captures ES5 as it is parsed today by
|
|
20
20
|
// git://github.com/ariya/esprima.git#master.
|
|
@@ -23,6 +23,7 @@ var _a = fork_1.default([
|
|
|
23
23
|
// configure the precise type hierarchy that you need.
|
|
24
24
|
es6_1.default,
|
|
25
25
|
es7_1.default,
|
|
26
|
+
es2020_1.default,
|
|
26
27
|
jsx_1.default,
|
|
27
28
|
flow_1.default,
|
|
28
29
|
esprima_1.default,
|
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.13.
|
|
4
|
+
"version": "0.13.4",
|
|
5
5
|
"description": "Esprima-compatible implementation of the Mozilla JS Parser API",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"ast",
|
|
@@ -36,26 +36,28 @@
|
|
|
36
36
|
"prepack": "npm run clean && npm run gen && npm run build",
|
|
37
37
|
"postpack": "npm run clean"
|
|
38
38
|
},
|
|
39
|
-
"dependencies": {
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"tslib": "^2.0.1"
|
|
41
|
+
},
|
|
40
42
|
"devDependencies": {
|
|
41
|
-
"@babel/parser": "7.
|
|
43
|
+
"@babel/parser": "7.7.7",
|
|
42
44
|
"@babel/types": "7.4.4",
|
|
43
45
|
"@types/esprima": "4.0.2",
|
|
44
46
|
"@types/glob": "7.1.1",
|
|
45
47
|
"@types/mocha": "5.2.6",
|
|
46
48
|
"@types/node": "12.0.0",
|
|
47
|
-
"espree": "
|
|
49
|
+
"espree": "7.3.0",
|
|
48
50
|
"esprima": "4.0.1",
|
|
49
51
|
"esprima-fb": "15001.1001.0-dev-harmony-fb",
|
|
50
|
-
"flow-parser": "0.
|
|
51
|
-
"glob": "7.1.
|
|
52
|
+
"flow-parser": "0.132.0",
|
|
53
|
+
"glob": "7.1.6",
|
|
52
54
|
"mocha": "6.1.4",
|
|
53
|
-
"recast": "0.
|
|
54
|
-
"reify": "0.
|
|
55
|
+
"recast": "0.20.0",
|
|
56
|
+
"reify": "0.20.12",
|
|
55
57
|
"ts-add-module-exports": "1.0.0",
|
|
56
58
|
"ts-emit-clean": "1.0.0",
|
|
57
59
|
"ts-node": "7.0.1",
|
|
58
|
-
"typescript": "3.
|
|
60
|
+
"typescript": "3.9.7"
|
|
59
61
|
},
|
|
60
62
|
"engines": {
|
|
61
63
|
"node": ">=4"
|
package/tsconfig.json
CHANGED