Debian Codegraph @

packages/babel-types/src/definitions/experimental.ts

raw
1 import defineType, {
2 assertEach,
3 assertNodeType,
4 assertValueType,
5 chain,
6 } from "./utils";
7
8 defineType("ArgumentPlaceholder", {});
9
10 defineType("BindExpression", {
11 visitor: ["object", "callee"],
12 aliases: ["Expression"],
13 fields: !process.env.BABEL_TYPES_8_BREAKING
14 ? {
15 object: {
16 validate: Object.assign(() => {}, {
17 oneOfNodeTypes: ["Expression"],
18 }),
19 },
20 callee: {
21 validate: Object.assign(() => {}, {
22 oneOfNodeTypes: ["Expression"],
23 }),
24 },
25 }
26 : {
27 object: {
28 validate: assertNodeType("Expression"),
29 },
30 callee: {
31 validate: assertNodeType("Expression"),
32 },
33 },
34 });
35
36 defineType("ImportAttribute", {
37 visitor: ["key", "value"],
38 fields: {
39 key: {
40 validate: assertNodeType("Identifier", "StringLiteral"),
41 },
42 value: {
43 validate: assertNodeType("StringLiteral"),
44 },
45 },
46 });
47
48 defineType("Decorator", {
49 visitor: ["expression"],
50 fields: {
51 expression: {
52 validate: assertNodeType("Expression"),
53 },
54 },
55 });
56
57 defineType("DoExpression", {
58 visitor: ["body"],
59 builder: ["body", "async"],
60 aliases: ["Expression"],
61 fields: {
62 body: {
63 validate: assertNodeType("BlockStatement"),
64 },
65 async: {
66 validate: assertValueType("boolean"),
67 default: false,
68 },
69 },
70 });
71
72 defineType("ExportDefaultSpecifier", {
73 visitor: ["exported"],
74 aliases: ["ModuleSpecifier"],
75 fields: {
76 exported: {
77 validate: assertNodeType("Identifier"),
78 },
79 },
80 });
81
82 defineType("RecordExpression", {
83 visitor: ["properties"],
84 aliases: ["Expression"],
85 fields: {
86 properties: {
87 validate: chain(
88 assertValueType("array"),
89 assertEach(assertNodeType("ObjectProperty", "SpreadElement")),
90 ),
91 },
92 },
93 });
94
95 defineType("TupleExpression", {
96 fields: {
97 elements: {
98 validate: chain(
99 assertValueType("array"),
100 assertEach(assertNodeType("Expression", "SpreadElement")),
101 ),
102 default: [],
103 },
104 },
105 visitor: ["elements"],
106 aliases: ["Expression"],
107 });
108
109 defineType("DecimalLiteral", {
110 builder: ["value"],
111 fields: {
112 value: {
113 validate: assertValueType("string"),
114 },
115 },
116 aliases: ["Expression", "Pureish", "Literal", "Immutable"],
117 });
118
119 // https://github.com/tc39/proposal-js-module-blocks
120 defineType("ModuleExpression", {
121 visitor: ["body"],
122 fields: {
123 body: {
124 validate: assertNodeType("Program"),
125 },
126 },
127 aliases: ["Expression"],
128 });
129
130 // https://github.com/tc39/proposal-pipeline-operator
131 // https://github.com/js-choi/proposal-hack-pipes
132 defineType("TopicReference", {
133 aliases: ["Expression"],
134 });
135
136 // https://github.com/tc39/proposal-pipeline-operator
137 // https://github.com/js-choi/proposal-smart-pipes
138 defineType("PipelineTopicExpression", {
139 builder: ["expression"],
140 visitor: ["expression"],
141 fields: {
142 expression: {
143 validate: assertNodeType("Expression"),
144 },
145 },
146 aliases: ["Expression"],
147 });
148
149 defineType("PipelineBareFunction", {
150 builder: ["callee"],
151 visitor: ["callee"],
152 fields: {
153 callee: {
154 validate: assertNodeType("Expression"),
155 },
156 },
157 aliases: ["Expression"],
158 });
159
160 defineType("PipelinePrimaryTopicReference", {
161 aliases: ["Expression"],
162 });