babel-types
Advanced tools
Comparing version 7.0.0-alpha.15 to 7.0.0-alpha.16
@@ -8,6 +8,4 @@ "use strict"; | ||
var COMMENT_KEYS = exports.COMMENT_KEYS = ["leadingComments", "trailingComments", "innerComments"]; | ||
var LOGICAL_OPERATORS = exports.LOGICAL_OPERATORS = ["||", "&&"]; | ||
var UPDATE_OPERATORS = exports.UPDATE_OPERATORS = ["++", "--"]; | ||
var BOOLEAN_NUMBER_BINARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = [">", "<", ">=", "<="]; | ||
@@ -19,3 +17,2 @@ var EQUALITY_BINARY_OPERATORS = exports.EQUALITY_BINARY_OPERATORS = ["==", "===", "!=", "!=="]; | ||
var BINARY_OPERATORS = exports.BINARY_OPERATORS = ["+"].concat(NUMBER_BINARY_OPERATORS, BOOLEAN_BINARY_OPERATORS); | ||
var BOOLEAN_UNARY_OPERATORS = exports.BOOLEAN_UNARY_OPERATORS = ["delete", "!"]; | ||
@@ -25,3 +22,2 @@ var NUMBER_UNARY_OPERATORS = exports.NUMBER_UNARY_OPERATORS = ["+", "-", "~"]; | ||
var UNARY_OPERATORS = exports.UNARY_OPERATORS = ["void"].concat(BOOLEAN_UNARY_OPERATORS, NUMBER_UNARY_OPERATORS, STRING_UNARY_OPERATORS); | ||
var INHERIT_KEYS = exports.INHERIT_KEYS = { | ||
@@ -31,4 +27,3 @@ optional: ["typeAnnotation", "typeParameters", "returnType"], | ||
}; | ||
var BLOCK_SCOPED_SYMBOL = exports.BLOCK_SCOPED_SYMBOL = Symbol.for("var used to be block scoped"); | ||
var NOT_LOCAL_BINDING = exports.NOT_LOCAL_BINDING = Symbol.for("should not be considered a local binding"); |
@@ -36,2 +36,3 @@ "use strict"; | ||
} | ||
return key; | ||
@@ -57,3 +58,2 @@ } | ||
var node = _ref; | ||
ensureLastUndefined = false; | ||
@@ -67,18 +67,8 @@ | ||
if (node.kind !== "var") return; | ||
var _arr = node.declarations; | ||
for (var _iterator2 = node.declarations, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { | ||
var _ref2; | ||
for (var _i2 = 0; _i2 < _arr.length; _i2++) { | ||
var declar = _arr[_i2]; | ||
var bindings = t.getBindingIdentifiers(declar); | ||
if (_isArray2) { | ||
if (_i2 >= _iterator2.length) break; | ||
_ref2 = _iterator2[_i2++]; | ||
} else { | ||
_i2 = _iterator2.next(); | ||
if (_i2.done) break; | ||
_ref2 = _i2.value; | ||
} | ||
var declar = _ref2; | ||
var bindings = t.getBindingIdentifiers(declar); | ||
for (var key in bindings) { | ||
@@ -101,3 +91,2 @@ declars.push({ | ||
if (!consequent || !alternate) return; | ||
exprs.push(t.conditionalExpression(node.test, consequent, alternate)); | ||
@@ -107,3 +96,2 @@ } else if (t.isBlockStatement(node)) { | ||
if (!body) return; | ||
exprs.push(body); | ||
@@ -130,3 +118,2 @@ } else if (t.isEmptyStatement(node)) { | ||
if (!nodes || !nodes.length) return; | ||
var declars = []; | ||
@@ -136,16 +123,4 @@ var result = gatherSequenceExpressions(nodes, scope, declars); | ||
for (var _iterator3 = declars, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { | ||
var _ref3; | ||
if (_isArray3) { | ||
if (_i3 >= _iterator3.length) break; | ||
_ref3 = _iterator3[_i3++]; | ||
} else { | ||
_i3 = _iterator3.next(); | ||
if (_i3.done) break; | ||
_ref3 = _i3.value; | ||
} | ||
var declar = _ref3; | ||
for (var _i3 = 0; _i3 < declars.length; _i3++) { | ||
var declar = declars[_i3]; | ||
scope.push(declar); | ||
@@ -159,3 +134,2 @@ } | ||
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.key; | ||
var alias = void 0; | ||
@@ -196,7 +170,4 @@ | ||
name = name + ""; | ||
name = name.replace(/[^a-zA-Z0-9$_]/g, "-"); | ||
name = name.replace(/^[-0-9]+/, ""); | ||
name = name.replace(/[-\s]+(.)?/g, function (match, c) { | ||
@@ -250,3 +221,2 @@ return c ? c.toUpperCase() : ""; | ||
node.type = newType; | ||
return node; | ||
@@ -334,4 +304,6 @@ } | ||
var props = []; | ||
for (var key in value) { | ||
var nodeKey = void 0; | ||
if (t.isValidIdentifier(key)) { | ||
@@ -342,4 +314,6 @@ nodeKey = t.identifier(key); | ||
} | ||
props.push(t.objectProperty(nodeKey, t.valueToNode(value[key]))); | ||
} | ||
return t.objectExpression(props); | ||
@@ -346,0 +320,0 @@ } |
"use strict"; | ||
exports.__esModule = true; | ||
exports.patternLikeCommon = exports.functionDeclarationCommon = exports.functionCommon = undefined; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _index = require("../index"); | ||
@@ -27,3 +32,2 @@ | ||
}); | ||
(0, _index3.default)("AssignmentExpression", { | ||
@@ -45,3 +49,2 @@ fields: { | ||
}); | ||
(0, _index3.default)("BinaryExpression", { | ||
@@ -63,3 +66,2 @@ builder: ["operator", "left", "right"], | ||
}); | ||
(0, _index3.default)("Directive", { | ||
@@ -73,3 +75,2 @@ visitor: ["value"], | ||
}); | ||
(0, _index3.default)("DirectiveLiteral", { | ||
@@ -83,3 +84,2 @@ builder: ["value"], | ||
}); | ||
(0, _index3.default)("BlockStatement", { | ||
@@ -99,3 +99,2 @@ builder: ["body", "directives"], | ||
}); | ||
(0, _index3.default)("BreakStatement", { | ||
@@ -111,5 +110,6 @@ visitor: ["label"], | ||
}); | ||
(0, _index3.default)("CallExpression", { | ||
visitor: ["callee", "arguments"], | ||
var callOrNew = { | ||
visitor: ["callee", "arguments", "typeParameters"], | ||
builder: ["callee", "arguments"], | ||
aliases: ["Expression"], | ||
fields: { | ||
@@ -125,7 +125,10 @@ callee: { | ||
optional: true | ||
}, | ||
typeParameters: { | ||
validate: (0, _index2.assertNodeType)("TypeParameterInstantiation"), | ||
optional: true | ||
} | ||
}, | ||
aliases: ["Expression"] | ||
}); | ||
} | ||
}; | ||
(0, _index3.default)("CallExpression", callOrNew); | ||
(0, _index3.default)("CatchClause", { | ||
@@ -135,3 +138,4 @@ visitor: ["param", "body"], | ||
param: { | ||
validate: (0, _index2.assertNodeType)("Identifier") | ||
validate: (0, _index2.assertNodeType)("Identifier"), | ||
optional: true | ||
}, | ||
@@ -144,3 +148,2 @@ body: { | ||
}); | ||
(0, _index3.default)("ConditionalExpression", { | ||
@@ -161,3 +164,2 @@ visitor: ["test", "consequent", "alternate"], | ||
}); | ||
(0, _index3.default)("ContinueStatement", { | ||
@@ -173,7 +175,5 @@ visitor: ["label"], | ||
}); | ||
(0, _index3.default)("DebuggerStatement", { | ||
aliases: ["Statement"] | ||
}); | ||
(0, _index3.default)("DoWhileStatement", { | ||
@@ -191,7 +191,5 @@ visitor: ["test", "body"], | ||
}); | ||
(0, _index3.default)("EmptyStatement", { | ||
aliases: ["Statement"] | ||
}); | ||
(0, _index3.default)("ExpressionStatement", { | ||
@@ -206,3 +204,2 @@ visitor: ["expression"], | ||
}); | ||
(0, _index3.default)("File", { | ||
@@ -217,3 +214,2 @@ builder: ["program", "comments", "tokens"], | ||
}); | ||
(0, _index3.default)("ForInStatement", { | ||
@@ -234,3 +230,2 @@ visitor: ["left", "right", "body"], | ||
}); | ||
(0, _index3.default)("ForStatement", { | ||
@@ -257,32 +252,49 @@ visitor: ["init", "test", "update", "body"], | ||
}); | ||
var functionCommon = exports.functionCommon = { | ||
params: { | ||
validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("LVal"))) | ||
}, | ||
generator: { | ||
default: false, | ||
validate: (0, _index2.assertValueType)("boolean") | ||
}, | ||
async: { | ||
validate: (0, _index2.assertValueType)("boolean"), | ||
default: false | ||
}, | ||
returnType: { | ||
validate: (0, _index2.assertNodeType)("TypeAnnotation", "Noop"), | ||
optional: true | ||
}, | ||
typeParameters: { | ||
validate: (0, _index2.assertNodeType)("TypeParameterDeclaration", "Noop"), | ||
optional: true | ||
} | ||
}; | ||
var functionDeclarationCommon = exports.functionDeclarationCommon = _extends({}, functionCommon, { | ||
declare: { | ||
validate: (0, _index2.assertValueType)("boolean"), | ||
optional: true | ||
}, | ||
id: { | ||
validate: (0, _index2.assertNodeType)("Identifier"), | ||
optional: true | ||
} | ||
}); | ||
(0, _index3.default)("FunctionDeclaration", { | ||
builder: ["id", "params", "body", "generator", "async"], | ||
visitor: ["id", "params", "body", "returnType", "typeParameters"], | ||
fields: { | ||
id: { | ||
validate: (0, _index2.assertNodeType)("Identifier") | ||
}, | ||
params: { | ||
validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("LVal"))) | ||
}, | ||
fields: _extends({}, functionDeclarationCommon, { | ||
body: { | ||
validate: (0, _index2.assertNodeType)("BlockStatement") | ||
}, | ||
generator: { | ||
default: false, | ||
validate: (0, _index2.assertValueType)("boolean") | ||
}, | ||
async: { | ||
default: false, | ||
validate: (0, _index2.assertValueType)("boolean") | ||
} | ||
}, | ||
}), | ||
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Statement", "Pureish", "Declaration"] | ||
}); | ||
(0, _index3.default)("FunctionExpression", { | ||
inherits: "FunctionDeclaration", | ||
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"], | ||
fields: { | ||
fields: _extends({}, functionCommon, { | ||
id: { | ||
@@ -292,24 +304,21 @@ validate: (0, _index2.assertNodeType)("Identifier"), | ||
}, | ||
params: { | ||
validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("LVal"))) | ||
}, | ||
body: { | ||
validate: (0, _index2.assertNodeType)("BlockStatement") | ||
}, | ||
generator: { | ||
default: false, | ||
validate: (0, _index2.assertValueType)("boolean") | ||
}, | ||
async: { | ||
default: false, | ||
validate: (0, _index2.assertValueType)("boolean") | ||
} | ||
}) | ||
}); | ||
var patternLikeCommon = exports.patternLikeCommon = { | ||
typeAnnotation: { | ||
validate: (0, _index2.assertNodeType)("TypeAnnotation", "Noop"), | ||
optional: true | ||
}, | ||
decorators: { | ||
validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Decorator"))) | ||
} | ||
}); | ||
}; | ||
(0, _index3.default)("Identifier", { | ||
builder: ["name"], | ||
visitor: ["typeAnnotation"], | ||
aliases: ["Expression", "LVal"], | ||
fields: { | ||
aliases: ["Expression", "PatternLike", "LVal", "TSEntityName"], | ||
fields: _extends({}, patternLikeCommon, { | ||
name: { | ||
@@ -320,8 +329,8 @@ validate: function validate(node, key, val) { | ||
}, | ||
decorators: { | ||
validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Decorator"))) | ||
optional: { | ||
validate: (0, _index2.assertValueType)("boolean"), | ||
optional: true | ||
} | ||
} | ||
}) | ||
}); | ||
(0, _index3.default)("IfStatement", { | ||
@@ -343,3 +352,2 @@ visitor: ["test", "consequent", "alternate"], | ||
}); | ||
(0, _index3.default)("LabeledStatement", { | ||
@@ -357,3 +365,2 @@ visitor: ["label", "body"], | ||
}); | ||
(0, _index3.default)("StringLiteral", { | ||
@@ -368,3 +375,2 @@ builder: ["value"], | ||
}); | ||
(0, _index3.default)("NumericLiteral", { | ||
@@ -380,7 +386,5 @@ builder: ["value"], | ||
}); | ||
(0, _index3.default)("NullLiteral", { | ||
aliases: ["Expression", "Pureish", "Literal", "Immutable"] | ||
}); | ||
(0, _index3.default)("BooleanLiteral", { | ||
@@ -395,3 +399,2 @@ builder: ["value"], | ||
}); | ||
(0, _index3.default)("RegExpLiteral", { | ||
@@ -411,3 +414,2 @@ builder: ["pattern", "flags"], | ||
}); | ||
(0, _index3.default)("LogicalExpression", { | ||
@@ -429,3 +431,2 @@ builder: ["operator", "left", "right"], | ||
}); | ||
(0, _index3.default)("MemberExpression", { | ||
@@ -443,3 +444,2 @@ builder: ["object", "property", "computed", "optional"], | ||
var computed = (0, _index2.assertNodeType)("Expression"); | ||
return function (node, key, val) { | ||
@@ -460,20 +460,3 @@ var validator = node.computed ? computed : normal; | ||
}); | ||
(0, _index3.default)("NewExpression", { | ||
visitor: ["callee", "arguments"], | ||
aliases: ["Expression"], | ||
fields: { | ||
callee: { | ||
validate: (0, _index2.assertNodeType)("Expression") | ||
}, | ||
arguments: { | ||
validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Expression", "SpreadElement"))) | ||
}, | ||
optional: { | ||
validate: (0, _index2.assertOneOf)(true, false), | ||
optional: true | ||
} | ||
} | ||
}); | ||
(0, _index3.default)("NewExpression", callOrNew); | ||
(0, _index3.default)("Program", { | ||
@@ -483,2 +466,5 @@ visitor: ["directives", "body"], | ||
fields: { | ||
sourceFile: { | ||
validate: (0, _index2.assertValueType)("string") | ||
}, | ||
directives: { | ||
@@ -494,3 +480,2 @@ validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Directive"))), | ||
}); | ||
(0, _index3.default)("ObjectExpression", { | ||
@@ -505,6 +490,5 @@ visitor: ["properties"], | ||
}); | ||
(0, _index3.default)("ObjectMethod", { | ||
builder: ["kind", "key", "params", "body", "computed"], | ||
fields: { | ||
fields: _extends({}, functionCommon, { | ||
kind: { | ||
@@ -520,5 +504,4 @@ validate: (0, _index2.chain)((0, _index2.assertValueType)("string"), (0, _index2.assertOneOf)("method", "get", "set")), | ||
validate: function () { | ||
var normal = (0, _index2.assertNodeType)("Expression"); | ||
var computed = (0, _index2.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral"); | ||
var normal = (0, _index2.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral"); | ||
var computed = (0, _index2.assertNodeType)("Expression"); | ||
return function (node, key, val) { | ||
@@ -535,16 +518,7 @@ var validator = node.computed ? computed : normal; | ||
validate: (0, _index2.assertNodeType)("BlockStatement") | ||
}, | ||
generator: { | ||
default: false, | ||
validate: (0, _index2.assertValueType)("boolean") | ||
}, | ||
async: { | ||
default: false, | ||
validate: (0, _index2.assertValueType)("boolean") | ||
} | ||
}, | ||
}), | ||
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"], | ||
aliases: ["UserWhitespacable", "Function", "Scopable", "BlockParent", "FunctionParent", "Method", "ObjectMember"] | ||
}); | ||
(0, _index3.default)("ObjectProperty", { | ||
@@ -561,3 +535,2 @@ builder: ["key", "value", "computed", "shorthand", "decorators"], | ||
var computed = (0, _index2.assertNodeType)("Expression"); | ||
return function (node, key, val) { | ||
@@ -570,3 +543,3 @@ var validator = node.computed ? computed : normal; | ||
value: { | ||
validate: (0, _index2.assertNodeType)("Expression", "Pattern", "RestElement") | ||
validate: (0, _index2.assertNodeType)("Expression", "PatternLike") | ||
}, | ||
@@ -585,16 +558,12 @@ shorthand: { | ||
}); | ||
(0, _index3.default)("RestElement", { | ||
visitor: ["argument", "typeAnnotation"], | ||
aliases: ["LVal"], | ||
fields: { | ||
builder: ["argument"], | ||
aliases: ["LVal", "PatternLike"], | ||
fields: _extends({}, patternLikeCommon, { | ||
argument: { | ||
validate: (0, _index2.assertNodeType)("LVal") | ||
}, | ||
decorators: { | ||
validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Decorator"))) | ||
} | ||
} | ||
}) | ||
}); | ||
(0, _index3.default)("ReturnStatement", { | ||
@@ -610,3 +579,2 @@ visitor: ["argument"], | ||
}); | ||
(0, _index3.default)("SequenceExpression", { | ||
@@ -621,3 +589,2 @@ visitor: ["expressions"], | ||
}); | ||
(0, _index3.default)("SwitchCase", { | ||
@@ -635,3 +602,2 @@ visitor: ["test", "consequent"], | ||
}); | ||
(0, _index3.default)("SwitchStatement", { | ||
@@ -649,7 +615,5 @@ visitor: ["discriminant", "cases"], | ||
}); | ||
(0, _index3.default)("ThisExpression", { | ||
aliases: ["Expression"] | ||
}); | ||
(0, _index3.default)("ThrowStatement", { | ||
@@ -664,3 +628,2 @@ visitor: ["argument"], | ||
}); | ||
(0, _index3.default)("TryStatement", { | ||
@@ -675,3 +638,3 @@ visitor: ["block", "handler", "finalizer"], | ||
optional: true, | ||
handler: (0, _index2.assertNodeType)("BlockStatement") | ||
validate: (0, _index2.assertNodeType)("BlockStatement") | ||
}, | ||
@@ -684,3 +647,2 @@ finalizer: { | ||
}); | ||
(0, _index3.default)("UnaryExpression", { | ||
@@ -702,3 +664,2 @@ builder: ["operator", "argument", "prefix"], | ||
}); | ||
(0, _index3.default)("UpdateExpression", { | ||
@@ -720,3 +681,2 @@ builder: ["operator", "argument", "prefix"], | ||
}); | ||
(0, _index3.default)("VariableDeclaration", { | ||
@@ -727,2 +687,6 @@ builder: ["kind", "declarations"], | ||
fields: { | ||
declare: { | ||
validate: (0, _index2.assertValueType)("boolean"), | ||
optional: true | ||
}, | ||
kind: { | ||
@@ -736,3 +700,2 @@ validate: (0, _index2.chain)((0, _index2.assertValueType)("string"), (0, _index2.assertOneOf)("var", "let", "const")) | ||
}); | ||
(0, _index3.default)("VariableDeclarator", { | ||
@@ -750,3 +713,2 @@ visitor: ["id", "init"], | ||
}); | ||
(0, _index3.default)("WhileStatement", { | ||
@@ -764,3 +726,2 @@ visitor: ["test", "body"], | ||
}); | ||
(0, _index3.default)("WithStatement", { | ||
@@ -767,0 +728,0 @@ visitor: ["object", "body"], |
"use strict"; | ||
exports.__esModule = true; | ||
exports.classMethodOrDeclareMethodCommon = exports.classMethodOrPropertyCommon = undefined; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _index = require("./index"); | ||
@@ -7,2 +12,4 @@ | ||
var _core = require("./core"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -12,4 +19,5 @@ | ||
visitor: ["left", "right"], | ||
aliases: ["Pattern", "LVal"], | ||
fields: { | ||
builder: ["left", "right"], | ||
aliases: ["Pattern", "PatternLike", "LVal"], | ||
fields: _extends({}, _core.patternLikeCommon, { | ||
left: { | ||
@@ -24,11 +32,11 @@ validate: (0, _index.assertNodeType)("Identifier", "ObjectPattern", "ArrayPattern") | ||
} | ||
} | ||
}) | ||
}); | ||
(0, _index2.default)("ArrayPattern", { | ||
visitor: ["elements", "typeAnnotation"], | ||
aliases: ["Pattern", "LVal"], | ||
fields: { | ||
builder: ["elements"], | ||
aliases: ["Pattern", "PatternLike", "LVal"], | ||
fields: _extends({}, _core.patternLikeCommon, { | ||
elements: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("Identifier", "Pattern", "RestElement"))) | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("PatternLike"))) | ||
}, | ||
@@ -38,5 +46,4 @@ decorators: { | ||
} | ||
} | ||
}) | ||
}); | ||
(0, _index2.default)("ArrowFunctionExpression", { | ||
@@ -46,16 +53,11 @@ builder: ["params", "body", "async"], | ||
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"], | ||
fields: { | ||
params: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("LVal"))) | ||
fields: _extends({}, _core.functionCommon, { | ||
expression: { | ||
validate: (0, _index.assertValueType)("boolean") | ||
}, | ||
body: { | ||
validate: (0, _index.assertNodeType)("BlockStatement", "Expression") | ||
}, | ||
async: { | ||
validate: (0, _index.assertValueType)("boolean"), | ||
default: false | ||
} | ||
} | ||
}) | ||
}); | ||
(0, _index2.default)("ClassBody", { | ||
@@ -65,7 +67,27 @@ visitor: ["body"], | ||
body: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("ClassMethod", "ClassProperty"))) | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("ClassMethod", "ClassProperty", "TSDeclareMethod", "TSIndexSignature"))) | ||
} | ||
} | ||
}); | ||
var classCommon = { | ||
typeParameters: { | ||
validate: (0, _index.assertNodeType)("TypeParameterDeclaration", "Noop"), | ||
optional: true | ||
}, | ||
body: { | ||
validate: (0, _index.assertNodeType)("ClassBody") | ||
}, | ||
superClass: { | ||
optional: true, | ||
validate: (0, _index.assertNodeType)("Expression") | ||
}, | ||
superTypeParameters: { | ||
validate: (0, _index.assertNodeType)("TypeParameterInstantiation"), | ||
optional: true | ||
}, | ||
implements: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("TSExpressionWithTypeArguments", "FlowClassImplements"))), | ||
optional: true | ||
} | ||
}; | ||
(0, _index2.default)("ClassDeclaration", { | ||
@@ -75,23 +97,25 @@ builder: ["id", "superClass", "body", "decorators"], | ||
aliases: ["Scopable", "Class", "Statement", "Declaration", "Pureish"], | ||
fields: { | ||
id: { | ||
validate: (0, _index.assertNodeType)("Identifier") | ||
fields: _extends({}, classCommon, { | ||
declare: { | ||
validate: (0, _index.assertValueType)("boolean"), | ||
optional: true | ||
}, | ||
body: { | ||
validate: (0, _index.assertNodeType)("ClassBody") | ||
abstract: { | ||
validate: (0, _index.assertValueType)("boolean"), | ||
optional: true | ||
}, | ||
superClass: { | ||
optional: true, | ||
validate: (0, _index.assertNodeType)("Expression") | ||
id: { | ||
validate: (0, _index.assertNodeType)("Identifier"), | ||
optional: true | ||
}, | ||
decorators: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("Decorator"))) | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("Decorator"))), | ||
optional: true | ||
} | ||
} | ||
}) | ||
}); | ||
(0, _index2.default)("ClassExpression", { | ||
inherits: "ClassDeclaration", | ||
aliases: ["Scopable", "Class", "Expression", "Pureish"], | ||
fields: { | ||
fields: _extends({}, classCommon, { | ||
id: { | ||
@@ -109,7 +133,7 @@ optional: true, | ||
decorators: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("Decorator"))) | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("Decorator"))), | ||
optional: true | ||
} | ||
} | ||
}) | ||
}); | ||
(0, _index2.default)("ExportAllDeclaration", { | ||
@@ -124,3 +148,2 @@ visitor: ["source"], | ||
}); | ||
(0, _index2.default)("ExportDefaultDeclaration", { | ||
@@ -131,7 +154,6 @@ visitor: ["declaration"], | ||
declaration: { | ||
validate: (0, _index.assertNodeType)("FunctionDeclaration", "ClassDeclaration", "Expression") | ||
validate: (0, _index.assertNodeType)("FunctionDeclaration", "TSDeclareFunction", "ClassDeclaration", "Expression") | ||
} | ||
} | ||
}); | ||
(0, _index2.default)("ExportNamedDeclaration", { | ||
@@ -154,3 +176,2 @@ visitor: ["declaration", "specifiers", "source"], | ||
}); | ||
(0, _index2.default)("ExportSpecifier", { | ||
@@ -168,3 +189,2 @@ visitor: ["local", "exported"], | ||
}); | ||
(0, _index2.default)("ForOfStatement", { | ||
@@ -189,3 +209,2 @@ visitor: ["left", "right", "body"], | ||
}); | ||
(0, _index2.default)("ImportDeclaration", { | ||
@@ -203,3 +222,2 @@ visitor: ["specifiers", "source"], | ||
}); | ||
(0, _index2.default)("ImportDefaultSpecifier", { | ||
@@ -214,3 +232,2 @@ visitor: ["local"], | ||
}); | ||
(0, _index2.default)("ImportNamespaceSpecifier", { | ||
@@ -225,3 +242,2 @@ visitor: ["local"], | ||
}); | ||
(0, _index2.default)("ImportSpecifier", { | ||
@@ -242,3 +258,2 @@ visitor: ["local", "imported"], | ||
}); | ||
(0, _index2.default)("MetaProperty", { | ||
@@ -256,3 +271,50 @@ visitor: ["meta", "property"], | ||
}); | ||
var classMethodOrPropertyCommon = exports.classMethodOrPropertyCommon = { | ||
abstract: { | ||
validate: (0, _index.assertValueType)("boolean"), | ||
optional: true | ||
}, | ||
accessibility: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("string"), (0, _index.assertOneOf)("public", "private", "protected")), | ||
optional: true | ||
}, | ||
static: { | ||
validate: (0, _index.assertValueType)("boolean"), | ||
optional: true | ||
}, | ||
computed: { | ||
default: false, | ||
validate: (0, _index.assertValueType)("boolean") | ||
}, | ||
optional: { | ||
validate: (0, _index.assertValueType)("boolean"), | ||
optional: true | ||
}, | ||
key: { | ||
validate: function () { | ||
var normal = (0, _index.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral"); | ||
var computed = (0, _index.assertNodeType)("Expression"); | ||
return function (node, key, val) { | ||
var validator = node.computed ? computed : normal; | ||
validator(node, key, val); | ||
}; | ||
}() | ||
} | ||
}; | ||
var classMethodOrDeclareMethodCommon = exports.classMethodOrDeclareMethodCommon = _extends({}, _core.functionCommon, classMethodOrPropertyCommon, { | ||
kind: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("string"), (0, _index.assertOneOf)("get", "set", "method", "constructor")), | ||
default: "method" | ||
}, | ||
access: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("string"), (0, _index.assertOneOf)("public", "private", "protected")), | ||
optional: true | ||
}, | ||
decorators: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("Decorator"))), | ||
optional: true | ||
} | ||
}); | ||
(0, _index2.default)("ClassMethod", { | ||
@@ -262,56 +324,18 @@ aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method"], | ||
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"], | ||
fields: { | ||
kind: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("string"), (0, _index.assertOneOf)("get", "set", "method", "constructor")), | ||
default: "method" | ||
}, | ||
computed: { | ||
default: false, | ||
validate: (0, _index.assertValueType)("boolean") | ||
}, | ||
static: { | ||
default: false, | ||
validate: (0, _index.assertValueType)("boolean") | ||
}, | ||
key: { | ||
validate: function () { | ||
var normal = (0, _index.assertNodeType)("Expression"); | ||
var computed = (0, _index.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral"); | ||
return function (node, key, val) { | ||
var validator = node.computed ? computed : normal; | ||
validator(node, key, val); | ||
}; | ||
}() | ||
}, | ||
params: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("LVal"))) | ||
}, | ||
fields: _extends({}, classMethodOrDeclareMethodCommon, { | ||
body: { | ||
validate: (0, _index.assertNodeType)("BlockStatement") | ||
}, | ||
generator: { | ||
default: false, | ||
validate: (0, _index.assertValueType)("boolean") | ||
}, | ||
async: { | ||
default: false, | ||
validate: (0, _index.assertValueType)("boolean") | ||
} | ||
} | ||
}) | ||
}); | ||
(0, _index2.default)("ObjectPattern", { | ||
visitor: ["properties", "typeAnnotation"], | ||
aliases: ["Pattern", "LVal"], | ||
fields: { | ||
builder: ["properties"], | ||
aliases: ["Pattern", "PatternLike", "LVal"], | ||
fields: _extends({}, _core.patternLikeCommon, { | ||
properties: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("RestElement", "Property"))) | ||
}, | ||
decorators: { | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("Decorator"))) | ||
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("RestElement", "ObjectProperty"))) | ||
} | ||
} | ||
}) | ||
}); | ||
(0, _index2.default)("SpreadElement", { | ||
@@ -326,7 +350,5 @@ visitor: ["argument"], | ||
}); | ||
(0, _index2.default)("Super", { | ||
aliases: ["Expression"] | ||
}); | ||
(0, _index2.default)("TaggedTemplateExpression", { | ||
@@ -344,3 +366,2 @@ visitor: ["tag", "quasi"], | ||
}); | ||
(0, _index2.default)("TemplateElement", { | ||
@@ -356,3 +377,2 @@ builder: ["value", "tail"], | ||
}); | ||
(0, _index2.default)("TemplateLiteral", { | ||
@@ -370,3 +390,2 @@ visitor: ["quasis", "expressions"], | ||
}); | ||
(0, _index2.default)("YieldExpression", { | ||
@@ -373,0 +392,0 @@ builder: ["argument", "delegate"], |
@@ -19,3 +19,2 @@ "use strict"; | ||
}); | ||
(0, _index2.default)("BindExpression", { | ||
@@ -26,7 +25,5 @@ visitor: ["object", "callee"], | ||
}); | ||
(0, _index2.default)("Import", { | ||
aliases: ["Expression"] | ||
}); | ||
(0, _index2.default)("Decorator", { | ||
@@ -40,3 +37,2 @@ visitor: ["expression"], | ||
}); | ||
(0, _index2.default)("DoExpression", { | ||
@@ -51,3 +47,2 @@ visitor: ["body"], | ||
}); | ||
(0, _index2.default)("ExportDefaultSpecifier", { | ||
@@ -62,3 +57,2 @@ visitor: ["exported"], | ||
}); | ||
(0, _index2.default)("ExportNamespaceSpecifier", { | ||
@@ -65,0 +59,0 @@ visitor: ["exported"], |
@@ -13,3 +13,2 @@ "use strict"; | ||
}); | ||
(0, _index2.default)("ArrayTypeAnnotation", { | ||
@@ -20,3 +19,2 @@ visitor: ["elementType"], | ||
}); | ||
(0, _index2.default)("BooleanTypeAnnotation", { | ||
@@ -26,3 +24,2 @@ aliases: ["Flow", "FlowBaseAnnotation"], | ||
}); | ||
(0, _index2.default)("BooleanLiteralTypeAnnotation", { | ||
@@ -32,3 +29,2 @@ aliases: ["Flow"], | ||
}); | ||
(0, _index2.default)("NullLiteralTypeAnnotation", { | ||
@@ -38,3 +34,2 @@ aliases: ["Flow", "FlowBaseAnnotation"], | ||
}); | ||
(0, _index2.default)("ClassImplements", { | ||
@@ -45,15 +40,2 @@ visitor: ["id", "typeParameters"], | ||
}); | ||
(0, _index2.default)("ClassProperty", { | ||
visitor: ["key", "value", "typeAnnotation", "decorators"], | ||
builder: ["key", "value", "typeAnnotation", "decorators", "computed"], | ||
aliases: ["Property"], | ||
fields: { | ||
computed: { | ||
validate: (0, _index.assertValueType)("boolean"), | ||
default: false | ||
} | ||
} | ||
}); | ||
(0, _index2.default)("DeclareClass", { | ||
@@ -64,3 +46,2 @@ visitor: ["id", "typeParameters", "extends", "body"], | ||
}); | ||
(0, _index2.default)("DeclareFunction", { | ||
@@ -71,3 +52,2 @@ visitor: ["id"], | ||
}); | ||
(0, _index2.default)("DeclareInterface", { | ||
@@ -78,3 +58,2 @@ visitor: ["id", "typeParameters", "extends", "body"], | ||
}); | ||
(0, _index2.default)("DeclareModule", { | ||
@@ -85,3 +64,2 @@ visitor: ["id", "body"], | ||
}); | ||
(0, _index2.default)("DeclareModuleExports", { | ||
@@ -92,3 +70,2 @@ visitor: ["typeAnnotation"], | ||
}); | ||
(0, _index2.default)("DeclareTypeAlias", { | ||
@@ -99,3 +76,2 @@ visitor: ["id", "typeParameters", "right"], | ||
}); | ||
(0, _index2.default)("DeclareVariable", { | ||
@@ -106,3 +82,2 @@ visitor: ["id"], | ||
}); | ||
(0, _index2.default)("DeclareExportDeclaration", { | ||
@@ -113,3 +88,2 @@ visitor: ["declaration", "specifiers", "source"], | ||
}); | ||
(0, _index2.default)("DeclareExportAllDeclaration", { | ||
@@ -120,7 +94,10 @@ visitor: ["source"], | ||
}); | ||
(0, _index2.default)("DeclaredPredicate", { | ||
visitor: ["value"], | ||
aliases: ["Flow", "FlowPredicate"], | ||
fields: {} | ||
}); | ||
(0, _index2.default)("ExistsTypeAnnotation", { | ||
aliases: ["Flow"] | ||
}); | ||
(0, _index2.default)("FunctionTypeAnnotation", { | ||
@@ -131,3 +108,2 @@ visitor: ["typeParameters", "params", "rest", "returnType"], | ||
}); | ||
(0, _index2.default)("FunctionTypeParam", { | ||
@@ -138,3 +114,2 @@ visitor: ["name", "typeAnnotation"], | ||
}); | ||
(0, _index2.default)("GenericTypeAnnotation", { | ||
@@ -145,3 +120,6 @@ visitor: ["id", "typeParameters"], | ||
}); | ||
(0, _index2.default)("InferredPredicate", { | ||
aliases: ["Flow", "FlowPredicate"], | ||
fields: {} | ||
}); | ||
(0, _index2.default)("InterfaceExtends", { | ||
@@ -152,3 +130,2 @@ visitor: ["id", "typeParameters"], | ||
}); | ||
(0, _index2.default)("InterfaceDeclaration", { | ||
@@ -159,3 +136,2 @@ visitor: ["id", "typeParameters", "extends", "body"], | ||
}); | ||
(0, _index2.default)("IntersectionTypeAnnotation", { | ||
@@ -166,11 +142,8 @@ visitor: ["types"], | ||
}); | ||
(0, _index2.default)("MixedTypeAnnotation", { | ||
aliases: ["Flow", "FlowBaseAnnotation"] | ||
}); | ||
(0, _index2.default)("EmptyTypeAnnotation", { | ||
aliases: ["Flow", "FlowBaseAnnotation"] | ||
}); | ||
(0, _index2.default)("NullableTypeAnnotation", { | ||
@@ -181,3 +154,2 @@ visitor: ["typeAnnotation"], | ||
}); | ||
(0, _index2.default)("NumberLiteralTypeAnnotation", { | ||
@@ -187,3 +159,2 @@ aliases: ["Flow"], | ||
}); | ||
(0, _index2.default)("NumberTypeAnnotation", { | ||
@@ -193,3 +164,2 @@ aliases: ["Flow", "FlowBaseAnnotation"], | ||
}); | ||
(0, _index2.default)("StringLiteralTypeAnnotation", { | ||
@@ -199,3 +169,2 @@ aliases: ["Flow"], | ||
}); | ||
(0, _index2.default)("StringTypeAnnotation", { | ||
@@ -205,3 +174,2 @@ aliases: ["Flow", "FlowBaseAnnotation"], | ||
}); | ||
(0, _index2.default)("ThisTypeAnnotation", { | ||
@@ -211,3 +179,2 @@ aliases: ["Flow", "FlowBaseAnnotation"], | ||
}); | ||
(0, _index2.default)("TupleTypeAnnotation", { | ||
@@ -218,3 +185,2 @@ visitor: ["types"], | ||
}); | ||
(0, _index2.default)("TypeofTypeAnnotation", { | ||
@@ -225,3 +191,2 @@ visitor: ["argument"], | ||
}); | ||
(0, _index2.default)("TypeAlias", { | ||
@@ -232,9 +197,2 @@ visitor: ["id", "typeParameters", "right"], | ||
}); | ||
(0, _index2.default)("TypeAnnotation", { | ||
visitor: ["typeAnnotation"], | ||
aliases: ["Flow"], | ||
fields: {} | ||
}); | ||
(0, _index2.default)("TypeCastExpression", { | ||
@@ -245,21 +203,2 @@ visitor: ["expression", "typeAnnotation"], | ||
}); | ||
(0, _index2.default)("TypeParameter", { | ||
visitor: ["bound"], | ||
aliases: ["Flow"], | ||
fields: {} | ||
}); | ||
(0, _index2.default)("TypeParameterDeclaration", { | ||
visitor: ["params"], | ||
aliases: ["Flow"], | ||
fields: {} | ||
}); | ||
(0, _index2.default)("TypeParameterInstantiation", { | ||
visitor: ["params"], | ||
aliases: ["Flow"], | ||
fields: {} | ||
}); | ||
(0, _index2.default)("ObjectTypeAnnotation", { | ||
@@ -270,3 +209,2 @@ visitor: ["properties", "indexers", "callProperties"], | ||
}); | ||
(0, _index2.default)("ObjectTypeCallProperty", { | ||
@@ -277,3 +215,2 @@ visitor: ["value"], | ||
}); | ||
(0, _index2.default)("ObjectTypeIndexer", { | ||
@@ -284,3 +221,2 @@ visitor: ["id", "key", "value"], | ||
}); | ||
(0, _index2.default)("ObjectTypeProperty", { | ||
@@ -291,3 +227,2 @@ visitor: ["key", "value"], | ||
}); | ||
(0, _index2.default)("ObjectTypeSpreadProperty", { | ||
@@ -298,3 +233,2 @@ visitor: ["argument"], | ||
}); | ||
(0, _index2.default)("QualifiedTypeIdentifier", { | ||
@@ -305,3 +239,2 @@ visitor: ["id", "qualification"], | ||
}); | ||
(0, _index2.default)("UnionTypeAnnotation", { | ||
@@ -312,3 +245,2 @@ visitor: ["types"], | ||
}); | ||
(0, _index2.default)("VoidTypeAnnotation", { | ||
@@ -315,0 +247,0 @@ aliases: ["Flow", "FlowBaseAnnotation"], |
@@ -48,2 +48,3 @@ "use strict"; | ||
} | ||
validator.each = callback; | ||
@@ -65,3 +66,2 @@ return validator; | ||
validate.oneOf = vals; | ||
return validate; | ||
@@ -78,16 +78,5 @@ } | ||
for (var _iterator = types, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
for (var _i = 0; _i < types.length; _i++) { | ||
var type = types[_i]; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref = _i.value; | ||
} | ||
var type = _ref; | ||
if (t.is(type, val)) { | ||
@@ -105,3 +94,2 @@ valid = true; | ||
validate.oneOfNodeTypes = types; | ||
return validate; | ||
@@ -118,16 +106,5 @@ } | ||
for (var _iterator2 = types, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { | ||
var _ref2; | ||
for (var _i2 = 0; _i2 < types.length; _i2++) { | ||
var type = types[_i2]; | ||
if (_isArray2) { | ||
if (_i2 >= _iterator2.length) break; | ||
_ref2 = _iterator2[_i2++]; | ||
} else { | ||
_i2 = _iterator2.next(); | ||
if (_i2.done) break; | ||
_ref2 = _i2.value; | ||
} | ||
var type = _ref2; | ||
if (getType(val) === type || t.is(type, val)) { | ||
@@ -145,3 +122,2 @@ valid = true; | ||
validate.oneOfNodeOrValueTypes = types; | ||
return validate; | ||
@@ -160,3 +136,2 @@ } | ||
validate.type = type; | ||
return validate; | ||
@@ -171,19 +146,8 @@ } | ||
function validate() { | ||
for (var _iterator3 = fns, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { | ||
var _ref3; | ||
if (_isArray3) { | ||
if (_i3 >= _iterator3.length) break; | ||
_ref3 = _iterator3[_i3++]; | ||
} else { | ||
_i3 = _iterator3.next(); | ||
if (_i3.done) break; | ||
_ref3 = _i3.value; | ||
} | ||
var fn = _ref3; | ||
for (var _i3 = 0; _i3 < fns.length; _i3++) { | ||
var fn = fns[_i3]; | ||
fn.apply(undefined, arguments); | ||
} | ||
} | ||
validate.chainOf = fns; | ||
@@ -195,5 +159,3 @@ return validate; | ||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var inherits = opts.inherits && store[opts.inherits] || {}; | ||
opts.fields = opts.fields || inherits.fields || {}; | ||
@@ -208,16 +170,6 @@ opts.visitor = opts.visitor || inherits.visitor || []; | ||
for (var _iterator4 = opts.visitor.concat(opts.builder), _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) { | ||
var _ref4; | ||
var _arr = opts.visitor.concat(opts.builder); | ||
if (_isArray4) { | ||
if (_i4 >= _iterator4.length) break; | ||
_ref4 = _iterator4[_i4++]; | ||
} else { | ||
_i4 = _iterator4.next(); | ||
if (_i4.done) break; | ||
_ref4 = _i4.value; | ||
} | ||
var key = _ref4; | ||
for (var _i4 = 0; _i4 < _arr.length; _i4++) { | ||
var key = _arr[_i4]; | ||
opts.fields[key] = opts.fields[key] || {}; | ||
@@ -232,2 +184,3 @@ } | ||
} | ||
if (field.default === undefined) { | ||
@@ -244,3 +197,2 @@ field.default = null; | ||
ALIAS_KEYS[type] = opts.aliases; | ||
store[type] = opts; | ||
@@ -247,0 +199,0 @@ } |
@@ -15,2 +15,6 @@ "use strict"; | ||
require("./experimental"); | ||
require("./experimental"); | ||
require("./tsFlowCommon"); | ||
require("./typescript"); |
@@ -22,3 +22,2 @@ "use strict"; | ||
}); | ||
(0, _index2.default)("JSXClosingElement", { | ||
@@ -33,3 +32,2 @@ visitor: ["name"], | ||
}); | ||
(0, _index2.default)("JSXElement", { | ||
@@ -52,7 +50,5 @@ builder: ["openingElement", "closingElement", "children", "selfClosing"], | ||
}); | ||
(0, _index2.default)("JSXEmptyExpression", { | ||
aliases: ["JSX", "Expression"] | ||
}); | ||
(0, _index2.default)("JSXExpressionContainer", { | ||
@@ -67,3 +63,2 @@ visitor: ["expression"], | ||
}); | ||
(0, _index2.default)("JSXSpreadChild", { | ||
@@ -78,3 +73,2 @@ visitor: ["expression"], | ||
}); | ||
(0, _index2.default)("JSXIdentifier", { | ||
@@ -89,3 +83,2 @@ builder: ["name"], | ||
}); | ||
(0, _index2.default)("JSXMemberExpression", { | ||
@@ -103,3 +96,2 @@ visitor: ["object", "property"], | ||
}); | ||
(0, _index2.default)("JSXNamespacedName", { | ||
@@ -117,3 +109,2 @@ visitor: ["namespace", "name"], | ||
}); | ||
(0, _index2.default)("JSXOpeningElement", { | ||
@@ -136,3 +127,2 @@ builder: ["name", "attributes", "selfClosing"], | ||
}); | ||
(0, _index2.default)("JSXSpreadAttribute", { | ||
@@ -147,3 +137,2 @@ visitor: ["argument"], | ||
}); | ||
(0, _index2.default)("JSXText", { | ||
@@ -150,0 +139,0 @@ aliases: ["JSX", "Immutable"], |
@@ -12,3 +12,2 @@ "use strict"; | ||
}); | ||
(0, _index2.default)("ParenthesizedExpression", { | ||
@@ -15,0 +14,0 @@ visitor: ["expression"], |
@@ -27,5 +27,3 @@ "use strict"; | ||
var bases = {}; | ||
var typeGroups = []; | ||
var types = []; | ||
@@ -55,2 +53,3 @@ | ||
} | ||
continue; | ||
@@ -64,2 +63,3 @@ } | ||
var existing = generics[name]; | ||
if (existing.typeParameters) { | ||
@@ -66,0 +66,0 @@ if (node.typeParameters) { |
191
lib/index.js
@@ -332,2 +332,3 @@ "use strict"; | ||
var is = t["is" + type]; | ||
if (!is) { | ||
@@ -341,2 +342,3 @@ is = t["is" + type] = function (node, opts) { | ||
opts = opts || {}; | ||
if (!is(node, opts)) { | ||
@@ -355,3 +357,2 @@ throw new Error("Expected type " + JSON.stringify(type) + " with option " + JSON.stringify(opts)); | ||
for (var type in t.VISITOR_KEYS) { | ||
@@ -364,2 +365,3 @@ registerType(type); | ||
} | ||
function isSpreadProperty() { | ||
@@ -370,3 +372,2 @@ return t.isSpreadElement.apply(t, arguments); | ||
t.FLIPPED_ALIAS_KEYS = {}; | ||
Object.keys(t.ALIAS_KEYS).forEach(function (type) { | ||
@@ -378,3 +379,2 @@ t.ALIAS_KEYS[type].forEach(function (alias) { | ||
}); | ||
Object.keys(t.FLIPPED_ALIAS_KEYS).forEach(function (type) { | ||
@@ -384,3 +384,2 @@ t[type.toUpperCase() + "_TYPES"] = t.FLIPPED_ALIAS_KEYS[type]; | ||
}); | ||
var TYPES = exports.TYPES = Object.keys(t.VISITOR_KEYS).concat(Object.keys(t.FLIPPED_ALIAS_KEYS)).concat(Object.keys(t.DEPRECATED_KEYS)); | ||
@@ -390,3 +389,2 @@ | ||
if (!node) return false; | ||
var matches = isType(node.type, type); | ||
@@ -404,6 +402,5 @@ if (!matches) return false; | ||
if (nodeType === targetType) return true; | ||
if (t.ALIAS_KEYS[targetType]) return false; | ||
var aliases = t.FLIPPED_ALIAS_KEYS[targetType]; | ||
var aliases = t.FLIPPED_ALIAS_KEYS[targetType]; | ||
if (aliases) { | ||
@@ -425,3 +422,2 @@ if (aliases[0] === nodeType) return true; | ||
var alias = _ref; | ||
if (nodeType === alias) return true; | ||
@@ -444,24 +440,10 @@ } | ||
node.type = type; | ||
var i = 0; | ||
var _arr = keys; | ||
for (var _iterator2 = keys, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { | ||
var _ref2; | ||
if (_isArray2) { | ||
if (_i2 >= _iterator2.length) break; | ||
_ref2 = _iterator2[_i2++]; | ||
} else { | ||
_i2 = _iterator2.next(); | ||
if (_i2.done) break; | ||
_ref2 = _i2.value; | ||
} | ||
var key = _ref2; | ||
for (var _i2 = 0; _i2 < _arr.length; _i2++) { | ||
var key = _arr[_i2]; | ||
var field = t.NODE_FIELDS[type][key]; | ||
var arg = arguments[i++]; | ||
if (arg === undefined) arg = (0, _clone2.default)(field.default); | ||
node[key] = arg; | ||
@@ -502,10 +484,7 @@ } | ||
if (!node) return; | ||
var fields = t.NODE_FIELDS[node.type]; | ||
if (!fields) return; | ||
var field = fields[key]; | ||
if (!field || !field.validate) return; | ||
if (field.optional && val == null) return; | ||
field.validate(node, key, val); | ||
@@ -516,17 +495,7 @@ } | ||
var keys = Object.keys(expected); | ||
var _arr2 = keys; | ||
for (var _iterator3 = keys, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { | ||
var _ref3; | ||
for (var _i3 = 0; _i3 < _arr2.length; _i3++) { | ||
var key = _arr2[_i3]; | ||
if (_isArray3) { | ||
if (_i3 >= _iterator3.length) break; | ||
_ref3 = _iterator3[_i3++]; | ||
} else { | ||
_i3 = _iterator3.next(); | ||
if (_i3.done) break; | ||
_ref3 = _i3.value; | ||
} | ||
var key = _ref3; | ||
if (actual[key] !== expected[key]) { | ||
@@ -554,3 +523,2 @@ return false; | ||
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "body"; | ||
return node[key] = t.toBlock(node[key], node); | ||
@@ -562,2 +530,3 @@ } | ||
var newNode = {}; | ||
for (var key in node) { | ||
@@ -567,2 +536,3 @@ if (key[0] === "_") continue; | ||
} | ||
return newNode; | ||
@@ -573,3 +543,3 @@ } | ||
var newNode = clone(node); | ||
delete newNode.loc; | ||
newNode.loc = null; | ||
return newNode; | ||
@@ -584,3 +554,2 @@ } | ||
if (key[0] === "_") continue; | ||
var val = node[key]; | ||
@@ -604,12 +573,11 @@ | ||
if (!t.isMemberExpression(member)) return false; | ||
var parts = Array.isArray(match) ? match : match.split("."); | ||
var nodes = []; | ||
var node = void 0; | ||
var node = void 0; | ||
for (node = member; t.isMemberExpression(node); node = node.object) { | ||
nodes.push(node.property); | ||
} | ||
nodes.push(node); | ||
if (nodes.length < parts.length) return false; | ||
@@ -621,2 +589,3 @@ if (!allowPartial && nodes.length > parts.length) return false; | ||
var value = void 0; | ||
if (t.isIdentifier(_node)) { | ||
@@ -644,18 +613,18 @@ value = _node.name; | ||
function removeComments(node) { | ||
for (var _iterator4 = t.COMMENT_KEYS, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) { | ||
var _ref4; | ||
for (var _iterator2 = t.COMMENT_KEYS, _isArray2 = Array.isArray(_iterator2), _i4 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { | ||
var _ref2; | ||
if (_isArray4) { | ||
if (_i4 >= _iterator4.length) break; | ||
_ref4 = _iterator4[_i4++]; | ||
if (_isArray2) { | ||
if (_i4 >= _iterator2.length) break; | ||
_ref2 = _iterator2[_i4++]; | ||
} else { | ||
_i4 = _iterator4.next(); | ||
_i4 = _iterator2.next(); | ||
if (_i4.done) break; | ||
_ref4 = _i4.value; | ||
_ref2 = _i4.value; | ||
} | ||
var key = _ref4; | ||
var key = _ref2; | ||
node[key] = null; | ||
} | ||
delete node[key]; | ||
} | ||
return node; | ||
@@ -691,17 +660,7 @@ } | ||
if (!child || !parent) return child; | ||
var _arr3 = t.INHERIT_KEYS.optional; | ||
for (var _iterator5 = t.INHERIT_KEYS.optional, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) { | ||
var _ref5; | ||
for (var _i5 = 0; _i5 < _arr3.length; _i5++) { | ||
var key = _arr3[_i5]; | ||
if (_isArray5) { | ||
if (_i5 >= _iterator5.length) break; | ||
_ref5 = _iterator5[_i5++]; | ||
} else { | ||
_i5 = _iterator5.next(); | ||
if (_i5.done) break; | ||
_ref5 = _i5.value; | ||
} | ||
var key = _ref5; | ||
if (child[key] == null) { | ||
@@ -713,19 +672,9 @@ child[key] = parent[key]; | ||
for (var _key2 in parent) { | ||
if (_key2[0] === "_") child[_key2] = parent[_key2]; | ||
if (_key2[0] === "_" && _key2 !== "__clone") child[_key2] = parent[_key2]; | ||
} | ||
for (var _iterator6 = t.INHERIT_KEYS.force, _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) { | ||
var _ref6; | ||
var _arr4 = t.INHERIT_KEYS.force; | ||
if (_isArray6) { | ||
if (_i6 >= _iterator6.length) break; | ||
_ref6 = _iterator6[_i6++]; | ||
} else { | ||
_i6 = _iterator6.next(); | ||
if (_i6.done) break; | ||
_ref6 = _i6.value; | ||
} | ||
var _key3 = _ref6; | ||
for (var _i6 = 0; _i6 < _arr4.length; _i6++) { | ||
var _key3 = _arr4[_i6]; | ||
child[_key3] = parent[_key3]; | ||
@@ -735,3 +684,2 @@ } | ||
t.inheritsComments(child, parent); | ||
return child; | ||
@@ -755,40 +703,36 @@ } | ||
if (!node) return; | ||
var keys = t.VISITOR_KEYS[node.type]; | ||
if (!keys) return; | ||
opts = opts || {}; | ||
enter(node, opts); | ||
for (var _iterator7 = keys, _isArray7 = Array.isArray(_iterator7), _i7 = 0, _iterator7 = _isArray7 ? _iterator7 : _iterator7[Symbol.iterator]();;) { | ||
var _ref7; | ||
for (var _iterator3 = keys, _isArray3 = Array.isArray(_iterator3), _i7 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { | ||
var _ref3; | ||
if (_isArray7) { | ||
if (_i7 >= _iterator7.length) break; | ||
_ref7 = _iterator7[_i7++]; | ||
if (_isArray3) { | ||
if (_i7 >= _iterator3.length) break; | ||
_ref3 = _iterator3[_i7++]; | ||
} else { | ||
_i7 = _iterator7.next(); | ||
_i7 = _iterator3.next(); | ||
if (_i7.done) break; | ||
_ref7 = _i7.value; | ||
_ref3 = _i7.value; | ||
} | ||
var key = _ref7; | ||
var key = _ref3; | ||
var subNode = node[key]; | ||
if (Array.isArray(subNode)) { | ||
for (var _iterator8 = subNode, _isArray8 = Array.isArray(_iterator8), _i8 = 0, _iterator8 = _isArray8 ? _iterator8 : _iterator8[Symbol.iterator]();;) { | ||
var _ref8; | ||
for (var _iterator4 = subNode, _isArray4 = Array.isArray(_iterator4), _i8 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) { | ||
var _ref4; | ||
if (_isArray8) { | ||
if (_i8 >= _iterator8.length) break; | ||
_ref8 = _iterator8[_i8++]; | ||
if (_isArray4) { | ||
if (_i8 >= _iterator4.length) break; | ||
_ref4 = _iterator4[_i8++]; | ||
} else { | ||
_i8 = _iterator8.next(); | ||
_i8 = _iterator4.next(); | ||
if (_i8.done) break; | ||
_ref8 = _i8.value; | ||
_ref4 = _i8.value; | ||
} | ||
var _node2 = _ref8; | ||
var _node2 = _ref4; | ||
traverseFast(_node2, enter, opts); | ||
@@ -803,3 +747,2 @@ } | ||
var CLEAR_KEYS = ["tokens", "start", "end", "loc", "raw", "rawValue"]; | ||
var CLEAR_KEYS_PLUS_COMMENTS = t.COMMENT_KEYS.concat(["comments"]).concat(CLEAR_KEYS); | ||
@@ -810,16 +753,16 @@ | ||
var map = opts.preserveComments ? CLEAR_KEYS : CLEAR_KEYS_PLUS_COMMENTS; | ||
for (var _iterator9 = map, _isArray9 = Array.isArray(_iterator9), _i9 = 0, _iterator9 = _isArray9 ? _iterator9 : _iterator9[Symbol.iterator]();;) { | ||
var _ref9; | ||
if (_isArray9) { | ||
if (_i9 >= _iterator9.length) break; | ||
_ref9 = _iterator9[_i9++]; | ||
for (var _iterator5 = map, _isArray5 = Array.isArray(_iterator5), _i9 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) { | ||
var _ref5; | ||
if (_isArray5) { | ||
if (_i9 >= _iterator5.length) break; | ||
_ref5 = _iterator5[_i9++]; | ||
} else { | ||
_i9 = _iterator9.next(); | ||
_i9 = _iterator5.next(); | ||
if (_i9.done) break; | ||
_ref9 = _i9.value; | ||
_ref5 = _i9.value; | ||
} | ||
var key = _ref9; | ||
var key = _ref5; | ||
if (node[key] != null) node[key] = undefined; | ||
@@ -833,16 +776,16 @@ } | ||
var syms = Object.getOwnPropertySymbols(node); | ||
for (var _iterator10 = syms, _isArray10 = Array.isArray(_iterator10), _i10 = 0, _iterator10 = _isArray10 ? _iterator10 : _iterator10[Symbol.iterator]();;) { | ||
var _ref10; | ||
if (_isArray10) { | ||
if (_i10 >= _iterator10.length) break; | ||
_ref10 = _iterator10[_i10++]; | ||
for (var _iterator6 = syms, _isArray6 = Array.isArray(_iterator6), _i10 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) { | ||
var _ref6; | ||
if (_isArray6) { | ||
if (_i10 >= _iterator6.length) break; | ||
_ref6 = _iterator6[_i10++]; | ||
} else { | ||
_i10 = _iterator10.next(); | ||
_i10 = _iterator6.next(); | ||
if (_i10.done) break; | ||
_ref10 = _i10.value; | ||
_ref6 = _i10.value; | ||
} | ||
var sym = _ref10; | ||
var sym = _ref6; | ||
node[sym] = null; | ||
@@ -849,0 +792,0 @@ } |
@@ -22,3 +22,2 @@ "use strict"; | ||
var lines = child.value.split(/\r\n|\n|\r/); | ||
var lastNonEmptyLine = 0; | ||
@@ -36,7 +35,5 @@ | ||
var line = lines[_i]; | ||
var isFirstLine = _i === 0; | ||
var isLastLine = _i === lines.length - 1; | ||
var isLastNonEmptyLine = _i === lastNonEmptyLine; | ||
var trimmedLine = line.replace(/\t/g, " "); | ||
@@ -77,3 +74,2 @@ | ||
if (t.isJSXEmptyExpression(child)) continue; | ||
elems.push(child); | ||
@@ -80,0 +76,0 @@ } |
@@ -20,3 +20,2 @@ "use strict"; | ||
if (!id) continue; | ||
var keys = t.getBindingIdentifiers.keys[id.type]; | ||
@@ -27,2 +26,3 @@ | ||
var _ids = ids[id.name] = ids[id.name] || []; | ||
_ids.push(id); | ||
@@ -32,2 +32,3 @@ } else { | ||
} | ||
continue; | ||
@@ -40,2 +41,3 @@ } | ||
} | ||
continue; | ||
@@ -58,2 +60,3 @@ } | ||
var key = keys[i]; | ||
if (id[key]) { | ||
@@ -76,3 +79,2 @@ search = search.concat(id[key]); | ||
TypeAlias: ["id"], | ||
CatchClause: ["param"], | ||
@@ -82,3 +84,2 @@ LabeledStatement: ["label"], | ||
AssignmentExpression: ["left"], | ||
ImportSpecifier: ["local"], | ||
@@ -88,22 +89,15 @@ ImportNamespaceSpecifier: ["local"], | ||
ImportDeclaration: ["specifiers"], | ||
ExportSpecifier: ["exported"], | ||
ExportNamespaceSpecifier: ["exported"], | ||
ExportDefaultSpecifier: ["exported"], | ||
FunctionDeclaration: ["id", "params"], | ||
FunctionExpression: ["id", "params"], | ||
ClassDeclaration: ["id"], | ||
ClassExpression: ["id"], | ||
RestElement: ["argument"], | ||
UpdateExpression: ["argument"], | ||
ObjectProperty: ["value"], | ||
AssignmentPattern: ["left"], | ||
ArrayPattern: ["elements"], | ||
ObjectPattern: ["properties"], | ||
VariableDeclaration: ["declarations"], | ||
@@ -110,0 +104,0 @@ VariableDeclarator: ["id"] |
@@ -36,2 +36,3 @@ "use strict"; | ||
var keys = _retrievers.getBindingIdentifiers.keys[parent.type]; | ||
if (keys) { | ||
@@ -41,2 +42,3 @@ for (var i = 0; i < keys.length; i++) { | ||
var val = parent[key]; | ||
if (Array.isArray(val)) { | ||
@@ -82,16 +84,6 @@ if (val.indexOf(node) >= 0) return true; | ||
case "FunctionExpression": | ||
for (var _iterator = parent.params, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
var _arr = parent.params; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref = _i.value; | ||
} | ||
var param = _ref; | ||
for (var _i = 0; _i < _arr.length; _i++) { | ||
var param = _arr[_i]; | ||
if (param === node) return false; | ||
@@ -178,3 +170,5 @@ } | ||
function isVar(node) { | ||
return t.isVariableDeclaration(node, { kind: "var" }) && !node[_constants.BLOCK_SCOPED_SYMBOL]; | ||
return t.isVariableDeclaration(node, { | ||
kind: "var" | ||
}) && !node[_constants.BLOCK_SCOPED_SYMBOL]; | ||
} | ||
@@ -189,3 +183,5 @@ | ||
function isScope(node, parent) { | ||
if (t.isBlockStatement(node) && t.isFunction(parent, { body: node })) { | ||
if (t.isBlockStatement(node) && t.isFunction(parent, { | ||
body: node | ||
})) { | ||
return false; | ||
@@ -220,18 +216,9 @@ } | ||
var fields = Object.keys(t.NODE_FIELDS[a.type] || a.type); | ||
var _Object$keys = Object.keys(t.NODE_FIELDS[a.type] || a.type); | ||
for (var _iterator2 = fields, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { | ||
var _ref2; | ||
var fields = _Object$keys; | ||
if (_isArray2) { | ||
if (_i2 >= _iterator2.length) break; | ||
_ref2 = _iterator2[_i2++]; | ||
} else { | ||
_i2 = _iterator2.next(); | ||
if (_i2.done) break; | ||
_ref2 = _i2.value; | ||
} | ||
for (var _i2 = 0; _i2 < fields.length; _i2++) { | ||
var field = fields[_i2]; | ||
var field = _ref2; | ||
if (_typeof(a[field]) !== _typeof(b[field])) { | ||
@@ -245,2 +232,3 @@ return false; | ||
} | ||
if (a[field].length !== b[field].length) { | ||
@@ -255,2 +243,3 @@ return false; | ||
} | ||
continue; | ||
@@ -257,0 +246,0 @@ } |
{ | ||
"name": "babel-types", | ||
"version": "7.0.0-alpha.15", | ||
"version": "7.0.0-alpha.16", | ||
"description": "Babel Types is a Lodash-esque utility library for AST nodes", | ||
@@ -13,8 +13,8 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
"lodash": "^4.2.0", | ||
"to-fast-properties": "^1.0.1" | ||
"to-fast-properties": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"babel-generator": "7.0.0-alpha.15", | ||
"babylon": "^7.0.0-beta.15" | ||
"babel-generator": "7.0.0-alpha.16", | ||
"babylon": "^7.0.0-beta.17" | ||
} | ||
} |
846
README.md
@@ -42,3 +42,3 @@ # babel-types | ||
```javascript | ||
t.arrayPattern(elements, typeAnnotation) | ||
t.arrayPattern(elements) | ||
``` | ||
@@ -48,7 +48,7 @@ | ||
Aliases: `Pattern`, `LVal` | ||
Aliases: `Pattern`, `PatternLike`, `LVal` | ||
- `elements`: `Array<Identifier | Pattern | RestElement>` (required) | ||
- `typeAnnotation` (required) | ||
- `elements`: `Array<PatternLike>` (required) | ||
- `decorators`: `Array<Decorator>` (default: `null`) | ||
- `typeAnnotation`: `TypeAnnotation | Noop` (default: `null`) | ||
@@ -82,4 +82,6 @@ --- | ||
- `async`: `boolean` (default: `false`) | ||
- `returnType` (default: `null`) | ||
- `typeParameters` (default: `null`) | ||
- `expression`: `boolean` (default: `null`) | ||
- `generator`: `boolean` (default: `false`) | ||
- `returnType`: `TypeAnnotation | Noop` (default: `null`) | ||
- `typeParameters`: `TypeParameterDeclaration | Noop` (default: `null`) | ||
@@ -110,3 +112,3 @@ --- | ||
Aliases: `Pattern`, `LVal` | ||
Aliases: `Pattern`, `PatternLike`, `LVal` | ||
@@ -116,2 +118,3 @@ - `left`: `Identifier | ObjectPattern | ArrayPattern` (required) | ||
- `decorators`: `Array<Decorator>` (default: `null`) | ||
- `typeAnnotation`: `TypeAnnotation | Noop` (default: `null`) | ||
@@ -238,2 +241,3 @@ --- | ||
- `optional`: `true | false` (default: `null`) | ||
- `typeParameters`: `TypeParameterInstantiation` (default: `null`) | ||
@@ -251,3 +255,3 @@ --- | ||
- `param`: `Identifier` (required) | ||
- `param`: `Identifier` (default: `null`) | ||
- `body`: `BlockStatement` (required) | ||
@@ -264,3 +268,3 @@ | ||
- `body`: `Array<ClassMethod | ClassProperty>` (required) | ||
- `body`: `Array<ClassMethod | ClassProperty | TSDeclareMethod | TSIndexSignature>` (required) | ||
@@ -278,10 +282,12 @@ --- | ||
- `id`: `Identifier` (required) | ||
- `id`: `Identifier` (default: `null`) | ||
- `superClass`: `Expression` (default: `null`) | ||
- `body`: `ClassBody` (required) | ||
- `decorators`: `Array<Decorator>` (required) | ||
- `implements` (default: `null`) | ||
- `decorators`: `Array<Decorator>` (default: `null`) | ||
- `abstract`: `boolean` (default: `null`) | ||
- `declare`: `boolean` (default: `null`) | ||
- `implements`: `Array<TSExpressionWithTypeArguments | FlowClassImplements>` (default: `null`) | ||
- `mixins` (default: `null`) | ||
- `superTypeParameters` (default: `null`) | ||
- `typeParameters` (default: `null`) | ||
- `superTypeParameters`: `TypeParameterInstantiation` (default: `null`) | ||
- `typeParameters`: `TypeParameterDeclaration | Noop` (default: `null`) | ||
@@ -302,7 +308,7 @@ --- | ||
- `body`: `ClassBody` (required) | ||
- `decorators`: `Array<Decorator>` (required) | ||
- `implements` (default: `null`) | ||
- `decorators`: `Array<Decorator>` (default: `null`) | ||
- `implements`: `Array<TSExpressionWithTypeArguments | FlowClassImplements>` (default: `null`) | ||
- `mixins` (default: `null`) | ||
- `superTypeParameters` (default: `null`) | ||
- `typeParameters` (default: `null`) | ||
- `superTypeParameters`: `TypeParameterInstantiation` (default: `null`) | ||
- `typeParameters`: `TypeParameterDeclaration | Noop` (default: `null`) | ||
@@ -339,8 +345,12 @@ --- | ||
- `computed`: `boolean` (default: `false`) | ||
- `static`: `boolean` (default: `false`) | ||
- `static`: `boolean` (default: `null`) | ||
- `abstract`: `boolean` (default: `null`) | ||
- `access`: `"public" | "private" | "protected"` (default: `null`) | ||
- `accessibility`: `"public" | "private" | "protected"` (default: `null`) | ||
- `async`: `boolean` (default: `false`) | ||
- `decorators` (default: `null`) | ||
- `decorators`: `Array<Decorator>` (default: `null`) | ||
- `generator`: `boolean` (default: `false`) | ||
- `returnType` (default: `null`) | ||
- `typeParameters` (default: `null`) | ||
- `optional`: `boolean` (default: `null`) | ||
- `returnType`: `TypeAnnotation | Noop` (default: `null`) | ||
- `typeParameters`: `TypeParameterDeclaration | Noop` (default: `null`) | ||
@@ -359,6 +369,11 @@ --- | ||
- `key` (required) | ||
- `value` (required) | ||
- `typeAnnotation` (required) | ||
- `decorators` (required) | ||
- `value`: `Expression` (default: `null`) | ||
- `typeAnnotation`: `TypeAnnotation | Noop` (default: `null`) | ||
- `decorators`: `Array<Decorator>` (default: `null`) | ||
- `computed`: `boolean` (default: `false`) | ||
- `abstract`: `boolean` (default: `null`) | ||
- `accessibility`: `"public" | "private" | "protected"` (default: `null`) | ||
- `optional`: `boolean` (default: `null`) | ||
- `readonly`: `boolean` (default: `null`) | ||
- `static`: `boolean` (default: `null`) | ||
@@ -535,2 +550,15 @@ --- | ||
### declaredPredicate | ||
```javascript | ||
t.declaredPredicate(value) | ||
``` | ||
See also `t.isDeclaredPredicate(node, opts)` and `t.assertDeclaredPredicate(node, opts)`. | ||
Aliases: `Flow`, `FlowPredicate` | ||
- `value` (required) | ||
--- | ||
### decorator | ||
@@ -654,3 +682,3 @@ ```javascript | ||
- `declaration`: `FunctionDeclaration | ClassDeclaration | Expression` (required) | ||
- `declaration`: `FunctionDeclaration | TSDeclareFunction | ClassDeclaration | Expression` (required) | ||
@@ -796,3 +824,3 @@ --- | ||
- `id`: `Identifier` (required) | ||
- `id`: `Identifier` (default: `null`) | ||
- `params`: `Array<LVal>` (required) | ||
@@ -802,4 +830,5 @@ - `body`: `BlockStatement` (required) | ||
- `async`: `boolean` (default: `false`) | ||
- `returnType` (default: `null`) | ||
- `typeParameters` (default: `null`) | ||
- `declare`: `boolean` (default: `null`) | ||
- `returnType`: `TypeAnnotation | Noop` (default: `null`) | ||
- `typeParameters`: `TypeParameterDeclaration | Noop` (default: `null`) | ||
@@ -822,4 +851,4 @@ --- | ||
- `async`: `boolean` (default: `false`) | ||
- `returnType` (default: `null`) | ||
- `typeParameters` (default: `null`) | ||
- `returnType`: `TypeAnnotation | Noop` (default: `null`) | ||
- `typeParameters`: `TypeParameterDeclaration | Noop` (default: `null`) | ||
@@ -879,7 +908,8 @@ --- | ||
Aliases: `Expression`, `LVal` | ||
Aliases: `Expression`, `PatternLike`, `LVal`, `TSEntityName` | ||
- `name`: `string` (required) | ||
- `decorators`: `Array<Decorator>` (default: `null`) | ||
- `typeAnnotation` (default: `null`) | ||
- `optional`: `boolean` (default: `null`) | ||
- `typeAnnotation`: `TypeAnnotation | Noop` (default: `null`) | ||
@@ -970,2 +1000,14 @@ --- | ||
### inferredPredicate | ||
```javascript | ||
t.inferredPredicate() | ||
``` | ||
See also `t.isInferredPredicate(node, opts)` and `t.assertInferredPredicate(node, opts)`. | ||
Aliases: `Flow`, `FlowPredicate` | ||
--- | ||
### interfaceDeclaration | ||
@@ -1260,2 +1302,3 @@ ```javascript | ||
- `optional`: `true | false` (default: `null`) | ||
- `typeParameters`: `TypeParameterInstantiation` (default: `null`) | ||
@@ -1372,3 +1415,3 @@ --- | ||
- `key`: if computed then `Expression` else `Identifier | Literal` (required) | ||
- `params` (required) | ||
- `params`: `Array<LVal>` (required) | ||
- `body`: `BlockStatement` (required) | ||
@@ -1379,4 +1422,4 @@ - `computed`: `boolean` (default: `false`) | ||
- `generator`: `boolean` (default: `false`) | ||
- `returnType` (default: `null`) | ||
- `typeParameters` (default: `null`) | ||
- `returnType`: `TypeAnnotation | Noop` (default: `null`) | ||
- `typeParameters`: `TypeParameterDeclaration | Noop` (default: `null`) | ||
@@ -1387,3 +1430,3 @@ --- | ||
```javascript | ||
t.objectPattern(properties, typeAnnotation) | ||
t.objectPattern(properties) | ||
``` | ||
@@ -1393,7 +1436,7 @@ | ||
Aliases: `Pattern`, `LVal` | ||
Aliases: `Pattern`, `PatternLike`, `LVal` | ||
- `properties`: `Array<RestElement | Property>` (required) | ||
- `typeAnnotation` (required) | ||
- `properties`: `Array<RestElement | ObjectProperty>` (required) | ||
- `decorators`: `Array<Decorator>` (default: `null`) | ||
- `typeAnnotation`: `TypeAnnotation | Noop` (default: `null`) | ||
@@ -1412,3 +1455,3 @@ --- | ||
- `key`: if computed then `Expression` else `Identifier | Literal` (required) | ||
- `value`: `Expression | Pattern | RestElement` (required) | ||
- `value`: `Expression | PatternLike` (required) | ||
- `computed`: `boolean` (default: `false`) | ||
@@ -1514,2 +1557,3 @@ - `shorthand`: `boolean` (default: `false`) | ||
- `directives`: `Array<Directive>` (default: `[]`) | ||
- `sourceFile`: `string` (default: `null`) | ||
@@ -1548,3 +1592,3 @@ --- | ||
```javascript | ||
t.restElement(argument, typeAnnotation) | ||
t.restElement(argument) | ||
``` | ||
@@ -1554,7 +1598,7 @@ | ||
Aliases: `LVal` | ||
Aliases: `LVal`, `PatternLike` | ||
- `argument`: `LVal` (required) | ||
- `typeAnnotation` (required) | ||
- `decorators`: `Array<Decorator>` (default: `null`) | ||
- `typeAnnotation`: `TypeAnnotation | Noop` (default: `null`) | ||
@@ -1677,2 +1721,700 @@ --- | ||
### tSAnyKeyword | ||
```javascript | ||
t.tSAnyKeyword() | ||
``` | ||
See also `t.isTSAnyKeyword(node, opts)` and `t.assertTSAnyKeyword(node, opts)`. | ||
Aliases: `TSType` | ||
--- | ||
### tSArrayType | ||
```javascript | ||
t.tSArrayType(elementType) | ||
``` | ||
See also `t.isTSArrayType(node, opts)` and `t.assertTSArrayType(node, opts)`. | ||
Aliases: `TSType` | ||
- `elementType`: `TSType` (required) | ||
--- | ||
### tSAsExpression | ||
```javascript | ||
t.tSAsExpression(expression, typeAnnotation) | ||
``` | ||
See also `t.isTSAsExpression(node, opts)` and `t.assertTSAsExpression(node, opts)`. | ||
Aliases: `Expression` | ||
- `expression`: `Expression` (required) | ||
- `typeAnnotation`: `TSType` (required) | ||
--- | ||
### tSBooleanKeyword | ||
```javascript | ||
t.tSBooleanKeyword() | ||
``` | ||
See also `t.isTSBooleanKeyword(node, opts)` and `t.assertTSBooleanKeyword(node, opts)`. | ||
Aliases: `TSType` | ||
--- | ||
### tSCallSignatureDeclaration | ||
```javascript | ||
t.tSCallSignatureDeclaration(typeParameters, parameters, typeAnnotation) | ||
``` | ||
See also `t.isTSCallSignatureDeclaration(node, opts)` and `t.assertTSCallSignatureDeclaration(node, opts)`. | ||
Aliases: `TSTypeElement` | ||
- `typeParameters`: `TypeParameterDeclaration` (default: `null`) | ||
- `parameters`: `Array<Identifier | RestElement>` (default: `null`) | ||
- `typeAnnotation`: `TypeAnnotation` (default: `null`) | ||
--- | ||
### tSConstructSignatureDeclaration | ||
```javascript | ||
t.tSConstructSignatureDeclaration(typeParameters, parameters, typeAnnotation) | ||
``` | ||
See also `t.isTSConstructSignatureDeclaration(node, opts)` and `t.assertTSConstructSignatureDeclaration(node, opts)`. | ||
Aliases: `TSTypeElement` | ||
- `typeParameters`: `TypeParameterDeclaration` (default: `null`) | ||
- `parameters`: `Array<Identifier | RestElement>` (default: `null`) | ||
- `typeAnnotation`: `TypeAnnotation` (default: `null`) | ||
--- | ||
### tSConstructorType | ||
```javascript | ||
t.tSConstructorType(typeParameters, typeAnnotation) | ||
``` | ||
See also `t.isTSConstructorType(node, opts)` and `t.assertTSConstructorType(node, opts)`. | ||
Aliases: `TSType` | ||
- `typeParameters`: `TypeParameterDeclaration` (default: `null`) | ||
- `typeAnnotation`: `TypeAnnotation` (default: `null`) | ||
- `parameters`: `Array<Identifier | RestElement>` (default: `null`) | ||
--- | ||
### tSDeclareFunction | ||
```javascript | ||
t.tSDeclareFunction(id, typeParameters, params, returnType) | ||
``` | ||
See also `t.isTSDeclareFunction(node, opts)` and `t.assertTSDeclareFunction(node, opts)`. | ||
Aliases: `Statement`, `Declaration` | ||
- `id`: `Identifier` (default: `null`) | ||
- `typeParameters`: `TypeParameterDeclaration | Noop` (default: `null`) | ||
- `params`: `Array<LVal>` (required) | ||
- `returnType`: `TypeAnnotation | Noop` (default: `null`) | ||
- `async`: `boolean` (default: `false`) | ||
- `declare`: `boolean` (default: `null`) | ||
- `generator`: `boolean` (default: `false`) | ||
--- | ||
### tSDeclareMethod | ||
```javascript | ||
t.tSDeclareMethod(decorators, key, typeParameters, params, returnType) | ||
``` | ||
See also `t.isTSDeclareMethod(node, opts)` and `t.assertTSDeclareMethod(node, opts)`. | ||
- `decorators`: `Array<Decorator>` (default: `null`) | ||
- `key` (required) | ||
- `typeParameters`: `TypeParameterDeclaration | Noop` (default: `null`) | ||
- `params`: `Array<LVal>` (required) | ||
- `returnType`: `TypeAnnotation | Noop` (default: `null`) | ||
- `abstract`: `boolean` (default: `null`) | ||
- `access`: `"public" | "private" | "protected"` (default: `null`) | ||
- `accessibility`: `"public" | "private" | "protected"` (default: `null`) | ||
- `async`: `boolean` (default: `false`) | ||
- `computed`: `boolean` (default: `false`) | ||
- `generator`: `boolean` (default: `false`) | ||
- `kind`: `"get" | "set" | "method" | "constructor"` (default: `'method'`) | ||
- `optional`: `boolean` (default: `null`) | ||
- `static`: `boolean` (default: `null`) | ||
--- | ||
### tSEnumDeclaration | ||
```javascript | ||
t.tSEnumDeclaration(id, members) | ||
``` | ||
See also `t.isTSEnumDeclaration(node, opts)` and `t.assertTSEnumDeclaration(node, opts)`. | ||
Aliases: `Statement`, `Declaration` | ||
- `id`: `Identifier` (required) | ||
- `members`: `Array<TSEnumMember>` (required) | ||
- `const`: `boolean` (default: `null`) | ||
- `declare`: `boolean` (default: `null`) | ||
- `initializer`: `Expression` (default: `null`) | ||
--- | ||
### tSEnumMember | ||
```javascript | ||
t.tSEnumMember(id, initializer) | ||
``` | ||
See also `t.isTSEnumMember(node, opts)` and `t.assertTSEnumMember(node, opts)`. | ||
- `id`: `Identifier | StringLiteral` (required) | ||
- `initializer`: `Expression` (default: `null`) | ||
--- | ||
### tSExportAssignment | ||
```javascript | ||
t.tSExportAssignment(expression) | ||
``` | ||
See also `t.isTSExportAssignment(node, opts)` and `t.assertTSExportAssignment(node, opts)`. | ||
Aliases: `Statement` | ||
- `expression`: `Expression` (required) | ||
--- | ||
### tSExpressionWithTypeArguments | ||
```javascript | ||
t.tSExpressionWithTypeArguments(expression, typeParameters) | ||
``` | ||
See also `t.isTSExpressionWithTypeArguments(node, opts)` and `t.assertTSExpressionWithTypeArguments(node, opts)`. | ||
Aliases: `TSType` | ||
- `expression`: `TSEntityName` (required) | ||
- `typeParameters`: `TypeParameterInstantiation` (default: `null`) | ||
--- | ||
### tSExternalModuleReference | ||
```javascript | ||
t.tSExternalModuleReference(expression) | ||
``` | ||
See also `t.isTSExternalModuleReference(node, opts)` and `t.assertTSExternalModuleReference(node, opts)`. | ||
- `expression`: `StringLiteral` (required) | ||
--- | ||
### tSFunctionType | ||
```javascript | ||
t.tSFunctionType(typeParameters, typeAnnotation) | ||
``` | ||
See also `t.isTSFunctionType(node, opts)` and `t.assertTSFunctionType(node, opts)`. | ||
Aliases: `TSType` | ||
- `typeParameters`: `TypeParameterDeclaration` (default: `null`) | ||
- `typeAnnotation`: `TypeAnnotation` (default: `null`) | ||
- `parameters`: `Array<Identifier | RestElement>` (default: `null`) | ||
--- | ||
### tSImportEqualsDeclaration | ||
```javascript | ||
t.tSImportEqualsDeclaration(id, moduleReference) | ||
``` | ||
See also `t.isTSImportEqualsDeclaration(node, opts)` and `t.assertTSImportEqualsDeclaration(node, opts)`. | ||
Aliases: `Statement` | ||
- `id`: `Identifier` (required) | ||
- `moduleReference`: `TSEntityName | TSExternalModuleReference` (required) | ||
- `isExport`: `boolean` (default: `null`) | ||
--- | ||
### tSIndexSignature | ||
```javascript | ||
t.tSIndexSignature(parameters, typeAnnotation) | ||
``` | ||
See also `t.isTSIndexSignature(node, opts)` and `t.assertTSIndexSignature(node, opts)`. | ||
Aliases: `TSTypeElement` | ||
- `parameters`: `Array<Identifier>` (required) | ||
- `typeAnnotation`: `TypeAnnotation` (default: `null`) | ||
- `readonly`: `boolean` (default: `null`) | ||
--- | ||
### tSIndexedAccessType | ||
```javascript | ||
t.tSIndexedAccessType(objectType, indexType) | ||
``` | ||
See also `t.isTSIndexedAccessType(node, opts)` and `t.assertTSIndexedAccessType(node, opts)`. | ||
Aliases: `TSType` | ||
- `objectType`: `TSType` (required) | ||
- `indexType`: `TSType` (required) | ||
--- | ||
### tSInterfaceBody | ||
```javascript | ||
t.tSInterfaceBody(body) | ||
``` | ||
See also `t.isTSInterfaceBody(node, opts)` and `t.assertTSInterfaceBody(node, opts)`. | ||
- `body`: `Array<TSTypeElement>` (required) | ||
--- | ||
### tSInterfaceDeclaration | ||
```javascript | ||
t.tSInterfaceDeclaration(id, typeParameters, extends, body) | ||
``` | ||
See also `t.isTSInterfaceDeclaration(node, opts)` and `t.assertTSInterfaceDeclaration(node, opts)`. | ||
Aliases: `Statement`, `Declaration` | ||
- `id`: `Identifier` (required) | ||
- `typeParameters`: `TypeParameterDeclaration` (default: `null`) | ||
- `extends`: `Array<TSExpressionWithTypeArguments>` (default: `null`) | ||
- `body`: `TSInterfaceBody` (required) | ||
- `declare`: `boolean` (default: `null`) | ||
--- | ||
### tSIntersectionType | ||
```javascript | ||
t.tSIntersectionType(types) | ||
``` | ||
See also `t.isTSIntersectionType(node, opts)` and `t.assertTSIntersectionType(node, opts)`. | ||
Aliases: `TSType` | ||
- `types`: `Array<TSType>` (required) | ||
--- | ||
### tSLiteralType | ||
```javascript | ||
t.tSLiteralType(literal) | ||
``` | ||
See also `t.isTSLiteralType(node, opts)` and `t.assertTSLiteralType(node, opts)`. | ||
Aliases: `TSType` | ||
- `literal`: `NumericLiteral | StringLiteral | BooleanLiteral` (required) | ||
--- | ||
### tSMappedType | ||
```javascript | ||
t.tSMappedType(typeParameter, typeAnnotation) | ||
``` | ||
See also `t.isTSMappedType(node, opts)` and `t.assertTSMappedType(node, opts)`. | ||
Aliases: `TSType` | ||
- `typeParameter`: `TypeParameter` (required) | ||
- `typeAnnotation`: `TSType` (default: `null`) | ||
- `optional`: `boolean` (default: `null`) | ||
- `readonly`: `boolean` (default: `null`) | ||
--- | ||
### tSMethodSignature | ||
```javascript | ||
t.tSMethodSignature(key, typeParameters, parameters, typeAnnotation) | ||
``` | ||
See also `t.isTSMethodSignature(node, opts)` and `t.assertTSMethodSignature(node, opts)`. | ||
Aliases: `TSTypeElement` | ||
- `key`: `Expression` (required) | ||
- `typeParameters`: `TypeParameterDeclaration` (default: `null`) | ||
- `parameters`: `Array<Identifier | RestElement>` (default: `null`) | ||
- `typeAnnotation`: `TypeAnnotation` (default: `null`) | ||
- `computed`: `boolean` (default: `null`) | ||
- `optional`: `boolean` (default: `null`) | ||
--- | ||
### tSModuleBlock | ||
```javascript | ||
t.tSModuleBlock(body) | ||
``` | ||
See also `t.isTSModuleBlock(node, opts)` and `t.assertTSModuleBlock(node, opts)`. | ||
- `body`: `Array<Statement>` (required) | ||
--- | ||
### tSModuleDeclaration | ||
```javascript | ||
t.tSModuleDeclaration(id, body) | ||
``` | ||
See also `t.isTSModuleDeclaration(node, opts)` and `t.assertTSModuleDeclaration(node, opts)`. | ||
Aliases: `Statement`, `Declaration` | ||
- `id`: `Identifier | StringLiteral` (required) | ||
- `body`: `TSModuleBlock | TSModuleDeclaration` (required) | ||
- `declare`: `boolean` (default: `null`) | ||
- `global`: `boolean` (default: `null`) | ||
--- | ||
### tSNamespaceExportDeclaration | ||
```javascript | ||
t.tSNamespaceExportDeclaration(id) | ||
``` | ||
See also `t.isTSNamespaceExportDeclaration(node, opts)` and `t.assertTSNamespaceExportDeclaration(node, opts)`. | ||
Aliases: `Statement` | ||
- `id`: `Identifier` (required) | ||
--- | ||
### tSNeverKeyword | ||
```javascript | ||
t.tSNeverKeyword() | ||
``` | ||
See also `t.isTSNeverKeyword(node, opts)` and `t.assertTSNeverKeyword(node, opts)`. | ||
Aliases: `TSType` | ||
--- | ||
### tSNonNullExpression | ||
```javascript | ||
t.tSNonNullExpression(expression) | ||
``` | ||
See also `t.isTSNonNullExpression(node, opts)` and `t.assertTSNonNullExpression(node, opts)`. | ||
Aliases: `Expression` | ||
- `expression`: `Expression` (required) | ||
--- | ||
### tSNullKeyword | ||
```javascript | ||
t.tSNullKeyword() | ||
``` | ||
See also `t.isTSNullKeyword(node, opts)` and `t.assertTSNullKeyword(node, opts)`. | ||
Aliases: `TSType` | ||
--- | ||
### tSNumberKeyword | ||
```javascript | ||
t.tSNumberKeyword() | ||
``` | ||
See also `t.isTSNumberKeyword(node, opts)` and `t.assertTSNumberKeyword(node, opts)`. | ||
Aliases: `TSType` | ||
--- | ||
### tSObjectKeyword | ||
```javascript | ||
t.tSObjectKeyword() | ||
``` | ||
See also `t.isTSObjectKeyword(node, opts)` and `t.assertTSObjectKeyword(node, opts)`. | ||
Aliases: `TSType` | ||
--- | ||
### tSParameterProperty | ||
```javascript | ||
t.tSParameterProperty(parameter) | ||
``` | ||
See also `t.isTSParameterProperty(node, opts)` and `t.assertTSParameterProperty(node, opts)`. | ||
Aliases: `LVal` | ||
- `parameter`: `Identifier | AssignmentPattern` (required) | ||
- `accessibility`: `'public' | 'private' | 'protected'` (default: `null`) | ||
- `readonly`: `boolean` (default: `null`) | ||
--- | ||
### tSParenthesizedType | ||
```javascript | ||
t.tSParenthesizedType(typeAnnotation) | ||
``` | ||
See also `t.isTSParenthesizedType(node, opts)` and `t.assertTSParenthesizedType(node, opts)`. | ||
Aliases: `TSType` | ||
- `typeAnnotation`: `TSType` (required) | ||
--- | ||
### tSPropertySignature | ||
```javascript | ||
t.tSPropertySignature(key, typeAnnotation, initializer) | ||
``` | ||
See also `t.isTSPropertySignature(node, opts)` and `t.assertTSPropertySignature(node, opts)`. | ||
Aliases: `TSTypeElement` | ||
- `key`: `Expression` (required) | ||
- `typeAnnotation`: `TypeAnnotation` (default: `null`) | ||
- `initializer`: `Expresssion` (default: `null`) | ||
- `computed`: `boolean` (default: `null`) | ||
- `optional`: `boolean` (default: `null`) | ||
- `readonly`: `boolean` (default: `null`) | ||
--- | ||
### tSQualifiedName | ||
```javascript | ||
t.tSQualifiedName(left, right) | ||
``` | ||
See also `t.isTSQualifiedName(node, opts)` and `t.assertTSQualifiedName(node, opts)`. | ||
Aliases: `TSEntityName` | ||
- `left`: `TSEntityName` (required) | ||
- `right`: `Identifier` (required) | ||
--- | ||
### tSStringKeyword | ||
```javascript | ||
t.tSStringKeyword() | ||
``` | ||
See also `t.isTSStringKeyword(node, opts)` and `t.assertTSStringKeyword(node, opts)`. | ||
Aliases: `TSType` | ||
--- | ||
### tSSymbolKeyword | ||
```javascript | ||
t.tSSymbolKeyword() | ||
``` | ||
See also `t.isTSSymbolKeyword(node, opts)` and `t.assertTSSymbolKeyword(node, opts)`. | ||
Aliases: `TSType` | ||
--- | ||
### tSThisType | ||
```javascript | ||
t.tSThisType() | ||
``` | ||
See also `t.isTSThisType(node, opts)` and `t.assertTSThisType(node, opts)`. | ||
Aliases: `TSType` | ||
--- | ||
### tSTupleType | ||
```javascript | ||
t.tSTupleType(elementTypes) | ||
``` | ||
See also `t.isTSTupleType(node, opts)` and `t.assertTSTupleType(node, opts)`. | ||
Aliases: `TSType` | ||
- `elementTypes`: `Array<TSType>` (required) | ||
--- | ||
### tSTypeAliasDeclaration | ||
```javascript | ||
t.tSTypeAliasDeclaration(id, typeParameters, typeAnnotation) | ||
``` | ||
See also `t.isTSTypeAliasDeclaration(node, opts)` and `t.assertTSTypeAliasDeclaration(node, opts)`. | ||
Aliases: `Statement`, `Declaration` | ||
- `id`: `Identifier` (required) | ||
- `typeParameters`: `TypeParameterDeclaration` (default: `null`) | ||
- `typeAnnotation`: `TSType` (required) | ||
- `declare`: `boolean` (default: `null`) | ||
--- | ||
### tSTypeAssertion | ||
```javascript | ||
t.tSTypeAssertion(typeAnnotation, expression) | ||
``` | ||
See also `t.isTSTypeAssertion(node, opts)` and `t.assertTSTypeAssertion(node, opts)`. | ||
Aliases: `Expression` | ||
- `typeAnnotation`: `TSType` (required) | ||
- `expression`: `Expression` (required) | ||
--- | ||
### tSTypeLiteral | ||
```javascript | ||
t.tSTypeLiteral(members) | ||
``` | ||
See also `t.isTSTypeLiteral(node, opts)` and `t.assertTSTypeLiteral(node, opts)`. | ||
Aliases: `TSType` | ||
- `members`: `Array<TSTypeElement>` (required) | ||
--- | ||
### tSTypeOperator | ||
```javascript | ||
t.tSTypeOperator(typeAnnotation) | ||
``` | ||
See also `t.isTSTypeOperator(node, opts)` and `t.assertTSTypeOperator(node, opts)`. | ||
Aliases: `TSType` | ||
- `typeAnnotation`: `TSType` (required) | ||
- `operator`: `string` (default: `null`) | ||
--- | ||
### tSTypePredicate | ||
```javascript | ||
t.tSTypePredicate(parameterName, typeAnnotation) | ||
``` | ||
See also `t.isTSTypePredicate(node, opts)` and `t.assertTSTypePredicate(node, opts)`. | ||
Aliases: `TSType` | ||
- `parameterName`: `Identifier | TSThisType` (required) | ||
- `typeAnnotation`: `TypeAnnotation` (required) | ||
--- | ||
### tSTypeQuery | ||
```javascript | ||
t.tSTypeQuery(exprName) | ||
``` | ||
See also `t.isTSTypeQuery(node, opts)` and `t.assertTSTypeQuery(node, opts)`. | ||
Aliases: `TSType` | ||
- `exprName`: `TSEntityName` (required) | ||
--- | ||
### tSTypeReference | ||
```javascript | ||
t.tSTypeReference(typeName, typeParameters) | ||
``` | ||
See also `t.isTSTypeReference(node, opts)` and `t.assertTSTypeReference(node, opts)`. | ||
Aliases: `TSType` | ||
- `typeName`: `TSEntityName` (required) | ||
- `typeParameters`: `TypeParameterInstantiation` (default: `null`) | ||
--- | ||
### tSUndefinedKeyword | ||
```javascript | ||
t.tSUndefinedKeyword() | ||
``` | ||
See also `t.isTSUndefinedKeyword(node, opts)` and `t.assertTSUndefinedKeyword(node, opts)`. | ||
Aliases: `TSType` | ||
--- | ||
### tSUnionType | ||
```javascript | ||
t.tSUnionType(types) | ||
``` | ||
See also `t.isTSUnionType(node, opts)` and `t.assertTSUnionType(node, opts)`. | ||
Aliases: `TSType` | ||
- `types`: `Array<TSType>` (required) | ||
--- | ||
### tSVoidKeyword | ||
```javascript | ||
t.tSVoidKeyword() | ||
``` | ||
See also `t.isTSVoidKeyword(node, opts)` and `t.assertTSVoidKeyword(node, opts)`. | ||
Aliases: `TSType` | ||
--- | ||
### taggedTemplateExpression | ||
@@ -1765,3 +2507,3 @@ ```javascript | ||
- `block` (required) | ||
- `handler` (default: `null`) | ||
- `handler`: `BlockStatement` (default: `null`) | ||
- `finalizer`: `BlockStatement` (default: `null`) | ||
@@ -1809,3 +2551,3 @@ - `body`: `BlockStatement` (default: `null`) | ||
- `typeAnnotation` (required) | ||
- `typeAnnotation`: `TSType | Flow` (required) | ||
@@ -1830,3 +2572,3 @@ --- | ||
```javascript | ||
t.typeParameter(bound) | ||
t.typeParameter(bound, constraint, default) | ||
``` | ||
@@ -1838,3 +2580,6 @@ | ||
- `bound` (required) | ||
- `bound`: `TypeAnnotation` (default: `null`) | ||
- `constraint`: `TSType` (default: `null`) | ||
- `default`: `TSType | Flow` (default: `null`) | ||
- `name`: `string` (default: `null`) | ||
@@ -1852,3 +2597,3 @@ --- | ||
- `params` (required) | ||
- `params`: `Array<TypeParameter>` (required) | ||
@@ -1866,3 +2611,3 @@ --- | ||
- `params` (required) | ||
- `params`: `Array<TSType | FlowType>` (required) | ||
@@ -1938,2 +2683,3 @@ --- | ||
- `declarations`: `Array<VariableDeclarator>` (required) | ||
- `declare`: `boolean` (default: `null`) | ||
@@ -1940,0 +2686,0 @@ --- |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
165037
20
3370
2721
+ Addedto-fast-properties@2.0.0(transitive)
- Removedto-fast-properties@1.0.3(transitive)
Updatedto-fast-properties@^2.0.0