-
Notifications
You must be signed in to change notification settings - Fork 198
/
es2020.ts
64 lines (51 loc) · 1.75 KB
/
es2020.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { Fork } from "../types";
import es2020OpsDef from "./operators/es2020";
import es2019Def from "./es2019";
import typesPlugin from "../types";
import sharedPlugin, { maybeSetModuleExports } from "../shared";
export default function (fork: Fork) {
// The es2020OpsDef plugin comes before es2019Def so LogicalOperators will be
// appropriately augmented before first used.
fork.use(es2020OpsDef);
fork.use(es2019Def);
const types = fork.use(typesPlugin);
const def = types.Type.def;
const or = types.Type.or;
const shared = fork.use(sharedPlugin);
const defaults = shared.defaults;
def("ImportExpression")
.bases("Expression")
.build("source")
.field("source", def("Expression"));
def("ExportAllDeclaration")
.bases("Declaration")
.build("source", "exported")
.field("source", def("Literal"))
.field("exported", or(
def("Identifier"),
null,
void 0,
), defaults["null"]);
// Optional chaining
def("ChainElement")
.bases("Node")
.field("optional", Boolean, defaults["false"]);
def("CallExpression")
.bases("Expression", "ChainElement");
def("MemberExpression")
.bases("Expression", "ChainElement");
def("ChainExpression")
.bases("Expression")
.build("expression")
.field("expression", def("ChainElement"));
def("OptionalCallExpression")
.bases("CallExpression")
.build("callee", "arguments", "optional")
.field("optional", Boolean, defaults["true"]);
// Deprecated optional chaining type, doesn't work with [email protected] or newer
def("OptionalMemberExpression")
.bases("MemberExpression")
.build("object", "property", "computed", "optional")
.field("optional", Boolean, defaults["true"]);
};
maybeSetModuleExports(() => module);