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.
- package/.travis.yml +2 -2
- package/def/babel-core.d.ts +2 -0
- package/def/babel-core.js +250 -290
- package/def/babel.d.ts +2 -0
- package/def/babel.js +12 -3
- package/def/core.d.ts +2 -0
- package/def/core.js +57 -126
- package/def/es-proposals.d.ts +2 -0
- package/def/es-proposals.js +34 -32
- package/def/es6.d.ts +2 -0
- package/def/es6.js +210 -253
- package/def/es7.d.ts +2 -0
- package/def/es7.js +35 -41
- package/def/esprima.d.ts +2 -0
- package/def/esprima.js +50 -71
- package/def/flow.d.ts +2 -0
- package/def/flow.js +289 -393
- package/def/jsx.d.ts +2 -0
- package/def/jsx.js +99 -125
- package/def/type-annotations.d.ts +7 -0
- package/def/type-annotations.js +42 -0
- package/def/typescript.d.ts +2 -0
- package/def/typescript.js +326 -444
- package/fork.d.ts +46 -0
- package/fork.js +40 -31
- package/gen/builders.d.ts +2539 -0
- package/gen/builders.js +2 -0
- package/gen/kinds.d.ts +259 -0
- package/gen/kinds.js +2 -0
- package/gen/namedTypes.d.ts +262 -0
- package/gen/namedTypes.js +2 -0
- package/gen/nodes.d.ts +1255 -0
- package/gen/nodes.js +2 -0
- package/gen/visitor.d.ts +263 -0
- package/gen/visitor.js +2 -0
- package/lib/equiv.d.ts +5 -0
- package/lib/equiv.js +19 -49
- package/lib/node-path.d.ts +22 -0
- package/lib/node-path.js +60 -125
- package/lib/path-visitor.d.ts +52 -0
- package/lib/path-visitor.js +117 -194
- package/lib/path.d.ts +25 -0
- package/lib/path.js +71 -107
- package/lib/scope.d.ts +26 -0
- package/lib/scope.js +100 -143
- package/lib/shared.d.ts +13 -0
- package/lib/shared.js +34 -31
- package/lib/types.d.ts +140 -0
- package/lib/types.js +584 -676
- package/main.d.ts +16 -0
- package/main.js +33 -18
- package/package.json +24 -7
- package/tsconfig.json +20 -0
- package/types.d.ts +6 -0
- package/types.js +2 -0
- package/def/e4x.js +0 -86
- package/def/mozilla.js +0 -42
package/main.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import fork from "./fork";
|
|
2
|
+
import { Omit } from "./types";
|
|
3
|
+
import { ASTNode, Type, AnyType, Field } from "./lib/types";
|
|
4
|
+
import { NodePath } from "./lib/node-path";
|
|
5
|
+
import { NamedTypes } from "./gen/namedTypes";
|
|
6
|
+
import { Builders } from "./gen/builders";
|
|
7
|
+
import { Visitor } from "./gen/visitor";
|
|
8
|
+
declare type GenTypes = {
|
|
9
|
+
namedTypes: NamedTypes;
|
|
10
|
+
builders: Builders;
|
|
11
|
+
visit<M = {}>(node: ASTNode, methods?: Visitor<M> & M): any;
|
|
12
|
+
};
|
|
13
|
+
declare type Main = Omit<ReturnType<typeof fork>, keyof GenTypes> & GenTypes;
|
|
14
|
+
declare const main: Main;
|
|
15
|
+
export default main;
|
|
16
|
+
export { ASTNode, Type, AnyType, Field, NodePath, NamedTypes, Builders, Visitor, };
|
package/main.js
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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 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 jsx_1 = __importDefault(require("./def/jsx"));
|
|
11
|
+
var flow_1 = __importDefault(require("./def/flow"));
|
|
12
|
+
var esprima_1 = __importDefault(require("./def/esprima"));
|
|
13
|
+
var babel_1 = __importDefault(require("./def/babel"));
|
|
14
|
+
var typescript_1 = __importDefault(require("./def/typescript"));
|
|
15
|
+
var es_proposals_1 = __importDefault(require("./def/es-proposals"));
|
|
16
|
+
var defs = [
|
|
17
|
+
// This core module of AST types captures ES5 as it is parsed today by
|
|
18
|
+
// git://github.com/ariya/esprima.git#master.
|
|
19
|
+
core_1.default,
|
|
20
|
+
// Feel free to add to or remove from this list of extension modules to
|
|
21
|
+
// configure the precise type hierarchy that you need.
|
|
22
|
+
es6_1.default,
|
|
23
|
+
es7_1.default,
|
|
24
|
+
jsx_1.default,
|
|
25
|
+
flow_1.default,
|
|
26
|
+
esprima_1.default,
|
|
27
|
+
babel_1.default,
|
|
28
|
+
typescript_1.default,
|
|
29
|
+
es_proposals_1.default,
|
|
30
|
+
];
|
|
31
|
+
var main = fork_1.default(defs);
|
|
32
|
+
exports.default = main;
|
|
33
|
+
module.exports = exports["default"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Ben Newman <bn@cs.stanford.edu>",
|
|
3
3
|
"name": "ast-types",
|
|
4
|
+
"version": "0.12.1",
|
|
4
5
|
"description": "Esprima-compatible implementation of the Mozilla JS Parser API",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"ast",
|
|
@@ -18,7 +19,6 @@
|
|
|
18
19
|
"transformation",
|
|
19
20
|
"syntax"
|
|
20
21
|
],
|
|
21
|
-
"version": "0.11.5",
|
|
22
22
|
"homepage": "http://github.com/benjamn/ast-types",
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
@@ -26,20 +26,37 @@
|
|
|
26
26
|
},
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"main": "main.js",
|
|
29
|
+
"types": "main.d.ts",
|
|
29
30
|
"scripts": {
|
|
30
|
-
"
|
|
31
|
+
"gen": "ts-node --transpile-only script/gen-types.ts",
|
|
32
|
+
"tsc": "tsc --noEmit",
|
|
33
|
+
"mocha": "test/run.sh",
|
|
34
|
+
"test": "npm run gen && npm run tsc && npm run mocha",
|
|
35
|
+
"clean": "ts-emit-clean",
|
|
36
|
+
"build": "tsc && ts-add-module-exports",
|
|
37
|
+
"prepack": "npm run clean && npm run gen && npm run build",
|
|
38
|
+
"postpack": "npm run clean"
|
|
31
39
|
},
|
|
32
40
|
"dependencies": {},
|
|
33
41
|
"devDependencies": {
|
|
34
|
-
"babel
|
|
35
|
-
"
|
|
36
|
-
"
|
|
42
|
+
"@babel/parser": "^7.1.6",
|
|
43
|
+
"@babel/types": "^7.1.6",
|
|
44
|
+
"@types/esprima": "^4.0.2",
|
|
45
|
+
"@types/glob": "^7.1.1",
|
|
46
|
+
"@types/mocha": "^5.2.5",
|
|
47
|
+
"@types/node": "^10.12.9",
|
|
48
|
+
"espree": "^4.0.0",
|
|
37
49
|
"esprima": "~4.0.0",
|
|
38
50
|
"esprima-fb": "~14001.1.0-dev-harmony-fb",
|
|
39
|
-
"flow-parser": "^0.
|
|
51
|
+
"flow-parser": "^0.83.0",
|
|
40
52
|
"glob": "^7.1.2",
|
|
41
53
|
"mocha": "^5.0.0",
|
|
42
|
-
"
|
|
54
|
+
"recast": "^0.16.1",
|
|
55
|
+
"reify": "^0.18.1",
|
|
56
|
+
"ts-add-module-exports": "^1.0.0",
|
|
57
|
+
"ts-emit-clean": "^1.0.0",
|
|
58
|
+
"ts-node": "^7.0.1",
|
|
59
|
+
"typescript": "^3.2.2"
|
|
43
60
|
},
|
|
44
61
|
"engines": {
|
|
45
62
|
"node": ">=4"
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"rootDir": ".",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noUnusedLocals": true,
|
|
9
|
+
"noUnusedParameters": true,
|
|
10
|
+
"noImplicitReturns": true,
|
|
11
|
+
"moduleResolution": "node",
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"stripInternal": true,
|
|
14
|
+
"lib": ["es2015"]
|
|
15
|
+
},
|
|
16
|
+
"exclude": [
|
|
17
|
+
"node_modules",
|
|
18
|
+
"test/data"
|
|
19
|
+
]
|
|
20
|
+
}
|
package/types.d.ts
ADDED
package/types.js
ADDED
package/def/e4x.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
module.exports = function (fork) {
|
|
2
|
-
fork.use(require("./core"));
|
|
3
|
-
var types = fork.use(require("../lib/types"));
|
|
4
|
-
var def = types.Type.def;
|
|
5
|
-
var or = types.Type.or;
|
|
6
|
-
|
|
7
|
-
// Note that none of these types are buildable because the Mozilla Parser
|
|
8
|
-
// API doesn't specify any builder functions, and nobody uses E4X anymore.
|
|
9
|
-
|
|
10
|
-
def("XMLDefaultDeclaration")
|
|
11
|
-
.bases("Declaration")
|
|
12
|
-
.field("namespace", def("Expression"));
|
|
13
|
-
|
|
14
|
-
def("XMLAnyName").bases("Expression");
|
|
15
|
-
|
|
16
|
-
def("XMLQualifiedIdentifier")
|
|
17
|
-
.bases("Expression")
|
|
18
|
-
.field("left", or(def("Identifier"), def("XMLAnyName")))
|
|
19
|
-
.field("right", or(def("Identifier"), def("Expression")))
|
|
20
|
-
.field("computed", Boolean);
|
|
21
|
-
|
|
22
|
-
def("XMLFunctionQualifiedIdentifier")
|
|
23
|
-
.bases("Expression")
|
|
24
|
-
.field("right", or(def("Identifier"), def("Expression")))
|
|
25
|
-
.field("computed", Boolean);
|
|
26
|
-
|
|
27
|
-
def("XMLAttributeSelector")
|
|
28
|
-
.bases("Expression")
|
|
29
|
-
.field("attribute", def("Expression"));
|
|
30
|
-
|
|
31
|
-
def("XMLFilterExpression")
|
|
32
|
-
.bases("Expression")
|
|
33
|
-
.field("left", def("Expression"))
|
|
34
|
-
.field("right", def("Expression"));
|
|
35
|
-
|
|
36
|
-
def("XMLElement")
|
|
37
|
-
.bases("XML", "Expression")
|
|
38
|
-
.field("contents", [def("XML")]);
|
|
39
|
-
|
|
40
|
-
def("XMLList")
|
|
41
|
-
.bases("XML", "Expression")
|
|
42
|
-
.field("contents", [def("XML")]);
|
|
43
|
-
|
|
44
|
-
def("XML").bases("Node");
|
|
45
|
-
|
|
46
|
-
def("XMLEscape")
|
|
47
|
-
.bases("XML")
|
|
48
|
-
.field("expression", def("Expression"));
|
|
49
|
-
|
|
50
|
-
def("XMLText")
|
|
51
|
-
.bases("XML")
|
|
52
|
-
.field("text", String);
|
|
53
|
-
|
|
54
|
-
def("XMLStartTag")
|
|
55
|
-
.bases("XML")
|
|
56
|
-
.field("contents", [def("XML")]);
|
|
57
|
-
|
|
58
|
-
def("XMLEndTag")
|
|
59
|
-
.bases("XML")
|
|
60
|
-
.field("contents", [def("XML")]);
|
|
61
|
-
|
|
62
|
-
def("XMLPointTag")
|
|
63
|
-
.bases("XML")
|
|
64
|
-
.field("contents", [def("XML")]);
|
|
65
|
-
|
|
66
|
-
def("XMLName")
|
|
67
|
-
.bases("XML")
|
|
68
|
-
.field("contents", or(String, [def("XML")]));
|
|
69
|
-
|
|
70
|
-
def("XMLAttribute")
|
|
71
|
-
.bases("XML")
|
|
72
|
-
.field("value", String);
|
|
73
|
-
|
|
74
|
-
def("XMLCdata")
|
|
75
|
-
.bases("XML")
|
|
76
|
-
.field("contents", String);
|
|
77
|
-
|
|
78
|
-
def("XMLComment")
|
|
79
|
-
.bases("XML")
|
|
80
|
-
.field("contents", String);
|
|
81
|
-
|
|
82
|
-
def("XMLProcessingInstruction")
|
|
83
|
-
.bases("XML")
|
|
84
|
-
.field("target", String)
|
|
85
|
-
.field("contents", or(String, null));
|
|
86
|
-
};
|
package/def/mozilla.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
module.exports = function (fork) {
|
|
2
|
-
fork.use(require("./core"));
|
|
3
|
-
var types = fork.use(require("../lib/types"));
|
|
4
|
-
var def = types.Type.def;
|
|
5
|
-
var or = types.Type.or;
|
|
6
|
-
var shared = fork.use(require("../lib/shared"));
|
|
7
|
-
var geq = shared.geq;
|
|
8
|
-
var defaults = shared.defaults;
|
|
9
|
-
|
|
10
|
-
def("Function")
|
|
11
|
-
// SpiderMonkey allows expression closures: function(x) x+1
|
|
12
|
-
.field("body", or(def("BlockStatement"), def("Expression")));
|
|
13
|
-
|
|
14
|
-
def("ForInStatement")
|
|
15
|
-
.build("left", "right", "body", "each")
|
|
16
|
-
.field("each", Boolean, defaults["false"]);
|
|
17
|
-
|
|
18
|
-
def("LetStatement")
|
|
19
|
-
.bases("Statement")
|
|
20
|
-
.build("head", "body")
|
|
21
|
-
// TODO Deviating from the spec by reusing VariableDeclarator here.
|
|
22
|
-
.field("head", [def("VariableDeclarator")])
|
|
23
|
-
.field("body", def("Statement"));
|
|
24
|
-
|
|
25
|
-
def("LetExpression")
|
|
26
|
-
.bases("Expression")
|
|
27
|
-
.build("head", "body")
|
|
28
|
-
// TODO Deviating from the spec by reusing VariableDeclarator here.
|
|
29
|
-
.field("head", [def("VariableDeclarator")])
|
|
30
|
-
.field("body", def("Expression"));
|
|
31
|
-
|
|
32
|
-
def("GraphExpression")
|
|
33
|
-
.bases("Expression")
|
|
34
|
-
.build("index", "expression")
|
|
35
|
-
.field("index", geq(0))
|
|
36
|
-
.field("expression", def("Literal"));
|
|
37
|
-
|
|
38
|
-
def("GraphIndexExpression")
|
|
39
|
-
.bases("Expression")
|
|
40
|
-
.build("index")
|
|
41
|
-
.field("index", geq(0));
|
|
42
|
-
};
|