Compare commits
87 Commits
v7.0.0-alp
...
v7.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79f4956948 | ||
|
|
7f92e1d9dd | ||
|
|
e37a5eb5eb | ||
|
|
66ec5263a4 | ||
|
|
13d931c417 | ||
|
|
47a9ba3440 | ||
|
|
a1debae8f0 | ||
|
|
30c4d6b456 | ||
|
|
0e58007264 | ||
|
|
577173cc02 | ||
|
|
8c457e9283 | ||
|
|
2a83867436 | ||
|
|
9dd65c809f | ||
|
|
af5f34ace5 | ||
|
|
57da9bdbed | ||
|
|
d86ae2fb84 | ||
|
|
18084db7cf | ||
|
|
8e19a5b057 | ||
|
|
95882d4e5a | ||
|
|
99ab2b206c | ||
|
|
77cfa94682 | ||
|
|
79c6814d65 | ||
|
|
d479673074 | ||
|
|
6630ae9794 | ||
|
|
6bb1486405 | ||
|
|
75808a2d14 | ||
|
|
4e9a25e34a | ||
|
|
0f823beeb1 | ||
|
|
829c75a866 | ||
|
|
9d7c82d869 | ||
|
|
21eeed8a8c | ||
|
|
889f4e7791 | ||
|
|
c5e81516dd | ||
|
|
6d965c0926 | ||
|
|
e32042f353 | ||
|
|
c1d07fd6db | ||
|
|
f83c83d49c | ||
|
|
605adc922d | ||
|
|
593cbc1d53 | ||
|
|
5c45753cd6 | ||
|
|
1563221171 | ||
|
|
b242e0d946 | ||
|
|
9322fd0458 | ||
|
|
f01438e9b1 | ||
|
|
ce5d1d0f59 | ||
|
|
7f1cd44d60 | ||
|
|
2841945095 | ||
|
|
76060bb2c7 | ||
|
|
84dfa659e7 | ||
|
|
e0b4543601 | ||
|
|
248743e6c5 | ||
|
|
9a1b8ea443 | ||
|
|
55aea26f13 | ||
|
|
fb9a752262 | ||
|
|
4a35243118 | ||
|
|
9fc910d8c0 | ||
|
|
51a293601b | ||
|
|
19c4dd2d8c | ||
|
|
2225892348 | ||
|
|
677160385c | ||
|
|
9b04cbbc4f | ||
|
|
4aca487b6d | ||
|
|
5afe40b095 | ||
|
|
b081f68e87 | ||
|
|
c9ed159a18 | ||
|
|
b9ed9919c1 | ||
|
|
04b4e414ad | ||
|
|
0b890ced19 | ||
|
|
c60bf9a897 | ||
|
|
245c78dcdc | ||
|
|
8a98141b60 | ||
|
|
78544417fc | ||
|
|
c6edce115c | ||
|
|
579499c66d | ||
|
|
827c70e015 | ||
|
|
8a5488e59f | ||
|
|
63204ae51e | ||
|
|
28ae47a174 | ||
|
|
aa684d1b0c | ||
|
|
1fdec955f8 | ||
|
|
213ad1ed7a | ||
|
|
797fb3c2e4 | ||
|
|
9d612e717e | ||
|
|
e919c6e6eb | ||
|
|
d82afb407e | ||
|
|
b858d7ce5e | ||
|
|
b83e0ec7b0 |
28
.babelrc.js
28
.babelrc.js
@@ -6,12 +6,28 @@ let envOpts = {
|
||||
|
||||
module.exports = {
|
||||
comments: false,
|
||||
plugins: [
|
||||
// temp until next release
|
||||
function() {
|
||||
return {
|
||||
visitor: {
|
||||
"Function": function(path) {
|
||||
const node = path.node;
|
||||
for (let i = 0; i < node.params.length; i++) {
|
||||
const param = node.params[i];
|
||||
if (param.type === "AssignmentPattern") {
|
||||
param.left.optional = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
],
|
||||
presets: [
|
||||
[
|
||||
"env", envOpts
|
||||
],
|
||||
["env", envOpts],
|
||||
"stage-0",
|
||||
"flow",
|
||||
"flow"
|
||||
],
|
||||
env: {
|
||||
cov: {
|
||||
@@ -21,9 +37,9 @@ module.exports = {
|
||||
}
|
||||
};
|
||||
|
||||
if (process.env.BABEL_ENV === 'development') {
|
||||
if (process.env.BABEL_ENV === "development") {
|
||||
envOpts.targets = {
|
||||
node: "current"
|
||||
};
|
||||
envOpts.debug = true;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -13,6 +13,5 @@ lib/types.js
|
||||
lib/third-party-libs.js.flow
|
||||
|
||||
[options]
|
||||
strip_root=true
|
||||
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
|
||||
suppress_comment= \\(.\\|\n\\)*\\$FlowIssue
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -22,6 +22,8 @@ package-lock.json
|
||||
/packages/babel-runtime/helpers/es6/*.js
|
||||
!/packages/babel-runtime/helpers/es6/toArray.js
|
||||
/packages/babel-register/test/.babel
|
||||
/packages/babel-cli/test/tmp
|
||||
/packages/babel-node/test/tmp
|
||||
/packages/*/lib
|
||||
.nyc_output
|
||||
/babel.sublime-workspace
|
||||
|
||||
@@ -12,7 +12,12 @@ node_js:
|
||||
- '4'
|
||||
|
||||
env:
|
||||
- JOB=test
|
||||
global:
|
||||
- PATH=$HOME/.yarn/bin:$PATH
|
||||
- JOB=test
|
||||
|
||||
before_install:
|
||||
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.28.1
|
||||
|
||||
script:
|
||||
- 'if [ "$JOB" = "test" ]; then make test-ci; fi'
|
||||
|
||||
@@ -40,7 +40,7 @@ Feel free to check out the `#discussion`/`#development` channels on our [Slack](
|
||||
|
||||
**Note:** Versions `< 5.1.10` can't be built.
|
||||
|
||||
Babel is built for Node.js 4 and up but we develop using Node.js 6. Make sure you are on npm 3.
|
||||
Babel is built for Node.js 4 and up but we develop using Node.js 6/8 and yarn.
|
||||
|
||||
You can check this with `node -v` and `npm -v`.
|
||||
|
||||
@@ -120,6 +120,12 @@ Use the `TEST_GREP` variable to run a subset of tests by name:
|
||||
$ TEST_GREP=transformation make test
|
||||
```
|
||||
|
||||
Substitute spaces for hyphens and forward slashes when targeting specific test names:
|
||||
|
||||
```sh
|
||||
$ TEST_GREP="arrow functions destructuring parameters" make test
|
||||
```
|
||||
|
||||
To enable the Node.js debugger added in v6.3.0, set the `TEST_DEBUG` environment variable:
|
||||
|
||||
```sh
|
||||
|
||||
5
Makefile
5
Makefile
@@ -8,6 +8,7 @@ export FORCE_COLOR = true
|
||||
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
|
||||
|
||||
build: clean
|
||||
rm -rf packages/*/lib
|
||||
./node_modules/.bin/gulp build
|
||||
|
||||
build-dist: build
|
||||
@@ -25,7 +26,7 @@ lint:
|
||||
./node_modules/.bin/eslint scripts packages *.js --format=codeframe
|
||||
|
||||
flow:
|
||||
./node_modules/.bin/flow check
|
||||
./node_modules/.bin/flow check --strip-root
|
||||
|
||||
fix:
|
||||
./node_modules/.bin/eslint scripts packages *.js --format=codeframe --fix
|
||||
@@ -46,6 +47,8 @@ clean-all:
|
||||
rm -rf packages/*/lib
|
||||
rm -rf node_modules
|
||||
rm -rf packages/*/node_modules
|
||||
rm -rf package-lock.json
|
||||
rm -rf packages/*/package-lock.json
|
||||
make clean
|
||||
|
||||
test-only:
|
||||
|
||||
@@ -86,6 +86,7 @@ Check out our [CONTRIBUTING.md](https://github.com/babel/babel/blob/master/CONTR
|
||||
You can also start by checking out the issues with the [help-wanted](https://github.com/babel/babel/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) label.
|
||||
|
||||
Our discussions/notes/roadmap: [babel/notes](https://github.com/babel/notes)
|
||||
Our progress on TC39 proposals: [babel/proposals](https://github.com/babel/proposals)
|
||||
|
||||
## Packages
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
machine:
|
||||
node:
|
||||
version:
|
||||
6
|
||||
8
|
||||
|
||||
dependencies:
|
||||
pre:
|
||||
|
||||
10
lerna.json
10
lerna.json
@@ -1,8 +1,7 @@
|
||||
{
|
||||
"lerna": "2.0.0-rc.4",
|
||||
"version": "7.0.0-alpha.15",
|
||||
"version": "7.0.0-alpha.19",
|
||||
"changelog": {
|
||||
"repo": "babel/babel",
|
||||
"labels": {
|
||||
"tag: spec compliancy": ":eyeglasses: Spec Compliancy",
|
||||
"tag: breaking change": ":boom: Breaking Change",
|
||||
@@ -21,5 +20,10 @@
|
||||
"test/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true
|
||||
}
|
||||
|
||||
790
lib/types.js
790
lib/types.js
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
@@ -11,38 +11,38 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"async": "^1.5.0",
|
||||
"babel-cli": "7.0.0-alpha.12",
|
||||
"babel-core": "7.0.0-alpha.12",
|
||||
"babel-eslint": "8.0.0-alpha.12",
|
||||
"babel-plugin-istanbul": "^2.0.1",
|
||||
"babel-preset-env": "2.0.0-alpha.12",
|
||||
"babel-preset-flow": "7.0.0-alpha.12",
|
||||
"babel-preset-stage-0": "7.0.0-alpha.12",
|
||||
"babel-register": "7.0.0-alpha.12",
|
||||
"babel-cli": "7.0.0-alpha.15",
|
||||
"babel-core": "7.0.0-alpha.15",
|
||||
"babel-eslint": "8.0.0-alpha.15",
|
||||
"babel-plugin-istanbul": "^4.1.4",
|
||||
"babel-preset-env": "2.0.0-alpha.15",
|
||||
"babel-preset-flow": "7.0.0-alpha.15",
|
||||
"babel-preset-stage-0": "7.0.0-alpha.15",
|
||||
"babel-register": "7.0.0-alpha.15",
|
||||
"browserify": "^13.1.1",
|
||||
"bundle-collapser": "^1.2.1",
|
||||
"chai": "^3.5.0",
|
||||
"chalk": "^1.1.1",
|
||||
"chai": "^4.1.0",
|
||||
"chalk": "^2.0.0",
|
||||
"derequire": "^2.0.2",
|
||||
"eslint": "^3.14.1",
|
||||
"eslint-config-babel": "^7.0.1",
|
||||
"eslint-plugin-flowtype": "^2.20.0",
|
||||
"eslint-plugin-prettier": "^2.1.2",
|
||||
"flow-bin": "^0.41.0",
|
||||
"flow-bin": "^0.52.0",
|
||||
"gulp": "^3.9.0",
|
||||
"gulp-babel": "babel/gulp-babel#b7-alpha",
|
||||
"gulp-babel": "^7.0.0",
|
||||
"gulp-newer": "^1.0.0",
|
||||
"gulp-plumber": "^1.0.1",
|
||||
"gulp-util": "^3.0.7",
|
||||
"gulp-watch": "^4.3.5",
|
||||
"husky": "^0.13.2",
|
||||
"lerna": "2.0.0-rc.4",
|
||||
"lerna-changelog": "^0.2.0",
|
||||
"lerna": "2.0.0",
|
||||
"lerna-changelog": "^0.6.0",
|
||||
"lint-staged": "^3.6.1",
|
||||
"lodash": "^4.2.0",
|
||||
"mocha": "^3.0.0",
|
||||
"nyc": "^10.0.0",
|
||||
"output-file-sync": "^1.1.1",
|
||||
"nyc": "^11.0.3",
|
||||
"output-file-sync": "^2.0.0",
|
||||
"prettier": "^1.5.0",
|
||||
"rimraf": "^2.4.3",
|
||||
"semver": "^5.0.0",
|
||||
@@ -67,5 +67,8 @@
|
||||
"eslint --format=codeframe --fix",
|
||||
"git add"
|
||||
]
|
||||
}
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "babel-cli",
|
||||
"version": "7.0.0-alpha.15",
|
||||
"version": "7.0.0-alpha.19",
|
||||
"description": "Babel command line.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -16,24 +16,24 @@
|
||||
"compiler"
|
||||
],
|
||||
"dependencies": {
|
||||
"babel-core": "7.0.0-alpha.15",
|
||||
"babel-polyfill": "7.0.0-alpha.15",
|
||||
"babel-register": "7.0.0-alpha.15",
|
||||
"babel-core": "7.0.0-alpha.19",
|
||||
"babel-polyfill": "7.0.0-alpha.19",
|
||||
"babel-register": "7.0.0-alpha.19",
|
||||
"commander": "^2.8.1",
|
||||
"convert-source-map": "^1.1.0",
|
||||
"fs-readdir-recursive": "^1.0.0",
|
||||
"glob": "^7.0.0",
|
||||
"lodash": "^4.2.0",
|
||||
"output-file-sync": "^1.1.0",
|
||||
"output-file-sync": "^2.0.0",
|
||||
"slash": "^1.0.0",
|
||||
"source-map": "^0.5.0",
|
||||
"v8flags": "^2.0.10"
|
||||
"v8flags": "^3.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"chokidar": "^1.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-helper-fixtures": "7.0.0-alpha.15"
|
||||
"babel-helper-fixtures": "7.0.0-alpha.19"
|
||||
},
|
||||
"bin": {
|
||||
"babel-doctor": "./bin/babel-doctor.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "babel-code-frame",
|
||||
"version": "7.0.0-alpha.15",
|
||||
"version": "7.0.0-alpha.19",
|
||||
"description": "Generate errors that contain a code frame that point to source locations.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -8,8 +8,11 @@
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-code-frame",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"chalk": "^1.1.0",
|
||||
"chalk": "^2.0.0",
|
||||
"esutils": "^2.0.2",
|
||||
"js-tokens": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"strip-ansi": "^4.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import assert from "assert";
|
||||
import chalk from "chalk";
|
||||
import stripAnsi from "strip-ansi";
|
||||
import codeFrame, { codeFrameColumns } from "..";
|
||||
|
||||
describe("babel-code-frame", function() {
|
||||
@@ -100,7 +101,7 @@ describe("babel-code-frame", function() {
|
||||
it("opts.highlightCode", function() {
|
||||
const rawLines = "console.log('babel')";
|
||||
const result = codeFrame(rawLines, 1, 9, { highlightCode: true });
|
||||
const stripped = chalk.stripColor(result);
|
||||
const stripped = stripAnsi(result);
|
||||
assert.ok(result.length > stripped.length);
|
||||
assert.equal(
|
||||
stripped,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "babel-core",
|
||||
"version": "7.0.0-alpha.15",
|
||||
"version": "7.0.0-alpha.19",
|
||||
"description": "Babel compiler core.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -25,14 +25,14 @@
|
||||
"./lib/config/loading/files/index.js": "./lib/config/loading/files/index-browser.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-code-frame": "7.0.0-alpha.15",
|
||||
"babel-generator": "7.0.0-alpha.15",
|
||||
"babel-helpers": "7.0.0-alpha.15",
|
||||
"babel-messages": "7.0.0-alpha.15",
|
||||
"babel-template": "7.0.0-alpha.15",
|
||||
"babel-traverse": "7.0.0-alpha.15",
|
||||
"babel-types": "7.0.0-alpha.15",
|
||||
"babylon": "7.0.0-beta.15",
|
||||
"babel-code-frame": "7.0.0-alpha.19",
|
||||
"babel-generator": "7.0.0-alpha.19",
|
||||
"babel-helpers": "7.0.0-alpha.19",
|
||||
"babel-messages": "7.0.0-alpha.19",
|
||||
"babel-template": "7.0.0-alpha.19",
|
||||
"babel-traverse": "7.0.0-alpha.19",
|
||||
"babel-types": "7.0.0-alpha.19",
|
||||
"babylon": "7.0.0-beta.19",
|
||||
"convert-source-map": "^1.1.0",
|
||||
"debug": "^2.1.1",
|
||||
"json5": "^0.5.0",
|
||||
@@ -42,7 +42,7 @@
|
||||
"source-map": "^0.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-helper-transform-fixture-test-runner": "7.0.0-alpha.15",
|
||||
"babel-register": "7.0.0-alpha.15"
|
||||
"babel-helper-transform-fixture-test-runner": "7.0.0-alpha.19",
|
||||
"babel-register": "7.0.0-alpha.19"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// @flow
|
||||
|
||||
import * as context from "../index";
|
||||
import Plugin from "./plugin";
|
||||
import * as messages from "babel-messages";
|
||||
|
||||
@@ -180,9 +180,24 @@ export default class File extends Store {
|
||||
|
||||
addImport(
|
||||
source: string,
|
||||
imported: string,
|
||||
imported?: string = "",
|
||||
name?: string = imported,
|
||||
): Object {
|
||||
): Object | null {
|
||||
const prependDeclaration = (
|
||||
specifiers: Array<BabelNodeImportSpecifier>,
|
||||
): void => {
|
||||
const declar = t.importDeclaration(specifiers, t.stringLiteral(source));
|
||||
declar._blockHoist = 3;
|
||||
|
||||
this.path.unshiftContainer("body", declar);
|
||||
};
|
||||
|
||||
// import "module-name";
|
||||
if (!imported) {
|
||||
prependDeclaration([]);
|
||||
return null;
|
||||
}
|
||||
|
||||
const alias = `${source}:${imported}`;
|
||||
let id = this.dynamicImportIds[alias];
|
||||
|
||||
@@ -202,10 +217,7 @@ export default class File extends Store {
|
||||
specifiers.push(t.importSpecifier(id, t.identifier(imported)));
|
||||
}
|
||||
|
||||
const declar = t.importDeclaration(specifiers, t.stringLiteral(source));
|
||||
declar._blockHoist = 3;
|
||||
|
||||
this.path.unshiftContainer("body", declar);
|
||||
prependDeclaration(specifiers);
|
||||
}
|
||||
|
||||
return id;
|
||||
@@ -236,7 +248,6 @@ export default class File extends Store {
|
||||
|
||||
if (t.isFunctionExpression(ref) && !ref.id) {
|
||||
ref.body._compact = true;
|
||||
ref._generated = true;
|
||||
ref.id = uid;
|
||||
ref.type = "FunctionDeclaration";
|
||||
this.path.unshiftContainer("body", ref);
|
||||
|
||||
30
packages/babel-core/test/fixtures/plugins/file-add-import/exec.js
vendored
Normal file
30
packages/babel-core/test/fixtures/plugins/file-add-import/exec.js
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
var res = transform("", {
|
||||
plugins: [
|
||||
function (b) {
|
||||
return {
|
||||
visitor: {
|
||||
Program: function(path, state) {
|
||||
var file = state.file;
|
||||
file.addImport("import-star", "*", "lib");
|
||||
file.addImport("import-default", "default", "foo");
|
||||
file.addImport("import-alias", "bar", "baz");
|
||||
file.addImport("import-default-alias", "quux");
|
||||
file.addImport("import-empty", "");
|
||||
file.addImport("import-none");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
var expected = multiline([
|
||||
'import "import-none";',
|
||||
'import "import-empty";',
|
||||
'import { quux as _quux } from "import-default-alias";',
|
||||
'import { bar as _baz } from "import-alias";',
|
||||
'import _foo from "import-default";',
|
||||
'import * as _lib from "import-star";',
|
||||
]);
|
||||
|
||||
assert.equal(res.code, expected);
|
||||
@@ -1,2 +1,2 @@
|
||||
export function foo() {}
|
||||
export function bar() {}
|
||||
export function bar() {}
|
||||
|
||||
@@ -13,4 +13,4 @@ var Foo = function (_Bar) {
|
||||
}
|
||||
|
||||
return Foo;
|
||||
}(Bar);
|
||||
}(Bar);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
function test() {
|
||||
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "hi";
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,4 +29,4 @@ class Class {
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var _values = values;
|
||||
value = _values[fieldName];
|
||||
rest = babelHelpers.objectWithoutProperties(_values, [fieldName]);
|
||||
var error = void 0;
|
||||
var _fieldName = fieldName;
|
||||
value = _values[_fieldName];
|
||||
rest = babelHelpers.objectWithoutProperties(_values, [_fieldName].map(babelHelpers.toPropertyKey));
|
||||
_values;
|
||||
var error = void 0;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
foobar();
|
||||
foobar();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "babel-generator",
|
||||
"version": "7.0.0-alpha.15",
|
||||
"version": "7.0.0-alpha.19",
|
||||
"description": "Turns an AST into code.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -11,15 +11,15 @@
|
||||
"lib"
|
||||
],
|
||||
"dependencies": {
|
||||
"babel-messages": "7.0.0-alpha.15",
|
||||
"babel-types": "7.0.0-alpha.15",
|
||||
"jsesc": "^1.3.0",
|
||||
"babel-messages": "7.0.0-alpha.19",
|
||||
"babel-types": "7.0.0-alpha.19",
|
||||
"jsesc": "^2.5.1",
|
||||
"lodash": "^4.2.0",
|
||||
"source-map": "^0.5.0",
|
||||
"trim-right": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-helper-fixtures": "7.0.0-alpha.15",
|
||||
"babylon": "^7.0.0-beta.15"
|
||||
"babel-helper-fixtures": "7.0.0-alpha.19",
|
||||
"babylon": "^7.0.0-beta.19"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,18 @@ export function ClassDeclaration(node: Object, parent: Object) {
|
||||
this.printJoin(node.decorators, node);
|
||||
}
|
||||
|
||||
if (node.declare) {
|
||||
// TS
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.abstract) {
|
||||
// TS
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("class");
|
||||
|
||||
if (node.id) {
|
||||
@@ -59,10 +71,25 @@ export function ClassBody(node: Object) {
|
||||
export function ClassProperty(node: Object) {
|
||||
this.printJoin(node.decorators, node);
|
||||
|
||||
if (node.accessibility) {
|
||||
// TS
|
||||
this.word(node.accessibility);
|
||||
this.space();
|
||||
}
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
if (node.abstract) {
|
||||
// TS
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
if (node.readonly) {
|
||||
// TS
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
if (node.computed) {
|
||||
this.token("[");
|
||||
this.print(node.key, node);
|
||||
@@ -71,6 +98,12 @@ export function ClassProperty(node: Object) {
|
||||
this._variance(node);
|
||||
this.print(node.key, node);
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
// TS
|
||||
this.token("?");
|
||||
}
|
||||
|
||||
this.print(node.typeAnnotation, node);
|
||||
if (node.value) {
|
||||
this.space();
|
||||
@@ -82,12 +115,30 @@ export function ClassProperty(node: Object) {
|
||||
}
|
||||
|
||||
export function ClassMethod(node: Object) {
|
||||
this._classMethodHead(node);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
export function _classMethodHead(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
|
||||
if (node.accessibility) {
|
||||
// TS
|
||||
this.word(node.accessibility);
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.abstract) {
|
||||
// TS
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this._method(node);
|
||||
this._methodHead(node);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ export function NewExpression(node: Object, parent: Object) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.print(node.typeParameters, node); // TS
|
||||
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
@@ -91,37 +93,16 @@ export function Decorator(node: Object) {
|
||||
this.newline();
|
||||
}
|
||||
|
||||
function commaSeparatorNewline() {
|
||||
this.token(",");
|
||||
this.newline();
|
||||
|
||||
if (!this.endsWith("\n")) this.space();
|
||||
}
|
||||
|
||||
export function CallExpression(node: Object) {
|
||||
this.print(node.callee, node);
|
||||
|
||||
this.print(node.typeParameters, node); // TS
|
||||
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
this.token("(");
|
||||
|
||||
const isPrettyCall = node._prettyCall;
|
||||
|
||||
let separator;
|
||||
if (isPrettyCall) {
|
||||
separator = commaSeparatorNewline;
|
||||
this.newline();
|
||||
this.indent();
|
||||
}
|
||||
|
||||
this.printList(node.arguments, node, { separator });
|
||||
|
||||
if (isPrettyCall) {
|
||||
this.newline();
|
||||
this.dedent();
|
||||
}
|
||||
|
||||
this.printList(node.arguments, node);
|
||||
this.token(")");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as t from "babel-types";
|
||||
import { ExportAllDeclaration } from "./modules";
|
||||
|
||||
export function AnyTypeAnnotation() {
|
||||
this.word("any");
|
||||
@@ -41,9 +42,28 @@ export function DeclareFunction(node: Object, parent: Object) {
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id.typeAnnotation.typeAnnotation, node);
|
||||
|
||||
if (node.predicate) {
|
||||
this.space();
|
||||
this.print(node.predicate, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
export function InferredPredicate(/*node: Object*/) {
|
||||
this.token("%");
|
||||
this.word("checks");
|
||||
}
|
||||
|
||||
export function DeclaredPredicate(node: Object) {
|
||||
this.token("%");
|
||||
this.word("checks");
|
||||
this.token("(");
|
||||
this.print(node.value, node);
|
||||
this.token(")");
|
||||
}
|
||||
|
||||
export function DeclareInterface(node: Object) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
@@ -75,6 +95,14 @@ export function DeclareTypeAlias(node: Object) {
|
||||
this.TypeAlias(node);
|
||||
}
|
||||
|
||||
export function DeclareOpaqueType(node: Object, parent: Object) {
|
||||
if (!t.isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this.OpaqueType(node);
|
||||
}
|
||||
|
||||
export function DeclareVariable(node: Object, parent: Object) {
|
||||
if (!t.isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
@@ -100,17 +128,10 @@ export function DeclareExportDeclaration(node: Object) {
|
||||
FlowExportDeclaration.apply(this, arguments);
|
||||
}
|
||||
|
||||
export function DeclareExportAllDeclaration(node: Object) {
|
||||
export function DeclareExportAllDeclaration(/*node: Object*/) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.word("export");
|
||||
this.space();
|
||||
this.token("*");
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
this.print(node.source, node);
|
||||
this.semicolon();
|
||||
ExportAllDeclaration.apply(this, arguments);
|
||||
}
|
||||
|
||||
function FlowExportDeclaration(node: Object) {
|
||||
@@ -290,38 +311,27 @@ export function TypeAlias(node: Object) {
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
export function TypeAnnotation(node: Object) {
|
||||
this.token(":");
|
||||
export function OpaqueType(node: Object) {
|
||||
this.word("opaque");
|
||||
this.space();
|
||||
if (node.optional) this.token("?");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
export function TypeParameter(node: Object) {
|
||||
this._variance(node);
|
||||
|
||||
this.word(node.name);
|
||||
|
||||
if (node.bound) {
|
||||
this.print(node.bound, node);
|
||||
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.default) {
|
||||
if (node.impltype) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(node.default, node);
|
||||
this.print(node.impltype, node);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
export function TypeParameterInstantiation(node: Object) {
|
||||
this.token("<");
|
||||
this.printList(node.params, node, {});
|
||||
this.token(">");
|
||||
}
|
||||
|
||||
export { TypeParameterInstantiation as TypeParameterDeclaration };
|
||||
|
||||
export function ObjectTypeAnnotation(node: Object) {
|
||||
if (node.exact) {
|
||||
this.token("{|");
|
||||
|
||||
@@ -8,3 +8,5 @@ export * from "./types";
|
||||
export * from "./flow";
|
||||
export * from "./base";
|
||||
export * from "./jsx";
|
||||
export * from "./tsFlowCommon";
|
||||
export * from "./typescript";
|
||||
|
||||
@@ -3,20 +3,31 @@ import * as t from "babel-types";
|
||||
export function _params(node: Object) {
|
||||
this.print(node.typeParameters, node);
|
||||
this.token("(");
|
||||
this.printList(node.params, node, {
|
||||
iterator: node => {
|
||||
if (node.optional) this.token("?");
|
||||
this.print(node.typeAnnotation, node);
|
||||
},
|
||||
});
|
||||
this._parameters(node.params, node);
|
||||
this.token(")");
|
||||
|
||||
if (node.returnType) {
|
||||
this.print(node.returnType, node);
|
||||
this.print(node.returnType, node);
|
||||
}
|
||||
|
||||
export function _parameters(parameters, parent) {
|
||||
for (let i = 0; i < parameters.length; i++) {
|
||||
this._param(parameters[i], parent);
|
||||
|
||||
if (i < parameters.length - 1) {
|
||||
this.token(",");
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function _method(node: Object) {
|
||||
export function _param(parameter, parent) {
|
||||
this.printJoin(parameter.decorators, parameter);
|
||||
this.print(parameter, parent);
|
||||
if (parameter.optional) this.token("?"); // TS / flow
|
||||
this.print(parameter.typeAnnotation, parameter); // TS / flow
|
||||
}
|
||||
|
||||
export function _methodHead(node: Object) {
|
||||
const kind = node.kind;
|
||||
const key = node.key;
|
||||
|
||||
@@ -44,12 +55,25 @@ export function _method(node: Object) {
|
||||
this.print(key, node);
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
// TS
|
||||
this.token("?");
|
||||
}
|
||||
|
||||
this._params(node);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
export function FunctionExpression(node: Object) {
|
||||
export function _predicate(node: Object) {
|
||||
if (node.predicate) {
|
||||
if (!node.returnType) {
|
||||
this.token(":");
|
||||
}
|
||||
this.space();
|
||||
this.print(node.predicate, node);
|
||||
}
|
||||
}
|
||||
|
||||
export function _functionHead(node: Object) {
|
||||
if (node.async) {
|
||||
this.word("async");
|
||||
this.space();
|
||||
@@ -57,14 +81,17 @@ export function FunctionExpression(node: Object) {
|
||||
this.word("function");
|
||||
if (node.generator) this.token("*");
|
||||
|
||||
this.space();
|
||||
if (node.id) {
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
} else {
|
||||
this.space();
|
||||
}
|
||||
|
||||
this._params(node);
|
||||
this._predicate(node);
|
||||
}
|
||||
|
||||
export function FunctionExpression(node: Object) {
|
||||
this._functionHead(node);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
@@ -89,6 +116,8 @@ export function ArrowFunctionExpression(node: Object) {
|
||||
this._params(node);
|
||||
}
|
||||
|
||||
this._predicate(node);
|
||||
|
||||
this.space();
|
||||
this.token("=>");
|
||||
this.space();
|
||||
|
||||
@@ -44,6 +44,10 @@ export function ExportNamespaceSpecifier(node: Object) {
|
||||
export function ExportAllDeclaration(node: Object) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
if (node.exportKind === "type") {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
this.token("*");
|
||||
this.space();
|
||||
this.word("from");
|
||||
|
||||
@@ -123,8 +123,8 @@ function buildLabelStatement(prefix, key = "label") {
|
||||
const label = node[key];
|
||||
if (label) {
|
||||
this.space();
|
||||
|
||||
const terminatorState = this.startTerminatorless();
|
||||
const isLabel = key == "label";
|
||||
const terminatorState = this.startTerminatorless(isLabel);
|
||||
this.print(label, node);
|
||||
this.endTerminatorless(terminatorState);
|
||||
}
|
||||
@@ -171,10 +171,12 @@ export function TryStatement(node: Object) {
|
||||
export function CatchClause(node: Object) {
|
||||
this.word("catch");
|
||||
this.space();
|
||||
this.token("(");
|
||||
this.print(node.param, node);
|
||||
this.token(")");
|
||||
this.space();
|
||||
if (node.param) {
|
||||
this.token("(");
|
||||
this.print(node.param, node);
|
||||
this.token(")");
|
||||
this.space();
|
||||
}
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
@@ -234,6 +236,12 @@ function constDeclarationIndent() {
|
||||
}
|
||||
|
||||
export function VariableDeclaration(node: Object, parent: Object) {
|
||||
if (node.declare) {
|
||||
// TS
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word(node.kind);
|
||||
this.space();
|
||||
|
||||
|
||||
38
packages/babel-generator/src/generators/tsFlowCommon.js
Normal file
38
packages/babel-generator/src/generators/tsFlowCommon.js
Normal file
@@ -0,0 +1,38 @@
|
||||
export function TypeAnnotation(node) {
|
||||
this.token(":");
|
||||
this.space();
|
||||
if (node.optional) this.token("?");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
export function TypeParameterInstantiation(node): void {
|
||||
this.token("<");
|
||||
this.printList(node.params, node, {});
|
||||
this.token(">");
|
||||
}
|
||||
|
||||
export { TypeParameterInstantiation as TypeParameterDeclaration };
|
||||
|
||||
export function TypeParameter(node) {
|
||||
this._variance(node);
|
||||
|
||||
this.word(node.name);
|
||||
|
||||
if (node.bound) {
|
||||
this.print(node.bound, node);
|
||||
}
|
||||
|
||||
if (node.constraint) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.constraint, node);
|
||||
}
|
||||
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(node.default, node);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,9 @@ export { ObjectExpression as ObjectPattern };
|
||||
|
||||
export function ObjectMethod(node: Object) {
|
||||
this.printJoin(node.decorators, node);
|
||||
this._method(node);
|
||||
this._methodHead(node);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
export function ObjectProperty(node: Object) {
|
||||
|
||||
456
packages/babel-generator/src/generators/typescript.js
Normal file
456
packages/babel-generator/src/generators/typescript.js
Normal file
@@ -0,0 +1,456 @@
|
||||
export function TSParameterProperty(node) {
|
||||
if (node.accessibility) {
|
||||
this.word(node.accessibility);
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this._param(node.parameter);
|
||||
}
|
||||
|
||||
export function TSDeclareFunction(node) {
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this._functionHead(node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
export function TSDeclareMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
export function TSQualifiedName(node) {
|
||||
this.print(node.left, node);
|
||||
this.token(".");
|
||||
this.print(node.right, node);
|
||||
}
|
||||
|
||||
export function TSCallSignatureDeclaration(node) {
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
}
|
||||
|
||||
export function TSConstructSignatureDeclaration(node) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
}
|
||||
|
||||
export function TSPropertySignature(node) {
|
||||
const { readonly, initializer } = node;
|
||||
if (readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
this.tsPrintPropertyOrMethodName(node);
|
||||
this.print(node.typeAnnotation, node);
|
||||
if (initializer) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(initializer, node);
|
||||
}
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
export function tsPrintPropertyOrMethodName(node) {
|
||||
if (node.computed) {
|
||||
this.token("[");
|
||||
}
|
||||
this.print(node.key, node);
|
||||
if (node.computed) {
|
||||
this.token("]");
|
||||
}
|
||||
if (node.optional) {
|
||||
this.token("?");
|
||||
}
|
||||
}
|
||||
|
||||
export function TSMethodSignature(node) {
|
||||
this.tsPrintPropertyOrMethodName(node);
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
export function TSIndexSignature(node) {
|
||||
const { readonly } = node;
|
||||
if (readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
this.token("[");
|
||||
this._parameters(node.parameters, node);
|
||||
this.token("]");
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
export function TSAnyKeyword() {
|
||||
this.word("any");
|
||||
}
|
||||
export function TSNumberKeyword() {
|
||||
this.word("number");
|
||||
}
|
||||
export function TSObjectKeyword() {
|
||||
this.word("object");
|
||||
}
|
||||
export function TSBooleanKeyword() {
|
||||
this.word("boolean");
|
||||
}
|
||||
export function TSStringKeyword() {
|
||||
this.word("string");
|
||||
}
|
||||
export function TSSymbolKeyword() {
|
||||
this.word("symbol");
|
||||
}
|
||||
export function TSVoidKeyword() {
|
||||
this.word("void");
|
||||
}
|
||||
export function TSUndefinedKeyword() {
|
||||
this.word("undefined");
|
||||
}
|
||||
export function TSNullKeyword() {
|
||||
this.word("null");
|
||||
}
|
||||
export function TSNeverKeyword() {
|
||||
this.word("never");
|
||||
}
|
||||
|
||||
export function TSThisType() {
|
||||
this.word("this");
|
||||
}
|
||||
|
||||
export function TSFunctionType(node) {
|
||||
this.tsPrintFunctionOrConstructorType(node);
|
||||
}
|
||||
|
||||
export function TSConstructorType(node) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.tsPrintFunctionOrConstructorType(node);
|
||||
}
|
||||
|
||||
export function tsPrintFunctionOrConstructorType(
|
||||
node: FunctionOrConstructorType,
|
||||
) {
|
||||
const { typeParameters, parameters } = node;
|
||||
this.print(typeParameters, node);
|
||||
this.token("(");
|
||||
this._parameters(parameters, node);
|
||||
this.token(")");
|
||||
this.space();
|
||||
this.token("=>");
|
||||
this.space();
|
||||
this.print(node.typeAnnotation.typeAnnotation, node);
|
||||
}
|
||||
|
||||
export function TSTypeReference(node) {
|
||||
this.print(node.typeName, node);
|
||||
this.print(node.typeParameters, node);
|
||||
}
|
||||
|
||||
export function TSTypePredicate(node) {
|
||||
this.print(node.parameterName);
|
||||
this.space();
|
||||
this.word("is");
|
||||
this.space();
|
||||
this.print(node.typeAnnotation.typeAnnotation);
|
||||
}
|
||||
|
||||
export function TSTypeQuery(node) {
|
||||
this.word("typeof");
|
||||
this.space();
|
||||
this.print(node.exprName);
|
||||
}
|
||||
|
||||
export function TSTypeLiteral(node) {
|
||||
this.tsPrintTypeLiteralOrInterfaceBody(node.members, node);
|
||||
}
|
||||
|
||||
export function tsPrintTypeLiteralOrInterfaceBody(members, node) {
|
||||
this.tsPrintBraced(members, node);
|
||||
}
|
||||
|
||||
export function tsPrintBraced(members, node) {
|
||||
this.token("{");
|
||||
if (members.length) {
|
||||
this.indent();
|
||||
this.newline();
|
||||
for (const member of members) {
|
||||
this.print(member, node);
|
||||
//this.token(sep);
|
||||
this.newline();
|
||||
}
|
||||
this.dedent();
|
||||
this.rightBrace();
|
||||
} else {
|
||||
this.token("}");
|
||||
}
|
||||
}
|
||||
|
||||
export function TSArrayType(node) {
|
||||
this.print(node.elementType);
|
||||
this.token("[]");
|
||||
}
|
||||
|
||||
export function TSTupleType(node) {
|
||||
this.token("[");
|
||||
this.printList(node.elementTypes, node);
|
||||
this.token("]");
|
||||
}
|
||||
|
||||
export function TSUnionType(node) {
|
||||
this.tsPrintUnionOrIntersectionType(node, "|");
|
||||
}
|
||||
|
||||
export function TSIntersectionType(node) {
|
||||
this.tsPrintUnionOrIntersectionType(node, "&");
|
||||
}
|
||||
|
||||
export function tsPrintUnionOrIntersectionType(node, sep) {
|
||||
this.printJoin(node.types, node, {
|
||||
separator() {
|
||||
this.space();
|
||||
this.token(sep);
|
||||
this.space();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function TSParenthesizedType(node) {
|
||||
this.token("(");
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.token(")");
|
||||
}
|
||||
|
||||
export function TSTypeOperator(node) {
|
||||
this.token(node.operator);
|
||||
this.space();
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
export function TSIndexedAccessType(node) {
|
||||
this.print(node.objectType, node);
|
||||
this.token("[");
|
||||
this.print(node.indexType, node);
|
||||
this.token("]");
|
||||
}
|
||||
|
||||
export function TSMappedType(node) {
|
||||
const { readonly, typeParameter, optional } = node;
|
||||
this.token("{");
|
||||
this.space();
|
||||
if (readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.token("[");
|
||||
this.word(typeParameter.name);
|
||||
this.space();
|
||||
this.word("in");
|
||||
this.space();
|
||||
this.print(typeParameter.constraint, typeParameter);
|
||||
this.token("]");
|
||||
|
||||
if (optional) {
|
||||
this.token("?");
|
||||
}
|
||||
this.token(":");
|
||||
this.space();
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.space();
|
||||
this.token("}");
|
||||
}
|
||||
|
||||
export function TSLiteralType(node) {
|
||||
this.print(node.literal, node);
|
||||
}
|
||||
|
||||
export function TSExpressionWithTypeArguments(node) {
|
||||
this.print(node.expression, node);
|
||||
this.print(node.typeParameters, node);
|
||||
}
|
||||
|
||||
export function TSInterfaceDeclaration(node) {
|
||||
const { declare, id, typeParameters, extends: extendz, body } = node;
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this.word("interface");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(typeParameters, node);
|
||||
if (extendz) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(extendz, node);
|
||||
}
|
||||
this.space();
|
||||
this.print(body, node);
|
||||
}
|
||||
|
||||
export function TSInterfaceBody(node) {
|
||||
this.tsPrintTypeLiteralOrInterfaceBody(node.body, node);
|
||||
}
|
||||
|
||||
export function TSTypeAliasDeclaration(node) {
|
||||
const { declare, id, typeParameters, typeAnnotation } = node;
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(typeParameters, node);
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(typeAnnotation, node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
export function TSAsExpression(node) {
|
||||
const { expression, typeAnnotation } = node;
|
||||
this.print(expression, node);
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(typeAnnotation, node);
|
||||
}
|
||||
|
||||
export function TSTypeAssertion(node) {
|
||||
const { typeAnnotation, expression } = node;
|
||||
this.token("<");
|
||||
this.print(typeAnnotation, node);
|
||||
this.token(">");
|
||||
this.space();
|
||||
this.print(expression, node);
|
||||
}
|
||||
|
||||
export function TSEnumDeclaration(node) {
|
||||
const { declare, const: isConst, id, members } = node;
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
if (isConst) {
|
||||
this.word("const");
|
||||
this.space();
|
||||
}
|
||||
this.word("enum");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.space();
|
||||
this.tsPrintBraced(members, node);
|
||||
}
|
||||
|
||||
export function TSEnumMember(node) {
|
||||
const { id, initializer } = node;
|
||||
this.print(id, node);
|
||||
if (initializer) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(initializer, node);
|
||||
}
|
||||
this.token(",");
|
||||
}
|
||||
|
||||
export function TSModuleDeclaration(node) {
|
||||
const { declare, id } = node;
|
||||
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (!node.global) {
|
||||
this.word(id.type === "Identifier" ? "namespace" : "module");
|
||||
this.space();
|
||||
}
|
||||
this.print(id, node);
|
||||
|
||||
if (!node.body) {
|
||||
this.token(";");
|
||||
return;
|
||||
}
|
||||
|
||||
let body = node.body;
|
||||
while (body.type === "TSModuleDeclaration") {
|
||||
this.token(".");
|
||||
this.print(body.id, body);
|
||||
body = body.body;
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(body, node);
|
||||
}
|
||||
|
||||
export function TSModuleBlock(node) {
|
||||
this.tsPrintBraced(node.body, node);
|
||||
}
|
||||
|
||||
export function TSImportEqualsDeclaration(node) {
|
||||
const { isExport, id, moduleReference } = node;
|
||||
if (isExport) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
}
|
||||
this.word("import");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(moduleReference, node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
export function TSExternalModuleReference(node) {
|
||||
this.token("require(");
|
||||
this.print(node.expression, node);
|
||||
this.token(")");
|
||||
}
|
||||
|
||||
export function TSNonNullExpression(node) {
|
||||
this.print(node.expression, node);
|
||||
this.token("!");
|
||||
}
|
||||
|
||||
export function TSExportAssignment(node) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(node.expression, node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
export function TSNamespaceExportDeclaration(node) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.word("namespace");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
}
|
||||
|
||||
export function tsPrintSignatureDeclarationBase(node) {
|
||||
const { typeParameters, parameters } = node;
|
||||
this.print(typeParameters, node);
|
||||
this.token("(");
|
||||
this._parameters(parameters, node);
|
||||
this.token(")");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
@@ -93,6 +93,14 @@ export function Binary(node: Object, parent: Object): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function TSAsExpression() {
|
||||
return true;
|
||||
}
|
||||
|
||||
export function TSTypeAssertion() {
|
||||
return true;
|
||||
}
|
||||
|
||||
export function BinaryExpression(node: Object, parent: Object): boolean {
|
||||
// let i = (1 in []);
|
||||
// for ((1 in []);;);
|
||||
@@ -173,7 +181,9 @@ export function ConditionalExpression(node: Object, parent: Object): boolean {
|
||||
t.isBinary(parent) ||
|
||||
t.isConditionalExpression(parent, { test: node }) ||
|
||||
t.isAwaitExpression(parent) ||
|
||||
t.isTaggedTemplateExpression(parent)
|
||||
t.isTaggedTemplateExpression(parent) ||
|
||||
t.isTSTypeAssertion(parent) ||
|
||||
t.isTSAsExpression(parent)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ export default class Printer {
|
||||
_insideAux: boolean = false;
|
||||
_printedCommentStarts: Object = {};
|
||||
_parenPushNewlineState: ?Object = null;
|
||||
_noLineTerminator: boolean = false;
|
||||
_printAuxAfterOnNextUserNode: boolean = false;
|
||||
_printedComments: WeakSet = new WeakSet();
|
||||
_endsWithInteger = false;
|
||||
@@ -281,7 +282,7 @@ export default class Printer {
|
||||
*
|
||||
* This is to prevent breaking semantics for terminatorless separator nodes. eg:
|
||||
*
|
||||
* return foo;
|
||||
* return foo;
|
||||
*
|
||||
* returns `foo`. But if we do:
|
||||
*
|
||||
@@ -291,10 +292,15 @@ export default class Printer {
|
||||
* `undefined` will be returned and not `foo` due to the terminator.
|
||||
*/
|
||||
|
||||
startTerminatorless(): Object {
|
||||
return (this._parenPushNewlineState = {
|
||||
printed: false,
|
||||
});
|
||||
startTerminatorless(isLabel: boolean = false): Object {
|
||||
if (isLabel) {
|
||||
this._noLineTerminator = true;
|
||||
return null;
|
||||
} else {
|
||||
return (this._parenPushNewlineState = {
|
||||
printed: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -302,7 +308,8 @@ export default class Printer {
|
||||
*/
|
||||
|
||||
endTerminatorless(state: Object) {
|
||||
if (state.printed) {
|
||||
this._noLineTerminator = false;
|
||||
if (state && state.printed) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
this.token(")");
|
||||
@@ -319,7 +326,6 @@ export default class Printer {
|
||||
|
||||
const printMethod = this[node.type];
|
||||
if (!printMethod) {
|
||||
// eslint-disable-next-line max-len
|
||||
throw new ReferenceError(
|
||||
`unknown node of type ${JSON.stringify(
|
||||
node.type,
|
||||
@@ -531,13 +537,19 @@ export default class Printer {
|
||||
const isBlockComment = comment.type === "CommentBlock";
|
||||
|
||||
// Always add a newline before a block comment
|
||||
this.newline(this._buf.hasContent() && isBlockComment ? 1 : 0);
|
||||
this.newline(
|
||||
this._buf.hasContent() && !this._noLineTerminator && isBlockComment
|
||||
? 1
|
||||
: 0,
|
||||
);
|
||||
|
||||
if (!this.endsWith("[") && !this.endsWith("{")) this.space();
|
||||
|
||||
let val = !isBlockComment ? `//${comment.value}\n` : `/*${comment.value}*/`;
|
||||
let val =
|
||||
!isBlockComment && !this._noLineTerminator
|
||||
? `//${comment.value}\n`
|
||||
: `/*${comment.value}*/`;
|
||||
|
||||
//
|
||||
if (isBlockComment && this.format.indent.adjustMultilineComment) {
|
||||
const offset = comment.loc && comment.loc.start.column;
|
||||
if (offset) {
|
||||
@@ -560,7 +572,7 @@ export default class Printer {
|
||||
});
|
||||
|
||||
// Always add a newline after a block comment
|
||||
this.newline(isBlockComment ? 1 : 0);
|
||||
this.newline(isBlockComment && !this._noLineTerminator ? 1 : 0);
|
||||
}
|
||||
|
||||
_printComments(comments?: Array<Object>) {
|
||||
|
||||
@@ -2,4 +2,4 @@ foo("foo");
|
||||
foo("foo\nlol");
|
||||
foo("foo\n\"lol");
|
||||
foo("foo\n\"'lol");
|
||||
foo("😂");
|
||||
foo("😂");
|
||||
1
packages/babel-generator/test/fixtures/auto-string/jsx/options.json
vendored
Normal file
1
packages/babel-generator/test/fixtures/auto-string/jsx/options.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{ "plugins": ["jsx"] }
|
||||
@@ -2,4 +2,4 @@ foo('foo');
|
||||
foo('foo\nlol');
|
||||
foo('foo\n"lol');
|
||||
foo('foo\n"\'lol');
|
||||
foo('😂');
|
||||
foo('😂');
|
||||
@@ -3,4 +3,4 @@ function test() {
|
||||
* this is comment
|
||||
*/
|
||||
var i = 20;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
{ print("hello"); // comment
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
print("hello");
|
||||
// comment
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Leading to block
|
||||
{
|
||||
print("hello");
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,4 @@
|
||||
print("hello");
|
||||
|
||||
// comment2
|
||||
print("hello2");
|
||||
print("hello2");
|
||||
@@ -1,2 +1,2 @@
|
||||
do {} // LINE
|
||||
while (true);
|
||||
while (true);
|
||||
@@ -1,4 +1,4 @@
|
||||
function test() {
|
||||
// Leading to EmptyStatement
|
||||
; // Trailing to EmptyStatement
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
(function () {
|
||||
return; // comment
|
||||
})();
|
||||
})();
|
||||
@@ -1 +1 @@
|
||||
; // Trailing
|
||||
; // Trailing
|
||||
@@ -1 +1 @@
|
||||
var foo=1/ /* leading */1;
|
||||
var foo=1/ /* leading */1;
|
||||
@@ -7,4 +7,4 @@ finally {}
|
||||
{
|
||||
try {} catch (e) {} //
|
||||
finally {}
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,4 @@ function test() {
|
||||
* Leading to VariableDeclarator
|
||||
*/
|
||||
j = 20;
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
x=1;var{y=1}=obj;
|
||||
x=1;var{y=1}=obj;
|
||||
@@ -1 +1 @@
|
||||
1*1;1&&1;1+ +1;x+ ++y;a+ +b*2;a+ +b*2*2*2;a- -b;1+-b;1- --b;a- -b*2;1- --t*t;
|
||||
1*1;1&&1;1+ +1;x+ ++y;a+ +b*2;a+ +b*2*2*2;a- -b;1+-b;1- --b;a- -b*2;1- --t*t;
|
||||
@@ -1 +1 @@
|
||||
({[fieldName]:value,...rest}=values);let error;
|
||||
({[fieldName]:value,...rest}=values);let error;
|
||||
1
packages/babel-generator/test/fixtures/compact/expression-statement/options.json
vendored
Normal file
1
packages/babel-generator/test/fixtures/compact/expression-statement/options.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{ "plugins": ["objectRestSpread"] }
|
||||
@@ -1,2 +1,2 @@
|
||||
// foo
|
||||
bar();
|
||||
bar();
|
||||
@@ -1 +1 @@
|
||||
while(true)x();
|
||||
while(true)x();
|
||||
@@ -1,3 +1,3 @@
|
||||
x | y ^ z;
|
||||
x | y ^ z;
|
||||
(x | y) ^ z;
|
||||
(x | y) ^ z;
|
||||
@@ -1,2 +1,2 @@
|
||||
1.1.valueOf();
|
||||
1e+300.valueOf();
|
||||
1e+300.valueOf();
|
||||
@@ -2,4 +2,4 @@
|
||||
2..toString();
|
||||
0x1F7.toString();
|
||||
0b111110111.toString();
|
||||
0o767.toString();
|
||||
0o767.toString();
|
||||
@@ -9,4 +9,4 @@ new a().test;
|
||||
new (a().test)();
|
||||
new (a().b.c)();
|
||||
new a().b.c();
|
||||
new (a.b().c.d)();
|
||||
new (a.b().c.d)();
|
||||
@@ -1,3 +1,3 @@
|
||||
dejavu.Class.declare({
|
||||
method2: function () {}
|
||||
});
|
||||
});
|
||||
@@ -3,4 +3,4 @@ return(
|
||||
|
||||
l);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,4 @@ function foo() {
|
||||
return (
|
||||
1 && 2 ||
|
||||
3);
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,4 @@ delete delete i;
|
||||
+ +i;
|
||||
!!i;
|
||||
+ ++i;
|
||||
- --i;
|
||||
- --i;
|
||||
@@ -1,4 +1,4 @@
|
||||
var fact5 = function fact(n) {
|
||||
if (n <= 1) return 1;
|
||||
return n * fact(n - 1);
|
||||
}(5);
|
||||
}(5);
|
||||
@@ -1 +1 @@
|
||||
"\u00A9";
|
||||
"\u00A9";
|
||||
@@ -3,4 +3,4 @@ var a: ?number[];
|
||||
var a: (?number)[];
|
||||
var a: () => number[];
|
||||
var a: (() => number)[];
|
||||
var a: typeof A[];
|
||||
var a: typeof A[];
|
||||
@@ -1,2 +1,2 @@
|
||||
var foo: true;
|
||||
var bar: false;
|
||||
var bar: false;
|
||||
@@ -22,3 +22,11 @@ declare module B {
|
||||
declare export type B = {};
|
||||
declare export interface Moon {}
|
||||
}
|
||||
|
||||
declare module "foo" { declare export type * from "bar"; }
|
||||
declare export opaque type Foo;
|
||||
declare export opaque type Bar<T>;
|
||||
declare export opaque type Baz: Foo;
|
||||
declare export opaque type Foo<T>: Bar<T>;
|
||||
declare export opaque type Foo<T>: Bar;
|
||||
declare export opaque type Foo: Bar<T>;
|
||||
|
||||
@@ -29,4 +29,13 @@ declare export { c, d } from 'bar';
|
||||
declare module B {
|
||||
declare export type B = {};
|
||||
declare export interface Moon {}
|
||||
}
|
||||
}
|
||||
declare module "foo" {
|
||||
declare export type * from "bar";
|
||||
}
|
||||
declare export opaque type Foo;
|
||||
declare export opaque type Bar<T>;
|
||||
declare export opaque type Baz: Foo;
|
||||
declare export opaque type Foo<T>: Bar<T>;
|
||||
declare export opaque type Foo<T>: Bar;
|
||||
declare export opaque type Foo: Bar<T>;
|
||||
|
||||
@@ -19,3 +19,7 @@ declare type B = {
|
||||
declare interface I { foo: string }
|
||||
declare interface I<T> { foo: T }
|
||||
declare module.exports: { foo: string }
|
||||
declare opaque type Foo<T>: Bar<T>;
|
||||
declare opaque type ID;
|
||||
declare opaque type num: number;
|
||||
declare opaque type NumArray;
|
||||
|
||||
@@ -38,3 +38,7 @@ declare interface I<T> {
|
||||
declare module.exports: {
|
||||
foo: string
|
||||
}
|
||||
declare opaque type Foo<T>: Bar<T>;
|
||||
declare opaque type ID;
|
||||
declare opaque type num: number;
|
||||
declare opaque type NumArray;
|
||||
|
||||
1
packages/babel-generator/test/fixtures/flow/def-site-variance/options.json
vendored
Normal file
1
packages/babel-generator/test/fixtures/flow/def-site-variance/options.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{ "plugins": ["classProperties", "flow"] }
|
||||
@@ -1 +1 @@
|
||||
var foo: null;
|
||||
var foo: null;
|
||||
@@ -2,4 +2,4 @@ var a: 123;
|
||||
var a: 123.0;
|
||||
var a: 0x7B;
|
||||
var a: 0b1111011;
|
||||
var a: 0o173;
|
||||
var a: 0o173;
|
||||
14
packages/babel-generator/test/fixtures/flow/opaque-type-alias/actual.js
vendored
Normal file
14
packages/babel-generator/test/fixtures/flow/opaque-type-alias/actual.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
opaque type ID = string;
|
||||
opaque type Foo<T> = Bar<T>;
|
||||
opaque type Maybe<T> = _Maybe<T, *>;
|
||||
export opaque type Foo = number;
|
||||
|
||||
opaque type union =
|
||||
| {type: "A"}
|
||||
| {type: "B"}
|
||||
;
|
||||
|
||||
opaque type overloads =
|
||||
& ((x: string) => number)
|
||||
& ((x: number) => string)
|
||||
;
|
||||
10
packages/babel-generator/test/fixtures/flow/opaque-type-alias/expected.js
vendored
Normal file
10
packages/babel-generator/test/fixtures/flow/opaque-type-alias/expected.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
opaque type ID = string;
|
||||
opaque type Foo<T> = Bar<T>;
|
||||
opaque type Maybe<T> = _Maybe<T, *>;
|
||||
export opaque type Foo = number;
|
||||
opaque type union = {
|
||||
type: "A"
|
||||
} | {
|
||||
type: "B"
|
||||
};
|
||||
opaque type overloads = (x: string) => number & (x: number) => string;
|
||||
1
packages/babel-generator/test/fixtures/flow/options.json
vendored
Normal file
1
packages/babel-generator/test/fixtures/flow/options.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{ "plugins": ["flow"] }
|
||||
17
packages/babel-generator/test/fixtures/flow/predicates/actual.js
vendored
Normal file
17
packages/babel-generator/test/fixtures/flow/predicates/actual.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
declare function foo(x: mixed): boolean %checks(x !== null);
|
||||
|
||||
declare function my_filter<T, P: $Pred<1>>(v: Array<T>, cb: P): Array<$Refine<T,P,1>>;
|
||||
|
||||
declare function f2(x: mixed): string %checks(Array.isArray(x));
|
||||
|
||||
function foo(x: mixed): %checks { return typeof x === "string"; }
|
||||
|
||||
function is_string(x): boolean %checks {
|
||||
return typeof x === "string";
|
||||
}
|
||||
|
||||
var f = (x: mixed): %checks => typeof x === "string";
|
||||
|
||||
const foo = (x: mixed): boolean %checks => typeof x === "string";
|
||||
|
||||
(x): %checks => x !== null;
|
||||
17
packages/babel-generator/test/fixtures/flow/predicates/expected.js
vendored
Normal file
17
packages/babel-generator/test/fixtures/flow/predicates/expected.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
declare function foo(x: mixed): boolean %checks(x !== null);
|
||||
declare function my_filter<T, P: $Pred<1>>(v: Array<T>, cb: P): Array<$Refine<T, P, 1>>;
|
||||
declare function f2(x: mixed): string %checks(Array.isArray(x));
|
||||
|
||||
function foo(x: mixed): %checks {
|
||||
return typeof x === "string";
|
||||
}
|
||||
|
||||
function is_string(x): boolean %checks {
|
||||
return typeof x === "string";
|
||||
}
|
||||
|
||||
var f = (x: mixed): %checks => typeof x === "string";
|
||||
|
||||
const foo = (x: mixed): boolean %checks => typeof x === "string";
|
||||
|
||||
x: %checks => x !== null;
|
||||
@@ -1,4 +1,4 @@
|
||||
var a: A.B;
|
||||
var a: A.B.C;
|
||||
var a: A.B<T>;
|
||||
var a: typeof A.B<T>;
|
||||
var a: typeof A.B<T>;
|
||||
@@ -1,4 +1,4 @@
|
||||
var a: [] = [];
|
||||
var a: [Foo<T>] = [foo];
|
||||
var a: [number] = [123];
|
||||
var a: [number, string] = [123, "duck"];
|
||||
var a: [number, string] = [123, "duck"];
|
||||
@@ -123,3 +123,4 @@ var a: {| subtract: (x: number, ...y: Array<string>) => void |};
|
||||
var a: {| id<T>(x: T): T; |};
|
||||
function foo(numVal: number = 2) {}
|
||||
function foo(numVal?: number = 2) {}
|
||||
export type * from "foo";
|
||||
|
||||
@@ -286,4 +286,6 @@ var a: {|
|
||||
|
||||
function foo(numVal: number = 2) {}
|
||||
|
||||
function foo(numVal?: number = 2) {}
|
||||
function foo(numVal?: number = 2) {}
|
||||
|
||||
export type * from "foo";
|
||||
@@ -36,4 +36,4 @@ var a: {
|
||||
var a: {
|
||||
[a: number]: string,
|
||||
[b: number]: string,
|
||||
};
|
||||
};
|
||||
1
packages/babel-generator/test/fixtures/flowUsesCommas/ObjectExpression/options.json
vendored
Normal file
1
packages/babel-generator/test/fixtures/flowUsesCommas/ObjectExpression/options.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{ "plugins": ["flow"] }
|
||||
@@ -1 +1 @@
|
||||
export default class {}
|
||||
export default class {}
|
||||
@@ -1 +1 @@
|
||||
export default function () {}
|
||||
export default function () {}
|
||||
@@ -1 +1 @@
|
||||
export default (function () {})();
|
||||
export default (function () {})();
|
||||
@@ -1 +1 @@
|
||||
export default (class {})();
|
||||
export default (class {})();
|
||||
@@ -1 +1 @@
|
||||
export default class Foo {}
|
||||
export default class Foo {}
|
||||
@@ -1 +1 @@
|
||||
export default function foo() {}
|
||||
export default function foo() {}
|
||||
@@ -1 +1 @@
|
||||
export default {};
|
||||
export default {};
|
||||
@@ -7,4 +7,4 @@ export default i = 20;
|
||||
export function test() {}
|
||||
export class test2 {}
|
||||
export var j = 20;
|
||||
export let k = 42;
|
||||
export let k = 42;
|
||||
@@ -2,4 +2,4 @@ function test() {
|
||||
for (var i of array) {}
|
||||
|
||||
for (let i of array) {}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
import foo from "foo";
|
||||
import * as foo from "foo";
|
||||
import ok, { foo as bar, test as testing, logging } from "foo";
|
||||
import ok, { foo as bar, test as testing, logging } from "foo";
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user