ast-types 0.13.3 → 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/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 types_1 = __importDefault(require("./types"));
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
- addPattern(path.get("param"), bindings);
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
- "null": () => null;
6
- "emptyArray": () => never[];
7
- "false": () => boolean;
8
- "true": () => boolean;
9
- "undefined": () => void;
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 types_1 = __importDefault(require("./types"));
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<any>;
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
- var builtInTypes = {};
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("truthy", "string");
323
- var isFunction = defBuiltInType(function () { }, "function");
324
- var isArray = defBuiltInType([], "array");
325
- var isObject = defBuiltInType({}, "object");
326
- var isRegExp = defBuiltInType(/./, "RegExp");
327
- var isDate = defBuiltInType(new Date, "Date");
328
- var isNumber = defBuiltInType(3, "number");
329
- var isBoolean = defBuiltInType(true, "boolean");
330
- var isNull = defBuiltInType(null, "null");
331
- var isUndefined = defBuiltInType(void 0, "undefined");
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,21 +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
- var fork_1 = __importDefault(require("./fork"));
7
- var core_1 = __importDefault(require("./def/core"));
8
- var es6_1 = __importDefault(require("./def/es6"));
9
- var es7_1 = __importDefault(require("./def/es7"));
10
- var es2020_1 = __importDefault(require("./def/es2020"));
11
- var jsx_1 = __importDefault(require("./def/jsx"));
12
- var flow_1 = __importDefault(require("./def/flow"));
13
- var esprima_1 = __importDefault(require("./def/esprima"));
14
- var babel_1 = __importDefault(require("./def/babel"));
15
- var typescript_1 = __importDefault(require("./def/typescript"));
16
- var es_proposals_1 = __importDefault(require("./def/es-proposals"));
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"));
17
16
  var namedTypes_1 = require("./gen/namedTypes");
18
- exports.namedTypes = namedTypes_1.namedTypes;
17
+ Object.defineProperty(exports, "namedTypes", { enumerable: true, get: function () { return namedTypes_1.namedTypes; } });
19
18
  var _a = fork_1.default([
20
19
  // This core module of AST types captures ES5 as it is parsed today by
21
20
  // git://github.com/ariya/esprima.git#master.
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.3",
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.4.4",
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": "6.1.1",
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.98.1",
51
- "glob": "7.1.4",
52
+ "flow-parser": "0.132.0",
53
+ "glob": "7.1.6",
52
54
  "mocha": "6.1.4",
53
- "recast": "0.18.1",
54
- "reify": "0.20.6",
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.4.5"
60
+ "typescript": "3.9.7"
59
61
  },
60
62
  "engines": {
61
63
  "node": ">=4"
package/tsconfig.json CHANGED
@@ -10,6 +10,7 @@
10
10
  "noImplicitReturns": true,
11
11
  "moduleResolution": "node",
12
12
  "esModuleInterop": true,
13
+ "importHelpers": true,
13
14
  "stripInternal": true,
14
15
  "lib": ["es2015"]
15
16
  },
package/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - "12"
4
- - "11"
5
- - "10"
6
- - "9"
7
- - "8"
8
- - "7"
9
- - "6"
10
-
11
- sudo: false
package/def/esNext.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { Fork } from "../types";
2
- export default function (fork: Fork): void;
package/def/esNext.js DELETED
@@ -1,57 +0,0 @@
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 es6_1 = __importDefault(require("./es6"));
7
- var types_1 = __importDefault(require("../lib/types"));
8
- var shared_1 = __importDefault(require("../lib/shared"));
9
- function default_1(fork) {
10
- fork.use(es6_1.default);
11
- var types = fork.use(types_1.default);
12
- var def = types.Type.def;
13
- var or = types.Type.or;
14
- var defaults = fork.use(shared_1.default).defaults;
15
- def("SpreadProperty")
16
- .bases("Node")
17
- .build("argument")
18
- .field("argument", def("Expression"));
19
- def("ObjectExpression")
20
- .field("properties", [or(def("Property"), def("SpreadProperty"), def("SpreadElement"))]);
21
- def("SpreadPropertyPattern")
22
- .bases("Pattern")
23
- .build("argument")
24
- .field("argument", def("Pattern"));
25
- def("ObjectPattern")
26
- .field("properties", [or(def("Property"), def("PropertyPattern"), def("SpreadPropertyPattern"))]);
27
- def("Function")
28
- .field("async", Boolean, defaults["false"]);
29
- def("AwaitExpression")
30
- .bases("Expression")
31
- .build("argument", "all")
32
- .field("argument", or(def("Expression"), null))
33
- .field("all", Boolean, defaults["false"]);
34
- // Dynamic import(stringExpression)
35
- def("ImportExpression")
36
- .bases("Expression")
37
- .build("source")
38
- .field("source", def("Expression"));
39
- // https://github.com/tc39/proposal-optional-chaining
40
- // `a?.b` as per https://github.com/estree/estree/issues/146
41
- def("OptionalMemberExpression")
42
- .bases("MemberExpression")
43
- .build("object", "property", "computed", "optional")
44
- .field("optional", Boolean, defaults["true"]);
45
- // a?.b()
46
- def("OptionalCallExpression")
47
- .bases("CallExpression")
48
- .build("callee", "arguments", "optional")
49
- .field("optional", Boolean, defaults["true"]);
50
- // https://github.com/tc39/proposal-nullish-coalescing
51
- // `a ?? b` as per https://github.com/babel/babylon/pull/761/files
52
- var LogicalOperator = or("||", "&&", "??");
53
- def("LogicalExpression")
54
- .field("operator", LogicalOperator);
55
- }
56
- exports.default = default_1;
57
- module.exports = exports["default"];