|
@@ -0,0 +1,2886 @@
|
|
|
+"use strict";
|
|
|
+
|
|
|
+Object.defineProperty(exports, "__esModule", {
|
|
|
+ value: true
|
|
|
+});
|
|
|
+exports.anyTypeAnnotation = anyTypeAnnotation;
|
|
|
+exports.argumentPlaceholder = argumentPlaceholder;
|
|
|
+exports.arrayExpression = arrayExpression;
|
|
|
+exports.arrayPattern = arrayPattern;
|
|
|
+exports.arrayTypeAnnotation = arrayTypeAnnotation;
|
|
|
+exports.arrowFunctionExpression = arrowFunctionExpression;
|
|
|
+exports.assignmentExpression = assignmentExpression;
|
|
|
+exports.assignmentPattern = assignmentPattern;
|
|
|
+exports.awaitExpression = awaitExpression;
|
|
|
+exports.bigIntLiteral = bigIntLiteral;
|
|
|
+exports.binaryExpression = binaryExpression;
|
|
|
+exports.bindExpression = bindExpression;
|
|
|
+exports.blockStatement = blockStatement;
|
|
|
+exports.booleanLiteral = booleanLiteral;
|
|
|
+exports.booleanLiteralTypeAnnotation = booleanLiteralTypeAnnotation;
|
|
|
+exports.booleanTypeAnnotation = booleanTypeAnnotation;
|
|
|
+exports.breakStatement = breakStatement;
|
|
|
+exports.callExpression = callExpression;
|
|
|
+exports.catchClause = catchClause;
|
|
|
+exports.classAccessorProperty = classAccessorProperty;
|
|
|
+exports.classBody = classBody;
|
|
|
+exports.classDeclaration = classDeclaration;
|
|
|
+exports.classExpression = classExpression;
|
|
|
+exports.classImplements = classImplements;
|
|
|
+exports.classMethod = classMethod;
|
|
|
+exports.classPrivateMethod = classPrivateMethod;
|
|
|
+exports.classPrivateProperty = classPrivateProperty;
|
|
|
+exports.classProperty = classProperty;
|
|
|
+exports.conditionalExpression = conditionalExpression;
|
|
|
+exports.continueStatement = continueStatement;
|
|
|
+exports.debuggerStatement = debuggerStatement;
|
|
|
+exports.decimalLiteral = decimalLiteral;
|
|
|
+exports.declareClass = declareClass;
|
|
|
+exports.declareExportAllDeclaration = declareExportAllDeclaration;
|
|
|
+exports.declareExportDeclaration = declareExportDeclaration;
|
|
|
+exports.declareFunction = declareFunction;
|
|
|
+exports.declareInterface = declareInterface;
|
|
|
+exports.declareModule = declareModule;
|
|
|
+exports.declareModuleExports = declareModuleExports;
|
|
|
+exports.declareOpaqueType = declareOpaqueType;
|
|
|
+exports.declareTypeAlias = declareTypeAlias;
|
|
|
+exports.declareVariable = declareVariable;
|
|
|
+exports.declaredPredicate = declaredPredicate;
|
|
|
+exports.decorator = decorator;
|
|
|
+exports.directive = directive;
|
|
|
+exports.directiveLiteral = directiveLiteral;
|
|
|
+exports.doExpression = doExpression;
|
|
|
+exports.doWhileStatement = doWhileStatement;
|
|
|
+exports.emptyStatement = emptyStatement;
|
|
|
+exports.emptyTypeAnnotation = emptyTypeAnnotation;
|
|
|
+exports.enumBooleanBody = enumBooleanBody;
|
|
|
+exports.enumBooleanMember = enumBooleanMember;
|
|
|
+exports.enumDeclaration = enumDeclaration;
|
|
|
+exports.enumDefaultedMember = enumDefaultedMember;
|
|
|
+exports.enumNumberBody = enumNumberBody;
|
|
|
+exports.enumNumberMember = enumNumberMember;
|
|
|
+exports.enumStringBody = enumStringBody;
|
|
|
+exports.enumStringMember = enumStringMember;
|
|
|
+exports.enumSymbolBody = enumSymbolBody;
|
|
|
+exports.existsTypeAnnotation = existsTypeAnnotation;
|
|
|
+exports.exportAllDeclaration = exportAllDeclaration;
|
|
|
+exports.exportDefaultDeclaration = exportDefaultDeclaration;
|
|
|
+exports.exportDefaultSpecifier = exportDefaultSpecifier;
|
|
|
+exports.exportNamedDeclaration = exportNamedDeclaration;
|
|
|
+exports.exportNamespaceSpecifier = exportNamespaceSpecifier;
|
|
|
+exports.exportSpecifier = exportSpecifier;
|
|
|
+exports.expressionStatement = expressionStatement;
|
|
|
+exports.file = file;
|
|
|
+exports.forInStatement = forInStatement;
|
|
|
+exports.forOfStatement = forOfStatement;
|
|
|
+exports.forStatement = forStatement;
|
|
|
+exports.functionDeclaration = functionDeclaration;
|
|
|
+exports.functionExpression = functionExpression;
|
|
|
+exports.functionTypeAnnotation = functionTypeAnnotation;
|
|
|
+exports.functionTypeParam = functionTypeParam;
|
|
|
+exports.genericTypeAnnotation = genericTypeAnnotation;
|
|
|
+exports.identifier = identifier;
|
|
|
+exports.ifStatement = ifStatement;
|
|
|
+exports.import = _import;
|
|
|
+exports.importAttribute = importAttribute;
|
|
|
+exports.importDeclaration = importDeclaration;
|
|
|
+exports.importDefaultSpecifier = importDefaultSpecifier;
|
|
|
+exports.importExpression = importExpression;
|
|
|
+exports.importNamespaceSpecifier = importNamespaceSpecifier;
|
|
|
+exports.importSpecifier = importSpecifier;
|
|
|
+exports.indexedAccessType = indexedAccessType;
|
|
|
+exports.inferredPredicate = inferredPredicate;
|
|
|
+exports.interfaceDeclaration = interfaceDeclaration;
|
|
|
+exports.interfaceExtends = interfaceExtends;
|
|
|
+exports.interfaceTypeAnnotation = interfaceTypeAnnotation;
|
|
|
+exports.interpreterDirective = interpreterDirective;
|
|
|
+exports.intersectionTypeAnnotation = intersectionTypeAnnotation;
|
|
|
+exports.jSXAttribute = exports.jsxAttribute = jsxAttribute;
|
|
|
+exports.jSXClosingElement = exports.jsxClosingElement = jsxClosingElement;
|
|
|
+exports.jSXClosingFragment = exports.jsxClosingFragment = jsxClosingFragment;
|
|
|
+exports.jSXElement = exports.jsxElement = jsxElement;
|
|
|
+exports.jSXEmptyExpression = exports.jsxEmptyExpression = jsxEmptyExpression;
|
|
|
+exports.jSXExpressionContainer = exports.jsxExpressionContainer = jsxExpressionContainer;
|
|
|
+exports.jSXFragment = exports.jsxFragment = jsxFragment;
|
|
|
+exports.jSXIdentifier = exports.jsxIdentifier = jsxIdentifier;
|
|
|
+exports.jSXMemberExpression = exports.jsxMemberExpression = jsxMemberExpression;
|
|
|
+exports.jSXNamespacedName = exports.jsxNamespacedName = jsxNamespacedName;
|
|
|
+exports.jSXOpeningElement = exports.jsxOpeningElement = jsxOpeningElement;
|
|
|
+exports.jSXOpeningFragment = exports.jsxOpeningFragment = jsxOpeningFragment;
|
|
|
+exports.jSXSpreadAttribute = exports.jsxSpreadAttribute = jsxSpreadAttribute;
|
|
|
+exports.jSXSpreadChild = exports.jsxSpreadChild = jsxSpreadChild;
|
|
|
+exports.jSXText = exports.jsxText = jsxText;
|
|
|
+exports.labeledStatement = labeledStatement;
|
|
|
+exports.logicalExpression = logicalExpression;
|
|
|
+exports.memberExpression = memberExpression;
|
|
|
+exports.metaProperty = metaProperty;
|
|
|
+exports.mixedTypeAnnotation = mixedTypeAnnotation;
|
|
|
+exports.moduleExpression = moduleExpression;
|
|
|
+exports.newExpression = newExpression;
|
|
|
+exports.noop = noop;
|
|
|
+exports.nullLiteral = nullLiteral;
|
|
|
+exports.nullLiteralTypeAnnotation = nullLiteralTypeAnnotation;
|
|
|
+exports.nullableTypeAnnotation = nullableTypeAnnotation;
|
|
|
+exports.numberLiteral = NumberLiteral;
|
|
|
+exports.numberLiteralTypeAnnotation = numberLiteralTypeAnnotation;
|
|
|
+exports.numberTypeAnnotation = numberTypeAnnotation;
|
|
|
+exports.numericLiteral = numericLiteral;
|
|
|
+exports.objectExpression = objectExpression;
|
|
|
+exports.objectMethod = objectMethod;
|
|
|
+exports.objectPattern = objectPattern;
|
|
|
+exports.objectProperty = objectProperty;
|
|
|
+exports.objectTypeAnnotation = objectTypeAnnotation;
|
|
|
+exports.objectTypeCallProperty = objectTypeCallProperty;
|
|
|
+exports.objectTypeIndexer = objectTypeIndexer;
|
|
|
+exports.objectTypeInternalSlot = objectTypeInternalSlot;
|
|
|
+exports.objectTypeProperty = objectTypeProperty;
|
|
|
+exports.objectTypeSpreadProperty = objectTypeSpreadProperty;
|
|
|
+exports.opaqueType = opaqueType;
|
|
|
+exports.optionalCallExpression = optionalCallExpression;
|
|
|
+exports.optionalIndexedAccessType = optionalIndexedAccessType;
|
|
|
+exports.optionalMemberExpression = optionalMemberExpression;
|
|
|
+exports.parenthesizedExpression = parenthesizedExpression;
|
|
|
+exports.pipelineBareFunction = pipelineBareFunction;
|
|
|
+exports.pipelinePrimaryTopicReference = pipelinePrimaryTopicReference;
|
|
|
+exports.pipelineTopicExpression = pipelineTopicExpression;
|
|
|
+exports.placeholder = placeholder;
|
|
|
+exports.privateName = privateName;
|
|
|
+exports.program = program;
|
|
|
+exports.qualifiedTypeIdentifier = qualifiedTypeIdentifier;
|
|
|
+exports.recordExpression = recordExpression;
|
|
|
+exports.regExpLiteral = regExpLiteral;
|
|
|
+exports.regexLiteral = RegexLiteral;
|
|
|
+exports.restElement = restElement;
|
|
|
+exports.restProperty = RestProperty;
|
|
|
+exports.returnStatement = returnStatement;
|
|
|
+exports.sequenceExpression = sequenceExpression;
|
|
|
+exports.spreadElement = spreadElement;
|
|
|
+exports.spreadProperty = SpreadProperty;
|
|
|
+exports.staticBlock = staticBlock;
|
|
|
+exports.stringLiteral = stringLiteral;
|
|
|
+exports.stringLiteralTypeAnnotation = stringLiteralTypeAnnotation;
|
|
|
+exports.stringTypeAnnotation = stringTypeAnnotation;
|
|
|
+exports.super = _super;
|
|
|
+exports.switchCase = switchCase;
|
|
|
+exports.switchStatement = switchStatement;
|
|
|
+exports.symbolTypeAnnotation = symbolTypeAnnotation;
|
|
|
+exports.taggedTemplateExpression = taggedTemplateExpression;
|
|
|
+exports.templateElement = templateElement;
|
|
|
+exports.templateLiteral = templateLiteral;
|
|
|
+exports.thisExpression = thisExpression;
|
|
|
+exports.thisTypeAnnotation = thisTypeAnnotation;
|
|
|
+exports.throwStatement = throwStatement;
|
|
|
+exports.topicReference = topicReference;
|
|
|
+exports.tryStatement = tryStatement;
|
|
|
+exports.tSAnyKeyword = exports.tsAnyKeyword = tsAnyKeyword;
|
|
|
+exports.tSArrayType = exports.tsArrayType = tsArrayType;
|
|
|
+exports.tSAsExpression = exports.tsAsExpression = tsAsExpression;
|
|
|
+exports.tSBigIntKeyword = exports.tsBigIntKeyword = tsBigIntKeyword;
|
|
|
+exports.tSBooleanKeyword = exports.tsBooleanKeyword = tsBooleanKeyword;
|
|
|
+exports.tSCallSignatureDeclaration = exports.tsCallSignatureDeclaration = tsCallSignatureDeclaration;
|
|
|
+exports.tSConditionalType = exports.tsConditionalType = tsConditionalType;
|
|
|
+exports.tSConstructSignatureDeclaration = exports.tsConstructSignatureDeclaration = tsConstructSignatureDeclaration;
|
|
|
+exports.tSConstructorType = exports.tsConstructorType = tsConstructorType;
|
|
|
+exports.tSDeclareFunction = exports.tsDeclareFunction = tsDeclareFunction;
|
|
|
+exports.tSDeclareMethod = exports.tsDeclareMethod = tsDeclareMethod;
|
|
|
+exports.tSEnumBody = exports.tsEnumBody = tsEnumBody;
|
|
|
+exports.tSEnumDeclaration = exports.tsEnumDeclaration = tsEnumDeclaration;
|
|
|
+exports.tSEnumMember = exports.tsEnumMember = tsEnumMember;
|
|
|
+exports.tSExportAssignment = exports.tsExportAssignment = tsExportAssignment;
|
|
|
+exports.tSExpressionWithTypeArguments = exports.tsExpressionWithTypeArguments = tsExpressionWithTypeArguments;
|
|
|
+exports.tSExternalModuleReference = exports.tsExternalModuleReference = tsExternalModuleReference;
|
|
|
+exports.tSFunctionType = exports.tsFunctionType = tsFunctionType;
|
|
|
+exports.tSImportEqualsDeclaration = exports.tsImportEqualsDeclaration = tsImportEqualsDeclaration;
|
|
|
+exports.tSImportType = exports.tsImportType = tsImportType;
|
|
|
+exports.tSIndexSignature = exports.tsIndexSignature = tsIndexSignature;
|
|
|
+exports.tSIndexedAccessType = exports.tsIndexedAccessType = tsIndexedAccessType;
|
|
|
+exports.tSInferType = exports.tsInferType = tsInferType;
|
|
|
+exports.tSInstantiationExpression = exports.tsInstantiationExpression = tsInstantiationExpression;
|
|
|
+exports.tSInterfaceBody = exports.tsInterfaceBody = tsInterfaceBody;
|
|
|
+exports.tSInterfaceDeclaration = exports.tsInterfaceDeclaration = tsInterfaceDeclaration;
|
|
|
+exports.tSIntersectionType = exports.tsIntersectionType = tsIntersectionType;
|
|
|
+exports.tSIntrinsicKeyword = exports.tsIntrinsicKeyword = tsIntrinsicKeyword;
|
|
|
+exports.tSLiteralType = exports.tsLiteralType = tsLiteralType;
|
|
|
+exports.tSMappedType = exports.tsMappedType = tsMappedType;
|
|
|
+exports.tSMethodSignature = exports.tsMethodSignature = tsMethodSignature;
|
|
|
+exports.tSModuleBlock = exports.tsModuleBlock = tsModuleBlock;
|
|
|
+exports.tSModuleDeclaration = exports.tsModuleDeclaration = tsModuleDeclaration;
|
|
|
+exports.tSNamedTupleMember = exports.tsNamedTupleMember = tsNamedTupleMember;
|
|
|
+exports.tSNamespaceExportDeclaration = exports.tsNamespaceExportDeclaration = tsNamespaceExportDeclaration;
|
|
|
+exports.tSNeverKeyword = exports.tsNeverKeyword = tsNeverKeyword;
|
|
|
+exports.tSNonNullExpression = exports.tsNonNullExpression = tsNonNullExpression;
|
|
|
+exports.tSNullKeyword = exports.tsNullKeyword = tsNullKeyword;
|
|
|
+exports.tSNumberKeyword = exports.tsNumberKeyword = tsNumberKeyword;
|
|
|
+exports.tSObjectKeyword = exports.tsObjectKeyword = tsObjectKeyword;
|
|
|
+exports.tSOptionalType = exports.tsOptionalType = tsOptionalType;
|
|
|
+exports.tSParameterProperty = exports.tsParameterProperty = tsParameterProperty;
|
|
|
+exports.tSParenthesizedType = exports.tsParenthesizedType = tsParenthesizedType;
|
|
|
+exports.tSPropertySignature = exports.tsPropertySignature = tsPropertySignature;
|
|
|
+exports.tSQualifiedName = exports.tsQualifiedName = tsQualifiedName;
|
|
|
+exports.tSRestType = exports.tsRestType = tsRestType;
|
|
|
+exports.tSSatisfiesExpression = exports.tsSatisfiesExpression = tsSatisfiesExpression;
|
|
|
+exports.tSStringKeyword = exports.tsStringKeyword = tsStringKeyword;
|
|
|
+exports.tSSymbolKeyword = exports.tsSymbolKeyword = tsSymbolKeyword;
|
|
|
+exports.tSTemplateLiteralType = exports.tsTemplateLiteralType = tsTemplateLiteralType;
|
|
|
+exports.tSThisType = exports.tsThisType = tsThisType;
|
|
|
+exports.tSTupleType = exports.tsTupleType = tsTupleType;
|
|
|
+exports.tSTypeAliasDeclaration = exports.tsTypeAliasDeclaration = tsTypeAliasDeclaration;
|
|
|
+exports.tSTypeAnnotation = exports.tsTypeAnnotation = tsTypeAnnotation;
|
|
|
+exports.tSTypeAssertion = exports.tsTypeAssertion = tsTypeAssertion;
|
|
|
+exports.tSTypeLiteral = exports.tsTypeLiteral = tsTypeLiteral;
|
|
|
+exports.tSTypeOperator = exports.tsTypeOperator = tsTypeOperator;
|
|
|
+exports.tSTypeParameter = exports.tsTypeParameter = tsTypeParameter;
|
|
|
+exports.tSTypeParameterDeclaration = exports.tsTypeParameterDeclaration = tsTypeParameterDeclaration;
|
|
|
+exports.tSTypeParameterInstantiation = exports.tsTypeParameterInstantiation = tsTypeParameterInstantiation;
|
|
|
+exports.tSTypePredicate = exports.tsTypePredicate = tsTypePredicate;
|
|
|
+exports.tSTypeQuery = exports.tsTypeQuery = tsTypeQuery;
|
|
|
+exports.tSTypeReference = exports.tsTypeReference = tsTypeReference;
|
|
|
+exports.tSUndefinedKeyword = exports.tsUndefinedKeyword = tsUndefinedKeyword;
|
|
|
+exports.tSUnionType = exports.tsUnionType = tsUnionType;
|
|
|
+exports.tSUnknownKeyword = exports.tsUnknownKeyword = tsUnknownKeyword;
|
|
|
+exports.tSVoidKeyword = exports.tsVoidKeyword = tsVoidKeyword;
|
|
|
+exports.tupleExpression = tupleExpression;
|
|
|
+exports.tupleTypeAnnotation = tupleTypeAnnotation;
|
|
|
+exports.typeAlias = typeAlias;
|
|
|
+exports.typeAnnotation = typeAnnotation;
|
|
|
+exports.typeCastExpression = typeCastExpression;
|
|
|
+exports.typeParameter = typeParameter;
|
|
|
+exports.typeParameterDeclaration = typeParameterDeclaration;
|
|
|
+exports.typeParameterInstantiation = typeParameterInstantiation;
|
|
|
+exports.typeofTypeAnnotation = typeofTypeAnnotation;
|
|
|
+exports.unaryExpression = unaryExpression;
|
|
|
+exports.unionTypeAnnotation = unionTypeAnnotation;
|
|
|
+exports.updateExpression = updateExpression;
|
|
|
+exports.v8IntrinsicIdentifier = v8IntrinsicIdentifier;
|
|
|
+exports.variableDeclaration = variableDeclaration;
|
|
|
+exports.variableDeclarator = variableDeclarator;
|
|
|
+exports.variance = variance;
|
|
|
+exports.voidTypeAnnotation = voidTypeAnnotation;
|
|
|
+exports.whileStatement = whileStatement;
|
|
|
+exports.withStatement = withStatement;
|
|
|
+exports.yieldExpression = yieldExpression;
|
|
|
+var _validate = require("../../validators/validate.js");
|
|
|
+var _deprecationWarning = require("../../utils/deprecationWarning.js");
|
|
|
+var utils = require("../../definitions/utils.js");
|
|
|
+const {
|
|
|
+ validateInternal: validate
|
|
|
+} = _validate;
|
|
|
+const {
|
|
|
+ NODE_FIELDS
|
|
|
+} = utils;
|
|
|
+function arrayExpression(elements = []) {
|
|
|
+ const node = {
|
|
|
+ type: "ArrayExpression",
|
|
|
+ elements
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ArrayExpression;
|
|
|
+ validate(defs.elements, node, "elements", elements, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function assignmentExpression(operator, left, right) {
|
|
|
+ const node = {
|
|
|
+ type: "AssignmentExpression",
|
|
|
+ operator,
|
|
|
+ left,
|
|
|
+ right
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.AssignmentExpression;
|
|
|
+ validate(defs.operator, node, "operator", operator);
|
|
|
+ validate(defs.left, node, "left", left, 1);
|
|
|
+ validate(defs.right, node, "right", right, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function binaryExpression(operator, left, right) {
|
|
|
+ const node = {
|
|
|
+ type: "BinaryExpression",
|
|
|
+ operator,
|
|
|
+ left,
|
|
|
+ right
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.BinaryExpression;
|
|
|
+ validate(defs.operator, node, "operator", operator);
|
|
|
+ validate(defs.left, node, "left", left, 1);
|
|
|
+ validate(defs.right, node, "right", right, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function interpreterDirective(value) {
|
|
|
+ const node = {
|
|
|
+ type: "InterpreterDirective",
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.InterpreterDirective;
|
|
|
+ validate(defs.value, node, "value", value);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function directive(value) {
|
|
|
+ const node = {
|
|
|
+ type: "Directive",
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.Directive;
|
|
|
+ validate(defs.value, node, "value", value, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function directiveLiteral(value) {
|
|
|
+ const node = {
|
|
|
+ type: "DirectiveLiteral",
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DirectiveLiteral;
|
|
|
+ validate(defs.value, node, "value", value);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function blockStatement(body, directives = []) {
|
|
|
+ const node = {
|
|
|
+ type: "BlockStatement",
|
|
|
+ body,
|
|
|
+ directives
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.BlockStatement;
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ validate(defs.directives, node, "directives", directives, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function breakStatement(label = null) {
|
|
|
+ const node = {
|
|
|
+ type: "BreakStatement",
|
|
|
+ label
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.BreakStatement;
|
|
|
+ validate(defs.label, node, "label", label, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function callExpression(callee, _arguments) {
|
|
|
+ const node = {
|
|
|
+ type: "CallExpression",
|
|
|
+ callee,
|
|
|
+ arguments: _arguments
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.CallExpression;
|
|
|
+ validate(defs.callee, node, "callee", callee, 1);
|
|
|
+ validate(defs.arguments, node, "arguments", _arguments, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function catchClause(param = null, body) {
|
|
|
+ const node = {
|
|
|
+ type: "CatchClause",
|
|
|
+ param,
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.CatchClause;
|
|
|
+ validate(defs.param, node, "param", param, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function conditionalExpression(test, consequent, alternate) {
|
|
|
+ const node = {
|
|
|
+ type: "ConditionalExpression",
|
|
|
+ test,
|
|
|
+ consequent,
|
|
|
+ alternate
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ConditionalExpression;
|
|
|
+ validate(defs.test, node, "test", test, 1);
|
|
|
+ validate(defs.consequent, node, "consequent", consequent, 1);
|
|
|
+ validate(defs.alternate, node, "alternate", alternate, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function continueStatement(label = null) {
|
|
|
+ const node = {
|
|
|
+ type: "ContinueStatement",
|
|
|
+ label
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ContinueStatement;
|
|
|
+ validate(defs.label, node, "label", label, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function debuggerStatement() {
|
|
|
+ return {
|
|
|
+ type: "DebuggerStatement"
|
|
|
+ };
|
|
|
+}
|
|
|
+function doWhileStatement(test, body) {
|
|
|
+ const node = {
|
|
|
+ type: "DoWhileStatement",
|
|
|
+ test,
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DoWhileStatement;
|
|
|
+ validate(defs.test, node, "test", test, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function emptyStatement() {
|
|
|
+ return {
|
|
|
+ type: "EmptyStatement"
|
|
|
+ };
|
|
|
+}
|
|
|
+function expressionStatement(expression) {
|
|
|
+ const node = {
|
|
|
+ type: "ExpressionStatement",
|
|
|
+ expression
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ExpressionStatement;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function file(program, comments = null, tokens = null) {
|
|
|
+ const node = {
|
|
|
+ type: "File",
|
|
|
+ program,
|
|
|
+ comments,
|
|
|
+ tokens
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.File;
|
|
|
+ validate(defs.program, node, "program", program, 1);
|
|
|
+ validate(defs.comments, node, "comments", comments, 1);
|
|
|
+ validate(defs.tokens, node, "tokens", tokens);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function forInStatement(left, right, body) {
|
|
|
+ const node = {
|
|
|
+ type: "ForInStatement",
|
|
|
+ left,
|
|
|
+ right,
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ForInStatement;
|
|
|
+ validate(defs.left, node, "left", left, 1);
|
|
|
+ validate(defs.right, node, "right", right, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function forStatement(init = null, test = null, update = null, body) {
|
|
|
+ const node = {
|
|
|
+ type: "ForStatement",
|
|
|
+ init,
|
|
|
+ test,
|
|
|
+ update,
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ForStatement;
|
|
|
+ validate(defs.init, node, "init", init, 1);
|
|
|
+ validate(defs.test, node, "test", test, 1);
|
|
|
+ validate(defs.update, node, "update", update, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function functionDeclaration(id = null, params, body, generator = false, async = false) {
|
|
|
+ const node = {
|
|
|
+ type: "FunctionDeclaration",
|
|
|
+ id,
|
|
|
+ params,
|
|
|
+ body,
|
|
|
+ generator,
|
|
|
+ async
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.FunctionDeclaration;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.params, node, "params", params, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ validate(defs.generator, node, "generator", generator);
|
|
|
+ validate(defs.async, node, "async", async);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function functionExpression(id = null, params, body, generator = false, async = false) {
|
|
|
+ const node = {
|
|
|
+ type: "FunctionExpression",
|
|
|
+ id,
|
|
|
+ params,
|
|
|
+ body,
|
|
|
+ generator,
|
|
|
+ async
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.FunctionExpression;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.params, node, "params", params, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ validate(defs.generator, node, "generator", generator);
|
|
|
+ validate(defs.async, node, "async", async);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function identifier(name) {
|
|
|
+ const node = {
|
|
|
+ type: "Identifier",
|
|
|
+ name
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.Identifier;
|
|
|
+ validate(defs.name, node, "name", name);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function ifStatement(test, consequent, alternate = null) {
|
|
|
+ const node = {
|
|
|
+ type: "IfStatement",
|
|
|
+ test,
|
|
|
+ consequent,
|
|
|
+ alternate
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.IfStatement;
|
|
|
+ validate(defs.test, node, "test", test, 1);
|
|
|
+ validate(defs.consequent, node, "consequent", consequent, 1);
|
|
|
+ validate(defs.alternate, node, "alternate", alternate, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function labeledStatement(label, body) {
|
|
|
+ const node = {
|
|
|
+ type: "LabeledStatement",
|
|
|
+ label,
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.LabeledStatement;
|
|
|
+ validate(defs.label, node, "label", label, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function stringLiteral(value) {
|
|
|
+ const node = {
|
|
|
+ type: "StringLiteral",
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.StringLiteral;
|
|
|
+ validate(defs.value, node, "value", value);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function numericLiteral(value) {
|
|
|
+ const node = {
|
|
|
+ type: "NumericLiteral",
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.NumericLiteral;
|
|
|
+ validate(defs.value, node, "value", value);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function nullLiteral() {
|
|
|
+ return {
|
|
|
+ type: "NullLiteral"
|
|
|
+ };
|
|
|
+}
|
|
|
+function booleanLiteral(value) {
|
|
|
+ const node = {
|
|
|
+ type: "BooleanLiteral",
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.BooleanLiteral;
|
|
|
+ validate(defs.value, node, "value", value);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function regExpLiteral(pattern, flags = "") {
|
|
|
+ const node = {
|
|
|
+ type: "RegExpLiteral",
|
|
|
+ pattern,
|
|
|
+ flags
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.RegExpLiteral;
|
|
|
+ validate(defs.pattern, node, "pattern", pattern);
|
|
|
+ validate(defs.flags, node, "flags", flags);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function logicalExpression(operator, left, right) {
|
|
|
+ const node = {
|
|
|
+ type: "LogicalExpression",
|
|
|
+ operator,
|
|
|
+ left,
|
|
|
+ right
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.LogicalExpression;
|
|
|
+ validate(defs.operator, node, "operator", operator);
|
|
|
+ validate(defs.left, node, "left", left, 1);
|
|
|
+ validate(defs.right, node, "right", right, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function memberExpression(object, property, computed = false, optional = null) {
|
|
|
+ const node = {
|
|
|
+ type: "MemberExpression",
|
|
|
+ object,
|
|
|
+ property,
|
|
|
+ computed,
|
|
|
+ optional
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.MemberExpression;
|
|
|
+ validate(defs.object, node, "object", object, 1);
|
|
|
+ validate(defs.property, node, "property", property, 1);
|
|
|
+ validate(defs.computed, node, "computed", computed);
|
|
|
+ validate(defs.optional, node, "optional", optional);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function newExpression(callee, _arguments) {
|
|
|
+ const node = {
|
|
|
+ type: "NewExpression",
|
|
|
+ callee,
|
|
|
+ arguments: _arguments
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.NewExpression;
|
|
|
+ validate(defs.callee, node, "callee", callee, 1);
|
|
|
+ validate(defs.arguments, node, "arguments", _arguments, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function program(body, directives = [], sourceType = "script", interpreter = null) {
|
|
|
+ const node = {
|
|
|
+ type: "Program",
|
|
|
+ body,
|
|
|
+ directives,
|
|
|
+ sourceType,
|
|
|
+ interpreter
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.Program;
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ validate(defs.directives, node, "directives", directives, 1);
|
|
|
+ validate(defs.sourceType, node, "sourceType", sourceType);
|
|
|
+ validate(defs.interpreter, node, "interpreter", interpreter, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function objectExpression(properties) {
|
|
|
+ const node = {
|
|
|
+ type: "ObjectExpression",
|
|
|
+ properties
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ObjectExpression;
|
|
|
+ validate(defs.properties, node, "properties", properties, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function objectMethod(kind = "method", key, params, body, computed = false, generator = false, async = false) {
|
|
|
+ const node = {
|
|
|
+ type: "ObjectMethod",
|
|
|
+ kind,
|
|
|
+ key,
|
|
|
+ params,
|
|
|
+ body,
|
|
|
+ computed,
|
|
|
+ generator,
|
|
|
+ async
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ObjectMethod;
|
|
|
+ validate(defs.kind, node, "kind", kind);
|
|
|
+ validate(defs.key, node, "key", key, 1);
|
|
|
+ validate(defs.params, node, "params", params, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ validate(defs.computed, node, "computed", computed);
|
|
|
+ validate(defs.generator, node, "generator", generator);
|
|
|
+ validate(defs.async, node, "async", async);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function objectProperty(key, value, computed = false, shorthand = false, decorators = null) {
|
|
|
+ const node = {
|
|
|
+ type: "ObjectProperty",
|
|
|
+ key,
|
|
|
+ value,
|
|
|
+ computed,
|
|
|
+ shorthand,
|
|
|
+ decorators
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ObjectProperty;
|
|
|
+ validate(defs.key, node, "key", key, 1);
|
|
|
+ validate(defs.value, node, "value", value, 1);
|
|
|
+ validate(defs.computed, node, "computed", computed);
|
|
|
+ validate(defs.shorthand, node, "shorthand", shorthand);
|
|
|
+ validate(defs.decorators, node, "decorators", decorators, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function restElement(argument) {
|
|
|
+ const node = {
|
|
|
+ type: "RestElement",
|
|
|
+ argument
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.RestElement;
|
|
|
+ validate(defs.argument, node, "argument", argument, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function returnStatement(argument = null) {
|
|
|
+ const node = {
|
|
|
+ type: "ReturnStatement",
|
|
|
+ argument
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ReturnStatement;
|
|
|
+ validate(defs.argument, node, "argument", argument, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function sequenceExpression(expressions) {
|
|
|
+ const node = {
|
|
|
+ type: "SequenceExpression",
|
|
|
+ expressions
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.SequenceExpression;
|
|
|
+ validate(defs.expressions, node, "expressions", expressions, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function parenthesizedExpression(expression) {
|
|
|
+ const node = {
|
|
|
+ type: "ParenthesizedExpression",
|
|
|
+ expression
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ParenthesizedExpression;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function switchCase(test = null, consequent) {
|
|
|
+ const node = {
|
|
|
+ type: "SwitchCase",
|
|
|
+ test,
|
|
|
+ consequent
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.SwitchCase;
|
|
|
+ validate(defs.test, node, "test", test, 1);
|
|
|
+ validate(defs.consequent, node, "consequent", consequent, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function switchStatement(discriminant, cases) {
|
|
|
+ const node = {
|
|
|
+ type: "SwitchStatement",
|
|
|
+ discriminant,
|
|
|
+ cases
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.SwitchStatement;
|
|
|
+ validate(defs.discriminant, node, "discriminant", discriminant, 1);
|
|
|
+ validate(defs.cases, node, "cases", cases, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function thisExpression() {
|
|
|
+ return {
|
|
|
+ type: "ThisExpression"
|
|
|
+ };
|
|
|
+}
|
|
|
+function throwStatement(argument) {
|
|
|
+ const node = {
|
|
|
+ type: "ThrowStatement",
|
|
|
+ argument
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ThrowStatement;
|
|
|
+ validate(defs.argument, node, "argument", argument, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tryStatement(block, handler = null, finalizer = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TryStatement",
|
|
|
+ block,
|
|
|
+ handler,
|
|
|
+ finalizer
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TryStatement;
|
|
|
+ validate(defs.block, node, "block", block, 1);
|
|
|
+ validate(defs.handler, node, "handler", handler, 1);
|
|
|
+ validate(defs.finalizer, node, "finalizer", finalizer, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function unaryExpression(operator, argument, prefix = true) {
|
|
|
+ const node = {
|
|
|
+ type: "UnaryExpression",
|
|
|
+ operator,
|
|
|
+ argument,
|
|
|
+ prefix
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.UnaryExpression;
|
|
|
+ validate(defs.operator, node, "operator", operator);
|
|
|
+ validate(defs.argument, node, "argument", argument, 1);
|
|
|
+ validate(defs.prefix, node, "prefix", prefix);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function updateExpression(operator, argument, prefix = false) {
|
|
|
+ const node = {
|
|
|
+ type: "UpdateExpression",
|
|
|
+ operator,
|
|
|
+ argument,
|
|
|
+ prefix
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.UpdateExpression;
|
|
|
+ validate(defs.operator, node, "operator", operator);
|
|
|
+ validate(defs.argument, node, "argument", argument, 1);
|
|
|
+ validate(defs.prefix, node, "prefix", prefix);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function variableDeclaration(kind, declarations) {
|
|
|
+ const node = {
|
|
|
+ type: "VariableDeclaration",
|
|
|
+ kind,
|
|
|
+ declarations
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.VariableDeclaration;
|
|
|
+ validate(defs.kind, node, "kind", kind);
|
|
|
+ validate(defs.declarations, node, "declarations", declarations, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function variableDeclarator(id, init = null) {
|
|
|
+ const node = {
|
|
|
+ type: "VariableDeclarator",
|
|
|
+ id,
|
|
|
+ init
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.VariableDeclarator;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.init, node, "init", init, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function whileStatement(test, body) {
|
|
|
+ const node = {
|
|
|
+ type: "WhileStatement",
|
|
|
+ test,
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.WhileStatement;
|
|
|
+ validate(defs.test, node, "test", test, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function withStatement(object, body) {
|
|
|
+ const node = {
|
|
|
+ type: "WithStatement",
|
|
|
+ object,
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.WithStatement;
|
|
|
+ validate(defs.object, node, "object", object, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function assignmentPattern(left, right) {
|
|
|
+ const node = {
|
|
|
+ type: "AssignmentPattern",
|
|
|
+ left,
|
|
|
+ right
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.AssignmentPattern;
|
|
|
+ validate(defs.left, node, "left", left, 1);
|
|
|
+ validate(defs.right, node, "right", right, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function arrayPattern(elements) {
|
|
|
+ const node = {
|
|
|
+ type: "ArrayPattern",
|
|
|
+ elements
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ArrayPattern;
|
|
|
+ validate(defs.elements, node, "elements", elements, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function arrowFunctionExpression(params, body, async = false) {
|
|
|
+ const node = {
|
|
|
+ type: "ArrowFunctionExpression",
|
|
|
+ params,
|
|
|
+ body,
|
|
|
+ async,
|
|
|
+ expression: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ArrowFunctionExpression;
|
|
|
+ validate(defs.params, node, "params", params, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ validate(defs.async, node, "async", async);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function classBody(body) {
|
|
|
+ const node = {
|
|
|
+ type: "ClassBody",
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ClassBody;
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function classExpression(id = null, superClass = null, body, decorators = null) {
|
|
|
+ const node = {
|
|
|
+ type: "ClassExpression",
|
|
|
+ id,
|
|
|
+ superClass,
|
|
|
+ body,
|
|
|
+ decorators
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ClassExpression;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.superClass, node, "superClass", superClass, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ validate(defs.decorators, node, "decorators", decorators, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function classDeclaration(id = null, superClass = null, body, decorators = null) {
|
|
|
+ const node = {
|
|
|
+ type: "ClassDeclaration",
|
|
|
+ id,
|
|
|
+ superClass,
|
|
|
+ body,
|
|
|
+ decorators
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ClassDeclaration;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.superClass, node, "superClass", superClass, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ validate(defs.decorators, node, "decorators", decorators, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function exportAllDeclaration(source) {
|
|
|
+ const node = {
|
|
|
+ type: "ExportAllDeclaration",
|
|
|
+ source
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ExportAllDeclaration;
|
|
|
+ validate(defs.source, node, "source", source, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function exportDefaultDeclaration(declaration) {
|
|
|
+ const node = {
|
|
|
+ type: "ExportDefaultDeclaration",
|
|
|
+ declaration
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ExportDefaultDeclaration;
|
|
|
+ validate(defs.declaration, node, "declaration", declaration, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function exportNamedDeclaration(declaration = null, specifiers = [], source = null) {
|
|
|
+ const node = {
|
|
|
+ type: "ExportNamedDeclaration",
|
|
|
+ declaration,
|
|
|
+ specifiers,
|
|
|
+ source
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ExportNamedDeclaration;
|
|
|
+ validate(defs.declaration, node, "declaration", declaration, 1);
|
|
|
+ validate(defs.specifiers, node, "specifiers", specifiers, 1);
|
|
|
+ validate(defs.source, node, "source", source, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function exportSpecifier(local, exported) {
|
|
|
+ const node = {
|
|
|
+ type: "ExportSpecifier",
|
|
|
+ local,
|
|
|
+ exported
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ExportSpecifier;
|
|
|
+ validate(defs.local, node, "local", local, 1);
|
|
|
+ validate(defs.exported, node, "exported", exported, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function forOfStatement(left, right, body, _await = false) {
|
|
|
+ const node = {
|
|
|
+ type: "ForOfStatement",
|
|
|
+ left,
|
|
|
+ right,
|
|
|
+ body,
|
|
|
+ await: _await
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ForOfStatement;
|
|
|
+ validate(defs.left, node, "left", left, 1);
|
|
|
+ validate(defs.right, node, "right", right, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ validate(defs.await, node, "await", _await);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function importDeclaration(specifiers, source) {
|
|
|
+ const node = {
|
|
|
+ type: "ImportDeclaration",
|
|
|
+ specifiers,
|
|
|
+ source
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ImportDeclaration;
|
|
|
+ validate(defs.specifiers, node, "specifiers", specifiers, 1);
|
|
|
+ validate(defs.source, node, "source", source, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function importDefaultSpecifier(local) {
|
|
|
+ const node = {
|
|
|
+ type: "ImportDefaultSpecifier",
|
|
|
+ local
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ImportDefaultSpecifier;
|
|
|
+ validate(defs.local, node, "local", local, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function importNamespaceSpecifier(local) {
|
|
|
+ const node = {
|
|
|
+ type: "ImportNamespaceSpecifier",
|
|
|
+ local
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ImportNamespaceSpecifier;
|
|
|
+ validate(defs.local, node, "local", local, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function importSpecifier(local, imported) {
|
|
|
+ const node = {
|
|
|
+ type: "ImportSpecifier",
|
|
|
+ local,
|
|
|
+ imported
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ImportSpecifier;
|
|
|
+ validate(defs.local, node, "local", local, 1);
|
|
|
+ validate(defs.imported, node, "imported", imported, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function importExpression(source, options = null) {
|
|
|
+ const node = {
|
|
|
+ type: "ImportExpression",
|
|
|
+ source,
|
|
|
+ options
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ImportExpression;
|
|
|
+ validate(defs.source, node, "source", source, 1);
|
|
|
+ validate(defs.options, node, "options", options, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function metaProperty(meta, property) {
|
|
|
+ const node = {
|
|
|
+ type: "MetaProperty",
|
|
|
+ meta,
|
|
|
+ property
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.MetaProperty;
|
|
|
+ validate(defs.meta, node, "meta", meta, 1);
|
|
|
+ validate(defs.property, node, "property", property, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function classMethod(kind = "method", key, params, body, computed = false, _static = false, generator = false, async = false) {
|
|
|
+ const node = {
|
|
|
+ type: "ClassMethod",
|
|
|
+ kind,
|
|
|
+ key,
|
|
|
+ params,
|
|
|
+ body,
|
|
|
+ computed,
|
|
|
+ static: _static,
|
|
|
+ generator,
|
|
|
+ async
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ClassMethod;
|
|
|
+ validate(defs.kind, node, "kind", kind);
|
|
|
+ validate(defs.key, node, "key", key, 1);
|
|
|
+ validate(defs.params, node, "params", params, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ validate(defs.computed, node, "computed", computed);
|
|
|
+ validate(defs.static, node, "static", _static);
|
|
|
+ validate(defs.generator, node, "generator", generator);
|
|
|
+ validate(defs.async, node, "async", async);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function objectPattern(properties) {
|
|
|
+ const node = {
|
|
|
+ type: "ObjectPattern",
|
|
|
+ properties
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ObjectPattern;
|
|
|
+ validate(defs.properties, node, "properties", properties, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function spreadElement(argument) {
|
|
|
+ const node = {
|
|
|
+ type: "SpreadElement",
|
|
|
+ argument
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.SpreadElement;
|
|
|
+ validate(defs.argument, node, "argument", argument, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function _super() {
|
|
|
+ return {
|
|
|
+ type: "Super"
|
|
|
+ };
|
|
|
+}
|
|
|
+function taggedTemplateExpression(tag, quasi) {
|
|
|
+ const node = {
|
|
|
+ type: "TaggedTemplateExpression",
|
|
|
+ tag,
|
|
|
+ quasi
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TaggedTemplateExpression;
|
|
|
+ validate(defs.tag, node, "tag", tag, 1);
|
|
|
+ validate(defs.quasi, node, "quasi", quasi, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function templateElement(value, tail = false) {
|
|
|
+ const node = {
|
|
|
+ type: "TemplateElement",
|
|
|
+ value,
|
|
|
+ tail
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TemplateElement;
|
|
|
+ validate(defs.value, node, "value", value);
|
|
|
+ validate(defs.tail, node, "tail", tail);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function templateLiteral(quasis, expressions) {
|
|
|
+ const node = {
|
|
|
+ type: "TemplateLiteral",
|
|
|
+ quasis,
|
|
|
+ expressions
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TemplateLiteral;
|
|
|
+ validate(defs.quasis, node, "quasis", quasis, 1);
|
|
|
+ validate(defs.expressions, node, "expressions", expressions, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function yieldExpression(argument = null, delegate = false) {
|
|
|
+ const node = {
|
|
|
+ type: "YieldExpression",
|
|
|
+ argument,
|
|
|
+ delegate
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.YieldExpression;
|
|
|
+ validate(defs.argument, node, "argument", argument, 1);
|
|
|
+ validate(defs.delegate, node, "delegate", delegate);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function awaitExpression(argument) {
|
|
|
+ const node = {
|
|
|
+ type: "AwaitExpression",
|
|
|
+ argument
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.AwaitExpression;
|
|
|
+ validate(defs.argument, node, "argument", argument, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function _import() {
|
|
|
+ return {
|
|
|
+ type: "Import"
|
|
|
+ };
|
|
|
+}
|
|
|
+function bigIntLiteral(value) {
|
|
|
+ const node = {
|
|
|
+ type: "BigIntLiteral",
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.BigIntLiteral;
|
|
|
+ validate(defs.value, node, "value", value);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function exportNamespaceSpecifier(exported) {
|
|
|
+ const node = {
|
|
|
+ type: "ExportNamespaceSpecifier",
|
|
|
+ exported
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ExportNamespaceSpecifier;
|
|
|
+ validate(defs.exported, node, "exported", exported, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function optionalMemberExpression(object, property, computed = false, optional) {
|
|
|
+ const node = {
|
|
|
+ type: "OptionalMemberExpression",
|
|
|
+ object,
|
|
|
+ property,
|
|
|
+ computed,
|
|
|
+ optional
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.OptionalMemberExpression;
|
|
|
+ validate(defs.object, node, "object", object, 1);
|
|
|
+ validate(defs.property, node, "property", property, 1);
|
|
|
+ validate(defs.computed, node, "computed", computed);
|
|
|
+ validate(defs.optional, node, "optional", optional);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function optionalCallExpression(callee, _arguments, optional) {
|
|
|
+ const node = {
|
|
|
+ type: "OptionalCallExpression",
|
|
|
+ callee,
|
|
|
+ arguments: _arguments,
|
|
|
+ optional
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.OptionalCallExpression;
|
|
|
+ validate(defs.callee, node, "callee", callee, 1);
|
|
|
+ validate(defs.arguments, node, "arguments", _arguments, 1);
|
|
|
+ validate(defs.optional, node, "optional", optional);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function classProperty(key, value = null, typeAnnotation = null, decorators = null, computed = false, _static = false) {
|
|
|
+ const node = {
|
|
|
+ type: "ClassProperty",
|
|
|
+ key,
|
|
|
+ value,
|
|
|
+ typeAnnotation,
|
|
|
+ decorators,
|
|
|
+ computed,
|
|
|
+ static: _static
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ClassProperty;
|
|
|
+ validate(defs.key, node, "key", key, 1);
|
|
|
+ validate(defs.value, node, "value", value, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ validate(defs.decorators, node, "decorators", decorators, 1);
|
|
|
+ validate(defs.computed, node, "computed", computed);
|
|
|
+ validate(defs.static, node, "static", _static);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function classAccessorProperty(key, value = null, typeAnnotation = null, decorators = null, computed = false, _static = false) {
|
|
|
+ const node = {
|
|
|
+ type: "ClassAccessorProperty",
|
|
|
+ key,
|
|
|
+ value,
|
|
|
+ typeAnnotation,
|
|
|
+ decorators,
|
|
|
+ computed,
|
|
|
+ static: _static
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ClassAccessorProperty;
|
|
|
+ validate(defs.key, node, "key", key, 1);
|
|
|
+ validate(defs.value, node, "value", value, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ validate(defs.decorators, node, "decorators", decorators, 1);
|
|
|
+ validate(defs.computed, node, "computed", computed);
|
|
|
+ validate(defs.static, node, "static", _static);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function classPrivateProperty(key, value = null, decorators = null, _static = false) {
|
|
|
+ const node = {
|
|
|
+ type: "ClassPrivateProperty",
|
|
|
+ key,
|
|
|
+ value,
|
|
|
+ decorators,
|
|
|
+ static: _static
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ClassPrivateProperty;
|
|
|
+ validate(defs.key, node, "key", key, 1);
|
|
|
+ validate(defs.value, node, "value", value, 1);
|
|
|
+ validate(defs.decorators, node, "decorators", decorators, 1);
|
|
|
+ validate(defs.static, node, "static", _static);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function classPrivateMethod(kind = "method", key, params, body, _static = false) {
|
|
|
+ const node = {
|
|
|
+ type: "ClassPrivateMethod",
|
|
|
+ kind,
|
|
|
+ key,
|
|
|
+ params,
|
|
|
+ body,
|
|
|
+ static: _static
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ClassPrivateMethod;
|
|
|
+ validate(defs.kind, node, "kind", kind);
|
|
|
+ validate(defs.key, node, "key", key, 1);
|
|
|
+ validate(defs.params, node, "params", params, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ validate(defs.static, node, "static", _static);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function privateName(id) {
|
|
|
+ const node = {
|
|
|
+ type: "PrivateName",
|
|
|
+ id
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.PrivateName;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function staticBlock(body) {
|
|
|
+ const node = {
|
|
|
+ type: "StaticBlock",
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.StaticBlock;
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function importAttribute(key, value) {
|
|
|
+ const node = {
|
|
|
+ type: "ImportAttribute",
|
|
|
+ key,
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ImportAttribute;
|
|
|
+ validate(defs.key, node, "key", key, 1);
|
|
|
+ validate(defs.value, node, "value", value, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function anyTypeAnnotation() {
|
|
|
+ return {
|
|
|
+ type: "AnyTypeAnnotation"
|
|
|
+ };
|
|
|
+}
|
|
|
+function arrayTypeAnnotation(elementType) {
|
|
|
+ const node = {
|
|
|
+ type: "ArrayTypeAnnotation",
|
|
|
+ elementType
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ArrayTypeAnnotation;
|
|
|
+ validate(defs.elementType, node, "elementType", elementType, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function booleanTypeAnnotation() {
|
|
|
+ return {
|
|
|
+ type: "BooleanTypeAnnotation"
|
|
|
+ };
|
|
|
+}
|
|
|
+function booleanLiteralTypeAnnotation(value) {
|
|
|
+ const node = {
|
|
|
+ type: "BooleanLiteralTypeAnnotation",
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.BooleanLiteralTypeAnnotation;
|
|
|
+ validate(defs.value, node, "value", value);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function nullLiteralTypeAnnotation() {
|
|
|
+ return {
|
|
|
+ type: "NullLiteralTypeAnnotation"
|
|
|
+ };
|
|
|
+}
|
|
|
+function classImplements(id, typeParameters = null) {
|
|
|
+ const node = {
|
|
|
+ type: "ClassImplements",
|
|
|
+ id,
|
|
|
+ typeParameters
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ClassImplements;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function declareClass(id, typeParameters = null, _extends = null, body) {
|
|
|
+ const node = {
|
|
|
+ type: "DeclareClass",
|
|
|
+ id,
|
|
|
+ typeParameters,
|
|
|
+ extends: _extends,
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DeclareClass;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.extends, node, "extends", _extends, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function declareFunction(id) {
|
|
|
+ const node = {
|
|
|
+ type: "DeclareFunction",
|
|
|
+ id
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DeclareFunction;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function declareInterface(id, typeParameters = null, _extends = null, body) {
|
|
|
+ const node = {
|
|
|
+ type: "DeclareInterface",
|
|
|
+ id,
|
|
|
+ typeParameters,
|
|
|
+ extends: _extends,
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DeclareInterface;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.extends, node, "extends", _extends, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function declareModule(id, body, kind = null) {
|
|
|
+ const node = {
|
|
|
+ type: "DeclareModule",
|
|
|
+ id,
|
|
|
+ body,
|
|
|
+ kind
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DeclareModule;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ validate(defs.kind, node, "kind", kind);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function declareModuleExports(typeAnnotation) {
|
|
|
+ const node = {
|
|
|
+ type: "DeclareModuleExports",
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DeclareModuleExports;
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function declareTypeAlias(id, typeParameters = null, right) {
|
|
|
+ const node = {
|
|
|
+ type: "DeclareTypeAlias",
|
|
|
+ id,
|
|
|
+ typeParameters,
|
|
|
+ right
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DeclareTypeAlias;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.right, node, "right", right, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function declareOpaqueType(id, typeParameters = null, supertype = null) {
|
|
|
+ const node = {
|
|
|
+ type: "DeclareOpaqueType",
|
|
|
+ id,
|
|
|
+ typeParameters,
|
|
|
+ supertype
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DeclareOpaqueType;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.supertype, node, "supertype", supertype, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function declareVariable(id) {
|
|
|
+ const node = {
|
|
|
+ type: "DeclareVariable",
|
|
|
+ id
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DeclareVariable;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function declareExportDeclaration(declaration = null, specifiers = null, source = null, attributes = null) {
|
|
|
+ const node = {
|
|
|
+ type: "DeclareExportDeclaration",
|
|
|
+ declaration,
|
|
|
+ specifiers,
|
|
|
+ source,
|
|
|
+ attributes
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DeclareExportDeclaration;
|
|
|
+ validate(defs.declaration, node, "declaration", declaration, 1);
|
|
|
+ validate(defs.specifiers, node, "specifiers", specifiers, 1);
|
|
|
+ validate(defs.source, node, "source", source, 1);
|
|
|
+ validate(defs.attributes, node, "attributes", attributes, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function declareExportAllDeclaration(source, attributes = null) {
|
|
|
+ const node = {
|
|
|
+ type: "DeclareExportAllDeclaration",
|
|
|
+ source,
|
|
|
+ attributes
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DeclareExportAllDeclaration;
|
|
|
+ validate(defs.source, node, "source", source, 1);
|
|
|
+ validate(defs.attributes, node, "attributes", attributes, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function declaredPredicate(value) {
|
|
|
+ const node = {
|
|
|
+ type: "DeclaredPredicate",
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DeclaredPredicate;
|
|
|
+ validate(defs.value, node, "value", value, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function existsTypeAnnotation() {
|
|
|
+ return {
|
|
|
+ type: "ExistsTypeAnnotation"
|
|
|
+ };
|
|
|
+}
|
|
|
+function functionTypeAnnotation(typeParameters = null, params, rest = null, returnType) {
|
|
|
+ const node = {
|
|
|
+ type: "FunctionTypeAnnotation",
|
|
|
+ typeParameters,
|
|
|
+ params,
|
|
|
+ rest,
|
|
|
+ returnType
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.FunctionTypeAnnotation;
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.params, node, "params", params, 1);
|
|
|
+ validate(defs.rest, node, "rest", rest, 1);
|
|
|
+ validate(defs.returnType, node, "returnType", returnType, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function functionTypeParam(name = null, typeAnnotation) {
|
|
|
+ const node = {
|
|
|
+ type: "FunctionTypeParam",
|
|
|
+ name,
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.FunctionTypeParam;
|
|
|
+ validate(defs.name, node, "name", name, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function genericTypeAnnotation(id, typeParameters = null) {
|
|
|
+ const node = {
|
|
|
+ type: "GenericTypeAnnotation",
|
|
|
+ id,
|
|
|
+ typeParameters
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.GenericTypeAnnotation;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function inferredPredicate() {
|
|
|
+ return {
|
|
|
+ type: "InferredPredicate"
|
|
|
+ };
|
|
|
+}
|
|
|
+function interfaceExtends(id, typeParameters = null) {
|
|
|
+ const node = {
|
|
|
+ type: "InterfaceExtends",
|
|
|
+ id,
|
|
|
+ typeParameters
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.InterfaceExtends;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function interfaceDeclaration(id, typeParameters = null, _extends = null, body) {
|
|
|
+ const node = {
|
|
|
+ type: "InterfaceDeclaration",
|
|
|
+ id,
|
|
|
+ typeParameters,
|
|
|
+ extends: _extends,
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.InterfaceDeclaration;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.extends, node, "extends", _extends, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function interfaceTypeAnnotation(_extends = null, body) {
|
|
|
+ const node = {
|
|
|
+ type: "InterfaceTypeAnnotation",
|
|
|
+ extends: _extends,
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.InterfaceTypeAnnotation;
|
|
|
+ validate(defs.extends, node, "extends", _extends, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function intersectionTypeAnnotation(types) {
|
|
|
+ const node = {
|
|
|
+ type: "IntersectionTypeAnnotation",
|
|
|
+ types
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.IntersectionTypeAnnotation;
|
|
|
+ validate(defs.types, node, "types", types, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function mixedTypeAnnotation() {
|
|
|
+ return {
|
|
|
+ type: "MixedTypeAnnotation"
|
|
|
+ };
|
|
|
+}
|
|
|
+function emptyTypeAnnotation() {
|
|
|
+ return {
|
|
|
+ type: "EmptyTypeAnnotation"
|
|
|
+ };
|
|
|
+}
|
|
|
+function nullableTypeAnnotation(typeAnnotation) {
|
|
|
+ const node = {
|
|
|
+ type: "NullableTypeAnnotation",
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.NullableTypeAnnotation;
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function numberLiteralTypeAnnotation(value) {
|
|
|
+ const node = {
|
|
|
+ type: "NumberLiteralTypeAnnotation",
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.NumberLiteralTypeAnnotation;
|
|
|
+ validate(defs.value, node, "value", value);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function numberTypeAnnotation() {
|
|
|
+ return {
|
|
|
+ type: "NumberTypeAnnotation"
|
|
|
+ };
|
|
|
+}
|
|
|
+function objectTypeAnnotation(properties, indexers = [], callProperties = [], internalSlots = [], exact = false) {
|
|
|
+ const node = {
|
|
|
+ type: "ObjectTypeAnnotation",
|
|
|
+ properties,
|
|
|
+ indexers,
|
|
|
+ callProperties,
|
|
|
+ internalSlots,
|
|
|
+ exact
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ObjectTypeAnnotation;
|
|
|
+ validate(defs.properties, node, "properties", properties, 1);
|
|
|
+ validate(defs.indexers, node, "indexers", indexers, 1);
|
|
|
+ validate(defs.callProperties, node, "callProperties", callProperties, 1);
|
|
|
+ validate(defs.internalSlots, node, "internalSlots", internalSlots, 1);
|
|
|
+ validate(defs.exact, node, "exact", exact);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function objectTypeInternalSlot(id, value, optional, _static, method) {
|
|
|
+ const node = {
|
|
|
+ type: "ObjectTypeInternalSlot",
|
|
|
+ id,
|
|
|
+ value,
|
|
|
+ optional,
|
|
|
+ static: _static,
|
|
|
+ method
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ObjectTypeInternalSlot;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.value, node, "value", value, 1);
|
|
|
+ validate(defs.optional, node, "optional", optional);
|
|
|
+ validate(defs.static, node, "static", _static);
|
|
|
+ validate(defs.method, node, "method", method);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function objectTypeCallProperty(value) {
|
|
|
+ const node = {
|
|
|
+ type: "ObjectTypeCallProperty",
|
|
|
+ value,
|
|
|
+ static: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ObjectTypeCallProperty;
|
|
|
+ validate(defs.value, node, "value", value, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function objectTypeIndexer(id = null, key, value, variance = null) {
|
|
|
+ const node = {
|
|
|
+ type: "ObjectTypeIndexer",
|
|
|
+ id,
|
|
|
+ key,
|
|
|
+ value,
|
|
|
+ variance,
|
|
|
+ static: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ObjectTypeIndexer;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.key, node, "key", key, 1);
|
|
|
+ validate(defs.value, node, "value", value, 1);
|
|
|
+ validate(defs.variance, node, "variance", variance, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function objectTypeProperty(key, value, variance = null) {
|
|
|
+ const node = {
|
|
|
+ type: "ObjectTypeProperty",
|
|
|
+ key,
|
|
|
+ value,
|
|
|
+ variance,
|
|
|
+ kind: null,
|
|
|
+ method: null,
|
|
|
+ optional: null,
|
|
|
+ proto: null,
|
|
|
+ static: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ObjectTypeProperty;
|
|
|
+ validate(defs.key, node, "key", key, 1);
|
|
|
+ validate(defs.value, node, "value", value, 1);
|
|
|
+ validate(defs.variance, node, "variance", variance, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function objectTypeSpreadProperty(argument) {
|
|
|
+ const node = {
|
|
|
+ type: "ObjectTypeSpreadProperty",
|
|
|
+ argument
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ObjectTypeSpreadProperty;
|
|
|
+ validate(defs.argument, node, "argument", argument, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function opaqueType(id, typeParameters = null, supertype = null, impltype) {
|
|
|
+ const node = {
|
|
|
+ type: "OpaqueType",
|
|
|
+ id,
|
|
|
+ typeParameters,
|
|
|
+ supertype,
|
|
|
+ impltype
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.OpaqueType;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.supertype, node, "supertype", supertype, 1);
|
|
|
+ validate(defs.impltype, node, "impltype", impltype, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function qualifiedTypeIdentifier(id, qualification) {
|
|
|
+ const node = {
|
|
|
+ type: "QualifiedTypeIdentifier",
|
|
|
+ id,
|
|
|
+ qualification
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.QualifiedTypeIdentifier;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.qualification, node, "qualification", qualification, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function stringLiteralTypeAnnotation(value) {
|
|
|
+ const node = {
|
|
|
+ type: "StringLiteralTypeAnnotation",
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.StringLiteralTypeAnnotation;
|
|
|
+ validate(defs.value, node, "value", value);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function stringTypeAnnotation() {
|
|
|
+ return {
|
|
|
+ type: "StringTypeAnnotation"
|
|
|
+ };
|
|
|
+}
|
|
|
+function symbolTypeAnnotation() {
|
|
|
+ return {
|
|
|
+ type: "SymbolTypeAnnotation"
|
|
|
+ };
|
|
|
+}
|
|
|
+function thisTypeAnnotation() {
|
|
|
+ return {
|
|
|
+ type: "ThisTypeAnnotation"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tupleTypeAnnotation(types) {
|
|
|
+ const node = {
|
|
|
+ type: "TupleTypeAnnotation",
|
|
|
+ types
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TupleTypeAnnotation;
|
|
|
+ validate(defs.types, node, "types", types, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function typeofTypeAnnotation(argument) {
|
|
|
+ const node = {
|
|
|
+ type: "TypeofTypeAnnotation",
|
|
|
+ argument
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TypeofTypeAnnotation;
|
|
|
+ validate(defs.argument, node, "argument", argument, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function typeAlias(id, typeParameters = null, right) {
|
|
|
+ const node = {
|
|
|
+ type: "TypeAlias",
|
|
|
+ id,
|
|
|
+ typeParameters,
|
|
|
+ right
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TypeAlias;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.right, node, "right", right, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function typeAnnotation(typeAnnotation) {
|
|
|
+ const node = {
|
|
|
+ type: "TypeAnnotation",
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TypeAnnotation;
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function typeCastExpression(expression, typeAnnotation) {
|
|
|
+ const node = {
|
|
|
+ type: "TypeCastExpression",
|
|
|
+ expression,
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TypeCastExpression;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function typeParameter(bound = null, _default = null, variance = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TypeParameter",
|
|
|
+ bound,
|
|
|
+ default: _default,
|
|
|
+ variance,
|
|
|
+ name: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TypeParameter;
|
|
|
+ validate(defs.bound, node, "bound", bound, 1);
|
|
|
+ validate(defs.default, node, "default", _default, 1);
|
|
|
+ validate(defs.variance, node, "variance", variance, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function typeParameterDeclaration(params) {
|
|
|
+ const node = {
|
|
|
+ type: "TypeParameterDeclaration",
|
|
|
+ params
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TypeParameterDeclaration;
|
|
|
+ validate(defs.params, node, "params", params, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function typeParameterInstantiation(params) {
|
|
|
+ const node = {
|
|
|
+ type: "TypeParameterInstantiation",
|
|
|
+ params
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TypeParameterInstantiation;
|
|
|
+ validate(defs.params, node, "params", params, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function unionTypeAnnotation(types) {
|
|
|
+ const node = {
|
|
|
+ type: "UnionTypeAnnotation",
|
|
|
+ types
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.UnionTypeAnnotation;
|
|
|
+ validate(defs.types, node, "types", types, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function variance(kind) {
|
|
|
+ const node = {
|
|
|
+ type: "Variance",
|
|
|
+ kind
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.Variance;
|
|
|
+ validate(defs.kind, node, "kind", kind);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function voidTypeAnnotation() {
|
|
|
+ return {
|
|
|
+ type: "VoidTypeAnnotation"
|
|
|
+ };
|
|
|
+}
|
|
|
+function enumDeclaration(id, body) {
|
|
|
+ const node = {
|
|
|
+ type: "EnumDeclaration",
|
|
|
+ id,
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.EnumDeclaration;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function enumBooleanBody(members) {
|
|
|
+ const node = {
|
|
|
+ type: "EnumBooleanBody",
|
|
|
+ members,
|
|
|
+ explicitType: null,
|
|
|
+ hasUnknownMembers: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.EnumBooleanBody;
|
|
|
+ validate(defs.members, node, "members", members, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function enumNumberBody(members) {
|
|
|
+ const node = {
|
|
|
+ type: "EnumNumberBody",
|
|
|
+ members,
|
|
|
+ explicitType: null,
|
|
|
+ hasUnknownMembers: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.EnumNumberBody;
|
|
|
+ validate(defs.members, node, "members", members, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function enumStringBody(members) {
|
|
|
+ const node = {
|
|
|
+ type: "EnumStringBody",
|
|
|
+ members,
|
|
|
+ explicitType: null,
|
|
|
+ hasUnknownMembers: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.EnumStringBody;
|
|
|
+ validate(defs.members, node, "members", members, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function enumSymbolBody(members) {
|
|
|
+ const node = {
|
|
|
+ type: "EnumSymbolBody",
|
|
|
+ members,
|
|
|
+ hasUnknownMembers: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.EnumSymbolBody;
|
|
|
+ validate(defs.members, node, "members", members, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function enumBooleanMember(id) {
|
|
|
+ const node = {
|
|
|
+ type: "EnumBooleanMember",
|
|
|
+ id,
|
|
|
+ init: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.EnumBooleanMember;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function enumNumberMember(id, init) {
|
|
|
+ const node = {
|
|
|
+ type: "EnumNumberMember",
|
|
|
+ id,
|
|
|
+ init
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.EnumNumberMember;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.init, node, "init", init, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function enumStringMember(id, init) {
|
|
|
+ const node = {
|
|
|
+ type: "EnumStringMember",
|
|
|
+ id,
|
|
|
+ init
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.EnumStringMember;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.init, node, "init", init, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function enumDefaultedMember(id) {
|
|
|
+ const node = {
|
|
|
+ type: "EnumDefaultedMember",
|
|
|
+ id
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.EnumDefaultedMember;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function indexedAccessType(objectType, indexType) {
|
|
|
+ const node = {
|
|
|
+ type: "IndexedAccessType",
|
|
|
+ objectType,
|
|
|
+ indexType
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.IndexedAccessType;
|
|
|
+ validate(defs.objectType, node, "objectType", objectType, 1);
|
|
|
+ validate(defs.indexType, node, "indexType", indexType, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function optionalIndexedAccessType(objectType, indexType) {
|
|
|
+ const node = {
|
|
|
+ type: "OptionalIndexedAccessType",
|
|
|
+ objectType,
|
|
|
+ indexType,
|
|
|
+ optional: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.OptionalIndexedAccessType;
|
|
|
+ validate(defs.objectType, node, "objectType", objectType, 1);
|
|
|
+ validate(defs.indexType, node, "indexType", indexType, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function jsxAttribute(name, value = null) {
|
|
|
+ const node = {
|
|
|
+ type: "JSXAttribute",
|
|
|
+ name,
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.JSXAttribute;
|
|
|
+ validate(defs.name, node, "name", name, 1);
|
|
|
+ validate(defs.value, node, "value", value, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function jsxClosingElement(name) {
|
|
|
+ const node = {
|
|
|
+ type: "JSXClosingElement",
|
|
|
+ name
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.JSXClosingElement;
|
|
|
+ validate(defs.name, node, "name", name, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function jsxElement(openingElement, closingElement = null, children, selfClosing = null) {
|
|
|
+ const node = {
|
|
|
+ type: "JSXElement",
|
|
|
+ openingElement,
|
|
|
+ closingElement,
|
|
|
+ children,
|
|
|
+ selfClosing
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.JSXElement;
|
|
|
+ validate(defs.openingElement, node, "openingElement", openingElement, 1);
|
|
|
+ validate(defs.closingElement, node, "closingElement", closingElement, 1);
|
|
|
+ validate(defs.children, node, "children", children, 1);
|
|
|
+ validate(defs.selfClosing, node, "selfClosing", selfClosing);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function jsxEmptyExpression() {
|
|
|
+ return {
|
|
|
+ type: "JSXEmptyExpression"
|
|
|
+ };
|
|
|
+}
|
|
|
+function jsxExpressionContainer(expression) {
|
|
|
+ const node = {
|
|
|
+ type: "JSXExpressionContainer",
|
|
|
+ expression
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.JSXExpressionContainer;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function jsxSpreadChild(expression) {
|
|
|
+ const node = {
|
|
|
+ type: "JSXSpreadChild",
|
|
|
+ expression
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.JSXSpreadChild;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function jsxIdentifier(name) {
|
|
|
+ const node = {
|
|
|
+ type: "JSXIdentifier",
|
|
|
+ name
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.JSXIdentifier;
|
|
|
+ validate(defs.name, node, "name", name);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function jsxMemberExpression(object, property) {
|
|
|
+ const node = {
|
|
|
+ type: "JSXMemberExpression",
|
|
|
+ object,
|
|
|
+ property
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.JSXMemberExpression;
|
|
|
+ validate(defs.object, node, "object", object, 1);
|
|
|
+ validate(defs.property, node, "property", property, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function jsxNamespacedName(namespace, name) {
|
|
|
+ const node = {
|
|
|
+ type: "JSXNamespacedName",
|
|
|
+ namespace,
|
|
|
+ name
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.JSXNamespacedName;
|
|
|
+ validate(defs.namespace, node, "namespace", namespace, 1);
|
|
|
+ validate(defs.name, node, "name", name, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function jsxOpeningElement(name, attributes, selfClosing = false) {
|
|
|
+ const node = {
|
|
|
+ type: "JSXOpeningElement",
|
|
|
+ name,
|
|
|
+ attributes,
|
|
|
+ selfClosing
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.JSXOpeningElement;
|
|
|
+ validate(defs.name, node, "name", name, 1);
|
|
|
+ validate(defs.attributes, node, "attributes", attributes, 1);
|
|
|
+ validate(defs.selfClosing, node, "selfClosing", selfClosing);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function jsxSpreadAttribute(argument) {
|
|
|
+ const node = {
|
|
|
+ type: "JSXSpreadAttribute",
|
|
|
+ argument
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.JSXSpreadAttribute;
|
|
|
+ validate(defs.argument, node, "argument", argument, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function jsxText(value) {
|
|
|
+ const node = {
|
|
|
+ type: "JSXText",
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.JSXText;
|
|
|
+ validate(defs.value, node, "value", value);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function jsxFragment(openingFragment, closingFragment, children) {
|
|
|
+ const node = {
|
|
|
+ type: "JSXFragment",
|
|
|
+ openingFragment,
|
|
|
+ closingFragment,
|
|
|
+ children
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.JSXFragment;
|
|
|
+ validate(defs.openingFragment, node, "openingFragment", openingFragment, 1);
|
|
|
+ validate(defs.closingFragment, node, "closingFragment", closingFragment, 1);
|
|
|
+ validate(defs.children, node, "children", children, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function jsxOpeningFragment() {
|
|
|
+ return {
|
|
|
+ type: "JSXOpeningFragment"
|
|
|
+ };
|
|
|
+}
|
|
|
+function jsxClosingFragment() {
|
|
|
+ return {
|
|
|
+ type: "JSXClosingFragment"
|
|
|
+ };
|
|
|
+}
|
|
|
+function noop() {
|
|
|
+ return {
|
|
|
+ type: "Noop"
|
|
|
+ };
|
|
|
+}
|
|
|
+function placeholder(expectedNode, name) {
|
|
|
+ const node = {
|
|
|
+ type: "Placeholder",
|
|
|
+ expectedNode,
|
|
|
+ name
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.Placeholder;
|
|
|
+ validate(defs.expectedNode, node, "expectedNode", expectedNode);
|
|
|
+ validate(defs.name, node, "name", name, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function v8IntrinsicIdentifier(name) {
|
|
|
+ const node = {
|
|
|
+ type: "V8IntrinsicIdentifier",
|
|
|
+ name
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.V8IntrinsicIdentifier;
|
|
|
+ validate(defs.name, node, "name", name);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function argumentPlaceholder() {
|
|
|
+ return {
|
|
|
+ type: "ArgumentPlaceholder"
|
|
|
+ };
|
|
|
+}
|
|
|
+function bindExpression(object, callee) {
|
|
|
+ const node = {
|
|
|
+ type: "BindExpression",
|
|
|
+ object,
|
|
|
+ callee
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.BindExpression;
|
|
|
+ validate(defs.object, node, "object", object, 1);
|
|
|
+ validate(defs.callee, node, "callee", callee, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function decorator(expression) {
|
|
|
+ const node = {
|
|
|
+ type: "Decorator",
|
|
|
+ expression
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.Decorator;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function doExpression(body, async = false) {
|
|
|
+ const node = {
|
|
|
+ type: "DoExpression",
|
|
|
+ body,
|
|
|
+ async
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DoExpression;
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ validate(defs.async, node, "async", async);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function exportDefaultSpecifier(exported) {
|
|
|
+ const node = {
|
|
|
+ type: "ExportDefaultSpecifier",
|
|
|
+ exported
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ExportDefaultSpecifier;
|
|
|
+ validate(defs.exported, node, "exported", exported, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function recordExpression(properties) {
|
|
|
+ const node = {
|
|
|
+ type: "RecordExpression",
|
|
|
+ properties
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.RecordExpression;
|
|
|
+ validate(defs.properties, node, "properties", properties, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tupleExpression(elements = []) {
|
|
|
+ const node = {
|
|
|
+ type: "TupleExpression",
|
|
|
+ elements
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TupleExpression;
|
|
|
+ validate(defs.elements, node, "elements", elements, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function decimalLiteral(value) {
|
|
|
+ const node = {
|
|
|
+ type: "DecimalLiteral",
|
|
|
+ value
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.DecimalLiteral;
|
|
|
+ validate(defs.value, node, "value", value);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function moduleExpression(body) {
|
|
|
+ const node = {
|
|
|
+ type: "ModuleExpression",
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.ModuleExpression;
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function topicReference() {
|
|
|
+ return {
|
|
|
+ type: "TopicReference"
|
|
|
+ };
|
|
|
+}
|
|
|
+function pipelineTopicExpression(expression) {
|
|
|
+ const node = {
|
|
|
+ type: "PipelineTopicExpression",
|
|
|
+ expression
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.PipelineTopicExpression;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function pipelineBareFunction(callee) {
|
|
|
+ const node = {
|
|
|
+ type: "PipelineBareFunction",
|
|
|
+ callee
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.PipelineBareFunction;
|
|
|
+ validate(defs.callee, node, "callee", callee, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function pipelinePrimaryTopicReference() {
|
|
|
+ return {
|
|
|
+ type: "PipelinePrimaryTopicReference"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsParameterProperty(parameter) {
|
|
|
+ const node = {
|
|
|
+ type: "TSParameterProperty",
|
|
|
+ parameter
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSParameterProperty;
|
|
|
+ validate(defs.parameter, node, "parameter", parameter, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsDeclareFunction(id = null, typeParameters = null, params, returnType = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSDeclareFunction",
|
|
|
+ id,
|
|
|
+ typeParameters,
|
|
|
+ params,
|
|
|
+ returnType
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSDeclareFunction;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.params, node, "params", params, 1);
|
|
|
+ validate(defs.returnType, node, "returnType", returnType, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsDeclareMethod(decorators = null, key, typeParameters = null, params, returnType = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSDeclareMethod",
|
|
|
+ decorators,
|
|
|
+ key,
|
|
|
+ typeParameters,
|
|
|
+ params,
|
|
|
+ returnType
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSDeclareMethod;
|
|
|
+ validate(defs.decorators, node, "decorators", decorators, 1);
|
|
|
+ validate(defs.key, node, "key", key, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.params, node, "params", params, 1);
|
|
|
+ validate(defs.returnType, node, "returnType", returnType, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsQualifiedName(left, right) {
|
|
|
+ const node = {
|
|
|
+ type: "TSQualifiedName",
|
|
|
+ left,
|
|
|
+ right
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSQualifiedName;
|
|
|
+ validate(defs.left, node, "left", left, 1);
|
|
|
+ validate(defs.right, node, "right", right, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsCallSignatureDeclaration(typeParameters = null, parameters, typeAnnotation = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSCallSignatureDeclaration",
|
|
|
+ typeParameters,
|
|
|
+ parameters,
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSCallSignatureDeclaration;
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.parameters, node, "parameters", parameters, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsConstructSignatureDeclaration(typeParameters = null, parameters, typeAnnotation = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSConstructSignatureDeclaration",
|
|
|
+ typeParameters,
|
|
|
+ parameters,
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSConstructSignatureDeclaration;
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.parameters, node, "parameters", parameters, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsPropertySignature(key, typeAnnotation = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSPropertySignature",
|
|
|
+ key,
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSPropertySignature;
|
|
|
+ validate(defs.key, node, "key", key, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsMethodSignature(key, typeParameters = null, parameters, typeAnnotation = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSMethodSignature",
|
|
|
+ key,
|
|
|
+ typeParameters,
|
|
|
+ parameters,
|
|
|
+ typeAnnotation,
|
|
|
+ kind: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSMethodSignature;
|
|
|
+ validate(defs.key, node, "key", key, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.parameters, node, "parameters", parameters, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsIndexSignature(parameters, typeAnnotation = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSIndexSignature",
|
|
|
+ parameters,
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSIndexSignature;
|
|
|
+ validate(defs.parameters, node, "parameters", parameters, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsAnyKeyword() {
|
|
|
+ return {
|
|
|
+ type: "TSAnyKeyword"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsBooleanKeyword() {
|
|
|
+ return {
|
|
|
+ type: "TSBooleanKeyword"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsBigIntKeyword() {
|
|
|
+ return {
|
|
|
+ type: "TSBigIntKeyword"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsIntrinsicKeyword() {
|
|
|
+ return {
|
|
|
+ type: "TSIntrinsicKeyword"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsNeverKeyword() {
|
|
|
+ return {
|
|
|
+ type: "TSNeverKeyword"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsNullKeyword() {
|
|
|
+ return {
|
|
|
+ type: "TSNullKeyword"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsNumberKeyword() {
|
|
|
+ return {
|
|
|
+ type: "TSNumberKeyword"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsObjectKeyword() {
|
|
|
+ return {
|
|
|
+ type: "TSObjectKeyword"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsStringKeyword() {
|
|
|
+ return {
|
|
|
+ type: "TSStringKeyword"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsSymbolKeyword() {
|
|
|
+ return {
|
|
|
+ type: "TSSymbolKeyword"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsUndefinedKeyword() {
|
|
|
+ return {
|
|
|
+ type: "TSUndefinedKeyword"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsUnknownKeyword() {
|
|
|
+ return {
|
|
|
+ type: "TSUnknownKeyword"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsVoidKeyword() {
|
|
|
+ return {
|
|
|
+ type: "TSVoidKeyword"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsThisType() {
|
|
|
+ return {
|
|
|
+ type: "TSThisType"
|
|
|
+ };
|
|
|
+}
|
|
|
+function tsFunctionType(typeParameters = null, parameters, typeAnnotation = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSFunctionType",
|
|
|
+ typeParameters,
|
|
|
+ parameters,
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSFunctionType;
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.parameters, node, "parameters", parameters, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsConstructorType(typeParameters = null, parameters, typeAnnotation = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSConstructorType",
|
|
|
+ typeParameters,
|
|
|
+ parameters,
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSConstructorType;
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.parameters, node, "parameters", parameters, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsTypeReference(typeName, typeParameters = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSTypeReference",
|
|
|
+ typeName,
|
|
|
+ typeParameters
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSTypeReference;
|
|
|
+ validate(defs.typeName, node, "typeName", typeName, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsTypePredicate(parameterName, typeAnnotation = null, asserts = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSTypePredicate",
|
|
|
+ parameterName,
|
|
|
+ typeAnnotation,
|
|
|
+ asserts
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSTypePredicate;
|
|
|
+ validate(defs.parameterName, node, "parameterName", parameterName, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ validate(defs.asserts, node, "asserts", asserts);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsTypeQuery(exprName, typeParameters = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSTypeQuery",
|
|
|
+ exprName,
|
|
|
+ typeParameters
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSTypeQuery;
|
|
|
+ validate(defs.exprName, node, "exprName", exprName, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsTypeLiteral(members) {
|
|
|
+ const node = {
|
|
|
+ type: "TSTypeLiteral",
|
|
|
+ members
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSTypeLiteral;
|
|
|
+ validate(defs.members, node, "members", members, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsArrayType(elementType) {
|
|
|
+ const node = {
|
|
|
+ type: "TSArrayType",
|
|
|
+ elementType
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSArrayType;
|
|
|
+ validate(defs.elementType, node, "elementType", elementType, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsTupleType(elementTypes) {
|
|
|
+ const node = {
|
|
|
+ type: "TSTupleType",
|
|
|
+ elementTypes
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSTupleType;
|
|
|
+ validate(defs.elementTypes, node, "elementTypes", elementTypes, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsOptionalType(typeAnnotation) {
|
|
|
+ const node = {
|
|
|
+ type: "TSOptionalType",
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSOptionalType;
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsRestType(typeAnnotation) {
|
|
|
+ const node = {
|
|
|
+ type: "TSRestType",
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSRestType;
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsNamedTupleMember(label, elementType, optional = false) {
|
|
|
+ const node = {
|
|
|
+ type: "TSNamedTupleMember",
|
|
|
+ label,
|
|
|
+ elementType,
|
|
|
+ optional
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSNamedTupleMember;
|
|
|
+ validate(defs.label, node, "label", label, 1);
|
|
|
+ validate(defs.elementType, node, "elementType", elementType, 1);
|
|
|
+ validate(defs.optional, node, "optional", optional);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsUnionType(types) {
|
|
|
+ const node = {
|
|
|
+ type: "TSUnionType",
|
|
|
+ types
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSUnionType;
|
|
|
+ validate(defs.types, node, "types", types, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsIntersectionType(types) {
|
|
|
+ const node = {
|
|
|
+ type: "TSIntersectionType",
|
|
|
+ types
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSIntersectionType;
|
|
|
+ validate(defs.types, node, "types", types, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsConditionalType(checkType, extendsType, trueType, falseType) {
|
|
|
+ const node = {
|
|
|
+ type: "TSConditionalType",
|
|
|
+ checkType,
|
|
|
+ extendsType,
|
|
|
+ trueType,
|
|
|
+ falseType
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSConditionalType;
|
|
|
+ validate(defs.checkType, node, "checkType", checkType, 1);
|
|
|
+ validate(defs.extendsType, node, "extendsType", extendsType, 1);
|
|
|
+ validate(defs.trueType, node, "trueType", trueType, 1);
|
|
|
+ validate(defs.falseType, node, "falseType", falseType, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsInferType(typeParameter) {
|
|
|
+ const node = {
|
|
|
+ type: "TSInferType",
|
|
|
+ typeParameter
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSInferType;
|
|
|
+ validate(defs.typeParameter, node, "typeParameter", typeParameter, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsParenthesizedType(typeAnnotation) {
|
|
|
+ const node = {
|
|
|
+ type: "TSParenthesizedType",
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSParenthesizedType;
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsTypeOperator(typeAnnotation) {
|
|
|
+ const node = {
|
|
|
+ type: "TSTypeOperator",
|
|
|
+ typeAnnotation,
|
|
|
+ operator: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSTypeOperator;
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsIndexedAccessType(objectType, indexType) {
|
|
|
+ const node = {
|
|
|
+ type: "TSIndexedAccessType",
|
|
|
+ objectType,
|
|
|
+ indexType
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSIndexedAccessType;
|
|
|
+ validate(defs.objectType, node, "objectType", objectType, 1);
|
|
|
+ validate(defs.indexType, node, "indexType", indexType, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsMappedType(typeParameter, typeAnnotation = null, nameType = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSMappedType",
|
|
|
+ typeParameter,
|
|
|
+ typeAnnotation,
|
|
|
+ nameType
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSMappedType;
|
|
|
+ validate(defs.typeParameter, node, "typeParameter", typeParameter, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ validate(defs.nameType, node, "nameType", nameType, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsTemplateLiteralType(quasis, types) {
|
|
|
+ const node = {
|
|
|
+ type: "TSTemplateLiteralType",
|
|
|
+ quasis,
|
|
|
+ types
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSTemplateLiteralType;
|
|
|
+ validate(defs.quasis, node, "quasis", quasis, 1);
|
|
|
+ validate(defs.types, node, "types", types, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsLiteralType(literal) {
|
|
|
+ const node = {
|
|
|
+ type: "TSLiteralType",
|
|
|
+ literal
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSLiteralType;
|
|
|
+ validate(defs.literal, node, "literal", literal, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsExpressionWithTypeArguments(expression, typeParameters = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSExpressionWithTypeArguments",
|
|
|
+ expression,
|
|
|
+ typeParameters
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSExpressionWithTypeArguments;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsInterfaceDeclaration(id, typeParameters = null, _extends = null, body) {
|
|
|
+ const node = {
|
|
|
+ type: "TSInterfaceDeclaration",
|
|
|
+ id,
|
|
|
+ typeParameters,
|
|
|
+ extends: _extends,
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSInterfaceDeclaration;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.extends, node, "extends", _extends, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsInterfaceBody(body) {
|
|
|
+ const node = {
|
|
|
+ type: "TSInterfaceBody",
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSInterfaceBody;
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsTypeAliasDeclaration(id, typeParameters = null, typeAnnotation) {
|
|
|
+ const node = {
|
|
|
+ type: "TSTypeAliasDeclaration",
|
|
|
+ id,
|
|
|
+ typeParameters,
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSTypeAliasDeclaration;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsInstantiationExpression(expression, typeParameters = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSInstantiationExpression",
|
|
|
+ expression,
|
|
|
+ typeParameters
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSInstantiationExpression;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsAsExpression(expression, typeAnnotation) {
|
|
|
+ const node = {
|
|
|
+ type: "TSAsExpression",
|
|
|
+ expression,
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSAsExpression;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsSatisfiesExpression(expression, typeAnnotation) {
|
|
|
+ const node = {
|
|
|
+ type: "TSSatisfiesExpression",
|
|
|
+ expression,
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSSatisfiesExpression;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsTypeAssertion(typeAnnotation, expression) {
|
|
|
+ const node = {
|
|
|
+ type: "TSTypeAssertion",
|
|
|
+ typeAnnotation,
|
|
|
+ expression
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSTypeAssertion;
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsEnumBody(members) {
|
|
|
+ const node = {
|
|
|
+ type: "TSEnumBody",
|
|
|
+ members
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSEnumBody;
|
|
|
+ validate(defs.members, node, "members", members, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsEnumDeclaration(id, members) {
|
|
|
+ const node = {
|
|
|
+ type: "TSEnumDeclaration",
|
|
|
+ id,
|
|
|
+ members
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSEnumDeclaration;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.members, node, "members", members, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsEnumMember(id, initializer = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSEnumMember",
|
|
|
+ id,
|
|
|
+ initializer
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSEnumMember;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.initializer, node, "initializer", initializer, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsModuleDeclaration(id, body) {
|
|
|
+ const node = {
|
|
|
+ type: "TSModuleDeclaration",
|
|
|
+ id,
|
|
|
+ body,
|
|
|
+ kind: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSModuleDeclaration;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsModuleBlock(body) {
|
|
|
+ const node = {
|
|
|
+ type: "TSModuleBlock",
|
|
|
+ body
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSModuleBlock;
|
|
|
+ validate(defs.body, node, "body", body, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsImportType(argument, qualifier = null, typeParameters = null) {
|
|
|
+ const node = {
|
|
|
+ type: "TSImportType",
|
|
|
+ argument,
|
|
|
+ qualifier,
|
|
|
+ typeParameters
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSImportType;
|
|
|
+ validate(defs.argument, node, "argument", argument, 1);
|
|
|
+ validate(defs.qualifier, node, "qualifier", qualifier, 1);
|
|
|
+ validate(defs.typeParameters, node, "typeParameters", typeParameters, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsImportEqualsDeclaration(id, moduleReference) {
|
|
|
+ const node = {
|
|
|
+ type: "TSImportEqualsDeclaration",
|
|
|
+ id,
|
|
|
+ moduleReference,
|
|
|
+ isExport: null
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSImportEqualsDeclaration;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ validate(defs.moduleReference, node, "moduleReference", moduleReference, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsExternalModuleReference(expression) {
|
|
|
+ const node = {
|
|
|
+ type: "TSExternalModuleReference",
|
|
|
+ expression
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSExternalModuleReference;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsNonNullExpression(expression) {
|
|
|
+ const node = {
|
|
|
+ type: "TSNonNullExpression",
|
|
|
+ expression
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSNonNullExpression;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsExportAssignment(expression) {
|
|
|
+ const node = {
|
|
|
+ type: "TSExportAssignment",
|
|
|
+ expression
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSExportAssignment;
|
|
|
+ validate(defs.expression, node, "expression", expression, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsNamespaceExportDeclaration(id) {
|
|
|
+ const node = {
|
|
|
+ type: "TSNamespaceExportDeclaration",
|
|
|
+ id
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSNamespaceExportDeclaration;
|
|
|
+ validate(defs.id, node, "id", id, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsTypeAnnotation(typeAnnotation) {
|
|
|
+ const node = {
|
|
|
+ type: "TSTypeAnnotation",
|
|
|
+ typeAnnotation
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSTypeAnnotation;
|
|
|
+ validate(defs.typeAnnotation, node, "typeAnnotation", typeAnnotation, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsTypeParameterInstantiation(params) {
|
|
|
+ const node = {
|
|
|
+ type: "TSTypeParameterInstantiation",
|
|
|
+ params
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSTypeParameterInstantiation;
|
|
|
+ validate(defs.params, node, "params", params, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsTypeParameterDeclaration(params) {
|
|
|
+ const node = {
|
|
|
+ type: "TSTypeParameterDeclaration",
|
|
|
+ params
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSTypeParameterDeclaration;
|
|
|
+ validate(defs.params, node, "params", params, 1);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function tsTypeParameter(constraint = null, _default = null, name) {
|
|
|
+ const node = {
|
|
|
+ type: "TSTypeParameter",
|
|
|
+ constraint,
|
|
|
+ default: _default,
|
|
|
+ name
|
|
|
+ };
|
|
|
+ const defs = NODE_FIELDS.TSTypeParameter;
|
|
|
+ validate(defs.constraint, node, "constraint", constraint, 1);
|
|
|
+ validate(defs.default, node, "default", _default, 1);
|
|
|
+ validate(defs.name, node, "name", name);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+function NumberLiteral(value) {
|
|
|
+ (0, _deprecationWarning.default)("NumberLiteral", "NumericLiteral", "The node type ");
|
|
|
+ return numericLiteral(value);
|
|
|
+}
|
|
|
+function RegexLiteral(pattern, flags = "") {
|
|
|
+ (0, _deprecationWarning.default)("RegexLiteral", "RegExpLiteral", "The node type ");
|
|
|
+ return regExpLiteral(pattern, flags);
|
|
|
+}
|
|
|
+function RestProperty(argument) {
|
|
|
+ (0, _deprecationWarning.default)("RestProperty", "RestElement", "The node type ");
|
|
|
+ return restElement(argument);
|
|
|
+}
|
|
|
+function SpreadProperty(argument) {
|
|
|
+ (0, _deprecationWarning.default)("SpreadProperty", "SpreadElement", "The node type ");
|
|
|
+ return spreadElement(argument);
|
|
|
+}
|
|
|
+
|
|
|
+//# sourceMappingURL=lowercase.js.map
|