Commit 762b95bc authored by Cholgrrr's avatar Cholgrrr
Browse files

Merge branch 'New_Structure' of https://gitlab.com/Cholgrrr/m4labplatform into New_Structure

parents 613a2f33 a2e8cafb
...@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = addComment; exports.default = addComment;
var _addComments = _interopRequireDefault(require("./addComments")); var _addComments = require("./addComments");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function addComment(node, type, content, line) { function addComment(node, type, content, line) {
return (0, _addComments.default)(node, type, [{ return (0, _addComments.default)(node, type, [{
......
...@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = inheritInnerComments; exports.default = inheritInnerComments;
var _inherit = _interopRequireDefault(require("../utils/inherit")); var _inherit = require("../utils/inherit");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function inheritInnerComments(child, parent) { function inheritInnerComments(child, parent) {
(0, _inherit.default)("innerComments", child, parent); (0, _inherit.default)("innerComments", child, parent);
......
...@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = inheritLeadingComments; exports.default = inheritLeadingComments;
var _inherit = _interopRequireDefault(require("../utils/inherit")); var _inherit = require("../utils/inherit");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function inheritLeadingComments(child, parent) { function inheritLeadingComments(child, parent) {
(0, _inherit.default)("leadingComments", child, parent); (0, _inherit.default)("leadingComments", child, parent);
......
...@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = inheritTrailingComments; exports.default = inheritTrailingComments;
var _inherit = _interopRequireDefault(require("../utils/inherit")); var _inherit = require("../utils/inherit");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function inheritTrailingComments(child, parent) { function inheritTrailingComments(child, parent) {
(0, _inherit.default)("trailingComments", child, parent); (0, _inherit.default)("trailingComments", child, parent);
......
...@@ -5,13 +5,11 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,13 +5,11 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = inheritsComments; exports.default = inheritsComments;
var _inheritTrailingComments = _interopRequireDefault(require("./inheritTrailingComments")); var _inheritTrailingComments = require("./inheritTrailingComments");
var _inheritLeadingComments = _interopRequireDefault(require("./inheritLeadingComments")); var _inheritLeadingComments = require("./inheritLeadingComments");
var _inheritInnerComments = _interopRequireDefault(require("./inheritInnerComments")); var _inheritInnerComments = require("./inheritInnerComments");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function inheritsComments(child, parent) { function inheritsComments(child, parent) {
(0, _inheritTrailingComments.default)(child, parent); (0, _inheritTrailingComments.default)(child, parent);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.TSTYPE_TYPES = exports.TSTYPEELEMENT_TYPES = exports.PRIVATE_TYPES = exports.JSX_TYPES = exports.ENUMMEMBER_TYPES = exports.ENUMBODY_TYPES = exports.FLOWPREDICATE_TYPES = exports.FLOWDECLARATION_TYPES = exports.FLOWBASEANNOTATION_TYPES = exports.FLOWTYPE_TYPES = exports.FLOW_TYPES = exports.MODULESPECIFIER_TYPES = exports.EXPORTDECLARATION_TYPES = exports.MODULEDECLARATION_TYPES = exports.CLASS_TYPES = exports.PATTERN_TYPES = exports.UNARYLIKE_TYPES = exports.PROPERTY_TYPES = exports.OBJECTMEMBER_TYPES = exports.METHOD_TYPES = exports.USERWHITESPACABLE_TYPES = exports.IMMUTABLE_TYPES = exports.LITERAL_TYPES = exports.TSENTITYNAME_TYPES = exports.LVAL_TYPES = exports.PATTERNLIKE_TYPES = exports.DECLARATION_TYPES = exports.PUREISH_TYPES = exports.FUNCTIONPARENT_TYPES = exports.FUNCTION_TYPES = exports.FORXSTATEMENT_TYPES = exports.FOR_TYPES = exports.EXPRESSIONWRAPPER_TYPES = exports.WHILE_TYPES = exports.LOOP_TYPES = exports.CONDITIONAL_TYPES = exports.COMPLETIONSTATEMENT_TYPES = exports.TERMINATORLESS_TYPES = exports.STATEMENT_TYPES = exports.BLOCK_TYPES = exports.BLOCKPARENT_TYPES = exports.SCOPABLE_TYPES = exports.BINARY_TYPES = exports.EXPRESSION_TYPES = void 0; exports.TSBASETYPE_TYPES = exports.TSTYPE_TYPES = exports.TSTYPEELEMENT_TYPES = exports.PRIVATE_TYPES = exports.JSX_TYPES = exports.ENUMMEMBER_TYPES = exports.ENUMBODY_TYPES = exports.FLOWPREDICATE_TYPES = exports.FLOWDECLARATION_TYPES = exports.FLOWBASEANNOTATION_TYPES = exports.FLOWTYPE_TYPES = exports.FLOW_TYPES = exports.MODULESPECIFIER_TYPES = exports.EXPORTDECLARATION_TYPES = exports.MODULEDECLARATION_TYPES = exports.CLASS_TYPES = exports.PATTERN_TYPES = exports.UNARYLIKE_TYPES = exports.PROPERTY_TYPES = exports.OBJECTMEMBER_TYPES = exports.METHOD_TYPES = exports.USERWHITESPACABLE_TYPES = exports.IMMUTABLE_TYPES = exports.LITERAL_TYPES = exports.TSENTITYNAME_TYPES = exports.LVAL_TYPES = exports.PATTERNLIKE_TYPES = exports.DECLARATION_TYPES = exports.PUREISH_TYPES = exports.FUNCTIONPARENT_TYPES = exports.FUNCTION_TYPES = exports.FORXSTATEMENT_TYPES = exports.FOR_TYPES = exports.EXPRESSIONWRAPPER_TYPES = exports.WHILE_TYPES = exports.LOOP_TYPES = exports.CONDITIONAL_TYPES = exports.COMPLETIONSTATEMENT_TYPES = exports.TERMINATORLESS_TYPES = exports.STATEMENT_TYPES = exports.BLOCK_TYPES = exports.BLOCKPARENT_TYPES = exports.SCOPABLE_TYPES = exports.BINARY_TYPES = exports.EXPRESSION_TYPES = void 0;
var _definitions = require("../../definitions"); var _definitions = require("../../definitions");
...@@ -94,4 +94,6 @@ exports.PRIVATE_TYPES = PRIVATE_TYPES; ...@@ -94,4 +94,6 @@ exports.PRIVATE_TYPES = PRIVATE_TYPES;
const TSTYPEELEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSTypeElement"]; const TSTYPEELEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSTypeElement"];
exports.TSTYPEELEMENT_TYPES = TSTYPEELEMENT_TYPES; exports.TSTYPEELEMENT_TYPES = TSTYPEELEMENT_TYPES;
const TSTYPE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSType"]; const TSTYPE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSType"];
exports.TSTYPE_TYPES = TSTYPE_TYPES; exports.TSTYPE_TYPES = TSTYPE_TYPES;
\ No newline at end of file const TSBASETYPE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSBaseType"];
exports.TSBASETYPE_TYPES = TSBASETYPE_TYPES;
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.NOT_LOCAL_BINDING = exports.BLOCK_SCOPED_SYMBOL = exports.INHERIT_KEYS = exports.UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = exports.NUMBER_UNARY_OPERATORS = exports.BOOLEAN_UNARY_OPERATORS = exports.BINARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = exports.EQUALITY_BINARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = exports.UPDATE_OPERATORS = exports.LOGICAL_OPERATORS = exports.COMMENT_KEYS = exports.FOR_INIT_KEYS = exports.FLATTENABLE_KEYS = exports.STATEMENT_OR_BLOCK_KEYS = void 0; exports.NOT_LOCAL_BINDING = exports.BLOCK_SCOPED_SYMBOL = exports.INHERIT_KEYS = exports.UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = exports.NUMBER_UNARY_OPERATORS = exports.BOOLEAN_UNARY_OPERATORS = exports.ASSIGNMENT_OPERATORS = exports.BINARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = exports.EQUALITY_BINARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = exports.UPDATE_OPERATORS = exports.LOGICAL_OPERATORS = exports.COMMENT_KEYS = exports.FOR_INIT_KEYS = exports.FLATTENABLE_KEYS = exports.STATEMENT_OR_BLOCK_KEYS = void 0;
const STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"]; const STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"];
exports.STATEMENT_OR_BLOCK_KEYS = STATEMENT_OR_BLOCK_KEYS; exports.STATEMENT_OR_BLOCK_KEYS = STATEMENT_OR_BLOCK_KEYS;
const FLATTENABLE_KEYS = ["body", "expressions"]; const FLATTENABLE_KEYS = ["body", "expressions"];
...@@ -28,6 +28,8 @@ const NUMBER_BINARY_OPERATORS = ["-", "/", "%", "*", "**", "&", "|", ">>", ">>>" ...@@ -28,6 +28,8 @@ const NUMBER_BINARY_OPERATORS = ["-", "/", "%", "*", "**", "&", "|", ">>", ">>>"
exports.NUMBER_BINARY_OPERATORS = NUMBER_BINARY_OPERATORS; exports.NUMBER_BINARY_OPERATORS = NUMBER_BINARY_OPERATORS;
const BINARY_OPERATORS = ["+", ...NUMBER_BINARY_OPERATORS, ...BOOLEAN_BINARY_OPERATORS]; const BINARY_OPERATORS = ["+", ...NUMBER_BINARY_OPERATORS, ...BOOLEAN_BINARY_OPERATORS];
exports.BINARY_OPERATORS = BINARY_OPERATORS; exports.BINARY_OPERATORS = BINARY_OPERATORS;
const ASSIGNMENT_OPERATORS = ["=", "+=", ...NUMBER_BINARY_OPERATORS.map(op => op + "="), ...LOGICAL_OPERATORS.map(op => op + "=")];
exports.ASSIGNMENT_OPERATORS = ASSIGNMENT_OPERATORS;
const BOOLEAN_UNARY_OPERATORS = ["delete", "!"]; const BOOLEAN_UNARY_OPERATORS = ["delete", "!"];
exports.BOOLEAN_UNARY_OPERATORS = BOOLEAN_UNARY_OPERATORS; exports.BOOLEAN_UNARY_OPERATORS = BOOLEAN_UNARY_OPERATORS;
const NUMBER_UNARY_OPERATORS = ["+", "-", "~"]; const NUMBER_UNARY_OPERATORS = ["+", "-", "~"];
......
...@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = ensureBlock; exports.default = ensureBlock;
var _toBlock = _interopRequireDefault(require("./toBlock")); var _toBlock = require("./toBlock");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function ensureBlock(node, key = "body") { function ensureBlock(node, key = "body") {
return node[key] = (0, _toBlock.default)(node[key], node); return node[key] = (0, _toBlock.default)(node[key], node);
......
...@@ -5,22 +5,22 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,22 +5,22 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = gatherSequenceExpressions; exports.default = gatherSequenceExpressions;
var _getBindingIdentifiers = _interopRequireDefault(require("../retrievers/getBindingIdentifiers")); var _getBindingIdentifiers = require("../retrievers/getBindingIdentifiers");
var _generated = require("../validators/generated"); var _generated = require("../validators/generated");
var _generated2 = require("../builders/generated"); var _generated2 = require("../builders/generated");
var _cloneNode = _interopRequireDefault(require("../clone/cloneNode")); var _cloneNode = require("../clone/cloneNode");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function gatherSequenceExpressions(nodes, scope, declars) { function gatherSequenceExpressions(nodes, scope, declars) {
const exprs = []; const exprs = [];
let ensureLastUndefined = true; let ensureLastUndefined = true;
for (const node of nodes) { for (const node of nodes) {
ensureLastUndefined = false; if (!(0, _generated.isEmptyStatement)(node)) {
ensureLastUndefined = false;
}
if ((0, _generated.isExpression)(node)) { if ((0, _generated.isExpression)(node)) {
exprs.push(node); exprs.push(node);
...@@ -55,7 +55,9 @@ function gatherSequenceExpressions(nodes, scope, declars) { ...@@ -55,7 +55,9 @@ function gatherSequenceExpressions(nodes, scope, declars) {
if (!body) return; if (!body) return;
exprs.push(body); exprs.push(body);
} else if ((0, _generated.isEmptyStatement)(node)) { } else if ((0, _generated.isEmptyStatement)(node)) {
ensureLastUndefined = true; if (nodes.indexOf(node) === 0) {
ensureLastUndefined = true;
}
} else { } else {
return; return;
} }
......
...@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = toBindingIdentifierName; exports.default = toBindingIdentifierName;
var _toIdentifier = _interopRequireDefault(require("./toIdentifier")); var _toIdentifier = require("./toIdentifier");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function toBindingIdentifierName(name) { function toBindingIdentifierName(name) {
name = (0, _toIdentifier.default)(name); name = (0, _toIdentifier.default)(name);
......
...@@ -3,10 +3,13 @@ ...@@ -3,10 +3,13 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.default = toExpression; exports.default = void 0;
var _generated = require("../validators/generated"); var _generated = require("../validators/generated");
var _default = toExpression;
exports.default = _default;
function toExpression(node) { function toExpression(node) {
if ((0, _generated.isExpressionStatement)(node)) { if ((0, _generated.isExpressionStatement)(node)) {
node = node.expression; node = node.expression;
......
...@@ -5,13 +5,18 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,13 +5,18 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = toIdentifier; exports.default = toIdentifier;
var _isValidIdentifier = _interopRequireDefault(require("../validators/isValidIdentifier")); var _isValidIdentifier = require("../validators/isValidIdentifier");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _helperValidatorIdentifier = require("@babel/helper-validator-identifier");
function toIdentifier(input) {
input = input + "";
let name = "";
for (const c of input) {
name += (0, _helperValidatorIdentifier.isIdentifierChar)(c.codePointAt(0)) ? c : "-";
}
function toIdentifier(name) {
name = name + "";
name = name.replace(/[^a-zA-Z0-9$_]/g, "-");
name = name.replace(/^[-0-9]+/, ""); name = name.replace(/^[-0-9]+/, "");
name = name.replace(/[-\s]+(.)?/g, function (match, c) { name = name.replace(/[-\s]+(.)?/g, function (match, c) {
return c ? c.toUpperCase() : ""; return c ? c.toUpperCase() : "";
......
...@@ -7,11 +7,9 @@ exports.default = toKeyAlias; ...@@ -7,11 +7,9 @@ exports.default = toKeyAlias;
var _generated = require("../validators/generated"); var _generated = require("../validators/generated");
var _cloneNode = _interopRequireDefault(require("../clone/cloneNode")); var _cloneNode = require("../clone/cloneNode");
var _removePropertiesDeep = _interopRequireDefault(require("../modifications/removePropertiesDeep")); var _removePropertiesDeep = require("../modifications/removePropertiesDeep");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function toKeyAlias(node, key = node.key) { function toKeyAlias(node, key = node.key) {
let alias; let alias;
......
...@@ -5,12 +5,10 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,12 +5,10 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = toSequenceExpression; exports.default = toSequenceExpression;
var _gatherSequenceExpressions = _interopRequireDefault(require("./gatherSequenceExpressions")); var _gatherSequenceExpressions = require("./gatherSequenceExpressions");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function toSequenceExpression(nodes, scope) { function toSequenceExpression(nodes, scope) {
if (!nodes || !nodes.length) return; if (!(nodes != null && nodes.length)) return;
const declars = []; const declars = [];
const result = (0, _gatherSequenceExpressions.default)(nodes, scope, declars); const result = (0, _gatherSequenceExpressions.default)(nodes, scope, declars);
if (!result) return; if (!result) return;
......
...@@ -3,12 +3,15 @@ ...@@ -3,12 +3,15 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.default = toStatement; exports.default = void 0;
var _generated = require("../validators/generated"); var _generated = require("../validators/generated");
var _generated2 = require("../builders/generated"); var _generated2 = require("../builders/generated");
var _default = toStatement;
exports.default = _default;
function toStatement(node, ignore) { function toStatement(node, ignore) {
if ((0, _generated.isStatement)(node)) { if ((0, _generated.isStatement)(node)) {
return node; return node;
......
...@@ -3,17 +3,28 @@ ...@@ -3,17 +3,28 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.default = valueToNode; exports.default = void 0;
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject")); var _isValidIdentifier = require("../validators/isValidIdentifier");
var _isRegExp = _interopRequireDefault(require("lodash/isRegExp")); var _generated = require("../builders/generated");
var _isValidIdentifier = _interopRequireDefault(require("../validators/isValidIdentifier")); var _default = valueToNode;
exports.default = _default;
const objectToString = Function.call.bind(Object.prototype.toString);
var _generated = require("../builders/generated"); function isRegExp(value) {
return objectToString(value) === "[object RegExp]";
}
function isPlainObject(value) {
if (typeof value !== "object" || value === null || Object.prototype.toString.call(value) !== "[object Object]") {
return false;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const proto = Object.getPrototypeOf(value);
return proto === null || Object.getPrototypeOf(proto) === null;
}
function valueToNode(value) { function valueToNode(value) {
if (value === undefined) { if (value === undefined) {
...@@ -56,7 +67,7 @@ function valueToNode(value) { ...@@ -56,7 +67,7 @@ function valueToNode(value) {
return result; return result;
} }
if ((0, _isRegExp.default)(value)) { if (isRegExp(value)) {
const pattern = value.source; const pattern = value.source;
const flags = value.toString().match(/\/([a-z]+|)$/)[1]; const flags = value.toString().match(/\/([a-z]+|)$/)[1];
return (0, _generated.regExpLiteral)(pattern, flags); return (0, _generated.regExpLiteral)(pattern, flags);
...@@ -66,7 +77,7 @@ function valueToNode(value) { ...@@ -66,7 +77,7 @@ function valueToNode(value) {
return (0, _generated.arrayExpression)(value.map(valueToNode)); return (0, _generated.arrayExpression)(value.map(valueToNode));
} }
if ((0, _isPlainObject.default)(value)) { if (isPlainObject(value)) {
const props = []; const props = [];
for (const key of Object.keys(value)) { for (const key of Object.keys(value)) {
......
...@@ -3,25 +3,23 @@ ...@@ -3,25 +3,23 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.patternLikeCommon = exports.functionDeclarationCommon = exports.functionTypeAnnotationCommon = exports.functionCommon = void 0; exports.classMethodOrDeclareMethodCommon = exports.classMethodOrPropertyCommon = exports.patternLikeCommon = exports.functionDeclarationCommon = exports.functionTypeAnnotationCommon = exports.functionCommon = void 0;
var _isValidIdentifier = _interopRequireDefault(require("../validators/isValidIdentifier")); var _is = require("../validators/is");
var _constants = require("../constants"); var _isValidIdentifier = require("../validators/isValidIdentifier");
var _utils = _interopRequireWildcard(require("./utils"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } var _helperValidatorIdentifier = require("@babel/helper-validator-identifier");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } var _constants = require("../constants");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _utils = require("./utils");
(0, _utils.default)("ArrayExpression", { (0, _utils.default)("ArrayExpression", {
fields: { fields: {
elements: { elements: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "Expression", "SpreadElement"))), validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "Expression", "SpreadElement"))),
default: [] default: !process.env.BABEL_TYPES_8_BREAKING ? [] : undefined
} }
}, },
visitor: ["elements"], visitor: ["elements"],
...@@ -30,10 +28,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de ...@@ -30,10 +28,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
(0, _utils.default)("AssignmentExpression", { (0, _utils.default)("AssignmentExpression", {
fields: { fields: {
operator: { operator: {
validate: (0, _utils.assertValueType)("string") validate: function () {
if (!process.env.BABEL_TYPES_8_BREAKING) {
return (0, _utils.assertValueType)("string");
}
const identifier = (0, _utils.assertOneOf)(..._constants.ASSIGNMENT_OPERATORS);
const pattern = (0, _utils.assertOneOf)("=");
return function (node, key, val) {
const validator = (0, _is.default)("Pattern", node.left) ? pattern : identifier;
validator(node, key, val);
};
}()
}, },
left: { left: {
validate: (0, _utils.assertNodeType)("LVal") validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern")
}, },
right: { right: {
validate: (0, _utils.assertNodeType)("Expression") validate: (0, _utils.assertNodeType)("Expression")
...@@ -50,7 +59,18 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de ...@@ -50,7 +59,18 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
validate: (0, _utils.assertOneOf)(..._constants.BINARY_OPERATORS) validate: (0, _utils.assertOneOf)(..._constants.BINARY_OPERATORS)
}, },
left: { left: {
validate: (0, _utils.assertNodeType)("Expression") validate: function () {
const expression = (0, _utils.assertNodeType)("Expression");
const inOp = (0, _utils.assertNodeType)("Expression", "PrivateName");
const validator = function (node, key, val) {
const validator = node.operator === "in" ? inOp : expression;
validator(node, key, val);
};
validator.oneOfNodeTypes = ["Expression", "PrivateName"];
return validator;
}()
}, },
right: { right: {
validate: (0, _utils.assertNodeType)("Expression") validate: (0, _utils.assertNodeType)("Expression")
...@@ -111,17 +131,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de ...@@ -111,17 +131,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
visitor: ["callee", "arguments", "typeParameters", "typeArguments"], visitor: ["callee", "arguments", "typeParameters", "typeArguments"],
builder: ["callee", "arguments"], builder: ["callee", "arguments"],
aliases: ["Expression"], aliases: ["Expression"],
fields: { fields: Object.assign({
callee: { callee: {
validate: (0, _utils.assertNodeType)("Expression", "V8IntrinsicIdentifier") validate: (0, _utils.assertNodeType)("Expression", "V8IntrinsicIdentifier")
}, },
arguments: { arguments: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName", "ArgumentPlaceholder"))) validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName", "ArgumentPlaceholder")))
}, }
}, !process.env.BABEL_TYPES_8_BREAKING ? {
optional: { optional: {
validate: (0, _utils.assertOneOf)(true, false), validate: (0, _utils.assertOneOf)(true, false),
optional: true optional: true
}, }
} : {}, {
typeArguments: { typeArguments: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"), validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"),
optional: true optional: true
...@@ -130,13 +152,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de ...@@ -130,13 +152,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"), validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"),
optional: true optional: true
} }
} })
}); });
(0, _utils.default)("CatchClause", { (0, _utils.default)("CatchClause", {
visitor: ["param", "body"], visitor: ["param", "body"],
fields: { fields: {
param: { param: {
validate: (0, _utils.assertNodeType)("Identifier"), validate: (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern"),
optional: true optional: true
}, },
body: { body: {
...@@ -203,6 +225,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de ...@@ -203,6 +225,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
fields: { fields: {
program: { program: {
validate: (0, _utils.assertNodeType)("Program") validate: (0, _utils.assertNodeType)("Program")
},
comments: {
validate: !process.env.BABEL_TYPES_8_BREAKING ? Object.assign(() => {}, {
each: {
oneOfNodeTypes: ["CommentBlock", "CommentLine"]
}
}) : (0, _utils.assertEach)((0, _utils.assertNodeType)("CommentBlock", "CommentLine")),
optional: true
},
tokens: {
validate: (0, _utils.assertEach)(Object.assign(() => {}, {
type: "any"
})),
optional: true
} }
} }
}); });
...@@ -211,7 +247,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de ...@@ -211,7 +247,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"], aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"],
fields: { fields: {
left: { left: {
validate: (0, _utils.assertNodeType)("VariableDeclaration", "LVal") validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("VariableDeclaration", "LVal") : (0, _utils.assertNodeType)("VariableDeclaration", "Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern")
}, },
right: { right: {
validate: (0, _utils.assertNodeType)("Expression") validate: (0, _utils.assertNodeType)("Expression")
...@@ -244,14 +280,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de ...@@ -244,14 +280,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
}); });
const functionCommon = { const functionCommon = {
params: { params: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Identifier", "Pattern", "RestElement", "TSParameterProperty"))) validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Identifier", "Pattern", "RestElement")))
}, },
generator: { generator: {
default: false, default: false
validate: (0, _utils.assertValueType)("boolean")
}, },
async: { async: {
validate: (0, _utils.assertValueType)("boolean"),
default: false default: false
} }
}; };
...@@ -281,17 +315,26 @@ exports.functionDeclarationCommon = functionDeclarationCommon; ...@@ -281,17 +315,26 @@ exports.functionDeclarationCommon = functionDeclarationCommon;
(0, _utils.default)("FunctionDeclaration", { (0, _utils.default)("FunctionDeclaration", {
builder: ["id", "params", "body", "generator", "async"], builder: ["id", "params", "body", "generator", "async"],
visitor: ["id", "params", "body", "returnType", "typeParameters"], visitor: ["id", "params", "body", "returnType", "typeParameters"],
fields: Object.assign({}, functionDeclarationCommon, {}, functionTypeAnnotationCommon, { fields: Object.assign({}, functionDeclarationCommon, functionTypeAnnotationCommon, {
body: { body: {
validate: (0, _utils.assertNodeType)("BlockStatement") validate: (0, _utils.assertNodeType)("BlockStatement")
} }
}), }),
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Statement", "Pureish", "Declaration"] aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Statement", "Pureish", "Declaration"],
validate: function () {
if (!process.env.BABEL_TYPES_8_BREAKING) return () => {};
const identifier = (0, _utils.assertNodeType)("Identifier");
return function (parent, key, node) {
if (!(0, _is.default)("ExportDefaultDeclaration", parent)) {
identifier(node, "id", node.id);
}
};
}()
}); });
(0, _utils.default)("FunctionExpression", { (0, _utils.default)("FunctionExpression", {
inherits: "FunctionDeclaration", inherits: "FunctionDeclaration",
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"], aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"],
fields: Object.assign({}, functionCommon, {}, functionTypeAnnotationCommon, { fields: Object.assign({}, functionCommon, functionTypeAnnotationCommon, {
id: { id: {
validate: (0, _utils.assertNodeType)("Identifier"), validate: (0, _utils.assertNodeType)("Identifier"),
optional: true optional: true
...@@ -317,15 +360,54 @@ exports.patternLikeCommon = patternLikeCommon; ...@@ -317,15 +360,54 @@ exports.patternLikeCommon = patternLikeCommon;
aliases: ["Expression", "PatternLike", "LVal", "TSEntityName"], aliases: ["Expression", "PatternLike", "LVal", "TSEntityName"],
fields: Object.assign({}, patternLikeCommon, { fields: Object.assign({}, patternLikeCommon, {
name: { name: {
validate: (0, _utils.chain)(function (node, key, val) { validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), Object.assign(function (node, key, val) {
if (!(0, _isValidIdentifier.default)(val)) {} if (!process.env.BABEL_TYPES_8_BREAKING) return;
}, (0, _utils.assertValueType)("string"))
if (!(0, _isValidIdentifier.default)(val, false)) {
throw new TypeError(`"${val}" is not a valid identifier name`);
}
}, {
type: "string"
}))
}, },
optional: { optional: {
validate: (0, _utils.assertValueType)("boolean"), validate: (0, _utils.assertValueType)("boolean"),
optional: true optional: true
} }
}) }),
validate(parent, key, node) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
const match = /\.(\w+)$/.exec(key);
if (!match) return;
const [, parentKey] = match;
const nonComp = {
computed: false
};
if (parentKey === "property") {
if ((0, _is.default)("MemberExpression", parent, nonComp)) return;
if ((0, _is.default)("OptionalMemberExpression", parent, nonComp)) return;
} else if (parentKey === "key") {
if ((0, _is.default)("Property", parent, nonComp)) return;
if ((0, _is.default)("Method", parent, nonComp)) return;
} else if (parentKey === "exported") {
if ((0, _is.default)("ExportSpecifier", parent)) return;
} else if (parentKey === "imported") {
if ((0, _is.default)("ImportSpecifier", parent, {
imported: node
})) return;
} else if (parentKey === "meta") {
if ((0, _is.default)("MetaProperty", parent, {
meta: node
})) return;
}
if (((0, _helperValidatorIdentifier.isKeyword)(node.name) || (0, _helperValidatorIdentifier.isReservedWord)(node.name, false)) && node.name !== "this") {
throw new TypeError(`"${node.name}" is not a valid identifier`);
}
}
}); });
(0, _utils.default)("IfStatement", { (0, _utils.default)("IfStatement", {
visitor: ["test", "consequent", "alternate"], visitor: ["test", "consequent", "alternate"],
...@@ -389,13 +471,22 @@ exports.patternLikeCommon = patternLikeCommon; ...@@ -389,13 +471,22 @@ exports.patternLikeCommon = patternLikeCommon;
(0, _utils.default)("RegExpLiteral", { (0, _utils.default)("RegExpLiteral", {
builder: ["pattern", "flags"], builder: ["pattern", "flags"],
deprecatedAlias: "RegexLiteral", deprecatedAlias: "RegexLiteral",
aliases: ["Expression", "Literal"], aliases: ["Expression", "Pureish", "Literal"],
fields: { fields: {
pattern: { pattern: {
validate: (0, _utils.assertValueType)("string") validate: (0, _utils.assertValueType)("string")
}, },
flags: { flags: {
validate: (0, _utils.assertValueType)("string"), validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), Object.assign(function (node, key, val) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
const invalid = /[^gimsuy]/.exec(val);
if (invalid) {
throw new TypeError(`"${invalid[0]}" is not a valid RegExp flag`);
}
}, {
type: "string"
})),
default: "" default: ""
} }
} }
...@@ -417,10 +508,10 @@ exports.patternLikeCommon = patternLikeCommon; ...@@ -417,10 +508,10 @@ exports.patternLikeCommon = patternLikeCommon;
} }
}); });
(0, _utils.default)("MemberExpression", { (0, _utils.default)("MemberExpression", {
builder: ["object", "property", "computed", "optional"], builder: ["object", "property", "computed", ...(!process.env.BABEL_TYPES_8_BREAKING ? ["optional"] : [])],
visitor: ["object", "property"], visitor: ["object", "property"],
aliases: ["Expression", "LVal"], aliases: ["Expression", "LVal"],
fields: { fields: Object.assign({
object: { object: {
validate: (0, _utils.assertNodeType)("Expression") validate: (0, _utils.assertNodeType)("Expression")
}, },
...@@ -428,20 +519,25 @@ exports.patternLikeCommon = patternLikeCommon; ...@@ -428,20 +519,25 @@ exports.patternLikeCommon = patternLikeCommon;
validate: function () { validate: function () {
const normal = (0, _utils.assertNodeType)("Identifier", "PrivateName"); const normal = (0, _utils.assertNodeType)("Identifier", "PrivateName");
const computed = (0, _utils.assertNodeType)("Expression"); const computed = (0, _utils.assertNodeType)("Expression");
return function (node, key, val) {
const validator = function (node, key, val) {
const validator = node.computed ? computed : normal; const validator = node.computed ? computed : normal;
validator(node, key, val); validator(node, key, val);
}; };
validator.oneOfNodeTypes = ["Expression", "Identifier", "PrivateName"];
return validator;
}() }()
}, },
computed: { computed: {
default: false default: false
}, }
}, !process.env.BABEL_TYPES_8_BREAKING ? {
optional: { optional: {
validate: (0, _utils.assertOneOf)(true, false), validate: (0, _utils.assertOneOf)(true, false),
optional: true optional: true
} }
} } : {})
}); });
(0, _utils.default)("NewExpression", { (0, _utils.default)("NewExpression", {
inherits: "CallExpression" inherits: "CallExpression"
...@@ -482,28 +578,33 @@ exports.patternLikeCommon = patternLikeCommon; ...@@ -482,28 +578,33 @@ exports.patternLikeCommon = patternLikeCommon;
} }
}); });
(0, _utils.default)("ObjectMethod", { (0, _utils.default)("ObjectMethod", {
builder: ["kind", "key", "params", "body", "computed"], builder: ["kind", "key", "params", "body", "computed", "generator", "async"],
fields: Object.assign({}, functionCommon, {}, functionTypeAnnotationCommon, { fields: Object.assign({}, functionCommon, functionTypeAnnotationCommon, {
kind: { kind: Object.assign({
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("method", "get", "set")), validate: (0, _utils.assertOneOf)("method", "get", "set")
}, !process.env.BABEL_TYPES_8_BREAKING ? {
default: "method" default: "method"
}, } : {}),
computed: { computed: {
validate: (0, _utils.assertValueType)("boolean"),
default: false default: false
}, },
key: { key: {
validate: function () { validate: function () {
const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral"); const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral");
const computed = (0, _utils.assertNodeType)("Expression"); const computed = (0, _utils.assertNodeType)("Expression");
return function (node, key, val) {
const validator = function (node, key, val) {
const validator = node.computed ? computed : normal; const validator = node.computed ? computed : normal;
validator(node, key, val); validator(node, key, val);
}; };
validator.oneOfNodeTypes = ["Expression", "Identifier", "StringLiteral", "NumericLiteral"];
return validator;
}() }()
}, },
decorators: { decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))) validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
optional: true
}, },
body: { body: {
validate: (0, _utils.assertNodeType)("BlockStatement") validate: (0, _utils.assertNodeType)("BlockStatement")
...@@ -513,27 +614,44 @@ exports.patternLikeCommon = patternLikeCommon; ...@@ -513,27 +614,44 @@ exports.patternLikeCommon = patternLikeCommon;
aliases: ["UserWhitespacable", "Function", "Scopable", "BlockParent", "FunctionParent", "Method", "ObjectMember"] aliases: ["UserWhitespacable", "Function", "Scopable", "BlockParent", "FunctionParent", "Method", "ObjectMember"]
}); });
(0, _utils.default)("ObjectProperty", { (0, _utils.default)("ObjectProperty", {
builder: ["key", "value", "computed", "shorthand", "decorators"], builder: ["key", "value", "computed", "shorthand", ...(!process.env.BABEL_TYPES_8_BREAKING ? ["decorators"] : [])],
fields: { fields: {
computed: { computed: {
validate: (0, _utils.assertValueType)("boolean"),
default: false default: false
}, },
key: { key: {
validate: function () { validate: function () {
const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral"); const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral");
const computed = (0, _utils.assertNodeType)("Expression"); const computed = (0, _utils.assertNodeType)("Expression");
return function (node, key, val) {
const validator = function (node, key, val) {
const validator = node.computed ? computed : normal; const validator = node.computed ? computed : normal;
validator(node, key, val); validator(node, key, val);
}; };
validator.oneOfNodeTypes = ["Expression", "Identifier", "StringLiteral", "NumericLiteral"];
return validator;
}() }()
}, },
value: { value: {
validate: (0, _utils.assertNodeType)("Expression", "PatternLike") validate: (0, _utils.assertNodeType)("Expression", "PatternLike")
}, },
shorthand: { shorthand: {
validate: (0, _utils.assertValueType)("boolean"), validate: (0, _utils.chain)((0, _utils.assertValueType)("boolean"), Object.assign(function (node, key, val) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (val && node.computed) {
throw new TypeError("Property shorthand of ObjectProperty cannot be true if computed is true");
}
}, {
type: "boolean"
}), function (node, key, val) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (val && !(0, _is.default)("Identifier", node.key)) {
throw new TypeError("Property shorthand of ObjectProperty cannot be true if key is not an Identifier");
}
}),
default: false default: false
}, },
decorators: { decorators: {
...@@ -542,7 +660,16 @@ exports.patternLikeCommon = patternLikeCommon; ...@@ -542,7 +660,16 @@ exports.patternLikeCommon = patternLikeCommon;
} }
}, },
visitor: ["key", "value", "decorators"], visitor: ["key", "value", "decorators"],
aliases: ["UserWhitespacable", "Property", "ObjectMember"] aliases: ["UserWhitespacable", "Property", "ObjectMember"],
validate: function () {
const pattern = (0, _utils.assertNodeType)("Identifier", "Pattern");
const expression = (0, _utils.assertNodeType)("Expression");
return function (parent, key, node) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
const validator = (0, _is.default)("ObjectPattern", parent) ? pattern : expression;
validator(node, "value", node.value);
};
}()
}); });
(0, _utils.default)("RestElement", { (0, _utils.default)("RestElement", {
visitor: ["argument", "typeAnnotation"], visitor: ["argument", "typeAnnotation"],
...@@ -551,9 +678,21 @@ exports.patternLikeCommon = patternLikeCommon; ...@@ -551,9 +678,21 @@ exports.patternLikeCommon = patternLikeCommon;
deprecatedAlias: "RestProperty", deprecatedAlias: "RestProperty",
fields: Object.assign({}, patternLikeCommon, { fields: Object.assign({}, patternLikeCommon, {
argument: { argument: {
validate: (0, _utils.assertNodeType)("LVal") validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "Pattern", "MemberExpression")
} }
}) }),
validate(parent, key) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
const match = /(\w+)\[(\d+)\]/.exec(key);
if (!match) throw new Error("Internal Babel error: malformed key.");
const [, listKey, index] = match;
if (parent[listKey].length > index + 1) {
throw new TypeError(`RestElement must be last element of ${listKey}`);
}
}
}); });
(0, _utils.default)("ReturnStatement", { (0, _utils.default)("ReturnStatement", {
visitor: ["argument"], visitor: ["argument"],
...@@ -624,7 +763,15 @@ exports.patternLikeCommon = patternLikeCommon; ...@@ -624,7 +763,15 @@ exports.patternLikeCommon = patternLikeCommon;
aliases: ["Statement"], aliases: ["Statement"],
fields: { fields: {
block: { block: {
validate: (0, _utils.assertNodeType)("BlockStatement") validate: (0, _utils.chain)((0, _utils.assertNodeType)("BlockStatement"), Object.assign(function (node) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (!node.handler && !node.finalizer) {
throw new TypeError("TryStatement expects either a handler or finalizer, or both");
}
}, {
oneOfNodeTypes: ["BlockStatement"]
}))
}, },
handler: { handler: {
optional: true, optional: true,
...@@ -659,7 +806,7 @@ exports.patternLikeCommon = patternLikeCommon; ...@@ -659,7 +806,7 @@ exports.patternLikeCommon = patternLikeCommon;
default: false default: false
}, },
argument: { argument: {
validate: (0, _utils.assertNodeType)("Expression") validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("Expression") : (0, _utils.assertNodeType)("Identifier", "MemberExpression")
}, },
operator: { operator: {
validate: (0, _utils.assertOneOf)(..._constants.UPDATE_OPERATORS) validate: (0, _utils.assertOneOf)(..._constants.UPDATE_OPERATORS)
...@@ -678,18 +825,41 @@ exports.patternLikeCommon = patternLikeCommon; ...@@ -678,18 +825,41 @@ exports.patternLikeCommon = patternLikeCommon;
optional: true optional: true
}, },
kind: { kind: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("var", "let", "const")) validate: (0, _utils.assertOneOf)("var", "let", "const")
}, },
declarations: { declarations: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("VariableDeclarator"))) validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("VariableDeclarator")))
} }
},
validate(parent, key, node) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (!(0, _is.default)("ForXStatement", parent, {
left: node
})) return;
if (node.declarations.length !== 1) {
throw new TypeError(`Exactly one VariableDeclarator is required in the VariableDeclaration of a ${parent.type}`);
}
} }
}); });
(0, _utils.default)("VariableDeclarator", { (0, _utils.default)("VariableDeclarator", {
visitor: ["id", "init"], visitor: ["id", "init"],
fields: { fields: {
id: { id: {
validate: (0, _utils.assertNodeType)("LVal") validate: function () {
if (!process.env.BABEL_TYPES_8_BREAKING) {
return (0, _utils.assertNodeType)("LVal");
}
const normal = (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern");
const without = (0, _utils.assertNodeType)("Identifier");
return function (node, key, val) {
const validator = node.init ? normal : without;
validator(node, key, val);
};
}()
}, },
definite: { definite: {
optional: true, optional: true,
...@@ -709,7 +879,7 @@ exports.patternLikeCommon = patternLikeCommon; ...@@ -709,7 +879,7 @@ exports.patternLikeCommon = patternLikeCommon;
validate: (0, _utils.assertNodeType)("Expression") validate: (0, _utils.assertNodeType)("Expression")
}, },
body: { body: {
validate: (0, _utils.assertNodeType)("BlockStatement", "Statement") validate: (0, _utils.assertNodeType)("Statement")
} }
} }
}); });
...@@ -721,7 +891,599 @@ exports.patternLikeCommon = patternLikeCommon; ...@@ -721,7 +891,599 @@ exports.patternLikeCommon = patternLikeCommon;
validate: (0, _utils.assertNodeType)("Expression") validate: (0, _utils.assertNodeType)("Expression")
}, },
body: { body: {
validate: (0, _utils.assertNodeType)("BlockStatement", "Statement") validate: (0, _utils.assertNodeType)("Statement")
}
}
});
(0, _utils.default)("AssignmentPattern", {
visitor: ["left", "right", "decorators"],
builder: ["left", "right"],
aliases: ["Pattern", "PatternLike", "LVal"],
fields: Object.assign({}, patternLikeCommon, {
left: {
validate: (0, _utils.assertNodeType)("Identifier", "ObjectPattern", "ArrayPattern", "MemberExpression")
},
right: {
validate: (0, _utils.assertNodeType)("Expression")
},
decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
optional: true
}
})
});
(0, _utils.default)("ArrayPattern", {
visitor: ["elements", "typeAnnotation"],
builder: ["elements"],
aliases: ["Pattern", "PatternLike", "LVal"],
fields: Object.assign({}, patternLikeCommon, {
elements: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "PatternLike")))
},
decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
optional: true
}
})
});
(0, _utils.default)("ArrowFunctionExpression", {
builder: ["params", "body", "async"],
visitor: ["params", "body", "returnType", "typeParameters"],
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"],
fields: Object.assign({}, functionCommon, functionTypeAnnotationCommon, {
expression: {
validate: (0, _utils.assertValueType)("boolean")
},
body: {
validate: (0, _utils.assertNodeType)("BlockStatement", "Expression")
}
})
});
(0, _utils.default)("ClassBody", {
visitor: ["body"],
fields: {
body: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ClassMethod", "ClassPrivateMethod", "ClassProperty", "ClassPrivateProperty", "TSDeclareMethod", "TSIndexSignature")))
}
}
});
(0, _utils.default)("ClassExpression", {
builder: ["id", "superClass", "body", "decorators"],
visitor: ["id", "body", "superClass", "mixins", "typeParameters", "superTypeParameters", "implements", "decorators"],
aliases: ["Scopable", "Class", "Expression"],
fields: {
id: {
validate: (0, _utils.assertNodeType)("Identifier"),
optional: true
},
typeParameters: {
validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"),
optional: true
},
body: {
validate: (0, _utils.assertNodeType)("ClassBody")
},
superClass: {
optional: true,
validate: (0, _utils.assertNodeType)("Expression")
},
superTypeParameters: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
optional: true
},
implements: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSExpressionWithTypeArguments", "ClassImplements"))),
optional: true
},
decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
optional: true
},
mixins: {
validate: (0, _utils.assertNodeType)("InterfaceExtends"),
optional: true
}
}
});
(0, _utils.default)("ClassDeclaration", {
inherits: "ClassExpression",
aliases: ["Scopable", "Class", "Statement", "Declaration"],
fields: {
id: {
validate: (0, _utils.assertNodeType)("Identifier")
},
typeParameters: {
validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"),
optional: true
},
body: {
validate: (0, _utils.assertNodeType)("ClassBody")
},
superClass: {
optional: true,
validate: (0, _utils.assertNodeType)("Expression")
},
superTypeParameters: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
optional: true
},
implements: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSExpressionWithTypeArguments", "ClassImplements"))),
optional: true
},
decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
optional: true
},
mixins: {
validate: (0, _utils.assertNodeType)("InterfaceExtends"),
optional: true
},
declare: {
validate: (0, _utils.assertValueType)("boolean"),
optional: true
},
abstract: {
validate: (0, _utils.assertValueType)("boolean"),
optional: true
}
},
validate: function () {
const identifier = (0, _utils.assertNodeType)("Identifier");
return function (parent, key, node) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (!(0, _is.default)("ExportDefaultDeclaration", parent)) {
identifier(node, "id", node.id);
}
};
}()
});
(0, _utils.default)("ExportAllDeclaration", {
visitor: ["source"],
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
fields: {
source: {
validate: (0, _utils.assertNodeType)("StringLiteral")
},
exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")),
assertions: {
optional: true,
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute")))
}
}
});
(0, _utils.default)("ExportDefaultDeclaration", {
visitor: ["declaration"],
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
fields: {
declaration: {
validate: (0, _utils.assertNodeType)("FunctionDeclaration", "TSDeclareFunction", "ClassDeclaration", "Expression")
}
}
});
(0, _utils.default)("ExportNamedDeclaration", {
visitor: ["declaration", "specifiers", "source"],
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
fields: {
declaration: {
optional: true,
validate: (0, _utils.chain)((0, _utils.assertNodeType)("Declaration"), Object.assign(function (node, key, val) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (val && node.specifiers.length) {
throw new TypeError("Only declaration or specifiers is allowed on ExportNamedDeclaration");
}
}, {
oneOfNodeTypes: ["Declaration"]
}), function (node, key, val) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (val && node.source) {
throw new TypeError("Cannot export a declaration from a source");
}
})
},
assertions: {
optional: true,
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute")))
},
specifiers: {
default: [],
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)(function () {
const sourced = (0, _utils.assertNodeType)("ExportSpecifier", "ExportDefaultSpecifier", "ExportNamespaceSpecifier");
const sourceless = (0, _utils.assertNodeType)("ExportSpecifier");
if (!process.env.BABEL_TYPES_8_BREAKING) return sourced;
return function (node, key, val) {
const validator = node.source ? sourced : sourceless;
validator(node, key, val);
};
}()))
},
source: {
validate: (0, _utils.assertNodeType)("StringLiteral"),
optional: true
},
exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value"))
}
});
(0, _utils.default)("ExportSpecifier", {
visitor: ["local", "exported"],
aliases: ["ModuleSpecifier"],
fields: {
local: {
validate: (0, _utils.assertNodeType)("Identifier")
},
exported: {
validate: (0, _utils.assertNodeType)("Identifier", "StringLiteral")
}
}
});
(0, _utils.default)("ForOfStatement", {
visitor: ["left", "right", "body"],
builder: ["left", "right", "body", "await"],
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"],
fields: {
left: {
validate: function () {
if (!process.env.BABEL_TYPES_8_BREAKING) {
return (0, _utils.assertNodeType)("VariableDeclaration", "LVal");
}
const declaration = (0, _utils.assertNodeType)("VariableDeclaration");
const lval = (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern");
return function (node, key, val) {
if ((0, _is.default)("VariableDeclaration", val)) {
declaration(node, key, val);
} else {
lval(node, key, val);
}
};
}()
},
right: {
validate: (0, _utils.assertNodeType)("Expression")
},
body: {
validate: (0, _utils.assertNodeType)("Statement")
},
await: {
default: false
}
}
});
(0, _utils.default)("ImportDeclaration", {
visitor: ["specifiers", "source"],
aliases: ["Statement", "Declaration", "ModuleDeclaration"],
fields: {
assertions: {
optional: true,
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute")))
},
specifiers: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportSpecifier", "ImportDefaultSpecifier", "ImportNamespaceSpecifier")))
},
source: {
validate: (0, _utils.assertNodeType)("StringLiteral")
},
importKind: {
validate: (0, _utils.assertOneOf)("type", "typeof", "value"),
optional: true
}
}
});
(0, _utils.default)("ImportDefaultSpecifier", {
visitor: ["local"],
aliases: ["ModuleSpecifier"],
fields: {
local: {
validate: (0, _utils.assertNodeType)("Identifier")
}
}
});
(0, _utils.default)("ImportNamespaceSpecifier", {
visitor: ["local"],
aliases: ["ModuleSpecifier"],
fields: {
local: {
validate: (0, _utils.assertNodeType)("Identifier")
}
}
});
(0, _utils.default)("ImportSpecifier", {
visitor: ["local", "imported"],
aliases: ["ModuleSpecifier"],
fields: {
local: {
validate: (0, _utils.assertNodeType)("Identifier")
},
imported: {
validate: (0, _utils.assertNodeType)("Identifier", "StringLiteral")
},
importKind: {
validate: (0, _utils.assertOneOf)("type", "typeof"),
optional: true
}
}
});
(0, _utils.default)("MetaProperty", {
visitor: ["meta", "property"],
aliases: ["Expression"],
fields: {
meta: {
validate: (0, _utils.chain)((0, _utils.assertNodeType)("Identifier"), Object.assign(function (node, key, val) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
let property;
switch (val.name) {
case "function":
property = "sent";
break;
case "new":
property = "target";
break;
case "import":
property = "meta";
break;
}
if (!(0, _is.default)("Identifier", node.property, {
name: property
})) {
throw new TypeError("Unrecognised MetaProperty");
}
}, {
oneOfNodeTypes: ["Identifier"]
}))
},
property: {
validate: (0, _utils.assertNodeType)("Identifier")
}
}
});
const classMethodOrPropertyCommon = {
abstract: {
validate: (0, _utils.assertValueType)("boolean"),
optional: true
},
accessibility: {
validate: (0, _utils.assertOneOf)("public", "private", "protected"),
optional: true
},
static: {
default: false
},
override: {
default: false
},
computed: {
default: false
},
optional: {
validate: (0, _utils.assertValueType)("boolean"),
optional: true
},
key: {
validate: (0, _utils.chain)(function () {
const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral");
const computed = (0, _utils.assertNodeType)("Expression");
return function (node, key, val) {
const validator = node.computed ? computed : normal;
validator(node, key, val);
};
}(), (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral", "Expression"))
}
};
exports.classMethodOrPropertyCommon = classMethodOrPropertyCommon;
const classMethodOrDeclareMethodCommon = Object.assign({}, functionCommon, classMethodOrPropertyCommon, {
params: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Identifier", "Pattern", "RestElement", "TSParameterProperty")))
},
kind: {
validate: (0, _utils.assertOneOf)("get", "set", "method", "constructor"),
default: "method"
},
access: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("public", "private", "protected")),
optional: true
},
decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
optional: true
}
});
exports.classMethodOrDeclareMethodCommon = classMethodOrDeclareMethodCommon;
(0, _utils.default)("ClassMethod", {
aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method"],
builder: ["kind", "key", "params", "body", "computed", "static", "generator", "async"],
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"],
fields: Object.assign({}, classMethodOrDeclareMethodCommon, functionTypeAnnotationCommon, {
body: {
validate: (0, _utils.assertNodeType)("BlockStatement")
}
})
});
(0, _utils.default)("ObjectPattern", {
visitor: ["properties", "typeAnnotation", "decorators"],
builder: ["properties"],
aliases: ["Pattern", "PatternLike", "LVal"],
fields: Object.assign({}, patternLikeCommon, {
properties: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("RestElement", "ObjectProperty")))
}
})
});
(0, _utils.default)("SpreadElement", {
visitor: ["argument"],
aliases: ["UnaryLike"],
deprecatedAlias: "SpreadProperty",
fields: {
argument: {
validate: (0, _utils.assertNodeType)("Expression")
}
}
});
(0, _utils.default)("Super", {
aliases: ["Expression"]
});
(0, _utils.default)("TaggedTemplateExpression", {
visitor: ["tag", "quasi"],
aliases: ["Expression"],
fields: {
tag: {
validate: (0, _utils.assertNodeType)("Expression")
},
quasi: {
validate: (0, _utils.assertNodeType)("TemplateLiteral")
},
typeParameters: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
optional: true
}
}
});
(0, _utils.default)("TemplateElement", {
builder: ["value", "tail"],
fields: {
value: {
validate: (0, _utils.assertShape)({
raw: {
validate: (0, _utils.assertValueType)("string")
},
cooked: {
validate: (0, _utils.assertValueType)("string"),
optional: true
}
})
},
tail: {
default: false
}
}
});
(0, _utils.default)("TemplateLiteral", {
visitor: ["quasis", "expressions"],
aliases: ["Expression", "Literal"],
fields: {
quasis: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TemplateElement")))
},
expressions: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "TSType")), function (node, key, val) {
if (node.quasis.length !== val.length + 1) {
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}`);
}
})
}
}
});
(0, _utils.default)("YieldExpression", {
builder: ["argument", "delegate"],
visitor: ["argument"],
aliases: ["Expression", "Terminatorless"],
fields: {
delegate: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("boolean"), Object.assign(function (node, key, val) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (val && !node.argument) {
throw new TypeError("Property delegate of YieldExpression cannot be true if there is no argument");
}
}, {
type: "boolean"
})),
default: false
},
argument: {
optional: true,
validate: (0, _utils.assertNodeType)("Expression")
}
}
});
(0, _utils.default)("AwaitExpression", {
builder: ["argument"],
visitor: ["argument"],
aliases: ["Expression", "Terminatorless"],
fields: {
argument: {
validate: (0, _utils.assertNodeType)("Expression")
}
}
});
(0, _utils.default)("Import", {
aliases: ["Expression"]
});
(0, _utils.default)("BigIntLiteral", {
builder: ["value"],
fields: {
value: {
validate: (0, _utils.assertValueType)("string")
}
},
aliases: ["Expression", "Pureish", "Literal", "Immutable"]
});
(0, _utils.default)("ExportNamespaceSpecifier", {
visitor: ["exported"],
aliases: ["ModuleSpecifier"],
fields: {
exported: {
validate: (0, _utils.assertNodeType)("Identifier")
}
}
});
(0, _utils.default)("OptionalMemberExpression", {
builder: ["object", "property", "computed", "optional"],
visitor: ["object", "property"],
aliases: ["Expression"],
fields: {
object: {
validate: (0, _utils.assertNodeType)("Expression")
},
property: {
validate: function () {
const normal = (0, _utils.assertNodeType)("Identifier");
const computed = (0, _utils.assertNodeType)("Expression");
const validator = function (node, key, val) {
const validator = node.computed ? computed : normal;
validator(node, key, val);
};
validator.oneOfNodeTypes = ["Expression", "Identifier"];
return validator;
}()
},
computed: {
default: false
},
optional: {
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertValueType)("boolean") : (0, _utils.chain)((0, _utils.assertValueType)("boolean"), (0, _utils.assertOptionalChainStart)())
}
}
});
(0, _utils.default)("OptionalCallExpression", {
visitor: ["callee", "arguments", "typeParameters", "typeArguments"],
builder: ["callee", "arguments", "optional"],
aliases: ["Expression"],
fields: {
callee: {
validate: (0, _utils.assertNodeType)("Expression")
},
arguments: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName", "ArgumentPlaceholder")))
},
optional: {
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertValueType)("boolean") : (0, _utils.chain)((0, _utils.assertValueType)("boolean"), (0, _utils.assertOptionalChainStart)())
},
typeArguments: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"),
optional: true
},
typeParameters: {
validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"),
optional: true
} }
} }
}); });
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.classMethodOrDeclareMethodCommon = exports.classMethodOrPropertyCommon = void 0;
var _utils = _interopRequireWildcard(require("./utils"));
var _core = require("./core");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
(0, _utils.default)("AssignmentPattern", {
visitor: ["left", "right", "decorators"],
builder: ["left", "right"],
aliases: ["Pattern", "PatternLike", "LVal"],
fields: Object.assign({}, _core.patternLikeCommon, {
left: {
validate: (0, _utils.assertNodeType)("Identifier", "ObjectPattern", "ArrayPattern", "MemberExpression")
},
right: {
validate: (0, _utils.assertNodeType)("Expression")
},
decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator")))
}
})
});
(0, _utils.default)("ArrayPattern", {
visitor: ["elements", "typeAnnotation"],
builder: ["elements"],
aliases: ["Pattern", "PatternLike", "LVal"],
fields: Object.assign({}, _core.patternLikeCommon, {
elements: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("PatternLike")))
},
decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator")))
}
})
});
(0, _utils.default)("ArrowFunctionExpression", {
builder: ["params", "body", "async"],
visitor: ["params", "body", "returnType", "typeParameters"],
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"],
fields: Object.assign({}, _core.functionCommon, {}, _core.functionTypeAnnotationCommon, {
expression: {
validate: (0, _utils.assertValueType)("boolean")
},
body: {
validate: (0, _utils.assertNodeType)("BlockStatement", "Expression")
}
})
});
(0, _utils.default)("ClassBody", {
visitor: ["body"],
fields: {
body: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ClassMethod", "ClassPrivateMethod", "ClassProperty", "ClassPrivateProperty", "TSDeclareMethod", "TSIndexSignature")))
}
}
});
const classCommon = {
typeParameters: {
validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"),
optional: true
},
body: {
validate: (0, _utils.assertNodeType)("ClassBody")
},
superClass: {
optional: true,
validate: (0, _utils.assertNodeType)("Expression")
},
superTypeParameters: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
optional: true
},
implements: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSExpressionWithTypeArguments", "ClassImplements"))),
optional: true
}
};
(0, _utils.default)("ClassDeclaration", {
builder: ["id", "superClass", "body", "decorators"],
visitor: ["id", "body", "superClass", "mixins", "typeParameters", "superTypeParameters", "implements", "decorators"],
aliases: ["Scopable", "Class", "Statement", "Declaration", "Pureish"],
fields: Object.assign({}, classCommon, {
declare: {
validate: (0, _utils.assertValueType)("boolean"),
optional: true
},
abstract: {
validate: (0, _utils.assertValueType)("boolean"),
optional: true
},
id: {
validate: (0, _utils.assertNodeType)("Identifier"),
optional: true
},
decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
optional: true
}
})
});
(0, _utils.default)("ClassExpression", {
inherits: "ClassDeclaration",
aliases: ["Scopable", "Class", "Expression", "Pureish"],
fields: Object.assign({}, classCommon, {
id: {
optional: true,
validate: (0, _utils.assertNodeType)("Identifier")
},
body: {
validate: (0, _utils.assertNodeType)("ClassBody")
},
superClass: {
optional: true,
validate: (0, _utils.assertNodeType)("Expression")
},
decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
optional: true
}
})
});
(0, _utils.default)("ExportAllDeclaration", {
visitor: ["source"],
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
fields: {
source: {
validate: (0, _utils.assertNodeType)("StringLiteral")
}
}
});
(0, _utils.default)("ExportDefaultDeclaration", {
visitor: ["declaration"],
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
fields: {
declaration: {
validate: (0, _utils.assertNodeType)("FunctionDeclaration", "TSDeclareFunction", "ClassDeclaration", "Expression")
}
}
});
(0, _utils.default)("ExportNamedDeclaration", {
visitor: ["declaration", "specifiers", "source"],
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
fields: {
declaration: {
validate: (0, _utils.assertNodeType)("Declaration"),
optional: true
},
specifiers: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ExportSpecifier", "ExportDefaultSpecifier", "ExportNamespaceSpecifier")))
},
source: {
validate: (0, _utils.assertNodeType)("StringLiteral"),
optional: true
},
exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value"))
}
});
(0, _utils.default)("ExportSpecifier", {
visitor: ["local", "exported"],
aliases: ["ModuleSpecifier"],
fields: {
local: {
validate: (0, _utils.assertNodeType)("Identifier")
},
exported: {
validate: (0, _utils.assertNodeType)("Identifier")
}
}
});
(0, _utils.default)("ForOfStatement", {
visitor: ["left", "right", "body"],
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"],
fields: {
left: {
validate: (0, _utils.assertNodeType)("VariableDeclaration", "LVal")
},
right: {
validate: (0, _utils.assertNodeType)("Expression")
},
body: {
validate: (0, _utils.assertNodeType)("Statement")
},
await: {
default: false,
validate: (0, _utils.assertValueType)("boolean")
}
}
});
(0, _utils.default)("ImportDeclaration", {
visitor: ["specifiers", "source"],
aliases: ["Statement", "Declaration", "ModuleDeclaration"],
fields: {
specifiers: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportSpecifier", "ImportDefaultSpecifier", "ImportNamespaceSpecifier")))
},
source: {
validate: (0, _utils.assertNodeType)("StringLiteral")
},
importKind: {
validate: (0, _utils.assertOneOf)("type", "typeof", "value"),
optional: true
}
}
});
(0, _utils.default)("ImportDefaultSpecifier", {
visitor: ["local"],
aliases: ["ModuleSpecifier"],
fields: {
local: {
validate: (0, _utils.assertNodeType)("Identifier")
}
}
});
(0, _utils.default)("ImportNamespaceSpecifier", {
visitor: ["local"],
aliases: ["ModuleSpecifier"],
fields: {
local: {
validate: (0, _utils.assertNodeType)("Identifier")
}
}
});
(0, _utils.default)("ImportSpecifier", {
visitor: ["local", "imported"],
aliases: ["ModuleSpecifier"],
fields: {
local: {
validate: (0, _utils.assertNodeType)("Identifier")
},
imported: {
validate: (0, _utils.assertNodeType)("Identifier")
},
importKind: {
validate: (0, _utils.assertOneOf)("type", "typeof"),
optional: true
}
}
});
(0, _utils.default)("MetaProperty", {
visitor: ["meta", "property"],
aliases: ["Expression"],
fields: {
meta: {
validate: (0, _utils.assertNodeType)("Identifier")
},
property: {
validate: (0, _utils.assertNodeType)("Identifier")
}
}
});
const classMethodOrPropertyCommon = {
abstract: {
validate: (0, _utils.assertValueType)("boolean"),
optional: true
},
accessibility: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("public", "private", "protected")),
optional: true
},
static: {
default: false,
validate: (0, _utils.assertValueType)("boolean")
},
computed: {
default: false,
validate: (0, _utils.assertValueType)("boolean")
},
optional: {
validate: (0, _utils.assertValueType)("boolean"),
optional: true
},
key: {
validate: (0, _utils.chain)(function () {
const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral");
const computed = (0, _utils.assertNodeType)("Expression");
return function (node, key, val) {
const validator = node.computed ? computed : normal;
validator(node, key, val);
};
}(), (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral", "Expression"))
}
};
exports.classMethodOrPropertyCommon = classMethodOrPropertyCommon;
const classMethodOrDeclareMethodCommon = Object.assign({}, _core.functionCommon, {}, classMethodOrPropertyCommon, {
kind: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("get", "set", "method", "constructor")),
default: "method"
},
access: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("public", "private", "protected")),
optional: true
},
decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
optional: true
}
});
exports.classMethodOrDeclareMethodCommon = classMethodOrDeclareMethodCommon;
(0, _utils.default)("ClassMethod", {
aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method"],
builder: ["kind", "key", "params", "body", "computed", "static"],
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"],
fields: Object.assign({}, classMethodOrDeclareMethodCommon, {}, _core.functionTypeAnnotationCommon, {
body: {
validate: (0, _utils.assertNodeType)("BlockStatement")
}
})
});
(0, _utils.default)("ObjectPattern", {
visitor: ["properties", "typeAnnotation", "decorators"],
builder: ["properties"],
aliases: ["Pattern", "PatternLike", "LVal"],
fields: Object.assign({}, _core.patternLikeCommon, {
properties: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("RestElement", "ObjectProperty")))
}
})
});
(0, _utils.default)("SpreadElement", {
visitor: ["argument"],
aliases: ["UnaryLike"],
deprecatedAlias: "SpreadProperty",
fields: {
argument: {
validate: (0, _utils.assertNodeType)("Expression")
}
}
});
(0, _utils.default)("Super", {
aliases: ["Expression"]
});
(0, _utils.default)("TaggedTemplateExpression", {
visitor: ["tag", "quasi"],
aliases: ["Expression"],
fields: {
tag: {
validate: (0, _utils.assertNodeType)("Expression")
},
quasi: {
validate: (0, _utils.assertNodeType)("TemplateLiteral")
},
typeParameters: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
optional: true
}
}
});
(0, _utils.default)("TemplateElement", {
builder: ["value", "tail"],
fields: {
value: {
validate: (0, _utils.assertShape)({
raw: {
validate: (0, _utils.assertValueType)("string")
},
cooked: {
validate: (0, _utils.assertValueType)("string"),
optional: true
}
})
},
tail: {
validate: (0, _utils.assertValueType)("boolean"),
default: false
}
}
});
(0, _utils.default)("TemplateLiteral", {
visitor: ["quasis", "expressions"],
aliases: ["Expression", "Literal"],
fields: {
quasis: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TemplateElement")))
},
expressions: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression")), function (node, key, val) {
if (node.quasis.length !== val.length + 1) {
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}`);
}
})
}
}
});
(0, _utils.default)("YieldExpression", {
builder: ["argument", "delegate"],
visitor: ["argument"],
aliases: ["Expression", "Terminatorless"],
fields: {
delegate: {
validate: (0, _utils.assertValueType)("boolean"),
default: false
},
argument: {
optional: true,
validate: (0, _utils.assertNodeType)("Expression")
}
}
});
\ No newline at end of file
"use strict"; "use strict";
var _utils = _interopRequireWildcard(require("./utils")); var _utils = require("./utils");
var _es = require("./es2015"); var _core = require("./core");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
(0, _utils.default)("ArgumentPlaceholder", {}); (0, _utils.default)("ArgumentPlaceholder", {});
(0, _utils.default)("AwaitExpression", {
builder: ["argument"],
visitor: ["argument"],
aliases: ["Expression", "Terminatorless"],
fields: {
argument: {
validate: (0, _utils.assertNodeType)("Expression")
}
}
});
(0, _utils.default)("BindExpression", { (0, _utils.default)("BindExpression", {
visitor: ["object", "callee"], visitor: ["object", "callee"],
aliases: ["Expression"], aliases: ["Expression"],
fields: {} fields: !process.env.BABEL_TYPES_8_BREAKING ? {
object: {
validate: Object.assign(() => {}, {
oneOfNodeTypes: ["Expression"]
})
},
callee: {
validate: Object.assign(() => {}, {
oneOfNodeTypes: ["Expression"]
})
}
} : {
object: {
validate: (0, _utils.assertNodeType)("Expression")
},
callee: {
validate: (0, _utils.assertNodeType)("Expression")
}
}
}); });
(0, _utils.default)("ClassProperty", { (0, _utils.default)("ClassProperty", {
visitor: ["key", "value", "typeAnnotation", "decorators"], visitor: ["key", "value", "typeAnnotation", "decorators"],
builder: ["key", "value", "typeAnnotation", "decorators", "computed", "static"], builder: ["key", "value", "typeAnnotation", "decorators", "computed", "static"],
aliases: ["Property"], aliases: ["Property"],
fields: Object.assign({}, _es.classMethodOrPropertyCommon, { fields: Object.assign({}, _core.classMethodOrPropertyCommon, {
value: { value: {
validate: (0, _utils.assertNodeType)("Expression"), validate: (0, _utils.assertNodeType)("Expression"),
optional: true optional: true
...@@ -55,32 +59,6 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; ...@@ -55,32 +59,6 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
} }
}) })
}); });
(0, _utils.default)("OptionalMemberExpression", {
builder: ["object", "property", "computed", "optional"],
visitor: ["object", "property"],
aliases: ["Expression"],
fields: {
object: {
validate: (0, _utils.assertNodeType)("Expression")
},
property: {
validate: function () {
const normal = (0, _utils.assertNodeType)("Identifier");
const computed = (0, _utils.assertNodeType)("Expression");
return function (node, key, val) {
const validator = node.computed ? computed : normal;
validator(node, key, val);
};
}()
},
computed: {
default: false
},
optional: {
validate: (0, _utils.assertValueType)("boolean")
}
}
});
(0, _utils.default)("PipelineTopicExpression", { (0, _utils.default)("PipelineTopicExpression", {
builder: ["expression"], builder: ["expression"],
visitor: ["expression"], visitor: ["expression"],
...@@ -102,33 +80,9 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; ...@@ -102,33 +80,9 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
(0, _utils.default)("PipelinePrimaryTopicReference", { (0, _utils.default)("PipelinePrimaryTopicReference", {
aliases: ["Expression"] aliases: ["Expression"]
}); });
(0, _utils.default)("OptionalCallExpression", {
visitor: ["callee", "arguments", "typeParameters", "typeArguments"],
builder: ["callee", "arguments", "optional"],
aliases: ["Expression"],
fields: {
callee: {
validate: (0, _utils.assertNodeType)("Expression")
},
arguments: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName")))
},
optional: {
validate: (0, _utils.assertValueType)("boolean")
},
typeArguments: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"),
optional: true
},
typeParameters: {
validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"),
optional: true
}
}
});
(0, _utils.default)("ClassPrivateProperty", { (0, _utils.default)("ClassPrivateProperty", {
visitor: ["key", "value", "decorators"], visitor: ["key", "value", "decorators"],
builder: ["key", "value", "decorators"], builder: ["key", "value", "decorators", "static"],
aliases: ["Property", "Private"], aliases: ["Property", "Private"],
fields: { fields: {
key: { key: {
...@@ -138,6 +92,10 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; ...@@ -138,6 +92,10 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
validate: (0, _utils.assertNodeType)("Expression"), validate: (0, _utils.assertNodeType)("Expression"),
optional: true optional: true
}, },
typeAnnotation: {
validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"),
optional: true
},
decorators: { decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
optional: true optional: true
...@@ -148,7 +106,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; ...@@ -148,7 +106,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
builder: ["kind", "key", "params", "body", "static"], builder: ["kind", "key", "params", "body", "static"],
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"], visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"],
aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method", "Private"], aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method", "Private"],
fields: Object.assign({}, _es.classMethodOrDeclareMethodCommon, { fields: Object.assign({}, _core.classMethodOrDeclareMethodCommon, _core.functionTypeAnnotationCommon, {
key: { key: {
validate: (0, _utils.assertNodeType)("PrivateName") validate: (0, _utils.assertNodeType)("PrivateName")
}, },
...@@ -157,8 +115,16 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; ...@@ -157,8 +115,16 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
} }
}) })
}); });
(0, _utils.default)("Import", { (0, _utils.default)("ImportAttribute", {
aliases: ["Expression"] visitor: ["key", "value"],
fields: {
key: {
validate: (0, _utils.assertNodeType)("Identifier", "StringLiteral")
},
value: {
validate: (0, _utils.assertNodeType)("StringLiteral")
}
}
}); });
(0, _utils.default)("Decorator", { (0, _utils.default)("Decorator", {
visitor: ["expression"], visitor: ["expression"],
...@@ -170,10 +136,15 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; ...@@ -170,10 +136,15 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
}); });
(0, _utils.default)("DoExpression", { (0, _utils.default)("DoExpression", {
visitor: ["body"], visitor: ["body"],
builder: ["body", "async"],
aliases: ["Expression"], aliases: ["Expression"],
fields: { fields: {
body: { body: {
validate: (0, _utils.assertNodeType)("BlockStatement") validate: (0, _utils.assertNodeType)("BlockStatement")
},
async: {
validate: (0, _utils.assertValueType)("boolean"),
default: false
} }
} }
}); });
...@@ -186,15 +157,6 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; ...@@ -186,15 +157,6 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
} }
} }
}); });
(0, _utils.default)("ExportNamespaceSpecifier", {
visitor: ["exported"],
aliases: ["ModuleSpecifier"],
fields: {
exported: {
validate: (0, _utils.assertNodeType)("Identifier")
}
}
});
(0, _utils.default)("PrivateName", { (0, _utils.default)("PrivateName", {
visitor: ["id"], visitor: ["id"],
aliases: ["Private"], aliases: ["Private"],
...@@ -204,7 +166,26 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; ...@@ -204,7 +166,26 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
} }
} }
}); });
(0, _utils.default)("BigIntLiteral", { (0, _utils.default)("RecordExpression", {
visitor: ["properties"],
aliases: ["Expression"],
fields: {
properties: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ObjectProperty", "SpreadElement")))
}
}
});
(0, _utils.default)("TupleExpression", {
fields: {
elements: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement"))),
default: []
}
},
visitor: ["elements"],
aliases: ["Expression"]
});
(0, _utils.default)("DecimalLiteral", {
builder: ["value"], builder: ["value"],
fields: { fields: {
value: { value: {
...@@ -212,4 +193,22 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; ...@@ -212,4 +193,22 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
} }
}, },
aliases: ["Expression", "Pureish", "Literal", "Immutable"] aliases: ["Expression", "Pureish", "Literal", "Immutable"]
});
(0, _utils.default)("StaticBlock", {
visitor: ["body"],
fields: {
body: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement")))
}
},
aliases: ["Scopable", "BlockParent"]
});
(0, _utils.default)("ModuleExpression", {
visitor: ["body"],
fields: {
body: {
validate: (0, _utils.assertNodeType)("Program")
}
},
aliases: ["Expression"]
}); });
\ No newline at end of file
"use strict"; "use strict";
var _utils = _interopRequireWildcard(require("./utils")); var _utils = require("./utils");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const defineInterfaceishType = (name, typeParameterType = "TypeParameterDeclaration") => { const defineInterfaceishType = (name, typeParameterType = "TypeParameterDeclaration") => {
(0, _utils.default)(name, { (0, _utils.default)(name, {
...@@ -140,6 +136,7 @@ defineInterfaceishType("DeclareInterface"); ...@@ -140,6 +136,7 @@ defineInterfaceishType("DeclareInterface");
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"),
params: (0, _utils.validate)((0, _utils.arrayOfType)("FunctionTypeParam")), params: (0, _utils.validate)((0, _utils.arrayOfType)("FunctionTypeParam")),
rest: (0, _utils.validateOptionalType)("FunctionTypeParam"), rest: (0, _utils.validateOptionalType)("FunctionTypeParam"),
this: (0, _utils.validateOptionalType)("FunctionTypeParam"),
returnType: (0, _utils.validateType)("FlowType") returnType: (0, _utils.validateType)("FlowType")
} }
}); });
...@@ -266,7 +263,8 @@ defineInterfaceishType("InterfaceDeclaration"); ...@@ -266,7 +263,8 @@ defineInterfaceishType("InterfaceDeclaration");
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
proto: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), proto: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
optional: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), optional: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
variance: (0, _utils.validateOptionalType)("Variance") variance: (0, _utils.validateOptionalType)("Variance"),
method: (0, _utils.validate)((0, _utils.assertValueType)("boolean"))
} }
}); });
(0, _utils.default)("ObjectTypeSpreadProperty", { (0, _utils.default)("ObjectTypeSpreadProperty", {
...@@ -304,6 +302,9 @@ defineInterfaceishType("InterfaceDeclaration"); ...@@ -304,6 +302,9 @@ defineInterfaceishType("InterfaceDeclaration");
(0, _utils.default)("StringTypeAnnotation", { (0, _utils.default)("StringTypeAnnotation", {
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] aliases: ["Flow", "FlowType", "FlowBaseAnnotation"]
}); });
(0, _utils.default)("SymbolTypeAnnotation", {
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"]
});
(0, _utils.default)("ThisTypeAnnotation", { (0, _utils.default)("ThisTypeAnnotation", {
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] aliases: ["Flow", "FlowType", "FlowBaseAnnotation"]
}); });
...@@ -387,7 +388,7 @@ defineInterfaceishType("InterfaceDeclaration"); ...@@ -387,7 +388,7 @@ defineInterfaceishType("InterfaceDeclaration");
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] aliases: ["Flow", "FlowType", "FlowBaseAnnotation"]
}); });
(0, _utils.default)("EnumDeclaration", { (0, _utils.default)("EnumDeclaration", {
alises: ["Declaration"], aliases: ["Statement", "Declaration"],
visitor: ["id", "body"], visitor: ["id", "body"],
fields: { fields: {
id: (0, _utils.validateType)("Identifier"), id: (0, _utils.validateType)("Identifier"),
...@@ -398,31 +399,35 @@ defineInterfaceishType("InterfaceDeclaration"); ...@@ -398,31 +399,35 @@ defineInterfaceishType("InterfaceDeclaration");
aliases: ["EnumBody"], aliases: ["EnumBody"],
visitor: ["members"], visitor: ["members"],
fields: { fields: {
explicit: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
members: (0, _utils.validateArrayOfType)("EnumBooleanMember") members: (0, _utils.validateArrayOfType)("EnumBooleanMember"),
hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean"))
} }
}); });
(0, _utils.default)("EnumNumberBody", { (0, _utils.default)("EnumNumberBody", {
aliases: ["EnumBody"], aliases: ["EnumBody"],
visitor: ["members"], visitor: ["members"],
fields: { fields: {
explicit: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
members: (0, _utils.validateArrayOfType)("EnumNumberMember") members: (0, _utils.validateArrayOfType)("EnumNumberMember"),
hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean"))
} }
}); });
(0, _utils.default)("EnumStringBody", { (0, _utils.default)("EnumStringBody", {
aliases: ["EnumBody"], aliases: ["EnumBody"],
visitor: ["members"], visitor: ["members"],
fields: { fields: {
explicit: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
members: (0, _utils.validateArrayOfType)(["EnumStringMember", "EnumDefaultedMember"]) members: (0, _utils.validateArrayOfType)(["EnumStringMember", "EnumDefaultedMember"]),
hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean"))
} }
}); });
(0, _utils.default)("EnumSymbolBody", { (0, _utils.default)("EnumSymbolBody", {
aliases: ["EnumBody"], aliases: ["EnumBody"],
visitor: ["members"], visitor: ["members"],
fields: { fields: {
members: (0, _utils.validateArrayOfType)("EnumDefaultedMember") members: (0, _utils.validateArrayOfType)("EnumDefaultedMember"),
hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean"))
} }
}); });
(0, _utils.default)("EnumBooleanMember", { (0, _utils.default)("EnumBooleanMember", {
...@@ -455,4 +460,21 @@ defineInterfaceishType("InterfaceDeclaration"); ...@@ -455,4 +460,21 @@ defineInterfaceishType("InterfaceDeclaration");
fields: { fields: {
id: (0, _utils.validateType)("Identifier") id: (0, _utils.validateType)("Identifier")
} }
});
(0, _utils.default)("IndexedAccessType", {
visitor: ["objectType", "indexType"],
aliases: ["Flow", "FlowType"],
fields: {
objectType: (0, _utils.validateType)("FlowType"),
indexType: (0, _utils.validateType)("FlowType")
}
});
(0, _utils.default)("OptionalIndexedAccessType", {
visitor: ["objectType", "indexType"],
aliases: ["Flow", "FlowType"],
fields: {
objectType: (0, _utils.validateType)("FlowType"),
indexType: (0, _utils.validateType)("FlowType"),
optional: (0, _utils.validate)((0, _utils.assertValueType)("boolean"))
}
}); });
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment