forked from benjamn/ast-types
-
Notifications
You must be signed in to change notification settings - Fork 0
/
es-proposals.ts
38 lines (29 loc) · 1.07 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
import { Fork } from "../types";
import typesPlugin from "../lib/types";
import sharedPlugin from "../lib/shared";
import coreDef from "./core";
export default function (fork: Fork) {
fork.use(coreDef);
var types = fork.use(typesPlugin);
var Type = types.Type;
var def = types.Type.def;
var or = Type.or;
var shared = fork.use(sharedPlugin);
var defaults = shared.defaults;
// https://github.com/tc39/proposal-optional-chaining
// `a?.b` as per https://github.com/estree/estree/issues/146
def("OptionalMemberExpression")
.bases("MemberExpression")
.build("object", "property", "computed", "optional")
.field("optional", Boolean, defaults["true"])
// a?.b()
def("OptionalCallExpression")
.bases("CallExpression")
.build("callee", "arguments", "optional")
.field("optional", Boolean, defaults["true"])
// https://github.com/tc39/proposal-nullish-coalescing
// `a ?? b` as per https://github.com/babel/babylon/pull/761/files
var LogicalOperator = or("||", "&&", "??");
def("LogicalExpression")
.field("operator", LogicalOperator)
};