babel-generator
Advanced tools
Comparing version 7.0.0-alpha.17 to 7.0.0-alpha.18
@@ -9,2 +9,3 @@ "use strict"; | ||
exports.ClassMethod = ClassMethod; | ||
exports._classMethodHead = _classMethodHead; | ||
@@ -22,2 +23,12 @@ var _babelTypes = require("babel-types"); | ||
if (node.declare) { | ||
this.word("declare"); | ||
this.space(); | ||
} | ||
if (node.abstract) { | ||
this.word("abstract"); | ||
this.space(); | ||
} | ||
this.word("class"); | ||
@@ -72,2 +83,7 @@ | ||
if (node.accessibility) { | ||
this.word(node.accessibility); | ||
this.space(); | ||
} | ||
if (node.static) { | ||
@@ -78,2 +94,12 @@ this.word("static"); | ||
if (node.abstract) { | ||
this.word("abstract"); | ||
this.space(); | ||
} | ||
if (node.readonly) { | ||
this.word("readonly"); | ||
this.space(); | ||
} | ||
if (node.computed) { | ||
@@ -89,2 +115,6 @@ this.token("["); | ||
if (node.optional) { | ||
this.token("?"); | ||
} | ||
this.print(node.typeAnnotation, node); | ||
@@ -103,4 +133,21 @@ | ||
function ClassMethod(node) { | ||
this._classMethodHead(node); | ||
this.space(); | ||
this.print(node.body, node); | ||
} | ||
function _classMethodHead(node) { | ||
this.printJoin(node.decorators, node); | ||
if (node.accessibility) { | ||
this.word(node.accessibility); | ||
this.space(); | ||
} | ||
if (node.abstract) { | ||
this.word("abstract"); | ||
this.space(); | ||
} | ||
if (node.static) { | ||
@@ -111,3 +158,3 @@ this.word("static"); | ||
this._method(node); | ||
this._methodHead(node); | ||
} |
@@ -91,2 +91,4 @@ "use strict"; | ||
this.print(node.typeParameters, node); | ||
if (node.optional) { | ||
@@ -121,2 +123,3 @@ this.token("?."); | ||
this.print(node.callee, node); | ||
this.print(node.typeParameters, node); | ||
@@ -123,0 +126,0 @@ if (node.optional) { |
"use strict"; | ||
exports.__esModule = true; | ||
exports.TypeParameterDeclaration = exports.StringLiteralTypeAnnotation = exports.NumberLiteralTypeAnnotation = exports.GenericTypeAnnotation = exports.ClassImplements = undefined; | ||
exports.StringLiteralTypeAnnotation = exports.NumberLiteralTypeAnnotation = exports.GenericTypeAnnotation = exports.ClassImplements = undefined; | ||
exports.AnyTypeAnnotation = AnyTypeAnnotation; | ||
@@ -18,2 +18,3 @@ exports.ArrayTypeAnnotation = ArrayTypeAnnotation; | ||
exports.DeclareTypeAlias = DeclareTypeAlias; | ||
exports.DeclareOpaqueType = DeclareOpaqueType; | ||
exports.DeclareVariable = DeclareVariable; | ||
@@ -54,5 +55,3 @@ exports.DeclareExportDeclaration = DeclareExportDeclaration; | ||
exports.TypeAlias = TypeAlias; | ||
exports.TypeAnnotation = TypeAnnotation; | ||
exports.TypeParameter = TypeParameter; | ||
exports.TypeParameterInstantiation = TypeParameterInstantiation; | ||
exports.OpaqueType = OpaqueType; | ||
exports.ObjectTypeAnnotation = ObjectTypeAnnotation; | ||
@@ -173,2 +172,11 @@ exports.ObjectTypeCallProperty = ObjectTypeCallProperty; | ||
function DeclareOpaqueType(node, parent) { | ||
if (!t.isDeclareExportDeclaration(parent)) { | ||
this.word("declare"); | ||
this.space(); | ||
} | ||
this.OpaqueType(node); | ||
} | ||
function DeclareVariable(node, parent) { | ||
@@ -383,34 +391,26 @@ if (!t.isDeclareExportDeclaration(parent)) { | ||
function TypeAnnotation(node) { | ||
this.token(":"); | ||
function OpaqueType(node) { | ||
this.word("opaque"); | ||
this.space(); | ||
if (node.optional) this.token("?"); | ||
this.print(node.typeAnnotation, node); | ||
} | ||
this.word("type"); | ||
this.space(); | ||
this.print(node.id, node); | ||
this.print(node.typeParameters, node); | ||
function TypeParameter(node) { | ||
this._variance(node); | ||
this.word(node.name); | ||
if (node.bound) { | ||
this.print(node.bound, node); | ||
if (node.supertype) { | ||
this.token(":"); | ||
this.space(); | ||
this.print(node.supertype, node); | ||
} | ||
if (node.default) { | ||
if (node.impltype) { | ||
this.space(); | ||
this.token("="); | ||
this.space(); | ||
this.print(node.default, node); | ||
this.print(node.impltype, node); | ||
} | ||
} | ||
function TypeParameterInstantiation(node) { | ||
this.token("<"); | ||
this.printList(node.params, node, {}); | ||
this.token(">"); | ||
this.semicolon(); | ||
} | ||
exports.TypeParameterDeclaration = TypeParameterInstantiation; | ||
function ObjectTypeAnnotation(node) { | ||
@@ -417,0 +417,0 @@ var _this = this; |
@@ -123,2 +123,26 @@ "use strict"; | ||
}); | ||
}); | ||
var _tsFlowCommon = require("./tsFlowCommon"); | ||
Object.keys(_tsFlowCommon).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _tsFlowCommon[key]; | ||
} | ||
}); | ||
}); | ||
var _typescript = require("./typescript"); | ||
Object.keys(_typescript).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _typescript[key]; | ||
} | ||
}); | ||
}); |
@@ -6,4 +6,7 @@ "use strict"; | ||
exports._params = _params; | ||
exports._method = _method; | ||
exports._parameters = _parameters; | ||
exports._param = _param; | ||
exports._methodHead = _methodHead; | ||
exports._predicate = _predicate; | ||
exports._functionHead = _functionHead; | ||
exports.FunctionExpression = FunctionExpression; | ||
@@ -19,21 +22,30 @@ exports.ArrowFunctionExpression = ArrowFunctionExpression; | ||
function _params(node) { | ||
var _this = this; | ||
this.print(node.typeParameters, node); | ||
this.token("("); | ||
this.printList(node.params, node, { | ||
iterator: function iterator(node) { | ||
if (node.optional) _this.token("?"); | ||
_this.print(node.typeAnnotation, node); | ||
} | ||
}); | ||
this._parameters(node.params, node); | ||
this.token(")"); | ||
this.print(node.returnType, node); | ||
} | ||
if (node.returnType) { | ||
this.print(node.returnType, node); | ||
function _parameters(parameters, parent) { | ||
for (var i = 0; i < parameters.length; i++) { | ||
this._param(parameters[i], parent); | ||
if (i < parameters.length - 1) { | ||
this.token(","); | ||
this.space(); | ||
} | ||
} | ||
} | ||
function _method(node) { | ||
function _param(parameter, parent) { | ||
this.printJoin(parameter.decorators, parameter); | ||
this.print(parameter, parent); | ||
if (parameter.optional) this.token("?"); | ||
this.print(parameter.typeAnnotation, parameter); | ||
} | ||
function _methodHead(node) { | ||
var kind = node.kind; | ||
@@ -66,6 +78,7 @@ var key = node.key; | ||
if (node.optional) { | ||
this.token("?"); | ||
} | ||
this._params(node); | ||
this.space(); | ||
this.print(node.body, node); | ||
} | ||
@@ -84,3 +97,3 @@ | ||
function FunctionExpression(node) { | ||
function _functionHead(node) { | ||
if (node.async) { | ||
@@ -93,8 +106,6 @@ this.word("async"); | ||
if (node.generator) this.token("*"); | ||
this.space(); | ||
if (node.id) { | ||
this.space(); | ||
this.print(node.id, node); | ||
} else { | ||
this.space(); | ||
} | ||
@@ -105,3 +116,7 @@ | ||
this._predicate(node); | ||
} | ||
function FunctionExpression(node) { | ||
this._functionHead(node); | ||
this.space(); | ||
@@ -108,0 +123,0 @@ this.print(node.body, node); |
@@ -266,2 +266,7 @@ "use strict"; | ||
function VariableDeclaration(node, parent) { | ||
if (node.declare) { | ||
this.word("declare"); | ||
this.space(); | ||
} | ||
this.word(node.kind); | ||
@@ -268,0 +273,0 @@ this.space(); |
@@ -62,3 +62,6 @@ "use strict"; | ||
this._method(node); | ||
this._methodHead(node); | ||
this.space(); | ||
this.print(node.body, node); | ||
} | ||
@@ -65,0 +68,0 @@ |
@@ -10,2 +10,4 @@ "use strict"; | ||
exports.Binary = Binary; | ||
exports.TSAsExpression = TSAsExpression; | ||
exports.TSTypeAssertion = TSTypeAssertion; | ||
exports.BinaryExpression = BinaryExpression; | ||
@@ -99,2 +101,10 @@ exports.SequenceExpression = SequenceExpression; | ||
function TSAsExpression() { | ||
return true; | ||
} | ||
function TSTypeAssertion() { | ||
return true; | ||
} | ||
function BinaryExpression(node, parent) { | ||
@@ -150,3 +160,3 @@ return node.operator === "in" && (t.isVariableDeclarator(parent) || t.isFor(parent)); | ||
test: node | ||
}) || t.isAwaitExpression(parent) || t.isTaggedTemplateExpression(parent)) { | ||
}) || t.isAwaitExpression(parent) || t.isTaggedTemplateExpression(parent) || t.isTSTypeAssertion(parent) || t.isTSAsExpression(parent)) { | ||
return true; | ||
@@ -153,0 +163,0 @@ } |
{ | ||
"name": "babel-generator", | ||
"version": "7.0.0-alpha.17", | ||
"version": "7.0.0-alpha.18", | ||
"description": "Turns an AST into code.", | ||
@@ -14,4 +14,4 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
"dependencies": { | ||
"babel-messages": "7.0.0-alpha.17", | ||
"babel-types": "7.0.0-alpha.17", | ||
"babel-messages": "7.0.0-alpha.18", | ||
"babel-types": "7.0.0-alpha.18", | ||
"jsesc": "^2.5.1", | ||
@@ -23,5 +23,5 @@ "lodash": "^4.2.0", | ||
"devDependencies": { | ||
"babel-helper-fixtures": "7.0.0-alpha.17", | ||
"babel-helper-fixtures": "7.0.0-alpha.18", | ||
"babylon": "^7.0.0-beta.18" | ||
} | ||
} |
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
104684
22
3338
+ Addedbabel-messages@7.0.0-alpha.18(transitive)
+ Addedbabel-types@7.0.0-alpha.18(transitive)
- Removedbabel-messages@7.0.0-alpha.17(transitive)
- Removedbabel-types@7.0.0-alpha.17(transitive)
Updatedbabel-types@7.0.0-alpha.18