babel-generator
Advanced tools
Comparing version 6.25.0 to 6.26.0
"use strict"; | ||
exports.__esModule = true; | ||
exports.TypeParameterDeclaration = exports.StringLiteralTypeAnnotation = exports.NumericLiteralTypeAnnotation = exports.GenericTypeAnnotation = exports.ClassImplements = undefined; | ||
exports.AnyTypeAnnotation = AnyTypeAnnotation; | ||
@@ -15,3 +16,5 @@ exports.ArrayTypeAnnotation = ArrayTypeAnnotation; | ||
exports.DeclareTypeAlias = DeclareTypeAlias; | ||
exports.DeclareOpaqueType = DeclareOpaqueType; | ||
exports.DeclareVariable = DeclareVariable; | ||
exports.DeclareExportDeclaration = DeclareExportDeclaration; | ||
exports.ExistentialTypeParam = ExistentialTypeParam; | ||
@@ -49,2 +52,3 @@ exports.FunctionTypeAnnotation = FunctionTypeAnnotation; | ||
exports.TypeAlias = TypeAlias; | ||
exports.OpaqueType = OpaqueType; | ||
exports.TypeAnnotation = TypeAnnotation; | ||
@@ -62,2 +66,9 @@ exports.TypeParameter = TypeParameter; | ||
exports.VoidTypeAnnotation = VoidTypeAnnotation; | ||
var _babelTypes = require("babel-types"); | ||
var t = _interopRequireWildcard(_babelTypes); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function AnyTypeAnnotation() { | ||
@@ -85,5 +96,7 @@ this.word("any"); | ||
function DeclareClass(node) { | ||
this.word("declare"); | ||
this.space(); | ||
function DeclareClass(node, parent) { | ||
if (!t.isDeclareExportDeclaration(parent)) { | ||
this.word("declare"); | ||
this.space(); | ||
} | ||
this.word("class"); | ||
@@ -94,5 +107,7 @@ this.space(); | ||
function DeclareFunction(node) { | ||
this.word("declare"); | ||
this.space(); | ||
function DeclareFunction(node, parent) { | ||
if (!t.isDeclareExportDeclaration(parent)) { | ||
this.word("declare"); | ||
this.space(); | ||
} | ||
this.word("function"); | ||
@@ -136,5 +151,15 @@ this.space(); | ||
function DeclareVariable(node) { | ||
this.word("declare"); | ||
this.space(); | ||
function DeclareOpaqueType(node, parent) { | ||
if (!t.isDeclareExportDeclaration(parent)) { | ||
this.word("declare"); | ||
this.space(); | ||
} | ||
this.OpaqueType(node); | ||
} | ||
function DeclareVariable(node, parent) { | ||
if (!t.isDeclareExportDeclaration(parent)) { | ||
this.word("declare"); | ||
this.space(); | ||
} | ||
this.word("var"); | ||
@@ -147,2 +172,40 @@ this.space(); | ||
function DeclareExportDeclaration(node) { | ||
this.word("declare"); | ||
this.space(); | ||
this.word("export"); | ||
this.space(); | ||
if (node.default) { | ||
this.word("default"); | ||
this.space(); | ||
} | ||
FlowExportDeclaration.apply(this, arguments); | ||
} | ||
function FlowExportDeclaration(node) { | ||
if (node.declaration) { | ||
var declar = node.declaration; | ||
this.print(declar, node); | ||
if (!t.isStatement(declar)) this.semicolon(); | ||
} else { | ||
this.token("{"); | ||
if (node.specifiers.length) { | ||
this.space(); | ||
this.printList(node.specifiers, node); | ||
this.space(); | ||
} | ||
this.token("}"); | ||
if (node.source) { | ||
this.space(); | ||
this.word("from"); | ||
this.space(); | ||
this.print(node.source, node); | ||
} | ||
this.semicolon(); | ||
} | ||
} | ||
function ExistentialTypeParam() { | ||
@@ -285,2 +348,22 @@ this.token("*"); | ||
} | ||
function OpaqueType(node) { | ||
this.word("opaque"); | ||
this.space(); | ||
this.word("type"); | ||
this.space(); | ||
this.print(node.id, node); | ||
this.print(node.typeParameters, node); | ||
if (node.supertype) { | ||
this.token(":"); | ||
this.space(); | ||
this.print(node.supertype, node); | ||
} | ||
if (node.impltype) { | ||
this.space(); | ||
this.token("="); | ||
this.space(); | ||
this.print(node.impltype, node); | ||
} | ||
this.semicolon(); | ||
} | ||
@@ -287,0 +370,0 @@ function TypeAnnotation(node) { |
{ | ||
"name": "babel-generator", | ||
"version": "6.25.0", | ||
"version": "6.26.0", | ||
"description": "Turns an AST into code.", | ||
@@ -15,14 +15,14 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
"babel-messages": "^6.23.0", | ||
"babel-runtime": "^6.22.0", | ||
"babel-types": "^6.25.0", | ||
"babel-runtime": "^6.26.0", | ||
"babel-types": "^6.26.0", | ||
"detect-indent": "^4.0.0", | ||
"jsesc": "^1.3.0", | ||
"lodash": "^4.2.0", | ||
"source-map": "^0.5.0", | ||
"lodash": "^4.17.4", | ||
"source-map": "^0.5.6", | ||
"trim-right": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"babel-helper-fixtures": "^6.22.0", | ||
"babylon": "^6.17.2" | ||
"babel-helper-fixtures": "^6.26.0", | ||
"babylon": "^6.18.0" | ||
} | ||
} |
@@ -57,8 +57,3 @@ # babel-generator | ||
If this is the case, and you want the sourcemaps to reflect the correct sources, you'll need | ||
to make some changes to your code. | ||
First, each node with a `loc` property (which indicates that node's original placement in the | ||
source document) must also include a `loc.filename` property, set to the source filename. | ||
Second, you should pass an object to `generate` as the `code` parameter. Keys | ||
to pass an object to `generate` as the `code` parameter. Keys | ||
should be the source filenames, and values should be the source content. | ||
@@ -74,10 +69,10 @@ | ||
const b = 'var b = 2;'; | ||
const astA = parse(a, { filename: 'a.js' }); | ||
const astB = parse(b, { filename: 'b.js' }); | ||
const astA = parse(a, { sourceFilename: 'a.js' }); | ||
const astB = parse(b, { sourceFilename: 'b.js' }); | ||
const ast = { | ||
type: 'Program', | ||
body: [].concat(astA.body, ast2.body) | ||
body: [].concat(astA.program.body, astB.program.body) | ||
}; | ||
const { code, map } = generate(ast, { /* options */ }, { | ||
const { code, map } = generate(ast, { sourceMaps: true }, { | ||
'a.js': a, | ||
@@ -84,0 +79,0 @@ 'b.js': b |
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
93344
2703
82
Updatedbabel-runtime@^6.26.0
Updatedbabel-types@^6.26.0
Updatedlodash@^4.17.4
Updatedsource-map@^0.5.6