forked from benjamn/ast-types
-
Notifications
You must be signed in to change notification settings - Fork 0
/
es-proposals.ts
49 lines (40 loc) · 1.22 KB
/
es-proposals.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
import { Fork } from "../types";
import typesPlugin from "../lib/types";
import sharedPlugin from "../lib/shared";
import es2020Def from "./es2020";
export default function (fork: Fork) {
fork.use(es2020Def);
const types = fork.use(typesPlugin);
const Type = types.Type;
const def = types.Type.def;
const or = Type.or;
const shared = fork.use(sharedPlugin);
const defaults = shared.defaults;
def("AwaitExpression")
.build("argument", "all")
.field("argument", or(def("Expression"), null))
.field("all", Boolean, defaults["false"]);
// Decorators
def("Decorator")
.bases("Node")
.build("expression")
.field("expression", def("Expression"));
def("Property")
.field("decorators",
or([def("Decorator")], null),
defaults["null"]);
def("MethodDefinition")
.field("decorators",
or([def("Decorator")], null),
defaults["null"]);
// Private names
def("PrivateName")
.bases("Expression", "Pattern")
.build("id")
.field("id", def("Identifier"));
def("ClassPrivateProperty")
.bases("ClassProperty")
.build("key", "value")
.field("key", def("PrivateName"))
.field("value", or(def("Expression"), null), defaults["null"]);
};