source: trip-planner-front/node_modules/@babel/types/lib/definitions/core.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 49.3 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.classMethodOrDeclareMethodCommon = exports.classMethodOrPropertyCommon = exports.patternLikeCommon = exports.functionDeclarationCommon = exports.functionTypeAnnotationCommon = exports.functionCommon = void 0;
7
8var _is = require("../validators/is");
9
10var _isValidIdentifier = require("../validators/isValidIdentifier");
11
12var _helperValidatorIdentifier = require("@babel/helper-validator-identifier");
13
14var _constants = require("../constants");
15
16var _utils = require("./utils");
17
18(0, _utils.default)("ArrayExpression", {
19 fields: {
20 elements: {
21 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "Expression", "SpreadElement"))),
22 default: !process.env.BABEL_TYPES_8_BREAKING ? [] : undefined
23 }
24 },
25 visitor: ["elements"],
26 aliases: ["Expression"]
27});
28(0, _utils.default)("AssignmentExpression", {
29 fields: {
30 operator: {
31 validate: function () {
32 if (!process.env.BABEL_TYPES_8_BREAKING) {
33 return (0, _utils.assertValueType)("string");
34 }
35
36 const identifier = (0, _utils.assertOneOf)(..._constants.ASSIGNMENT_OPERATORS);
37 const pattern = (0, _utils.assertOneOf)("=");
38 return function (node, key, val) {
39 const validator = (0, _is.default)("Pattern", node.left) ? pattern : identifier;
40 validator(node, key, val);
41 };
42 }()
43 },
44 left: {
45 validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern")
46 },
47 right: {
48 validate: (0, _utils.assertNodeType)("Expression")
49 }
50 },
51 builder: ["operator", "left", "right"],
52 visitor: ["left", "right"],
53 aliases: ["Expression"]
54});
55(0, _utils.default)("BinaryExpression", {
56 builder: ["operator", "left", "right"],
57 fields: {
58 operator: {
59 validate: (0, _utils.assertOneOf)(..._constants.BINARY_OPERATORS)
60 },
61 left: {
62 validate: function () {
63 const expression = (0, _utils.assertNodeType)("Expression");
64 const inOp = (0, _utils.assertNodeType)("Expression", "PrivateName");
65
66 const validator = function (node, key, val) {
67 const validator = node.operator === "in" ? inOp : expression;
68 validator(node, key, val);
69 };
70
71 validator.oneOfNodeTypes = ["Expression", "PrivateName"];
72 return validator;
73 }()
74 },
75 right: {
76 validate: (0, _utils.assertNodeType)("Expression")
77 }
78 },
79 visitor: ["left", "right"],
80 aliases: ["Binary", "Expression"]
81});
82(0, _utils.default)("InterpreterDirective", {
83 builder: ["value"],
84 fields: {
85 value: {
86 validate: (0, _utils.assertValueType)("string")
87 }
88 }
89});
90(0, _utils.default)("Directive", {
91 visitor: ["value"],
92 fields: {
93 value: {
94 validate: (0, _utils.assertNodeType)("DirectiveLiteral")
95 }
96 }
97});
98(0, _utils.default)("DirectiveLiteral", {
99 builder: ["value"],
100 fields: {
101 value: {
102 validate: (0, _utils.assertValueType)("string")
103 }
104 }
105});
106(0, _utils.default)("BlockStatement", {
107 builder: ["body", "directives"],
108 visitor: ["directives", "body"],
109 fields: {
110 directives: {
111 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Directive"))),
112 default: []
113 },
114 body: {
115 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement")))
116 }
117 },
118 aliases: ["Scopable", "BlockParent", "Block", "Statement"]
119});
120(0, _utils.default)("BreakStatement", {
121 visitor: ["label"],
122 fields: {
123 label: {
124 validate: (0, _utils.assertNodeType)("Identifier"),
125 optional: true
126 }
127 },
128 aliases: ["Statement", "Terminatorless", "CompletionStatement"]
129});
130(0, _utils.default)("CallExpression", {
131 visitor: ["callee", "arguments", "typeParameters", "typeArguments"],
132 builder: ["callee", "arguments"],
133 aliases: ["Expression"],
134 fields: Object.assign({
135 callee: {
136 validate: (0, _utils.assertNodeType)("Expression", "V8IntrinsicIdentifier")
137 },
138 arguments: {
139 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName", "ArgumentPlaceholder")))
140 }
141 }, !process.env.BABEL_TYPES_8_BREAKING ? {
142 optional: {
143 validate: (0, _utils.assertOneOf)(true, false),
144 optional: true
145 }
146 } : {}, {
147 typeArguments: {
148 validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"),
149 optional: true
150 },
151 typeParameters: {
152 validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"),
153 optional: true
154 }
155 })
156});
157(0, _utils.default)("CatchClause", {
158 visitor: ["param", "body"],
159 fields: {
160 param: {
161 validate: (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern"),
162 optional: true
163 },
164 body: {
165 validate: (0, _utils.assertNodeType)("BlockStatement")
166 }
167 },
168 aliases: ["Scopable", "BlockParent"]
169});
170(0, _utils.default)("ConditionalExpression", {
171 visitor: ["test", "consequent", "alternate"],
172 fields: {
173 test: {
174 validate: (0, _utils.assertNodeType)("Expression")
175 },
176 consequent: {
177 validate: (0, _utils.assertNodeType)("Expression")
178 },
179 alternate: {
180 validate: (0, _utils.assertNodeType)("Expression")
181 }
182 },
183 aliases: ["Expression", "Conditional"]
184});
185(0, _utils.default)("ContinueStatement", {
186 visitor: ["label"],
187 fields: {
188 label: {
189 validate: (0, _utils.assertNodeType)("Identifier"),
190 optional: true
191 }
192 },
193 aliases: ["Statement", "Terminatorless", "CompletionStatement"]
194});
195(0, _utils.default)("DebuggerStatement", {
196 aliases: ["Statement"]
197});
198(0, _utils.default)("DoWhileStatement", {
199 visitor: ["test", "body"],
200 fields: {
201 test: {
202 validate: (0, _utils.assertNodeType)("Expression")
203 },
204 body: {
205 validate: (0, _utils.assertNodeType)("Statement")
206 }
207 },
208 aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"]
209});
210(0, _utils.default)("EmptyStatement", {
211 aliases: ["Statement"]
212});
213(0, _utils.default)("ExpressionStatement", {
214 visitor: ["expression"],
215 fields: {
216 expression: {
217 validate: (0, _utils.assertNodeType)("Expression")
218 }
219 },
220 aliases: ["Statement", "ExpressionWrapper"]
221});
222(0, _utils.default)("File", {
223 builder: ["program", "comments", "tokens"],
224 visitor: ["program"],
225 fields: {
226 program: {
227 validate: (0, _utils.assertNodeType)("Program")
228 },
229 comments: {
230 validate: !process.env.BABEL_TYPES_8_BREAKING ? Object.assign(() => {}, {
231 each: {
232 oneOfNodeTypes: ["CommentBlock", "CommentLine"]
233 }
234 }) : (0, _utils.assertEach)((0, _utils.assertNodeType)("CommentBlock", "CommentLine")),
235 optional: true
236 },
237 tokens: {
238 validate: (0, _utils.assertEach)(Object.assign(() => {}, {
239 type: "any"
240 })),
241 optional: true
242 }
243 }
244});
245(0, _utils.default)("ForInStatement", {
246 visitor: ["left", "right", "body"],
247 aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"],
248 fields: {
249 left: {
250 validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("VariableDeclaration", "LVal") : (0, _utils.assertNodeType)("VariableDeclaration", "Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern")
251 },
252 right: {
253 validate: (0, _utils.assertNodeType)("Expression")
254 },
255 body: {
256 validate: (0, _utils.assertNodeType)("Statement")
257 }
258 }
259});
260(0, _utils.default)("ForStatement", {
261 visitor: ["init", "test", "update", "body"],
262 aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop"],
263 fields: {
264 init: {
265 validate: (0, _utils.assertNodeType)("VariableDeclaration", "Expression"),
266 optional: true
267 },
268 test: {
269 validate: (0, _utils.assertNodeType)("Expression"),
270 optional: true
271 },
272 update: {
273 validate: (0, _utils.assertNodeType)("Expression"),
274 optional: true
275 },
276 body: {
277 validate: (0, _utils.assertNodeType)("Statement")
278 }
279 }
280});
281const functionCommon = {
282 params: {
283 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Identifier", "Pattern", "RestElement")))
284 },
285 generator: {
286 default: false
287 },
288 async: {
289 default: false
290 }
291};
292exports.functionCommon = functionCommon;
293const functionTypeAnnotationCommon = {
294 returnType: {
295 validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"),
296 optional: true
297 },
298 typeParameters: {
299 validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"),
300 optional: true
301 }
302};
303exports.functionTypeAnnotationCommon = functionTypeAnnotationCommon;
304const functionDeclarationCommon = Object.assign({}, functionCommon, {
305 declare: {
306 validate: (0, _utils.assertValueType)("boolean"),
307 optional: true
308 },
309 id: {
310 validate: (0, _utils.assertNodeType)("Identifier"),
311 optional: true
312 }
313});
314exports.functionDeclarationCommon = functionDeclarationCommon;
315(0, _utils.default)("FunctionDeclaration", {
316 builder: ["id", "params", "body", "generator", "async"],
317 visitor: ["id", "params", "body", "returnType", "typeParameters"],
318 fields: Object.assign({}, functionDeclarationCommon, functionTypeAnnotationCommon, {
319 body: {
320 validate: (0, _utils.assertNodeType)("BlockStatement")
321 }
322 }),
323 aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Statement", "Pureish", "Declaration"],
324 validate: function () {
325 if (!process.env.BABEL_TYPES_8_BREAKING) return () => {};
326 const identifier = (0, _utils.assertNodeType)("Identifier");
327 return function (parent, key, node) {
328 if (!(0, _is.default)("ExportDefaultDeclaration", parent)) {
329 identifier(node, "id", node.id);
330 }
331 };
332 }()
333});
334(0, _utils.default)("FunctionExpression", {
335 inherits: "FunctionDeclaration",
336 aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"],
337 fields: Object.assign({}, functionCommon, functionTypeAnnotationCommon, {
338 id: {
339 validate: (0, _utils.assertNodeType)("Identifier"),
340 optional: true
341 },
342 body: {
343 validate: (0, _utils.assertNodeType)("BlockStatement")
344 }
345 })
346});
347const patternLikeCommon = {
348 typeAnnotation: {
349 validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"),
350 optional: true
351 },
352 decorators: {
353 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator")))
354 }
355};
356exports.patternLikeCommon = patternLikeCommon;
357(0, _utils.default)("Identifier", {
358 builder: ["name"],
359 visitor: ["typeAnnotation", "decorators"],
360 aliases: ["Expression", "PatternLike", "LVal", "TSEntityName"],
361 fields: Object.assign({}, patternLikeCommon, {
362 name: {
363 validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), Object.assign(function (node, key, val) {
364 if (!process.env.BABEL_TYPES_8_BREAKING) return;
365
366 if (!(0, _isValidIdentifier.default)(val, false)) {
367 throw new TypeError(`"${val}" is not a valid identifier name`);
368 }
369 }, {
370 type: "string"
371 }))
372 },
373 optional: {
374 validate: (0, _utils.assertValueType)("boolean"),
375 optional: true
376 }
377 }),
378
379 validate(parent, key, node) {
380 if (!process.env.BABEL_TYPES_8_BREAKING) return;
381 const match = /\.(\w+)$/.exec(key);
382 if (!match) return;
383 const [, parentKey] = match;
384 const nonComp = {
385 computed: false
386 };
387
388 if (parentKey === "property") {
389 if ((0, _is.default)("MemberExpression", parent, nonComp)) return;
390 if ((0, _is.default)("OptionalMemberExpression", parent, nonComp)) return;
391 } else if (parentKey === "key") {
392 if ((0, _is.default)("Property", parent, nonComp)) return;
393 if ((0, _is.default)("Method", parent, nonComp)) return;
394 } else if (parentKey === "exported") {
395 if ((0, _is.default)("ExportSpecifier", parent)) return;
396 } else if (parentKey === "imported") {
397 if ((0, _is.default)("ImportSpecifier", parent, {
398 imported: node
399 })) return;
400 } else if (parentKey === "meta") {
401 if ((0, _is.default)("MetaProperty", parent, {
402 meta: node
403 })) return;
404 }
405
406 if (((0, _helperValidatorIdentifier.isKeyword)(node.name) || (0, _helperValidatorIdentifier.isReservedWord)(node.name, false)) && node.name !== "this") {
407 throw new TypeError(`"${node.name}" is not a valid identifier`);
408 }
409 }
410
411});
412(0, _utils.default)("IfStatement", {
413 visitor: ["test", "consequent", "alternate"],
414 aliases: ["Statement", "Conditional"],
415 fields: {
416 test: {
417 validate: (0, _utils.assertNodeType)("Expression")
418 },
419 consequent: {
420 validate: (0, _utils.assertNodeType)("Statement")
421 },
422 alternate: {
423 optional: true,
424 validate: (0, _utils.assertNodeType)("Statement")
425 }
426 }
427});
428(0, _utils.default)("LabeledStatement", {
429 visitor: ["label", "body"],
430 aliases: ["Statement"],
431 fields: {
432 label: {
433 validate: (0, _utils.assertNodeType)("Identifier")
434 },
435 body: {
436 validate: (0, _utils.assertNodeType)("Statement")
437 }
438 }
439});
440(0, _utils.default)("StringLiteral", {
441 builder: ["value"],
442 fields: {
443 value: {
444 validate: (0, _utils.assertValueType)("string")
445 }
446 },
447 aliases: ["Expression", "Pureish", "Literal", "Immutable"]
448});
449(0, _utils.default)("NumericLiteral", {
450 builder: ["value"],
451 deprecatedAlias: "NumberLiteral",
452 fields: {
453 value: {
454 validate: (0, _utils.assertValueType)("number")
455 }
456 },
457 aliases: ["Expression", "Pureish", "Literal", "Immutable"]
458});
459(0, _utils.default)("NullLiteral", {
460 aliases: ["Expression", "Pureish", "Literal", "Immutable"]
461});
462(0, _utils.default)("BooleanLiteral", {
463 builder: ["value"],
464 fields: {
465 value: {
466 validate: (0, _utils.assertValueType)("boolean")
467 }
468 },
469 aliases: ["Expression", "Pureish", "Literal", "Immutable"]
470});
471(0, _utils.default)("RegExpLiteral", {
472 builder: ["pattern", "flags"],
473 deprecatedAlias: "RegexLiteral",
474 aliases: ["Expression", "Pureish", "Literal"],
475 fields: {
476 pattern: {
477 validate: (0, _utils.assertValueType)("string")
478 },
479 flags: {
480 validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), Object.assign(function (node, key, val) {
481 if (!process.env.BABEL_TYPES_8_BREAKING) return;
482 const invalid = /[^gimsuy]/.exec(val);
483
484 if (invalid) {
485 throw new TypeError(`"${invalid[0]}" is not a valid RegExp flag`);
486 }
487 }, {
488 type: "string"
489 })),
490 default: ""
491 }
492 }
493});
494(0, _utils.default)("LogicalExpression", {
495 builder: ["operator", "left", "right"],
496 visitor: ["left", "right"],
497 aliases: ["Binary", "Expression"],
498 fields: {
499 operator: {
500 validate: (0, _utils.assertOneOf)(..._constants.LOGICAL_OPERATORS)
501 },
502 left: {
503 validate: (0, _utils.assertNodeType)("Expression")
504 },
505 right: {
506 validate: (0, _utils.assertNodeType)("Expression")
507 }
508 }
509});
510(0, _utils.default)("MemberExpression", {
511 builder: ["object", "property", "computed", ...(!process.env.BABEL_TYPES_8_BREAKING ? ["optional"] : [])],
512 visitor: ["object", "property"],
513 aliases: ["Expression", "LVal"],
514 fields: Object.assign({
515 object: {
516 validate: (0, _utils.assertNodeType)("Expression")
517 },
518 property: {
519 validate: function () {
520 const normal = (0, _utils.assertNodeType)("Identifier", "PrivateName");
521 const computed = (0, _utils.assertNodeType)("Expression");
522
523 const validator = function (node, key, val) {
524 const validator = node.computed ? computed : normal;
525 validator(node, key, val);
526 };
527
528 validator.oneOfNodeTypes = ["Expression", "Identifier", "PrivateName"];
529 return validator;
530 }()
531 },
532 computed: {
533 default: false
534 }
535 }, !process.env.BABEL_TYPES_8_BREAKING ? {
536 optional: {
537 validate: (0, _utils.assertOneOf)(true, false),
538 optional: true
539 }
540 } : {})
541});
542(0, _utils.default)("NewExpression", {
543 inherits: "CallExpression"
544});
545(0, _utils.default)("Program", {
546 visitor: ["directives", "body"],
547 builder: ["body", "directives", "sourceType", "interpreter"],
548 fields: {
549 sourceFile: {
550 validate: (0, _utils.assertValueType)("string")
551 },
552 sourceType: {
553 validate: (0, _utils.assertOneOf)("script", "module"),
554 default: "script"
555 },
556 interpreter: {
557 validate: (0, _utils.assertNodeType)("InterpreterDirective"),
558 default: null,
559 optional: true
560 },
561 directives: {
562 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Directive"))),
563 default: []
564 },
565 body: {
566 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement")))
567 }
568 },
569 aliases: ["Scopable", "BlockParent", "Block"]
570});
571(0, _utils.default)("ObjectExpression", {
572 visitor: ["properties"],
573 aliases: ["Expression"],
574 fields: {
575 properties: {
576 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ObjectMethod", "ObjectProperty", "SpreadElement")))
577 }
578 }
579});
580(0, _utils.default)("ObjectMethod", {
581 builder: ["kind", "key", "params", "body", "computed", "generator", "async"],
582 fields: Object.assign({}, functionCommon, functionTypeAnnotationCommon, {
583 kind: Object.assign({
584 validate: (0, _utils.assertOneOf)("method", "get", "set")
585 }, !process.env.BABEL_TYPES_8_BREAKING ? {
586 default: "method"
587 } : {}),
588 computed: {
589 default: false
590 },
591 key: {
592 validate: function () {
593 const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral");
594 const computed = (0, _utils.assertNodeType)("Expression");
595
596 const validator = function (node, key, val) {
597 const validator = node.computed ? computed : normal;
598 validator(node, key, val);
599 };
600
601 validator.oneOfNodeTypes = ["Expression", "Identifier", "StringLiteral", "NumericLiteral"];
602 return validator;
603 }()
604 },
605 decorators: {
606 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
607 optional: true
608 },
609 body: {
610 validate: (0, _utils.assertNodeType)("BlockStatement")
611 }
612 }),
613 visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"],
614 aliases: ["UserWhitespacable", "Function", "Scopable", "BlockParent", "FunctionParent", "Method", "ObjectMember"]
615});
616(0, _utils.default)("ObjectProperty", {
617 builder: ["key", "value", "computed", "shorthand", ...(!process.env.BABEL_TYPES_8_BREAKING ? ["decorators"] : [])],
618 fields: {
619 computed: {
620 default: false
621 },
622 key: {
623 validate: function () {
624 const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral");
625 const computed = (0, _utils.assertNodeType)("Expression");
626
627 const validator = function (node, key, val) {
628 const validator = node.computed ? computed : normal;
629 validator(node, key, val);
630 };
631
632 validator.oneOfNodeTypes = ["Expression", "Identifier", "StringLiteral", "NumericLiteral"];
633 return validator;
634 }()
635 },
636 value: {
637 validate: (0, _utils.assertNodeType)("Expression", "PatternLike")
638 },
639 shorthand: {
640 validate: (0, _utils.chain)((0, _utils.assertValueType)("boolean"), Object.assign(function (node, key, val) {
641 if (!process.env.BABEL_TYPES_8_BREAKING) return;
642
643 if (val && node.computed) {
644 throw new TypeError("Property shorthand of ObjectProperty cannot be true if computed is true");
645 }
646 }, {
647 type: "boolean"
648 }), function (node, key, val) {
649 if (!process.env.BABEL_TYPES_8_BREAKING) return;
650
651 if (val && !(0, _is.default)("Identifier", node.key)) {
652 throw new TypeError("Property shorthand of ObjectProperty cannot be true if key is not an Identifier");
653 }
654 }),
655 default: false
656 },
657 decorators: {
658 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
659 optional: true
660 }
661 },
662 visitor: ["key", "value", "decorators"],
663 aliases: ["UserWhitespacable", "Property", "ObjectMember"],
664 validate: function () {
665 const pattern = (0, _utils.assertNodeType)("Identifier", "Pattern");
666 const expression = (0, _utils.assertNodeType)("Expression");
667 return function (parent, key, node) {
668 if (!process.env.BABEL_TYPES_8_BREAKING) return;
669 const validator = (0, _is.default)("ObjectPattern", parent) ? pattern : expression;
670 validator(node, "value", node.value);
671 };
672 }()
673});
674(0, _utils.default)("RestElement", {
675 visitor: ["argument", "typeAnnotation"],
676 builder: ["argument"],
677 aliases: ["LVal", "PatternLike"],
678 deprecatedAlias: "RestProperty",
679 fields: Object.assign({}, patternLikeCommon, {
680 argument: {
681 validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern", "MemberExpression")
682 },
683 optional: {
684 validate: (0, _utils.assertValueType)("boolean"),
685 optional: true
686 }
687 }),
688
689 validate(parent, key) {
690 if (!process.env.BABEL_TYPES_8_BREAKING) return;
691 const match = /(\w+)\[(\d+)\]/.exec(key);
692 if (!match) throw new Error("Internal Babel error: malformed key.");
693 const [, listKey, index] = match;
694
695 if (parent[listKey].length > index + 1) {
696 throw new TypeError(`RestElement must be last element of ${listKey}`);
697 }
698 }
699
700});
701(0, _utils.default)("ReturnStatement", {
702 visitor: ["argument"],
703 aliases: ["Statement", "Terminatorless", "CompletionStatement"],
704 fields: {
705 argument: {
706 validate: (0, _utils.assertNodeType)("Expression"),
707 optional: true
708 }
709 }
710});
711(0, _utils.default)("SequenceExpression", {
712 visitor: ["expressions"],
713 fields: {
714 expressions: {
715 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression")))
716 }
717 },
718 aliases: ["Expression"]
719});
720(0, _utils.default)("ParenthesizedExpression", {
721 visitor: ["expression"],
722 aliases: ["Expression", "ExpressionWrapper"],
723 fields: {
724 expression: {
725 validate: (0, _utils.assertNodeType)("Expression")
726 }
727 }
728});
729(0, _utils.default)("SwitchCase", {
730 visitor: ["test", "consequent"],
731 fields: {
732 test: {
733 validate: (0, _utils.assertNodeType)("Expression"),
734 optional: true
735 },
736 consequent: {
737 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement")))
738 }
739 }
740});
741(0, _utils.default)("SwitchStatement", {
742 visitor: ["discriminant", "cases"],
743 aliases: ["Statement", "BlockParent", "Scopable"],
744 fields: {
745 discriminant: {
746 validate: (0, _utils.assertNodeType)("Expression")
747 },
748 cases: {
749 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("SwitchCase")))
750 }
751 }
752});
753(0, _utils.default)("ThisExpression", {
754 aliases: ["Expression"]
755});
756(0, _utils.default)("ThrowStatement", {
757 visitor: ["argument"],
758 aliases: ["Statement", "Terminatorless", "CompletionStatement"],
759 fields: {
760 argument: {
761 validate: (0, _utils.assertNodeType)("Expression")
762 }
763 }
764});
765(0, _utils.default)("TryStatement", {
766 visitor: ["block", "handler", "finalizer"],
767 aliases: ["Statement"],
768 fields: {
769 block: {
770 validate: (0, _utils.chain)((0, _utils.assertNodeType)("BlockStatement"), Object.assign(function (node) {
771 if (!process.env.BABEL_TYPES_8_BREAKING) return;
772
773 if (!node.handler && !node.finalizer) {
774 throw new TypeError("TryStatement expects either a handler or finalizer, or both");
775 }
776 }, {
777 oneOfNodeTypes: ["BlockStatement"]
778 }))
779 },
780 handler: {
781 optional: true,
782 validate: (0, _utils.assertNodeType)("CatchClause")
783 },
784 finalizer: {
785 optional: true,
786 validate: (0, _utils.assertNodeType)("BlockStatement")
787 }
788 }
789});
790(0, _utils.default)("UnaryExpression", {
791 builder: ["operator", "argument", "prefix"],
792 fields: {
793 prefix: {
794 default: true
795 },
796 argument: {
797 validate: (0, _utils.assertNodeType)("Expression")
798 },
799 operator: {
800 validate: (0, _utils.assertOneOf)(..._constants.UNARY_OPERATORS)
801 }
802 },
803 visitor: ["argument"],
804 aliases: ["UnaryLike", "Expression"]
805});
806(0, _utils.default)("UpdateExpression", {
807 builder: ["operator", "argument", "prefix"],
808 fields: {
809 prefix: {
810 default: false
811 },
812 argument: {
813 validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("Expression") : (0, _utils.assertNodeType)("Identifier", "MemberExpression")
814 },
815 operator: {
816 validate: (0, _utils.assertOneOf)(..._constants.UPDATE_OPERATORS)
817 }
818 },
819 visitor: ["argument"],
820 aliases: ["Expression"]
821});
822(0, _utils.default)("VariableDeclaration", {
823 builder: ["kind", "declarations"],
824 visitor: ["declarations"],
825 aliases: ["Statement", "Declaration"],
826 fields: {
827 declare: {
828 validate: (0, _utils.assertValueType)("boolean"),
829 optional: true
830 },
831 kind: {
832 validate: (0, _utils.assertOneOf)("var", "let", "const")
833 },
834 declarations: {
835 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("VariableDeclarator")))
836 }
837 },
838
839 validate(parent, key, node) {
840 if (!process.env.BABEL_TYPES_8_BREAKING) return;
841 if (!(0, _is.default)("ForXStatement", parent, {
842 left: node
843 })) return;
844
845 if (node.declarations.length !== 1) {
846 throw new TypeError(`Exactly one VariableDeclarator is required in the VariableDeclaration of a ${parent.type}`);
847 }
848 }
849
850});
851(0, _utils.default)("VariableDeclarator", {
852 visitor: ["id", "init"],
853 fields: {
854 id: {
855 validate: function () {
856 if (!process.env.BABEL_TYPES_8_BREAKING) {
857 return (0, _utils.assertNodeType)("LVal");
858 }
859
860 const normal = (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern");
861 const without = (0, _utils.assertNodeType)("Identifier");
862 return function (node, key, val) {
863 const validator = node.init ? normal : without;
864 validator(node, key, val);
865 };
866 }()
867 },
868 definite: {
869 optional: true,
870 validate: (0, _utils.assertValueType)("boolean")
871 },
872 init: {
873 optional: true,
874 validate: (0, _utils.assertNodeType)("Expression")
875 }
876 }
877});
878(0, _utils.default)("WhileStatement", {
879 visitor: ["test", "body"],
880 aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"],
881 fields: {
882 test: {
883 validate: (0, _utils.assertNodeType)("Expression")
884 },
885 body: {
886 validate: (0, _utils.assertNodeType)("Statement")
887 }
888 }
889});
890(0, _utils.default)("WithStatement", {
891 visitor: ["object", "body"],
892 aliases: ["Statement"],
893 fields: {
894 object: {
895 validate: (0, _utils.assertNodeType)("Expression")
896 },
897 body: {
898 validate: (0, _utils.assertNodeType)("Statement")
899 }
900 }
901});
902(0, _utils.default)("AssignmentPattern", {
903 visitor: ["left", "right", "decorators"],
904 builder: ["left", "right"],
905 aliases: ["Pattern", "PatternLike", "LVal"],
906 fields: Object.assign({}, patternLikeCommon, {
907 left: {
908 validate: (0, _utils.assertNodeType)("Identifier", "ObjectPattern", "ArrayPattern", "MemberExpression")
909 },
910 right: {
911 validate: (0, _utils.assertNodeType)("Expression")
912 },
913 decorators: {
914 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
915 optional: true
916 }
917 })
918});
919(0, _utils.default)("ArrayPattern", {
920 visitor: ["elements", "typeAnnotation"],
921 builder: ["elements"],
922 aliases: ["Pattern", "PatternLike", "LVal"],
923 fields: Object.assign({}, patternLikeCommon, {
924 elements: {
925 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "PatternLike")))
926 },
927 decorators: {
928 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
929 optional: true
930 },
931 optional: {
932 validate: (0, _utils.assertValueType)("boolean"),
933 optional: true
934 }
935 })
936});
937(0, _utils.default)("ArrowFunctionExpression", {
938 builder: ["params", "body", "async"],
939 visitor: ["params", "body", "returnType", "typeParameters"],
940 aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"],
941 fields: Object.assign({}, functionCommon, functionTypeAnnotationCommon, {
942 expression: {
943 validate: (0, _utils.assertValueType)("boolean")
944 },
945 body: {
946 validate: (0, _utils.assertNodeType)("BlockStatement", "Expression")
947 }
948 })
949});
950(0, _utils.default)("ClassBody", {
951 visitor: ["body"],
952 fields: {
953 body: {
954 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ClassMethod", "ClassPrivateMethod", "ClassProperty", "ClassPrivateProperty", "TSDeclareMethod", "TSIndexSignature")))
955 }
956 }
957});
958(0, _utils.default)("ClassExpression", {
959 builder: ["id", "superClass", "body", "decorators"],
960 visitor: ["id", "body", "superClass", "mixins", "typeParameters", "superTypeParameters", "implements", "decorators"],
961 aliases: ["Scopable", "Class", "Expression"],
962 fields: {
963 id: {
964 validate: (0, _utils.assertNodeType)("Identifier"),
965 optional: true
966 },
967 typeParameters: {
968 validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"),
969 optional: true
970 },
971 body: {
972 validate: (0, _utils.assertNodeType)("ClassBody")
973 },
974 superClass: {
975 optional: true,
976 validate: (0, _utils.assertNodeType)("Expression")
977 },
978 superTypeParameters: {
979 validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
980 optional: true
981 },
982 implements: {
983 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSExpressionWithTypeArguments", "ClassImplements"))),
984 optional: true
985 },
986 decorators: {
987 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
988 optional: true
989 },
990 mixins: {
991 validate: (0, _utils.assertNodeType)("InterfaceExtends"),
992 optional: true
993 }
994 }
995});
996(0, _utils.default)("ClassDeclaration", {
997 inherits: "ClassExpression",
998 aliases: ["Scopable", "Class", "Statement", "Declaration"],
999 fields: {
1000 id: {
1001 validate: (0, _utils.assertNodeType)("Identifier")
1002 },
1003 typeParameters: {
1004 validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"),
1005 optional: true
1006 },
1007 body: {
1008 validate: (0, _utils.assertNodeType)("ClassBody")
1009 },
1010 superClass: {
1011 optional: true,
1012 validate: (0, _utils.assertNodeType)("Expression")
1013 },
1014 superTypeParameters: {
1015 validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
1016 optional: true
1017 },
1018 implements: {
1019 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSExpressionWithTypeArguments", "ClassImplements"))),
1020 optional: true
1021 },
1022 decorators: {
1023 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
1024 optional: true
1025 },
1026 mixins: {
1027 validate: (0, _utils.assertNodeType)("InterfaceExtends"),
1028 optional: true
1029 },
1030 declare: {
1031 validate: (0, _utils.assertValueType)("boolean"),
1032 optional: true
1033 },
1034 abstract: {
1035 validate: (0, _utils.assertValueType)("boolean"),
1036 optional: true
1037 }
1038 },
1039 validate: function () {
1040 const identifier = (0, _utils.assertNodeType)("Identifier");
1041 return function (parent, key, node) {
1042 if (!process.env.BABEL_TYPES_8_BREAKING) return;
1043
1044 if (!(0, _is.default)("ExportDefaultDeclaration", parent)) {
1045 identifier(node, "id", node.id);
1046 }
1047 };
1048 }()
1049});
1050(0, _utils.default)("ExportAllDeclaration", {
1051 visitor: ["source"],
1052 aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
1053 fields: {
1054 source: {
1055 validate: (0, _utils.assertNodeType)("StringLiteral")
1056 },
1057 exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")),
1058 assertions: {
1059 optional: true,
1060 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute")))
1061 }
1062 }
1063});
1064(0, _utils.default)("ExportDefaultDeclaration", {
1065 visitor: ["declaration"],
1066 aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
1067 fields: {
1068 declaration: {
1069 validate: (0, _utils.assertNodeType)("FunctionDeclaration", "TSDeclareFunction", "ClassDeclaration", "Expression")
1070 },
1071 exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("value"))
1072 }
1073});
1074(0, _utils.default)("ExportNamedDeclaration", {
1075 visitor: ["declaration", "specifiers", "source"],
1076 aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
1077 fields: {
1078 declaration: {
1079 optional: true,
1080 validate: (0, _utils.chain)((0, _utils.assertNodeType)("Declaration"), Object.assign(function (node, key, val) {
1081 if (!process.env.BABEL_TYPES_8_BREAKING) return;
1082
1083 if (val && node.specifiers.length) {
1084 throw new TypeError("Only declaration or specifiers is allowed on ExportNamedDeclaration");
1085 }
1086 }, {
1087 oneOfNodeTypes: ["Declaration"]
1088 }), function (node, key, val) {
1089 if (!process.env.BABEL_TYPES_8_BREAKING) return;
1090
1091 if (val && node.source) {
1092 throw new TypeError("Cannot export a declaration from a source");
1093 }
1094 })
1095 },
1096 assertions: {
1097 optional: true,
1098 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute")))
1099 },
1100 specifiers: {
1101 default: [],
1102 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)(function () {
1103 const sourced = (0, _utils.assertNodeType)("ExportSpecifier", "ExportDefaultSpecifier", "ExportNamespaceSpecifier");
1104 const sourceless = (0, _utils.assertNodeType)("ExportSpecifier");
1105 if (!process.env.BABEL_TYPES_8_BREAKING) return sourced;
1106 return function (node, key, val) {
1107 const validator = node.source ? sourced : sourceless;
1108 validator(node, key, val);
1109 };
1110 }()))
1111 },
1112 source: {
1113 validate: (0, _utils.assertNodeType)("StringLiteral"),
1114 optional: true
1115 },
1116 exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value"))
1117 }
1118});
1119(0, _utils.default)("ExportSpecifier", {
1120 visitor: ["local", "exported"],
1121 aliases: ["ModuleSpecifier"],
1122 fields: {
1123 local: {
1124 validate: (0, _utils.assertNodeType)("Identifier")
1125 },
1126 exported: {
1127 validate: (0, _utils.assertNodeType)("Identifier", "StringLiteral")
1128 }
1129 }
1130});
1131(0, _utils.default)("ForOfStatement", {
1132 visitor: ["left", "right", "body"],
1133 builder: ["left", "right", "body", "await"],
1134 aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"],
1135 fields: {
1136 left: {
1137 validate: function () {
1138 if (!process.env.BABEL_TYPES_8_BREAKING) {
1139 return (0, _utils.assertNodeType)("VariableDeclaration", "LVal");
1140 }
1141
1142 const declaration = (0, _utils.assertNodeType)("VariableDeclaration");
1143 const lval = (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern");
1144 return function (node, key, val) {
1145 if ((0, _is.default)("VariableDeclaration", val)) {
1146 declaration(node, key, val);
1147 } else {
1148 lval(node, key, val);
1149 }
1150 };
1151 }()
1152 },
1153 right: {
1154 validate: (0, _utils.assertNodeType)("Expression")
1155 },
1156 body: {
1157 validate: (0, _utils.assertNodeType)("Statement")
1158 },
1159 await: {
1160 default: false
1161 }
1162 }
1163});
1164(0, _utils.default)("ImportDeclaration", {
1165 visitor: ["specifiers", "source"],
1166 aliases: ["Statement", "Declaration", "ModuleDeclaration"],
1167 fields: {
1168 assertions: {
1169 optional: true,
1170 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute")))
1171 },
1172 specifiers: {
1173 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportSpecifier", "ImportDefaultSpecifier", "ImportNamespaceSpecifier")))
1174 },
1175 source: {
1176 validate: (0, _utils.assertNodeType)("StringLiteral")
1177 },
1178 importKind: {
1179 validate: (0, _utils.assertOneOf)("type", "typeof", "value"),
1180 optional: true
1181 }
1182 }
1183});
1184(0, _utils.default)("ImportDefaultSpecifier", {
1185 visitor: ["local"],
1186 aliases: ["ModuleSpecifier"],
1187 fields: {
1188 local: {
1189 validate: (0, _utils.assertNodeType)("Identifier")
1190 }
1191 }
1192});
1193(0, _utils.default)("ImportNamespaceSpecifier", {
1194 visitor: ["local"],
1195 aliases: ["ModuleSpecifier"],
1196 fields: {
1197 local: {
1198 validate: (0, _utils.assertNodeType)("Identifier")
1199 }
1200 }
1201});
1202(0, _utils.default)("ImportSpecifier", {
1203 visitor: ["local", "imported"],
1204 aliases: ["ModuleSpecifier"],
1205 fields: {
1206 local: {
1207 validate: (0, _utils.assertNodeType)("Identifier")
1208 },
1209 imported: {
1210 validate: (0, _utils.assertNodeType)("Identifier", "StringLiteral")
1211 },
1212 importKind: {
1213 validate: (0, _utils.assertOneOf)("type", "typeof"),
1214 optional: true
1215 }
1216 }
1217});
1218(0, _utils.default)("MetaProperty", {
1219 visitor: ["meta", "property"],
1220 aliases: ["Expression"],
1221 fields: {
1222 meta: {
1223 validate: (0, _utils.chain)((0, _utils.assertNodeType)("Identifier"), Object.assign(function (node, key, val) {
1224 if (!process.env.BABEL_TYPES_8_BREAKING) return;
1225 let property;
1226
1227 switch (val.name) {
1228 case "function":
1229 property = "sent";
1230 break;
1231
1232 case "new":
1233 property = "target";
1234 break;
1235
1236 case "import":
1237 property = "meta";
1238 break;
1239 }
1240
1241 if (!(0, _is.default)("Identifier", node.property, {
1242 name: property
1243 })) {
1244 throw new TypeError("Unrecognised MetaProperty");
1245 }
1246 }, {
1247 oneOfNodeTypes: ["Identifier"]
1248 }))
1249 },
1250 property: {
1251 validate: (0, _utils.assertNodeType)("Identifier")
1252 }
1253 }
1254});
1255const classMethodOrPropertyCommon = {
1256 abstract: {
1257 validate: (0, _utils.assertValueType)("boolean"),
1258 optional: true
1259 },
1260 accessibility: {
1261 validate: (0, _utils.assertOneOf)("public", "private", "protected"),
1262 optional: true
1263 },
1264 static: {
1265 default: false
1266 },
1267 override: {
1268 default: false
1269 },
1270 computed: {
1271 default: false
1272 },
1273 optional: {
1274 validate: (0, _utils.assertValueType)("boolean"),
1275 optional: true
1276 },
1277 key: {
1278 validate: (0, _utils.chain)(function () {
1279 const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral");
1280 const computed = (0, _utils.assertNodeType)("Expression");
1281 return function (node, key, val) {
1282 const validator = node.computed ? computed : normal;
1283 validator(node, key, val);
1284 };
1285 }(), (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral", "Expression"))
1286 }
1287};
1288exports.classMethodOrPropertyCommon = classMethodOrPropertyCommon;
1289const classMethodOrDeclareMethodCommon = Object.assign({}, functionCommon, classMethodOrPropertyCommon, {
1290 params: {
1291 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Identifier", "Pattern", "RestElement", "TSParameterProperty")))
1292 },
1293 kind: {
1294 validate: (0, _utils.assertOneOf)("get", "set", "method", "constructor"),
1295 default: "method"
1296 },
1297 access: {
1298 validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("public", "private", "protected")),
1299 optional: true
1300 },
1301 decorators: {
1302 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
1303 optional: true
1304 }
1305});
1306exports.classMethodOrDeclareMethodCommon = classMethodOrDeclareMethodCommon;
1307(0, _utils.default)("ClassMethod", {
1308 aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method"],
1309 builder: ["kind", "key", "params", "body", "computed", "static", "generator", "async"],
1310 visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"],
1311 fields: Object.assign({}, classMethodOrDeclareMethodCommon, functionTypeAnnotationCommon, {
1312 body: {
1313 validate: (0, _utils.assertNodeType)("BlockStatement")
1314 }
1315 })
1316});
1317(0, _utils.default)("ObjectPattern", {
1318 visitor: ["properties", "typeAnnotation", "decorators"],
1319 builder: ["properties"],
1320 aliases: ["Pattern", "PatternLike", "LVal"],
1321 fields: Object.assign({}, patternLikeCommon, {
1322 properties: {
1323 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("RestElement", "ObjectProperty")))
1324 }
1325 })
1326});
1327(0, _utils.default)("SpreadElement", {
1328 visitor: ["argument"],
1329 aliases: ["UnaryLike"],
1330 deprecatedAlias: "SpreadProperty",
1331 fields: {
1332 argument: {
1333 validate: (0, _utils.assertNodeType)("Expression")
1334 }
1335 }
1336});
1337(0, _utils.default)("Super", {
1338 aliases: ["Expression"]
1339});
1340(0, _utils.default)("TaggedTemplateExpression", {
1341 visitor: ["tag", "quasi", "typeParameters"],
1342 builder: ["tag", "quasi"],
1343 aliases: ["Expression"],
1344 fields: {
1345 tag: {
1346 validate: (0, _utils.assertNodeType)("Expression")
1347 },
1348 quasi: {
1349 validate: (0, _utils.assertNodeType)("TemplateLiteral")
1350 },
1351 typeParameters: {
1352 validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
1353 optional: true
1354 }
1355 }
1356});
1357(0, _utils.default)("TemplateElement", {
1358 builder: ["value", "tail"],
1359 fields: {
1360 value: {
1361 validate: (0, _utils.assertShape)({
1362 raw: {
1363 validate: (0, _utils.assertValueType)("string")
1364 },
1365 cooked: {
1366 validate: (0, _utils.assertValueType)("string"),
1367 optional: true
1368 }
1369 })
1370 },
1371 tail: {
1372 default: false
1373 }
1374 }
1375});
1376(0, _utils.default)("TemplateLiteral", {
1377 visitor: ["quasis", "expressions"],
1378 aliases: ["Expression", "Literal"],
1379 fields: {
1380 quasis: {
1381 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TemplateElement")))
1382 },
1383 expressions: {
1384 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "TSType")), function (node, key, val) {
1385 if (node.quasis.length !== val.length + 1) {
1386 throw new TypeError(`Number of ${node.type} quasis should be exactly one more than the number of expressions.\nExpected ${val.length + 1} quasis but got ${node.quasis.length}`);
1387 }
1388 })
1389 }
1390 }
1391});
1392(0, _utils.default)("YieldExpression", {
1393 builder: ["argument", "delegate"],
1394 visitor: ["argument"],
1395 aliases: ["Expression", "Terminatorless"],
1396 fields: {
1397 delegate: {
1398 validate: (0, _utils.chain)((0, _utils.assertValueType)("boolean"), Object.assign(function (node, key, val) {
1399 if (!process.env.BABEL_TYPES_8_BREAKING) return;
1400
1401 if (val && !node.argument) {
1402 throw new TypeError("Property delegate of YieldExpression cannot be true if there is no argument");
1403 }
1404 }, {
1405 type: "boolean"
1406 })),
1407 default: false
1408 },
1409 argument: {
1410 optional: true,
1411 validate: (0, _utils.assertNodeType)("Expression")
1412 }
1413 }
1414});
1415(0, _utils.default)("AwaitExpression", {
1416 builder: ["argument"],
1417 visitor: ["argument"],
1418 aliases: ["Expression", "Terminatorless"],
1419 fields: {
1420 argument: {
1421 validate: (0, _utils.assertNodeType)("Expression")
1422 }
1423 }
1424});
1425(0, _utils.default)("Import", {
1426 aliases: ["Expression"]
1427});
1428(0, _utils.default)("BigIntLiteral", {
1429 builder: ["value"],
1430 fields: {
1431 value: {
1432 validate: (0, _utils.assertValueType)("string")
1433 }
1434 },
1435 aliases: ["Expression", "Pureish", "Literal", "Immutable"]
1436});
1437(0, _utils.default)("ExportNamespaceSpecifier", {
1438 visitor: ["exported"],
1439 aliases: ["ModuleSpecifier"],
1440 fields: {
1441 exported: {
1442 validate: (0, _utils.assertNodeType)("Identifier")
1443 }
1444 }
1445});
1446(0, _utils.default)("OptionalMemberExpression", {
1447 builder: ["object", "property", "computed", "optional"],
1448 visitor: ["object", "property"],
1449 aliases: ["Expression"],
1450 fields: {
1451 object: {
1452 validate: (0, _utils.assertNodeType)("Expression")
1453 },
1454 property: {
1455 validate: function () {
1456 const normal = (0, _utils.assertNodeType)("Identifier");
1457 const computed = (0, _utils.assertNodeType)("Expression");
1458
1459 const validator = function (node, key, val) {
1460 const validator = node.computed ? computed : normal;
1461 validator(node, key, val);
1462 };
1463
1464 validator.oneOfNodeTypes = ["Expression", "Identifier"];
1465 return validator;
1466 }()
1467 },
1468 computed: {
1469 default: false
1470 },
1471 optional: {
1472 validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertValueType)("boolean") : (0, _utils.chain)((0, _utils.assertValueType)("boolean"), (0, _utils.assertOptionalChainStart)())
1473 }
1474 }
1475});
1476(0, _utils.default)("OptionalCallExpression", {
1477 visitor: ["callee", "arguments", "typeParameters", "typeArguments"],
1478 builder: ["callee", "arguments", "optional"],
1479 aliases: ["Expression"],
1480 fields: {
1481 callee: {
1482 validate: (0, _utils.assertNodeType)("Expression")
1483 },
1484 arguments: {
1485 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName", "ArgumentPlaceholder")))
1486 },
1487 optional: {
1488 validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertValueType)("boolean") : (0, _utils.chain)((0, _utils.assertValueType)("boolean"), (0, _utils.assertOptionalChainStart)())
1489 },
1490 typeArguments: {
1491 validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"),
1492 optional: true
1493 },
1494 typeParameters: {
1495 validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"),
1496 optional: true
1497 }
1498 }
1499});
1500(0, _utils.default)("ClassProperty", {
1501 visitor: ["key", "value", "typeAnnotation", "decorators"],
1502 builder: ["key", "value", "typeAnnotation", "decorators", "computed", "static"],
1503 aliases: ["Property"],
1504 fields: Object.assign({}, classMethodOrPropertyCommon, {
1505 value: {
1506 validate: (0, _utils.assertNodeType)("Expression"),
1507 optional: true
1508 },
1509 definite: {
1510 validate: (0, _utils.assertValueType)("boolean"),
1511 optional: true
1512 },
1513 typeAnnotation: {
1514 validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"),
1515 optional: true
1516 },
1517 decorators: {
1518 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
1519 optional: true
1520 },
1521 readonly: {
1522 validate: (0, _utils.assertValueType)("boolean"),
1523 optional: true
1524 },
1525 declare: {
1526 validate: (0, _utils.assertValueType)("boolean"),
1527 optional: true
1528 },
1529 variance: {
1530 validate: (0, _utils.assertNodeType)("Variance"),
1531 optional: true
1532 }
1533 })
1534});
1535(0, _utils.default)("ClassPrivateProperty", {
1536 visitor: ["key", "value", "decorators", "typeAnnotation"],
1537 builder: ["key", "value", "decorators", "static"],
1538 aliases: ["Property", "Private"],
1539 fields: {
1540 key: {
1541 validate: (0, _utils.assertNodeType)("PrivateName")
1542 },
1543 value: {
1544 validate: (0, _utils.assertNodeType)("Expression"),
1545 optional: true
1546 },
1547 typeAnnotation: {
1548 validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"),
1549 optional: true
1550 },
1551 decorators: {
1552 validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
1553 optional: true
1554 },
1555 readonly: {
1556 validate: (0, _utils.assertValueType)("boolean"),
1557 optional: true
1558 },
1559 definite: {
1560 validate: (0, _utils.assertValueType)("boolean"),
1561 optional: true
1562 },
1563 variance: {
1564 validate: (0, _utils.assertNodeType)("Variance"),
1565 optional: true
1566 }
1567 }
1568});
1569(0, _utils.default)("ClassPrivateMethod", {
1570 builder: ["kind", "key", "params", "body", "static"],
1571 visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"],
1572 aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method", "Private"],
1573 fields: Object.assign({}, classMethodOrDeclareMethodCommon, functionTypeAnnotationCommon, {
1574 key: {
1575 validate: (0, _utils.assertNodeType)("PrivateName")
1576 },
1577 body: {
1578 validate: (0, _utils.assertNodeType)("BlockStatement")
1579 }
1580 })
1581});
1582(0, _utils.default)("PrivateName", {
1583 visitor: ["id"],
1584 aliases: ["Private"],
1585 fields: {
1586 id: {
1587 validate: (0, _utils.assertNodeType)("Identifier")
1588 }
1589 }
1590});
Note: See TracBrowser for help on using the repository browser.