Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d329156ebc | ||
|
|
25b35261ca | ||
|
|
563874c06c | ||
|
|
b0acfb24dd | ||
|
|
599d2ff324 | ||
|
|
0856618ed5 | ||
|
|
bc0966a46f | ||
|
|
3498195ae2 | ||
|
|
fbf3cb0ac4 | ||
|
|
e6264a0992 | ||
|
|
0b37ab0362 | ||
|
|
57ae306457 | ||
|
|
fa5a40c8d5 | ||
|
|
a219b6de7a | ||
|
|
fa5057f9fb | ||
|
|
02f2d17e83 | ||
|
|
b351f29033 | ||
|
|
298c9a6c33 | ||
|
|
80d99b4d4e | ||
|
|
94fcabc4e3 | ||
|
|
5f1970433d | ||
|
|
b459f6a0a4 | ||
|
|
66062c2a8c | ||
|
|
8d4f95de45 | ||
|
|
d0f093e716 | ||
|
|
490798a26d | ||
|
|
eaa1474541 | ||
|
|
0e9502685a | ||
|
|
26be14b24d | ||
|
|
6f3460c767 | ||
|
|
cc080417b9 | ||
|
|
a00f371610 | ||
|
|
af66d521bd |
@@ -24,4 +24,6 @@ suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore
|
||||
suppress_type=$FlowFixMe
|
||||
suppress_type=$FlowSubtype
|
||||
esproposal.export_star_as=enable
|
||||
esproposal.optional_chaining=enable
|
||||
esproposal.nullish_coalescing=enable
|
||||
module.name_mapper='^@babel\/\([a-zA-Z0-9_\-]+\)$' -> '<PROJECT_ROOT>/packages/babel-\1/src/index'
|
||||
|
||||
2
.github/lock.yml
vendored
2
.github/lock.yml
vendored
@@ -4,7 +4,7 @@
|
||||
daysUntilLock: 91
|
||||
# Comment to post before locking. Set to `false` to disable
|
||||
lockComment: false
|
||||
only: issues
|
||||
# The label to be applied when an issue is locked
|
||||
lockLabel: 'outdated'
|
||||
|
||||
# Issues or pull requests with these labels will not be locked
|
||||
|
||||
42
.travis.yml
42
.travis.yml
@@ -3,41 +3,43 @@ git:
|
||||
language: node_js
|
||||
cache:
|
||||
yarn: true
|
||||
node_js:
|
||||
# We test the latest version on circleci
|
||||
- '11'
|
||||
- '10'
|
||||
- '8'
|
||||
- '6'
|
||||
|
||||
os: linux
|
||||
|
||||
env:
|
||||
global:
|
||||
- PATH=$HOME/.yarn/bin:$PATH
|
||||
- JOB=test
|
||||
|
||||
before_install:
|
||||
- curl -o- -L https://yarnpkg.com/install.sh | bash
|
||||
|
||||
install:
|
||||
# the `make test-ci` script runs this command already
|
||||
- if [ "$JOB" != "test" ] && [ "$JOB" != "lint" ]; then yarn install; fi
|
||||
- if [ "$JOB" = "lint" ]; then make bootstrap; fi
|
||||
|
||||
install: skip
|
||||
before_script:
|
||||
- if [ "$JOB" = "babel-parser-flow-tests" ]; then make bootstrap-flow; fi
|
||||
- if [ "$JOB" = "babel-parser-test262-tests" ]; then make bootstrap-test262; fi
|
||||
- curl -o- -L https://yarnpkg.com/install.sh | bash
|
||||
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install make; fi
|
||||
|
||||
script:
|
||||
- if [ "$JOB" = "test" ]; then make test-ci; fi
|
||||
- if [ "$JOB" = "lint" ]; then make lint && make flow; fi
|
||||
- if [ "$JOB" = "babel-parser-flow-tests" ]; then make test-flow-ci; fi
|
||||
- if [ "$JOB" = "babel-parser-test262-tests" ]; then make test-test262-ci; fi
|
||||
- if [ "$JOB" = "test" ]; then make -j test-ci; fi
|
||||
- if [ "$JOB" = "lint" ]; then make -j code-quality-ci; fi
|
||||
- if [ "$JOB" = "babel-parser-flow-tests" ]; then make -j test-flow-ci; fi
|
||||
- if [ "$JOB" = "babel-parser-test262-tests" ]; then make -j test-test262-ci; fi
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- node_js: "node"
|
||||
env: JOB=lint
|
||||
# We test the latest version on circleci
|
||||
- node_js: "11"
|
||||
# Move `windows` build to be the third since it is slow
|
||||
- os: windows
|
||||
node_js: "node"
|
||||
env:
|
||||
- JOB=test
|
||||
# https://travis-ci.community/t/build-doesnt-finish-after-completing-tests/288/9
|
||||
- YARN_GPG=no
|
||||
# Continue node_js matrix
|
||||
- node_js: "6"
|
||||
- node_js: "10"
|
||||
- node_js: "8"
|
||||
- node_js: "node"
|
||||
env: JOB=babel-parser-flow-tests
|
||||
- node_js: "node"
|
||||
|
||||
40
CHANGELOG.md
40
CHANGELOG.md
@@ -17,6 +17,46 @@ See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0
|
||||
|
||||
<!-- DO NOT CHANGE THESE COMMENTS - See .github/actions/trigger-github-release/update-changelog.js -->
|
||||
<!-- insert-new-changelog-here -->
|
||||
## v7.6.2 (2019-09-23)
|
||||
|
||||
#### :eyeglasses: Spec Compliance
|
||||
* `babel-parser`
|
||||
* [#10472](https://github.com/babel/babel/pull/10472) added check to disallow super.private variable access and test case added. ([@vivek12345](https://github.com/vivek12345))
|
||||
* [#10468](https://github.com/babel/babel/pull/10468) [parser] Disallow numeric separator in unicode scape sequences. ([@ivandevp](https://github.com/ivandevp))
|
||||
* [#10467](https://github.com/babel/babel/pull/10467) [parser] Invalid NonOctal Decimal. ([@gonzarodriguezt](https://github.com/gonzarodriguezt))
|
||||
* [#10461](https://github.com/babel/babel/pull/10461) [parser] Disallow static fields named `constructor`. ([@guywaldman](https://github.com/guywaldman))
|
||||
* [#10455](https://github.com/babel/babel/pull/10455) [parser] Report escapes in kws only if they won't be used as identifiers. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-parser`
|
||||
* [#10445](https://github.com/babel/babel/pull/10445) Leave trailing comments after handling a possible trailing comma. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-cli`
|
||||
* [#10400](https://github.com/babel/babel/pull/10400) fix: allow the process to exit naturally. ([@JLHwung](https://github.com/JLHwung))
|
||||
* `babel-core`
|
||||
* [#10402](https://github.com/babel/babel/pull/10402) fix: pass optionLoc when validating plugin object. ([@JLHwung](https://github.com/JLHwung))
|
||||
* `babel-plugin-transform-block-scoping`, `babel-plugin-transform-spread`, `babel-traverse`
|
||||
* [#10417](https://github.com/babel/babel/pull/10417) Do not guess relative execution status for exported fns. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
|
||||
* [#10275](https://github.com/babel/babel/pull/10275) fix object rest in array pattern. ([@tanhauhau](https://github.com/tanhauhau))
|
||||
|
||||
#### :house: Internal
|
||||
* `babel-plugin-transform-named-capturing-groups-regex`
|
||||
* [#10430](https://github.com/babel/babel/pull/10430) refactor: replace regexp-tree by regexpu. ([@JLHwung](https://github.com/JLHwung))
|
||||
* Other
|
||||
* [#10441](https://github.com/babel/babel/pull/10441) Update GitHub actions to v2. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* [#10427](https://github.com/babel/babel/pull/10427) chore: add lint-ts rule. ([@JLHwung](https://github.com/JLHwung))
|
||||
* `babel-helper-fixtures`
|
||||
* [#10428](https://github.com/babel/babel/pull/10428) chore: remove tryResolve dependency. ([@JLHwung](https://github.com/JLHwung))
|
||||
* `babel-node`
|
||||
* [#10429](https://github.com/babel/babel/pull/10429) Remove babel polyfill dependency of babel-node. ([@bdwain](https://github.com/bdwain))
|
||||
* `babel-generator`, `babel-helper-fixtures`
|
||||
* [#10420](https://github.com/babel/babel/pull/10420) chore: remove trim-right dependency. ([@JLHwung](https://github.com/JLHwung))
|
||||
* `babel-core`, `babel-plugin-transform-runtime`, `babel-register`
|
||||
* [#10405](https://github.com/babel/babel/pull/10405) Remove circular dependency. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
#### :running_woman: Performance
|
||||
* `babel-parser`
|
||||
* [#10421](https://github.com/babel/babel/pull/10421) Miscellaneous perf tweak. ([@JLHwung](https://github.com/JLHwung))
|
||||
|
||||
## v7.6.1 (2019-09-06)
|
||||
|
||||
|
||||
56
Gulpfile.js
56
Gulpfile.js
@@ -11,25 +11,20 @@ const filter = require("gulp-filter");
|
||||
const gulp = require("gulp");
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
const merge = require("merge-stream");
|
||||
const rollup = require("rollup");
|
||||
const rollupBabel = require("rollup-plugin-babel");
|
||||
const rollupNodeResolve = require("rollup-plugin-node-resolve");
|
||||
const rollupReplace = require("rollup-plugin-replace");
|
||||
const { registerStandalonePackageTask } = require("./scripts/gulp-tasks");
|
||||
|
||||
const sources = ["codemods", "packages"];
|
||||
const defaultSourcesGlob = "./@(codemods|packages)/*/src/**/*.js";
|
||||
|
||||
function swapSrcWithLib(srcPath) {
|
||||
const parts = srcPath.split(path.sep);
|
||||
parts[1] = "lib";
|
||||
parts[2] = "lib";
|
||||
return parts.join(path.sep);
|
||||
}
|
||||
|
||||
function getGlobFromSource(source) {
|
||||
return `./${source}/*/src/**/*.js`;
|
||||
}
|
||||
|
||||
function getIndexFromPackage(name) {
|
||||
return `${name}/src/index.js`;
|
||||
}
|
||||
@@ -56,32 +51,28 @@ function rename(fn) {
|
||||
});
|
||||
}
|
||||
|
||||
function buildBabel(exclude) {
|
||||
return merge(
|
||||
sources.map(source => {
|
||||
const base = path.join(__dirname, source);
|
||||
function buildBabel(exclude, sourcesGlob = defaultSourcesGlob) {
|
||||
const base = __dirname;
|
||||
|
||||
let stream = gulp.src(getGlobFromSource(source), { base: base });
|
||||
let stream = gulp.src(sourcesGlob, { base: __dirname });
|
||||
|
||||
if (exclude) {
|
||||
const filters = exclude.map(p => `!**/${p}/**`);
|
||||
filters.unshift("**");
|
||||
stream = stream.pipe(filter(filters));
|
||||
}
|
||||
if (exclude) {
|
||||
const filters = exclude.map(p => `!**/${p}/**`);
|
||||
filters.unshift("**");
|
||||
stream = stream.pipe(filter(filters));
|
||||
}
|
||||
|
||||
return stream
|
||||
.pipe(errorsLogger())
|
||||
.pipe(newer({ dest: base, map: swapSrcWithLib }))
|
||||
.pipe(compilationLogger())
|
||||
.pipe(babel())
|
||||
.pipe(
|
||||
// Passing 'file.relative' because newer() above uses a relative
|
||||
// path and this keeps it consistent.
|
||||
rename(file => path.resolve(file.base, swapSrcWithLib(file.relative)))
|
||||
)
|
||||
.pipe(gulp.dest(base));
|
||||
})
|
||||
);
|
||||
return stream
|
||||
.pipe(errorsLogger())
|
||||
.pipe(newer({ dest: base, map: swapSrcWithLib }))
|
||||
.pipe(compilationLogger())
|
||||
.pipe(babel())
|
||||
.pipe(
|
||||
// Passing 'file.relative' because newer() above uses a relative
|
||||
// path and this keeps it consistent.
|
||||
rename(file => path.resolve(file.base, swapSrcWithLib(file.relative)))
|
||||
)
|
||||
.pipe(gulp.dest(base));
|
||||
}
|
||||
|
||||
function buildRollup(packages) {
|
||||
@@ -118,6 +109,9 @@ const bundles = ["packages/babel-parser"];
|
||||
|
||||
gulp.task("build-rollup", () => buildRollup(bundles));
|
||||
gulp.task("build-babel", () => buildBabel(/* exclude */ bundles));
|
||||
gulp.task("build-babel-types", () =>
|
||||
buildBabel(/* exclude */ bundles, "packages/babel-types/src/**/*.js")
|
||||
);
|
||||
gulp.task("build", gulp.parallel("build-rollup", "build-babel"));
|
||||
|
||||
gulp.task("default", gulp.series("build"));
|
||||
@@ -128,7 +122,7 @@ gulp.task(
|
||||
"watch",
|
||||
gulp.series("build-no-bundle", function watch() {
|
||||
gulpWatch(
|
||||
sources.map(getGlobFromSource),
|
||||
defaultSourcesGlob,
|
||||
{ debounceDelay: 200 },
|
||||
gulp.task("build-no-bundle")
|
||||
);
|
||||
|
||||
185
Makefile
185
Makefile
@@ -1,6 +1,5 @@
|
||||
MAKEFLAGS = -j1
|
||||
FLOW_COMMIT = 09669846b7a7ca5a6c23c12d56bb3bebdafd67e9
|
||||
TEST262_COMMIT = ef7fd2bc27e7c10b4a71d2edc632a2934742a13e
|
||||
TEST262_COMMIT = 8688c4ab79059c3097098605e69f1ee5eda6c409
|
||||
|
||||
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
|
||||
export FORCE_COLOR = true
|
||||
@@ -9,64 +8,110 @@ SOURCES = packages codemods
|
||||
|
||||
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
|
||||
|
||||
build: clean clean-lib
|
||||
./node_modules/.bin/gulp build
|
||||
node ./packages/babel-standalone/scripts/generate.js
|
||||
node ./packages/babel-types/scripts/generateTypeHelpers.js
|
||||
# call build again as the generated files might need to be compiled again.
|
||||
./node_modules/.bin/gulp build
|
||||
# generate flow and typescript typings
|
||||
node packages/babel-types/scripts/generators/flow.js > ./packages/babel-types/lib/index.js.flow
|
||||
node packages/babel-types/scripts/generators/typescript.js > ./packages/babel-types/lib/index.d.ts
|
||||
build: build-bundle
|
||||
ifneq ("$(BABEL_COVERAGE)", "true")
|
||||
make build-standalone
|
||||
make build-preset-env-standalone
|
||||
$(MAKE) build-standalone
|
||||
endif
|
||||
|
||||
build-standalone:
|
||||
./node_modules/.bin/gulp build-babel-standalone
|
||||
build-bundle: clean clean-lib
|
||||
yarn gulp build
|
||||
$(MAKE) generate-standalone generate-type-helpers
|
||||
# call build again as the generated files might need to be compiled again.
|
||||
yarn gulp build
|
||||
$(MAKE) build-typings
|
||||
$(MAKE) build-dist
|
||||
|
||||
build-bundle-ci: bootstrap-only
|
||||
$(MAKE) build-bundle
|
||||
|
||||
generate-standalone:
|
||||
node packages/babel-standalone/scripts/generate.js
|
||||
|
||||
generate-type-helpers:
|
||||
node packages/babel-types/scripts/generateTypeHelpers.js
|
||||
|
||||
build-typings: build-flow-typings build-typescript-typings
|
||||
|
||||
build-flow-typings:
|
||||
node packages/babel-types/scripts/generators/flow.js > packages/babel-types/lib/index.js.flow
|
||||
|
||||
build-typescript-typings:
|
||||
node packages/babel-types/scripts/generators/typescript.js > packages/babel-types/lib/index.d.ts
|
||||
|
||||
build-standalone: build-babel-standalone build-preset-env-standalone
|
||||
|
||||
build-standalone-ci: build-bundle-ci
|
||||
$(MAKE) build-standalone
|
||||
|
||||
build-babel-standalone:
|
||||
yarn gulp build-babel-standalone
|
||||
|
||||
build-preset-env-standalone:
|
||||
./node_modules/.bin/gulp build-babel-preset-env-standalone
|
||||
yarn gulp build-babel-preset-env-standalone
|
||||
|
||||
prepublish-build-standalone:
|
||||
BABEL_ENV=production IS_PUBLISH=true ./node_modules/.bin/gulp build-babel-standalone
|
||||
BABEL_ENV=production IS_PUBLISH=true yarn gulp build-babel-standalone
|
||||
|
||||
prepublish-build-preset-env-standalone:
|
||||
BABEL_ENV=production IS_PUBLISH=true ./node_modules/.bin/gulp build-babel-preset-env-standalone
|
||||
BABEL_ENV=production IS_PUBLISH=true yarn gulp build-babel-preset-env-standalone
|
||||
|
||||
build-dist: build
|
||||
build-dist: build-polyfill-dist build-plugin-transform-runtime-dist
|
||||
|
||||
build-polyfill-dist:
|
||||
cd packages/babel-polyfill; \
|
||||
scripts/build-dist.sh
|
||||
|
||||
build-plugin-transform-runtime-dist:
|
||||
cd packages/babel-plugin-transform-runtime; \
|
||||
node scripts/build-dist.js
|
||||
|
||||
watch: clean clean-lib
|
||||
|
||||
build-no-bundle: clean clean-lib
|
||||
BABEL_ENV=development yarn gulp build-no-bundle
|
||||
# Ensure that build artifacts for types are created during local
|
||||
# development too.
|
||||
BABEL_ENV=development ./node_modules/.bin/gulp build-no-bundle
|
||||
node ./packages/babel-types/scripts/generateTypeHelpers.js
|
||||
node packages/babel-types/scripts/generators/flow.js > ./packages/babel-types/lib/index.js.flow
|
||||
node packages/babel-types/scripts/generators/typescript.js > ./packages/babel-types/lib/index.d.ts
|
||||
BABEL_ENV=development ./node_modules/.bin/gulp watch
|
||||
$(MAKE) generate-type-helpers
|
||||
$(MAKE) build-typings
|
||||
|
||||
watch: build-no-bundle
|
||||
BABEL_ENV=development yarn gulp watch
|
||||
|
||||
code-quality-ci: flowcheck-ci lint-ci
|
||||
|
||||
flowcheck-ci: bootstrap-flowcheck
|
||||
$(MAKE) flow
|
||||
|
||||
code-quality: flow lint
|
||||
|
||||
flow:
|
||||
./node_modules/.bin/flow check --strip-root
|
||||
yarn flow check --strip-root
|
||||
|
||||
bootstrap-flowcheck: bootstrap-only
|
||||
yarn gulp build-babel-types
|
||||
$(MAKE) build-typings
|
||||
|
||||
lint-ci: lint-js-ci lint-ts-ci
|
||||
|
||||
lint-js-ci: bootstrap-only
|
||||
$(MAKE) lint-js
|
||||
|
||||
lint-ts-ci: bootstrap-flowcheck
|
||||
$(MAKE) lint-ts
|
||||
|
||||
lint: lint-js lint-ts
|
||||
|
||||
lint-js:
|
||||
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe
|
||||
yarn eslint scripts $(SOURCES) '*.js' --format=codeframe
|
||||
|
||||
lint-ts:
|
||||
./scripts/tests/typescript/lint.sh
|
||||
scripts/tests/typescript/lint.sh
|
||||
|
||||
fix: fix-json
|
||||
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe --fix
|
||||
fix: fix-json fix-js
|
||||
|
||||
fix-js:
|
||||
yarn eslint scripts $(SOURCES) '*.js' --format=codeframe --fix
|
||||
|
||||
fix-json:
|
||||
./node_modules/.bin/prettier "{packages,codemod}/*/test/fixtures/**/options.json" --write --loglevel warn
|
||||
yarn prettier "{packages,codemod}/*/test/fixtures/**/options.json" --write --loglevel warn
|
||||
|
||||
clean: test-clean
|
||||
rm -f .npmrc
|
||||
@@ -79,72 +124,77 @@ test-clean:
|
||||
$(foreach source, $(SOURCES), \
|
||||
$(call clean-source-test, $(source)))
|
||||
|
||||
# Does not work on Windows; use "yarn jest" instead
|
||||
test-only:
|
||||
BABEL_ENV=test ./scripts/test.sh
|
||||
make test-clean
|
||||
$(MAKE) test-clean
|
||||
|
||||
test: lint test-only
|
||||
|
||||
test-ci: bootstrap test-only
|
||||
test-ci: jest-ci
|
||||
|
||||
jest-ci: build-standalone-ci
|
||||
BABEL_ENV=test yarn jest --maxWorkers=4 --ci
|
||||
$(MAKE) test-clean
|
||||
|
||||
# Does not work on Windows
|
||||
test-ci-coverage: SHELL:=/bin/bash
|
||||
test-ci-coverage:
|
||||
BABEL_COVERAGE=true BABEL_ENV=test make bootstrap
|
||||
BABEL_COVERAGE=true BABEL_ENV=test $(MAKE) bootstrap
|
||||
BABEL_ENV=test TEST_TYPE=cov ./scripts/test-cov.sh
|
||||
bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json
|
||||
|
||||
bootstrap-flow:
|
||||
rm -rf ./build/flow
|
||||
mkdir -p ./build
|
||||
git clone --branch=master --single-branch --shallow-since=2018-11-01 https://github.com/facebook/flow.git ./build/flow
|
||||
rm -rf build/flow
|
||||
mkdir -p build
|
||||
git clone --branch=master --single-branch --shallow-since=2018-11-01 https://github.com/facebook/flow.git build/flow
|
||||
cd build/flow && git checkout $(FLOW_COMMIT)
|
||||
|
||||
test-flow:
|
||||
node scripts/tests/flow/run_babel_parser_flow_tests.js
|
||||
|
||||
test-flow-ci: bootstrap test-flow
|
||||
test-flow-ci: build-bundle-ci bootstrap-flow
|
||||
$(MAKE) test-flow
|
||||
|
||||
test-flow-update-whitelist:
|
||||
node scripts/tests/flow/run_babel_parser_flow_tests.js --update-whitelist
|
||||
|
||||
bootstrap-test262:
|
||||
rm -rf ./build/test262
|
||||
mkdir -p ./build
|
||||
git clone --branch=master --single-branch --shallow-since=2019-01-01 https://github.com/tc39/test262.git ./build/test262
|
||||
rm -rf build/test262
|
||||
mkdir -p build
|
||||
git clone --branch=master --single-branch --shallow-since=2019-09-01 https://github.com/tc39/test262.git build/test262
|
||||
cd build/test262 && git checkout $(TEST262_COMMIT)
|
||||
|
||||
test-test262:
|
||||
node scripts/tests/test262/run_babel_parser_test262.js
|
||||
|
||||
test-test262-ci: bootstrap test-test262
|
||||
test-test262-ci: build-bundle-ci bootstrap-test262
|
||||
$(MAKE) test-test262
|
||||
|
||||
test-test262-update-whitelist:
|
||||
node scripts/tests/test262/run_babel_parser_test262.js --update-whitelist
|
||||
|
||||
# Does not work on Windows
|
||||
clone-license:
|
||||
./scripts/clone-license.sh
|
||||
|
||||
prepublish-build:
|
||||
make clean-lib
|
||||
rm -rf packages/babel-runtime/helpers
|
||||
rm -rf packages/babel-runtime-corejs2/helpers
|
||||
rm -rf packages/babel-runtime-corejs2/core-js
|
||||
NODE_ENV=production BABEL_ENV=production make build-dist
|
||||
make clone-license
|
||||
prepublish-build: clean-lib clean-runtime-helpers
|
||||
NODE_ENV=production BABEL_ENV=production $(MAKE) build-dist
|
||||
$(MAKE) clone-license
|
||||
|
||||
prepublish:
|
||||
make bootstrap-only
|
||||
make prepublish-build
|
||||
make test
|
||||
$(MAKE) bootstrap-only
|
||||
$(MAKE) prepublish-build
|
||||
$(MAKE) test
|
||||
|
||||
new-version:
|
||||
git pull --rebase
|
||||
./node_modules/.bin/lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone"
|
||||
yarn lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone"
|
||||
|
||||
# NOTE: Run make new-version first
|
||||
publish: prepublish
|
||||
./node_modules/.bin/lerna publish from-git --require-scripts
|
||||
make clean
|
||||
yarn lerna publish from-git --require-scripts
|
||||
$(MAKE) clean
|
||||
|
||||
publish-ci: prepublish
|
||||
ifneq ("$(NPM_TOKEN)", "")
|
||||
@@ -153,23 +203,30 @@ else
|
||||
echo "Missing NPM_TOKEN env var"
|
||||
exit 1
|
||||
endif
|
||||
./node_modules/.bin/lerna publish from-git --require-scripts --yes
|
||||
yarn lerna publish from-git --require-scripts --yes
|
||||
rm -f .npmrc
|
||||
make clean
|
||||
$(MAKE) clean
|
||||
|
||||
bootstrap-only: clean-all
|
||||
bootstrap-only: lerna-bootstrap
|
||||
|
||||
yarn-install: clean-all
|
||||
yarn --ignore-engines
|
||||
./node_modules/.bin/lerna bootstrap -- --ignore-engines
|
||||
|
||||
lerna-bootstrap: yarn-install
|
||||
yarn lerna bootstrap -- --ignore-engines
|
||||
|
||||
bootstrap: bootstrap-only
|
||||
make build
|
||||
cd packages/babel-plugin-transform-runtime; \
|
||||
node scripts/build-dist.js
|
||||
$(MAKE) build
|
||||
|
||||
clean-lib:
|
||||
$(foreach source, $(SOURCES), \
|
||||
$(call clean-source-lib, $(source)))
|
||||
|
||||
clean-runtime-helpers:
|
||||
rm -rf packages/babel-runtime/helpers
|
||||
rm -rf packages/babel-runtime-corejs2/helpers
|
||||
rm -rf packages/babel-runtime-corejs2/core-js
|
||||
|
||||
clean-all:
|
||||
rm -rf node_modules
|
||||
rm -rf package-lock.json
|
||||
@@ -178,7 +235,7 @@ clean-all:
|
||||
$(foreach source, $(SOURCES), \
|
||||
$(call clean-source-all, $(source)))
|
||||
|
||||
make clean
|
||||
$(MAKE) clean
|
||||
|
||||
define clean-source-lib
|
||||
rm -rf $(1)/*/lib
|
||||
|
||||
@@ -77,9 +77,10 @@ module.exports = function(api) {
|
||||
"@babel/proposal-object-rest-spread",
|
||||
{ useBuiltIns: true, loose: true },
|
||||
],
|
||||
"@babel/plugin-proposal-optional-chaining",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator",
|
||||
|
||||
// Explicitly use the lazy version of CommonJS modules.
|
||||
convertESM ? ["@babel/transform-modules-commonjs", { lazy: true }] : null,
|
||||
convertESM ? "@babel/transform-modules-commonjs" : null,
|
||||
].filter(Boolean),
|
||||
overrides: [
|
||||
{
|
||||
@@ -90,18 +91,17 @@ module.exports = function(api) {
|
||||
],
|
||||
},
|
||||
{
|
||||
test: "./packages/babel-register",
|
||||
test: ["./packages/babel-cli", "./packages/babel-core"],
|
||||
plugins: [
|
||||
// Override the root options to disable lazy imports for babel-register
|
||||
// because otherwise the require hook will try to lazy-import things
|
||||
// leading to dependency cycles.
|
||||
convertESM ? "@babel/transform-modules-commonjs" : null,
|
||||
// Explicitly use the lazy version of CommonJS modules.
|
||||
convertESM
|
||||
? ["@babel/transform-modules-commonjs", { lazy: true }]
|
||||
: null,
|
||||
].filter(Boolean),
|
||||
},
|
||||
{
|
||||
test: "./packages/babel-polyfill",
|
||||
presets: [["@babel/env", envOptsNoTargets]],
|
||||
plugins: [["@babel/transform-modules-commonjs", { lazy: false }]],
|
||||
},
|
||||
{
|
||||
// The vast majority of our src files are modules, but we use
|
||||
|
||||
@@ -15,7 +15,7 @@ This is quite taboo but let's look at the pros and cons:
|
||||
* Easy to coordinate changes across modules.
|
||||
* Single place to report issues.
|
||||
* Easier to setup a development environment.
|
||||
* Tests across modules are run together which finds bugs that touch multiple modules easier.
|
||||
* Tests across modules are run together which finds bugs that touch multiple modules more easily.
|
||||
|
||||
**Cons:**
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "7.6.2",
|
||||
"version": "7.6.3",
|
||||
"changelog": {
|
||||
"repo": "babel/babel",
|
||||
"cacheDir": ".changelog",
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
"@babel/eslint-plugin-development": "^1.0.1",
|
||||
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
||||
"@babel/plugin-proposal-export-namespace-from": "^7.5.2",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
|
||||
"@babel/plugin-proposal-numeric-separator": "^7.2.0",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.6.0",
|
||||
"@babel/plugin-transform-runtime": "^7.6.0",
|
||||
"@babel/preset-env": "^7.6.0",
|
||||
@@ -22,7 +24,7 @@
|
||||
"@babel/register": "^7.6.0",
|
||||
"@babel/runtime": "^7.6.0",
|
||||
"babel-eslint": "^11.0.0-beta.0",
|
||||
"babel-jest": "^24.8.0",
|
||||
"babel-jest": "^24.9.0",
|
||||
"babel-loader": "^8.0.6",
|
||||
"babel-plugin-transform-charcodes": "^0.2.0",
|
||||
"browserify": "^16.2.3",
|
||||
@@ -38,7 +40,7 @@
|
||||
"eslint-plugin-import": "^2.17.2",
|
||||
"eslint-plugin-prettier": "^3.1.0",
|
||||
"fancy-log": "^1.3.3",
|
||||
"flow-bin": "^0.102.0",
|
||||
"flow-bin": "^0.108.0",
|
||||
"graceful-fs": "^4.1.15",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-babel": "^8.0.0",
|
||||
@@ -49,12 +51,11 @@
|
||||
"gulp-uglify": "^3.0.2",
|
||||
"gulp-watch": "^5.0.1",
|
||||
"husky": "^3.0.0",
|
||||
"jest": "^24.8.0",
|
||||
"jest": "^24.9.0",
|
||||
"lerna": "^3.16.0",
|
||||
"lerna-changelog": "^0.5.0",
|
||||
"lint-staged": "^9.2.0",
|
||||
"lodash": "^4.17.13",
|
||||
"merge-stream": "^1.0.1",
|
||||
"output-file-sync": "^2.0.0",
|
||||
"prettier": "^1.17.1",
|
||||
"pump": "^3.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/cli",
|
||||
"version": "7.6.2",
|
||||
"version": "7.6.3",
|
||||
"description": "Babel command line.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -27,7 +27,7 @@
|
||||
"mkdirp": "^0.5.1",
|
||||
"output-file-sync": "^2.0.0",
|
||||
"slash": "^2.0.0",
|
||||
"source-map": "^0.5.0"
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"chokidar": "^2.1.8"
|
||||
@@ -36,8 +36,8 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.6.2",
|
||||
"@babel/helper-fixtures": "^7.6.2"
|
||||
"@babel/core": "^7.6.3",
|
||||
"@babel/helper-fixtures": "^7.6.3"
|
||||
},
|
||||
"bin": {
|
||||
"babel": "./bin/babel.js",
|
||||
|
||||
5
packages/babel-cli/test/fixtures/babel/stdin --filename windows/options.json
vendored
Normal file
5
packages/babel-cli/test/fixtures/babel/stdin --filename windows/options.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"args": ["--filename", "test.js"],
|
||||
"stderrContains": true,
|
||||
"os": ["win32"]
|
||||
}
|
||||
1
packages/babel-cli/test/fixtures/babel/stdin --filename windows/stderr.txt
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/stdin --filename windows/stderr.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
SyntaxError: <CWD>\test.js: Unexpected token, expected ";" (2:10)
|
||||
3
packages/babel-cli/test/fixtures/babel/stdin --filename windows/stdin.txt
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/stdin --filename windows/stdin.txt
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
arr.map(function () {
|
||||
return $]!;
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"args": ["--filename", "test.js"],
|
||||
"stderrContains": true
|
||||
"stderrContains": true,
|
||||
"os": ["linux", "darwin"]
|
||||
}
|
||||
|
||||
@@ -185,7 +185,29 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
|
||||
};
|
||||
|
||||
const optionsLoc = path.join(testLoc, "options.json");
|
||||
if (fs.existsSync(optionsLoc)) merge(opts, require(optionsLoc));
|
||||
if (fs.existsSync(optionsLoc)) {
|
||||
const taskOpts = require(optionsLoc);
|
||||
if (taskOpts.os) {
|
||||
let os = taskOpts.os;
|
||||
|
||||
if (!Array.isArray(os) && typeof os !== "string") {
|
||||
throw new Error(
|
||||
`'os' should be either string or string array: ${taskOpts.os}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof os === "string") {
|
||||
os = [os];
|
||||
}
|
||||
|
||||
if (!os.includes(process.platform)) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete taskOpts.os;
|
||||
}
|
||||
merge(opts, taskOpts);
|
||||
}
|
||||
|
||||
["stdout", "stdin", "stderr"].forEach(function(key) {
|
||||
const loc = path.join(testLoc, key + ".txt");
|
||||
@@ -205,7 +227,7 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
|
||||
opts.inFiles[".babelrc"] = helper.readFile(babelrcLoc);
|
||||
}
|
||||
|
||||
it(testName, buildTest(binName, testName, opts));
|
||||
it(testName, buildTest(binName, testName, opts), 20000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/core",
|
||||
"version": "7.6.2",
|
||||
"version": "7.6.3",
|
||||
"description": "Babel compiler core.",
|
||||
"main": "lib/index.js",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
@@ -34,21 +34,21 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.5.5",
|
||||
"@babel/generator": "^7.6.2",
|
||||
"@babel/generator": "^7.6.3",
|
||||
"@babel/helpers": "^7.6.2",
|
||||
"@babel/parser": "^7.6.2",
|
||||
"@babel/parser": "^7.6.3",
|
||||
"@babel/template": "^7.6.0",
|
||||
"@babel/traverse": "^7.6.2",
|
||||
"@babel/types": "^7.6.0",
|
||||
"@babel/traverse": "^7.6.3",
|
||||
"@babel/types": "^7.6.3",
|
||||
"convert-source-map": "^1.1.0",
|
||||
"debug": "^4.1.0",
|
||||
"json5": "^2.1.0",
|
||||
"lodash": "^4.17.13",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.4.1",
|
||||
"source-map": "^0.5.0"
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-transform-fixture-test-runner": "^7.6.0"
|
||||
"@babel/helper-transform-fixture-test-runner": "^7.6.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,6 +345,7 @@ function assertNoDuplicates(items: Array<UnloadedDescriptor>): void {
|
||||
}
|
||||
|
||||
if (nameMap.has(item.name)) {
|
||||
const conflicts = items.filter(i => i.value === item.value);
|
||||
throw new Error(
|
||||
[
|
||||
`Duplicate plugin/preset detected.`,
|
||||
@@ -355,6 +356,9 @@ function assertNoDuplicates(items: Array<UnloadedDescriptor>): void {
|
||||
` ['some-plugin', {}],`,
|
||||
` ['some-plugin', {}, 'some unique name'],`,
|
||||
` ]`,
|
||||
``,
|
||||
`Duplicates detected are:`,
|
||||
`${JSON.stringify(conflicts, null, 2)}`,
|
||||
].join("\n"),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ export default class File {
|
||||
): Error {
|
||||
let loc = node && (node.loc || node._loc);
|
||||
|
||||
msg = `${this.opts.filename}: ${msg}`;
|
||||
msg = `${this.opts.filename ?? "unknown"}: ${msg}`;
|
||||
|
||||
if (!loc && node) {
|
||||
const state = {
|
||||
|
||||
@@ -41,7 +41,7 @@ export default function generateCode(
|
||||
|
||||
if (typeof result.then === "function") {
|
||||
throw new Error(
|
||||
`You appear to be using an async parser plugin, ` +
|
||||
`You appear to be using an async codegen plugin, ` +
|
||||
`which your current version of Babel does not support. ` +
|
||||
`If you're using a published plugin, ` +
|
||||
`you may need to upgrade your @babel/core version.`,
|
||||
|
||||
@@ -55,11 +55,29 @@ export function runSync(
|
||||
ast,
|
||||
);
|
||||
|
||||
transformFile(file, config.passes);
|
||||
|
||||
const opts = file.opts;
|
||||
const { outputCode, outputMap } =
|
||||
opts.code !== false ? generateCode(config.passes, file) : {};
|
||||
try {
|
||||
transformFile(file, config.passes);
|
||||
} catch (e) {
|
||||
e.message = `${opts.filename ?? "unknown"}: ${e.message}`;
|
||||
if (!e.code) {
|
||||
e.code = "BABEL_TRANSFORM_ERROR";
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
let outputCode, outputMap;
|
||||
try {
|
||||
if (opts.code !== false) {
|
||||
({ outputCode, outputMap } = generateCode(config.passes, file));
|
||||
}
|
||||
} catch (e) {
|
||||
e.message = `${opts.filename ?? "unknown"}: ${e.message}`;
|
||||
if (!e.code) {
|
||||
e.code = "BABEL_GENERATE_ERROR";
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
return {
|
||||
metadata: file.metadata,
|
||||
|
||||
@@ -107,7 +107,7 @@ function parser(
|
||||
} else if (results.length === 1) {
|
||||
if (typeof results[0].then === "function") {
|
||||
throw new Error(
|
||||
`You appear to be using an async codegen plugin, ` +
|
||||
`You appear to be using an async parser plugin, ` +
|
||||
`which your current version of Babel does not support. ` +
|
||||
`If you're using a published plugin, you may need to upgrade ` +
|
||||
`your @babel/core version.`,
|
||||
@@ -121,6 +121,7 @@ function parser(
|
||||
err.message +=
|
||||
"\nConsider renaming the file to '.mjs', or setting sourceType:module " +
|
||||
"or sourceType:unambiguous in your Babel config for this file.";
|
||||
// err.code will be changed to BABEL_PARSE_ERROR later.
|
||||
}
|
||||
|
||||
const { loc, missingPlugin } = err;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import escapeRegExp from "lodash/escapeRegExp";
|
||||
import { loadOptions as loadOptionsOrig } from "../lib";
|
||||
|
||||
function fixture(...args) {
|
||||
@@ -33,7 +34,7 @@ describe("buildConfigChain", function() {
|
||||
cwd: fixture("nonexistant-fake"),
|
||||
filename: fixture("nonexistant-fake", "src.js"),
|
||||
babelrc: false,
|
||||
test: new RegExp(fixture("nonexistant-fake")),
|
||||
test: new RegExp(escapeRegExp(fixture("nonexistant-fake"))),
|
||||
comments: true,
|
||||
});
|
||||
|
||||
@@ -69,7 +70,7 @@ describe("buildConfigChain", function() {
|
||||
cwd: fixture("nonexistant-fake"),
|
||||
filename: fixture("nonexistant-fake", "src.js"),
|
||||
babelrc: false,
|
||||
test: new RegExp(fixture("nonexistant-unknown")),
|
||||
test: new RegExp(escapeRegExp(fixture("nonexistant-unknown"))),
|
||||
comments: true,
|
||||
});
|
||||
|
||||
@@ -107,7 +108,7 @@ describe("buildConfigChain", function() {
|
||||
cwd: fixture("nonexistant-fake"),
|
||||
filename: fixture("nonexistant-fake", "src.js"),
|
||||
babelrc: false,
|
||||
test: [new RegExp(fixture("nonexistant-fake"))],
|
||||
test: [new RegExp(escapeRegExp(fixture("nonexistant-fake")))],
|
||||
comments: true,
|
||||
});
|
||||
|
||||
@@ -143,7 +144,7 @@ describe("buildConfigChain", function() {
|
||||
cwd: fixture("nonexistant-fake"),
|
||||
filename: fixture("nonexistant-fake", "src.js"),
|
||||
babelrc: false,
|
||||
test: [new RegExp(fixture("nonexistant-unknown"))],
|
||||
test: [new RegExp(escapeRegExp(fixture("nonexistant-unknown")))],
|
||||
comments: true,
|
||||
});
|
||||
|
||||
@@ -183,7 +184,7 @@ describe("buildConfigChain", function() {
|
||||
cwd: fixture("nonexistant-fake"),
|
||||
filename: fixture("nonexistant-fake", "src.js"),
|
||||
babelrc: false,
|
||||
include: new RegExp(fixture("nonexistant-fake")),
|
||||
include: new RegExp(escapeRegExp(fixture("nonexistant-fake"))),
|
||||
comments: true,
|
||||
});
|
||||
|
||||
@@ -219,7 +220,7 @@ describe("buildConfigChain", function() {
|
||||
cwd: fixture("nonexistant-fake"),
|
||||
filename: fixture("nonexistant-fake", "src.js"),
|
||||
babelrc: false,
|
||||
include: new RegExp(fixture("nonexistant-unknown")),
|
||||
include: new RegExp(escapeRegExp(fixture("nonexistant-unknown"))),
|
||||
comments: true,
|
||||
});
|
||||
|
||||
@@ -257,7 +258,7 @@ describe("buildConfigChain", function() {
|
||||
cwd: fixture("nonexistant-fake"),
|
||||
filename: fixture("nonexistant-fake", "src.js"),
|
||||
babelrc: false,
|
||||
include: [new RegExp(fixture("nonexistant-fake"))],
|
||||
include: [new RegExp(escapeRegExp(fixture("nonexistant-fake")))],
|
||||
comments: true,
|
||||
});
|
||||
|
||||
@@ -293,7 +294,7 @@ describe("buildConfigChain", function() {
|
||||
cwd: fixture("nonexistant-fake"),
|
||||
filename: fixture("nonexistant-fake", "src.js"),
|
||||
babelrc: false,
|
||||
include: [new RegExp(fixture("nonexistant-unknown"))],
|
||||
include: [new RegExp(escapeRegExp(fixture("nonexistant-unknown")))],
|
||||
comments: true,
|
||||
});
|
||||
|
||||
@@ -333,7 +334,7 @@ describe("buildConfigChain", function() {
|
||||
cwd: fixture("nonexistant-fake"),
|
||||
filename: fixture("nonexistant-fake", "src.js"),
|
||||
babelrc: false,
|
||||
exclude: new RegExp(fixture("nonexistant-fake")),
|
||||
exclude: new RegExp(escapeRegExp(fixture("nonexistant-fake"))),
|
||||
comments: true,
|
||||
});
|
||||
|
||||
@@ -369,7 +370,7 @@ describe("buildConfigChain", function() {
|
||||
cwd: fixture("nonexistant-fake"),
|
||||
filename: fixture("nonexistant-fake", "src.js"),
|
||||
babelrc: false,
|
||||
exclude: new RegExp(fixture("nonexistant-unknown")),
|
||||
exclude: new RegExp(escapeRegExp(fixture("nonexistant-unknown"))),
|
||||
comments: true,
|
||||
});
|
||||
|
||||
@@ -407,7 +408,7 @@ describe("buildConfigChain", function() {
|
||||
cwd: fixture("nonexistant-fake"),
|
||||
filename: fixture("nonexistant-fake", "src.js"),
|
||||
babelrc: false,
|
||||
exclude: [new RegExp(fixture("nonexistant-fake"))],
|
||||
exclude: [new RegExp(escapeRegExp(fixture("nonexistant-fake")))],
|
||||
comments: true,
|
||||
});
|
||||
|
||||
@@ -443,7 +444,7 @@ describe("buildConfigChain", function() {
|
||||
cwd: fixture("nonexistant-fake"),
|
||||
filename: fixture("nonexistant-fake", "src.js"),
|
||||
babelrc: false,
|
||||
exclude: [new RegExp(fixture("nonexistant-unknown"))],
|
||||
exclude: [new RegExp(escapeRegExp(fixture("nonexistant-unknown")))],
|
||||
comments: true,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "undefined: someMsg\n> 1 | function f() {}"
|
||||
"throws": "unknown: someMsg\n> 1 | function f() {}"
|
||||
}
|
||||
|
||||
15
packages/babel-core/test/fixtures/plugins/transform-error/exec.js
vendored
Normal file
15
packages/babel-core/test/fixtures/plugins/transform-error/exec.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var code = "function f() {}";
|
||||
transform(code, {
|
||||
plugins: [
|
||||
function() {
|
||||
return {
|
||||
visitor: {
|
||||
FunctionDeclaration: function(path) {
|
||||
throw new Error("someMsg");
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
],
|
||||
filename: "/fake/path/example.js"
|
||||
});
|
||||
4
packages/babel-core/test/fixtures/plugins/transform-error/options.json
vendored
Normal file
4
packages/babel-core/test/fixtures/plugins/transform-error/options.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "/fake/path/example.js: someMsg",
|
||||
"os": ["linux", "darwin"]
|
||||
}
|
||||
@@ -27,14 +27,19 @@ describe("option-manager", () => {
|
||||
return { plugin, calls };
|
||||
}
|
||||
|
||||
it("should throw if a plugin is repeated", () => {
|
||||
const { calls, plugin } = makePlugin();
|
||||
it("should throw if a plugin is repeated, with information about the repeated plugin", () => {
|
||||
const { calls, plugin } = makePlugin("my-plugin");
|
||||
|
||||
expect(() => {
|
||||
loadOptions({
|
||||
plugins: [plugin, plugin],
|
||||
plugins: [
|
||||
[plugin, undefined, "my-plugin"],
|
||||
[plugin, undefined, "my-plugin"],
|
||||
],
|
||||
});
|
||||
}).toThrow(/Duplicate plugin\/preset detected/);
|
||||
}).toThrow(
|
||||
/Duplicate plugin\/preset detected.*Duplicates detected are.*my-plugin.*my-plugin/ms,
|
||||
);
|
||||
expect(calls).toEqual([]);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/generator",
|
||||
"version": "7.6.2",
|
||||
"version": "7.6.3",
|
||||
"description": "Turns an AST into code.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -14,13 +14,13 @@
|
||||
"lib"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.6.0",
|
||||
"@babel/types": "^7.6.3",
|
||||
"jsesc": "^2.5.1",
|
||||
"lodash": "^4.17.13",
|
||||
"source-map": "^0.5.0"
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-fixtures": "^7.6.2",
|
||||
"@babel/parser": "^7.6.2"
|
||||
"@babel/helper-fixtures": "^7.6.3",
|
||||
"@babel/parser": "^7.6.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,14 +24,20 @@ export default class SourceMap {
|
||||
|
||||
const code = this._code;
|
||||
if (typeof code === "string") {
|
||||
map.setSourceContent(this._opts.sourceFileName, code);
|
||||
map.setSourceContent(
|
||||
this._opts.sourceFileName.replace(/\\/g, "/"),
|
||||
code,
|
||||
);
|
||||
} else if (typeof code === "object") {
|
||||
Object.keys(code).forEach(sourceFileName => {
|
||||
map.setSourceContent(sourceFileName, code[sourceFileName]);
|
||||
map.setSourceContent(
|
||||
sourceFileName.replace(/\\/g, "/"),
|
||||
code[sourceFileName],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
this._rawMappings.forEach(map.addMapping, map);
|
||||
this._rawMappings.forEach(mapping => map.addMapping(mapping), map);
|
||||
}
|
||||
|
||||
return this._cachedMap.toJSON();
|
||||
@@ -83,7 +89,10 @@ export default class SourceMap {
|
||||
line: generatedLine,
|
||||
column: generatedColumn,
|
||||
},
|
||||
source: line == null ? undefined : filename || this._opts.sourceFileName,
|
||||
source:
|
||||
line == null
|
||||
? undefined
|
||||
: (filename || this._opts.sourceFileName).replace(/\\/g, "/"),
|
||||
original:
|
||||
line == null
|
||||
? undefined
|
||||
|
||||
@@ -11,13 +11,13 @@ declare class A { static [ indexer: number]: string }
|
||||
declare class A { static () : number }
|
||||
declare class B { (): number }
|
||||
declare class A mixins B<T>, C {}
|
||||
declare type A = string
|
||||
declare type A1 = string
|
||||
declare type T<U> = { [k:string]: U }
|
||||
declare type B = {
|
||||
declare type B1 = {
|
||||
fn?: (foo: string) => void,
|
||||
}
|
||||
declare interface I { foo: string }
|
||||
declare interface I<T> { foo: T }
|
||||
declare interface I1 { foo: string }
|
||||
declare interface I2<T> { foo: T }
|
||||
declare module.exports: { foo: string }
|
||||
declare opaque type Foo<T>: Bar<T>;
|
||||
declare opaque type ID;
|
||||
|
||||
@@ -22,17 +22,17 @@ declare class B {
|
||||
(): number
|
||||
}
|
||||
declare class A mixins B<T>, C {}
|
||||
declare type A = string;
|
||||
declare type A1 = string;
|
||||
declare type T<U> = {
|
||||
[k: string]: U
|
||||
};
|
||||
declare type B = {
|
||||
declare type B1 = {
|
||||
fn?: (foo: string) => void
|
||||
};
|
||||
declare interface I {
|
||||
declare interface I1 {
|
||||
foo: string
|
||||
}
|
||||
declare interface I<T> {
|
||||
declare interface I2<T> {
|
||||
foo: T
|
||||
}
|
||||
declare module.exports: {
|
||||
|
||||
@@ -5,10 +5,10 @@ type T2 = { +p: T };
|
||||
type T3 = { -p: T };
|
||||
type T4 = { +[k:K]: V };
|
||||
type T5 = { -[k:K]: V };
|
||||
interface I { +p: T }
|
||||
interface I { -p: T }
|
||||
interface I { +[k:K]: V }
|
||||
interface I { -[k:K]: V }
|
||||
interface I1 { +p: T }
|
||||
interface I2 { -p: T }
|
||||
interface I3 { +[k:K]: V }
|
||||
interface I4 { -[k:K]: V }
|
||||
declare class I { +p: T }
|
||||
declare class I { -p: T }
|
||||
declare class I { +[k:K]: V }
|
||||
|
||||
@@ -15,16 +15,16 @@ type T4 = {
|
||||
type T5 = {
|
||||
-[k: K]: V
|
||||
};
|
||||
interface I {
|
||||
interface I1 {
|
||||
+p: T
|
||||
}
|
||||
interface I {
|
||||
interface I2 {
|
||||
-p: T
|
||||
}
|
||||
interface I {
|
||||
interface I3 {
|
||||
+[k: K]: V
|
||||
}
|
||||
interface I {
|
||||
interface I4 {
|
||||
-[k: K]: V
|
||||
}
|
||||
declare class I {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
declare class C { static [[foo]]: T }
|
||||
declare class C { [[foo]]: T }
|
||||
interface I { [[foo]]: X }
|
||||
interface I { [[foo]](): X }
|
||||
interface I1 { [[foo]]: X }
|
||||
interface I2 { [[foo]](): X }
|
||||
type T1 = { [[foo]]: X }
|
||||
type T2 = { [[foo]](): X }
|
||||
type T3 = { [[foo]]?: X }
|
||||
|
||||
@@ -4,10 +4,10 @@ declare class C {
|
||||
declare class C {
|
||||
[[foo]]: T
|
||||
}
|
||||
interface I {
|
||||
interface I1 {
|
||||
[[foo]]: X
|
||||
}
|
||||
interface I {
|
||||
interface I2 {
|
||||
[[foo]]() => X
|
||||
}
|
||||
type T1 = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
interface A {
|
||||
interface A1 {
|
||||
@@iterator(): Iterator<File>;
|
||||
}
|
||||
|
||||
interface A {
|
||||
interface A2 {
|
||||
@@asyncIterator(): Iterator<File>;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
interface A {
|
||||
interface A1 {
|
||||
@@iterator(): Iterator<File>
|
||||
}
|
||||
interface A {
|
||||
interface A2 {
|
||||
@@asyncIterator(): Iterator<File>
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-fixtures",
|
||||
"version": "7.6.2",
|
||||
"version": "7.6.3",
|
||||
"description": "Helper function to support fixtures",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -192,6 +192,26 @@ export default function get(entryLoc): Array<Suite> {
|
||||
delete taskOpts.minNodeVersion;
|
||||
}
|
||||
|
||||
if (taskOpts.os) {
|
||||
let os = taskOpts.os;
|
||||
|
||||
if (!Array.isArray(os) && typeof os !== "string") {
|
||||
throw new Error(
|
||||
`'os' should be either string or string array: ${taskOpts.os}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof os === "string") {
|
||||
os = [os];
|
||||
}
|
||||
|
||||
if (!os.includes(process.platform)) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete taskOpts.os;
|
||||
}
|
||||
|
||||
// traceur checks
|
||||
|
||||
if (test.exec.code.indexOf("// Async.") >= 0) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-transform-fixture-test-runner",
|
||||
"version": "7.6.0",
|
||||
"version": "7.6.3",
|
||||
"description": "Transform test runner for @babel/helper-fixtures module",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -12,14 +12,14 @@
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.5.5",
|
||||
"@babel/core": "^7.6.0",
|
||||
"@babel/helper-fixtures": "^7.6.0",
|
||||
"@babel/core": "^7.6.3",
|
||||
"@babel/helper-fixtures": "^7.6.3",
|
||||
"@babel/polyfill": "^7.6.0",
|
||||
"babel-check-duplicated-nodes": "^1.0.0",
|
||||
"jest": "^24.8.0",
|
||||
"jest-diff": "^24.8.0",
|
||||
"lodash": "^4.17.13",
|
||||
"resolve": "^1.3.2",
|
||||
"source-map": "^0.5.0"
|
||||
"source-map": "^0.6.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,12 +295,22 @@ function validateFile(actualCode, expectedLoc, expectedCode) {
|
||||
}
|
||||
|
||||
function normalizeOutput(code) {
|
||||
return code
|
||||
let result = code
|
||||
.trim()
|
||||
.replace(
|
||||
new RegExp(escapeRegExp(path.resolve(__dirname, "../../../")), "g"),
|
||||
"<CWD>",
|
||||
);
|
||||
if (process.platform === "win32") {
|
||||
result = result.replace(
|
||||
new RegExp(
|
||||
escapeRegExp(path.resolve(__dirname, "../../../").replace(/\\/g, "/")),
|
||||
"g",
|
||||
),
|
||||
"<CWD>",
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const toEqualFile = () => ({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/node",
|
||||
"version": "7.6.2",
|
||||
"version": "7.6.3",
|
||||
"description": "Babel command line",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -31,8 +31,8 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.6.2",
|
||||
"@babel/helper-fixtures": "^7.6.2",
|
||||
"@babel/core": "^7.6.3",
|
||||
"@babel/helper-fixtures": "^7.6.3",
|
||||
"fs-readdir-recursive": "^1.0.0",
|
||||
"output-file-sync": "^2.0.0"
|
||||
},
|
||||
|
||||
@@ -198,7 +198,7 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
|
||||
opts.inFiles[".babelrc"] = helper.readFile(babelrcLoc);
|
||||
}
|
||||
|
||||
it(testName, buildTest(binName, testName, opts));
|
||||
it(testName, buildTest(binName, testName, opts), 20000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@babel/parser",
|
||||
"version": "7.6.2",
|
||||
"version": "7.6.3",
|
||||
"description": "A JavaScript parser",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"tag": "next"
|
||||
"access": "public"
|
||||
},
|
||||
"keywords": [
|
||||
"babel",
|
||||
@@ -29,7 +29,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/code-frame": "^7.5.5",
|
||||
"@babel/helper-fixtures": "^7.6.2",
|
||||
"@babel/helper-fixtures": "^7.6.3",
|
||||
"charcodes": "^0.2.0",
|
||||
"unicode-12.0.0": "^0.7.9"
|
||||
},
|
||||
|
||||
@@ -40,7 +40,7 @@ export default class CommentsParser extends BaseParser {
|
||||
|
||||
adjustCommentsAfterTrailingComma(
|
||||
node: Node,
|
||||
elements: Node[],
|
||||
elements: (Node | null)[],
|
||||
// When the current node is followed by a token which hasn't a respective AST node, we
|
||||
// need to take all the trailing comments to prevent them from being attached to an
|
||||
// unrelated node. e.g. in
|
||||
@@ -55,12 +55,15 @@ export default class CommentsParser extends BaseParser {
|
||||
return;
|
||||
}
|
||||
|
||||
if (elements.length === 0) {
|
||||
let lastElement = null;
|
||||
let i = elements.length;
|
||||
while (lastElement === null && i > 0) {
|
||||
lastElement = elements[--i];
|
||||
}
|
||||
if (lastElement === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const lastElement = last(elements);
|
||||
|
||||
for (let j = 0; j < this.state.leadingComments.length; j++) {
|
||||
if (
|
||||
this.state.leadingComments[j].end < this.state.commentPreviousNode.end
|
||||
|
||||
@@ -490,11 +490,7 @@ export default class ExpressionParser extends LValParser {
|
||||
// Parse unary operators, both prefix and postfix.
|
||||
|
||||
parseMaybeUnary(refShorthandDefaultPos: ?Pos): N.Expression {
|
||||
if (
|
||||
this.isContextual("await") &&
|
||||
(this.scope.inAsync ||
|
||||
(!this.scope.inFunction && this.options.allowAwaitOutsideFunction))
|
||||
) {
|
||||
if (this.isContextual("await") && this.isAwaitAllowed()) {
|
||||
return this.parseAwait();
|
||||
} else if (this.state.type.prefix) {
|
||||
const node = this.startNode();
|
||||
@@ -578,21 +574,16 @@ export default class ExpressionParser extends LValParser {
|
||||
startLoc: Position,
|
||||
noCalls?: ?boolean,
|
||||
): N.Expression {
|
||||
const maybeAsyncArrow = this.atPossibleAsync(base);
|
||||
|
||||
const state = {
|
||||
optionalChainMember: false,
|
||||
maybeAsyncArrow: this.atPossibleAsync(base),
|
||||
stop: false,
|
||||
};
|
||||
do {
|
||||
base = this.parseSubscript(
|
||||
base,
|
||||
startPos,
|
||||
startLoc,
|
||||
noCalls,
|
||||
state,
|
||||
maybeAsyncArrow,
|
||||
);
|
||||
base = this.parseSubscript(base, startPos, startLoc, noCalls, state);
|
||||
|
||||
// After parsing a subscript, this isn't "async" for sure.
|
||||
state.maybeAsyncArrow = false;
|
||||
} while (!state.stop);
|
||||
return base;
|
||||
}
|
||||
@@ -607,7 +598,6 @@ export default class ExpressionParser extends LValParser {
|
||||
startLoc: Position,
|
||||
noCalls: ?boolean,
|
||||
state: N.ParseSubscriptState,
|
||||
maybeAsyncArrow: boolean,
|
||||
): N.Expression {
|
||||
if (!noCalls && this.eat(tt.doubleColon)) {
|
||||
const node = this.startNodeAt(startPos, startLoc);
|
||||
@@ -623,7 +613,7 @@ export default class ExpressionParser extends LValParser {
|
||||
} else if (this.match(tt.questionDot)) {
|
||||
this.expectPlugin("optionalChaining");
|
||||
state.optionalChainMember = true;
|
||||
if (noCalls && this.lookahead().type === tt.parenL) {
|
||||
if (noCalls && this.lookaheadCharCode() === charCodes.leftParenthesis) {
|
||||
state.stop = true;
|
||||
return base;
|
||||
}
|
||||
@@ -682,8 +672,8 @@ export default class ExpressionParser extends LValParser {
|
||||
const oldYieldPos = this.state.yieldPos;
|
||||
const oldAwaitPos = this.state.awaitPos;
|
||||
this.state.maybeInArrowParameters = true;
|
||||
this.state.yieldPos = 0;
|
||||
this.state.awaitPos = 0;
|
||||
this.state.yieldPos = -1;
|
||||
this.state.awaitPos = -1;
|
||||
|
||||
this.next();
|
||||
|
||||
@@ -695,7 +685,7 @@ export default class ExpressionParser extends LValParser {
|
||||
|
||||
node.arguments = this.parseCallExpressionArguments(
|
||||
tt.parenR,
|
||||
maybeAsyncArrow,
|
||||
state.maybeAsyncArrow,
|
||||
base.type === "Import",
|
||||
base.type !== "Super",
|
||||
);
|
||||
@@ -705,7 +695,7 @@ export default class ExpressionParser extends LValParser {
|
||||
this.finishOptionalCallExpression(node);
|
||||
}
|
||||
|
||||
if (maybeAsyncArrow && this.shouldParseAsyncArrow()) {
|
||||
if (state.maybeAsyncArrow && this.shouldParseAsyncArrow()) {
|
||||
state.stop = true;
|
||||
|
||||
this.checkCommaAfterRestFromSpread();
|
||||
@@ -722,8 +712,34 @@ export default class ExpressionParser extends LValParser {
|
||||
|
||||
// We keep the old value if it isn't null, for cases like
|
||||
// (x = async(yield)) => {}
|
||||
this.state.yieldPos = oldYieldPos || this.state.yieldPos;
|
||||
this.state.awaitPos = oldAwaitPos || this.state.awaitPos;
|
||||
//
|
||||
// Hi developer of the future :) If you are implementing generator
|
||||
// arrow functions, please read the note below about "await" and
|
||||
// verify if the same logic is needed for yield.
|
||||
if (oldYieldPos !== -1) this.state.yieldPos = oldYieldPos;
|
||||
|
||||
// Await is trickier than yield. When parsing a possible arrow function
|
||||
// (e.g. something starting with `async(`) we don't know if its possible
|
||||
// parameters will actually be inside an async arrow function or if it is
|
||||
// a normal call expression.
|
||||
// If it ended up being a call expression, if we are in a context where
|
||||
// await expression are disallowed (and thus "await" is an identifier)
|
||||
// we must be careful not to leak this.state.awaitPos to an even outer
|
||||
// context, where "await" could not be an identifier.
|
||||
// For example, this code is valid because "await" isn't directly inside
|
||||
// an async function:
|
||||
//
|
||||
// async function a() {
|
||||
// function b(param = async (await)) {
|
||||
// }
|
||||
// }
|
||||
//
|
||||
if (
|
||||
(!this.isAwaitAllowed() && !oldMaybeInArrowParameters) ||
|
||||
oldAwaitPos !== -1
|
||||
) {
|
||||
this.state.awaitPos = oldAwaitPos;
|
||||
}
|
||||
}
|
||||
|
||||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||||
@@ -1237,8 +1253,8 @@ export default class ExpressionParser extends LValParser {
|
||||
const oldAwaitPos = this.state.awaitPos;
|
||||
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
|
||||
this.state.maybeInArrowParameters = true;
|
||||
this.state.yieldPos = 0;
|
||||
this.state.awaitPos = 0;
|
||||
this.state.yieldPos = -1;
|
||||
this.state.awaitPos = -1;
|
||||
this.state.inFSharpPipelineDirectBody = false;
|
||||
|
||||
const innerStartPos = this.state.start;
|
||||
@@ -1316,8 +1332,8 @@ export default class ExpressionParser extends LValParser {
|
||||
|
||||
// We keep the old value if it isn't null, for cases like
|
||||
// (x = (yield)) => {}
|
||||
this.state.yieldPos = oldYieldPos || this.state.yieldPos;
|
||||
this.state.awaitPos = oldAwaitPos || this.state.awaitPos;
|
||||
if (oldYieldPos !== -1) this.state.yieldPos = oldYieldPos;
|
||||
if (oldAwaitPos !== -1) this.state.awaitPos = oldAwaitPos;
|
||||
|
||||
if (!exprList.length) {
|
||||
this.unexpected(this.state.lastTokStart);
|
||||
@@ -1810,8 +1826,8 @@ export default class ExpressionParser extends LValParser {
|
||||
): T {
|
||||
const oldYieldPos = this.state.yieldPos;
|
||||
const oldAwaitPos = this.state.awaitPos;
|
||||
this.state.yieldPos = 0;
|
||||
this.state.awaitPos = 0;
|
||||
this.state.yieldPos = -1;
|
||||
this.state.awaitPos = -1;
|
||||
|
||||
this.initFunction(node, isAsync);
|
||||
node.generator = !!isGenerator;
|
||||
@@ -1848,8 +1864,8 @@ export default class ExpressionParser extends LValParser {
|
||||
const oldYieldPos = this.state.yieldPos;
|
||||
const oldAwaitPos = this.state.awaitPos;
|
||||
this.state.maybeInArrowParameters = false;
|
||||
this.state.yieldPos = 0;
|
||||
this.state.awaitPos = 0;
|
||||
this.state.yieldPos = -1;
|
||||
this.state.awaitPos = -1;
|
||||
|
||||
if (params) this.setArrowFunctionParameters(node, params);
|
||||
this.parseFunctionBody(node, true);
|
||||
@@ -1981,7 +1997,7 @@ export default class ExpressionParser extends LValParser {
|
||||
node.params[i],
|
||||
BIND_VAR,
|
||||
allowDuplicates ? null : nameHash,
|
||||
"function paramter list",
|
||||
"function parameter list",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2123,11 +2139,18 @@ export default class ExpressionParser extends LValParser {
|
||||
);
|
||||
}
|
||||
|
||||
if (this.scope.inAsync && word === "await") {
|
||||
this.raise(
|
||||
startLoc,
|
||||
"Can not use 'await' as identifier inside an async function",
|
||||
);
|
||||
if (word === "await") {
|
||||
if (this.scope.inAsync) {
|
||||
this.raise(
|
||||
startLoc,
|
||||
"Can not use 'await' as identifier inside an async function",
|
||||
);
|
||||
} else if (
|
||||
this.state.awaitPos === -1 &&
|
||||
(this.state.maybeInArrowParameters || this.isAwaitAllowed())
|
||||
) {
|
||||
this.state.awaitPos = this.state.start;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.state.inClassProperty && word === "arguments") {
|
||||
@@ -2157,10 +2180,16 @@ export default class ExpressionParser extends LValParser {
|
||||
}
|
||||
}
|
||||
|
||||
isAwaitAllowed(): boolean {
|
||||
if (this.scope.inFunction) return this.scope.inAsync;
|
||||
if (this.options.allowAwaitOutsideFunction) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Parses await expression inside async function.
|
||||
|
||||
parseAwait(): N.AwaitExpression {
|
||||
if (!this.state.awaitPos) {
|
||||
if (this.state.awaitPos === -1) {
|
||||
this.state.awaitPos = this.state.start;
|
||||
}
|
||||
const node = this.startNode();
|
||||
@@ -2189,7 +2218,7 @@ export default class ExpressionParser extends LValParser {
|
||||
// Parses yield expression inside generator.
|
||||
|
||||
parseYield(noIn?: ?boolean): N.YieldExpression {
|
||||
if (!this.state.yieldPos) {
|
||||
if (this.state.yieldPos === -1) {
|
||||
this.state.yieldPos = this.state.start;
|
||||
}
|
||||
const node = this.startNode();
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
isIdentifierStart,
|
||||
keywordRelationalOperator,
|
||||
} from "../util/identifier";
|
||||
import { lineBreak, skipWhiteSpace } from "../util/whitespace";
|
||||
import { lineBreak } from "../util/whitespace";
|
||||
import * as charCodes from "charcodes";
|
||||
import {
|
||||
BIND_CLASS,
|
||||
@@ -105,10 +105,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
if (!this.isContextual("let")) {
|
||||
return false;
|
||||
}
|
||||
skipWhiteSpace.lastIndex = this.state.pos;
|
||||
const skip = skipWhiteSpace.exec(this.input);
|
||||
// $FlowIgnore
|
||||
const next = this.state.pos + skip[0].length;
|
||||
const next = this.nextTokenStart();
|
||||
const nextCh = this.input.charCodeAt(next);
|
||||
// For ambiguous cases, determine if a LexicalDeclaration (or only a
|
||||
// Statement) is allowed here. If context is not empty then only a Statement
|
||||
@@ -170,7 +167,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
case tt._for:
|
||||
return this.parseForStatement(node);
|
||||
case tt._function:
|
||||
if (this.lookahead().type === tt.dot) break;
|
||||
if (this.lookaheadCharCode() === charCodes.dot) break;
|
||||
if (context) {
|
||||
if (this.state.strict) {
|
||||
this.raise(
|
||||
@@ -223,8 +220,11 @@ export default class StatementParser extends ExpressionParser {
|
||||
return this.parseEmptyStatement(node);
|
||||
case tt._export:
|
||||
case tt._import: {
|
||||
const nextToken = this.lookahead();
|
||||
if (nextToken.type === tt.parenL || nextToken.type === tt.dot) {
|
||||
const nextTokenCharCode = this.lookaheadCharCode();
|
||||
if (
|
||||
nextTokenCharCode === charCodes.leftParenthesis ||
|
||||
nextTokenCharCode === charCodes.dot
|
||||
) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1050,12 +1050,14 @@ export default class StatementParser extends ExpressionParser {
|
||||
node.id = this.parseFunctionId(requireId);
|
||||
}
|
||||
|
||||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||||
const oldInClassProperty = this.state.inClassProperty;
|
||||
const oldYieldPos = this.state.yieldPos;
|
||||
const oldAwaitPos = this.state.awaitPos;
|
||||
this.state.maybeInArrowParameters = false;
|
||||
this.state.inClassProperty = false;
|
||||
this.state.yieldPos = 0;
|
||||
this.state.awaitPos = 0;
|
||||
this.state.yieldPos = -1;
|
||||
this.state.awaitPos = -1;
|
||||
this.scope.enter(functionFlags(node.async, node.generator));
|
||||
|
||||
if (!isStatement) {
|
||||
@@ -1084,6 +1086,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
this.checkFunctionStatementId(node);
|
||||
}
|
||||
|
||||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||||
this.state.inClassProperty = oldInClassProperty;
|
||||
this.state.yieldPos = oldYieldPos;
|
||||
this.state.awaitPos = oldAwaitPos;
|
||||
@@ -1743,11 +1746,11 @@ export default class StatementParser extends ExpressionParser {
|
||||
maybeParseExportDeclaration(node: N.Node): boolean {
|
||||
if (this.shouldParseExportDeclaration()) {
|
||||
if (this.isContextual("async")) {
|
||||
const next = this.lookahead();
|
||||
const next = this.nextTokenStart();
|
||||
|
||||
// export async;
|
||||
if (next.type !== tt._function) {
|
||||
this.unexpected(next.start, `Unexpected token, expected "function"`);
|
||||
if (!this.isUnparsedContextual(next, "function")) {
|
||||
this.unexpected(next, `Unexpected token, expected "function"`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1762,21 +1765,10 @@ export default class StatementParser extends ExpressionParser {
|
||||
|
||||
isAsyncFunction(): boolean {
|
||||
if (!this.isContextual("async")) return false;
|
||||
|
||||
const { pos } = this.state;
|
||||
|
||||
skipWhiteSpace.lastIndex = pos;
|
||||
const skip = skipWhiteSpace.exec(this.input);
|
||||
|
||||
if (!skip || !skip.length) return false;
|
||||
|
||||
const next = pos + skip[0].length;
|
||||
|
||||
const next = this.nextTokenStart();
|
||||
return (
|
||||
!lineBreak.test(this.input.slice(pos, next)) &&
|
||||
this.input.slice(next, next + 8) === "function" &&
|
||||
(next + 8 === this.length ||
|
||||
!isIdentifierChar(this.input.charCodeAt(next + 8)))
|
||||
!lineBreak.test(this.input.slice(this.state.pos, next)) &&
|
||||
this.isUnparsedContextual(next, "function")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1838,10 +1830,10 @@ export default class StatementParser extends ExpressionParser {
|
||||
return false;
|
||||
}
|
||||
|
||||
const lookahead = this.lookahead();
|
||||
const next = this.nextTokenStart();
|
||||
return (
|
||||
lookahead.type === tt.comma ||
|
||||
(lookahead.type === tt.name && lookahead.value === "from")
|
||||
this.input.charCodeAt(next) === charCodes.comma ||
|
||||
this.isUnparsedContextual(next, "from")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import { types as tt, type TokenType } from "../tokenizer/types";
|
||||
import Tokenizer from "../tokenizer";
|
||||
import type { Node } from "../types";
|
||||
import { lineBreak, skipWhiteSpace } from "../util/whitespace";
|
||||
import { isIdentifierChar } from "../util/identifier";
|
||||
import * as charCodes from "charcodes";
|
||||
|
||||
const literal = /^('|")((?:\\?.)*?)\1/;
|
||||
|
||||
@@ -26,8 +28,15 @@ export default class UtilParser extends Tokenizer {
|
||||
}
|
||||
|
||||
isLookaheadRelational(op: "<" | ">"): boolean {
|
||||
const l = this.lookahead();
|
||||
return l.type === tt.relational && l.value === op;
|
||||
const next = this.nextTokenStart();
|
||||
if (this.input.charAt(next) === op) {
|
||||
if (next + 1 === this.input.length) {
|
||||
return true;
|
||||
}
|
||||
const afterNext = this.input.charCodeAt(next + 1);
|
||||
return afterNext !== op.charCodeAt(0) && afterNext !== charCodes.equalsTo;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO
|
||||
@@ -60,9 +69,18 @@ export default class UtilParser extends Tokenizer {
|
||||
);
|
||||
}
|
||||
|
||||
isUnparsedContextual(nameStart: number, name: string): boolean {
|
||||
const nameEnd = nameStart + name.length;
|
||||
return (
|
||||
this.input.slice(nameStart, nameEnd) === name &&
|
||||
(nameEnd === this.input.length ||
|
||||
!isIdentifierChar(this.input.charCodeAt(nameEnd)))
|
||||
);
|
||||
}
|
||||
|
||||
isLookaheadContextual(name: string): boolean {
|
||||
const l = this.lookahead();
|
||||
return l.type === tt.name && l.value === name;
|
||||
const next = this.nextTokenStart();
|
||||
return this.isUnparsedContextual(next, name);
|
||||
}
|
||||
|
||||
// Consumes contextual keyword if possible.
|
||||
@@ -159,15 +177,15 @@ export default class UtilParser extends Tokenizer {
|
||||
|
||||
checkYieldAwaitInDefaultParams() {
|
||||
if (
|
||||
this.state.yieldPos &&
|
||||
(!this.state.awaitPos || this.state.yieldPos < this.state.awaitPos)
|
||||
this.state.yieldPos !== -1 &&
|
||||
(this.state.awaitPos === -1 || this.state.yieldPos < this.state.awaitPos)
|
||||
) {
|
||||
this.raise(
|
||||
this.state.yieldPos,
|
||||
"Yield cannot be used as name inside a generator function",
|
||||
);
|
||||
}
|
||||
if (this.state.awaitPos) {
|
||||
if (this.state.awaitPos !== -1) {
|
||||
this.raise(
|
||||
this.state.awaitPos,
|
||||
"Await cannot be used as name inside an async function",
|
||||
|
||||
@@ -14,6 +14,8 @@ import {
|
||||
type BindingTypes,
|
||||
BIND_NONE,
|
||||
BIND_LEXICAL,
|
||||
BIND_VAR,
|
||||
BIND_FUNCTION,
|
||||
SCOPE_ARROW,
|
||||
SCOPE_OTHER,
|
||||
} from "../util/scopeflags";
|
||||
@@ -270,6 +272,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node.id = this.flowParseTypeAnnotatableIdentifier(
|
||||
/*allowPrimitiveOverride*/ true,
|
||||
);
|
||||
this.scope.declareName(node.id.name, BIND_VAR, node.id.start);
|
||||
this.semicolon();
|
||||
return this.finishNode(node, "DeclareVariable");
|
||||
}
|
||||
@@ -462,6 +465,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
): void {
|
||||
node.id = this.flowParseRestrictedIdentifier(/*liberal*/ !isClass);
|
||||
|
||||
this.scope.declareName(
|
||||
node.id.name,
|
||||
isClass ? BIND_FUNCTION : BIND_LEXICAL,
|
||||
node.id.start,
|
||||
);
|
||||
|
||||
if (this.isRelational("<")) {
|
||||
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
||||
} else {
|
||||
@@ -2634,7 +2643,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
startLoc: Position,
|
||||
noCalls: ?boolean,
|
||||
subscriptState: N.ParseSubscriptState,
|
||||
maybeAsyncArrow: boolean,
|
||||
): N.Expression {
|
||||
if (this.match(tt.questionDot) && this.isLookaheadRelational("<")) {
|
||||
this.expectPlugin("optionalChaining");
|
||||
@@ -2687,7 +2695,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
startLoc,
|
||||
noCalls,
|
||||
subscriptState,
|
||||
maybeAsyncArrow,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import type Parser from "../../parser";
|
||||
import {
|
||||
type BindingTypes,
|
||||
BIND_NONE,
|
||||
SCOPE_TS_MODULE,
|
||||
SCOPE_OTHER,
|
||||
BIND_TS_ENUM,
|
||||
BIND_TS_CONST_ENUM,
|
||||
@@ -19,6 +20,7 @@ import {
|
||||
BIND_CLASS,
|
||||
} from "../../util/scopeflags";
|
||||
import TypeScriptScopeHandler from "./scope";
|
||||
import * as charCodes from "charcodes";
|
||||
|
||||
type TsModifier =
|
||||
| "readonly"
|
||||
@@ -657,7 +659,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
: this.match(tt._null)
|
||||
? "TSNullKeyword"
|
||||
: keywordTypeFromName(this.state.value);
|
||||
if (type !== undefined && this.lookahead().type !== tt.dot) {
|
||||
if (
|
||||
type !== undefined &&
|
||||
this.lookaheadCharCode() !== charCodes.dot
|
||||
) {
|
||||
const node: N.TsKeywordType = this.startNode();
|
||||
this.next();
|
||||
return this.finishNode(node, type);
|
||||
@@ -1163,7 +1168,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
this.tsParseModuleOrNamespaceDeclaration(inner, true);
|
||||
node.body = inner;
|
||||
} else {
|
||||
this.scope.enter(SCOPE_TS_MODULE);
|
||||
node.body = this.tsParseModuleBlock();
|
||||
this.scope.exit();
|
||||
}
|
||||
return this.finishNode(node, "TSModuleDeclaration");
|
||||
}
|
||||
@@ -1179,9 +1186,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
} else {
|
||||
this.unexpected();
|
||||
}
|
||||
|
||||
if (this.match(tt.braceL)) {
|
||||
this.scope.enter(SCOPE_TS_MODULE);
|
||||
node.body = this.tsParseModuleBlock();
|
||||
this.scope.exit();
|
||||
} else {
|
||||
this.semicolon();
|
||||
}
|
||||
@@ -1203,7 +1211,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
|
||||
tsIsExternalModuleReference(): boolean {
|
||||
return (
|
||||
this.isContextual("require") && this.lookahead().type === tt.parenL
|
||||
this.isContextual("require") &&
|
||||
this.lookaheadCharCode() === charCodes.leftParenthesis
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1332,10 +1341,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
// `global { }` (with no `declare`) may appear inside an ambient module declaration.
|
||||
// Would like to use tsParseAmbientExternalModuleDeclaration here, but already ran past "global".
|
||||
if (this.match(tt.braceL)) {
|
||||
this.scope.enter(SCOPE_TS_MODULE);
|
||||
const mod: N.TsModuleDeclaration = node;
|
||||
mod.global = true;
|
||||
mod.id = expr;
|
||||
mod.body = this.tsParseModuleBlock();
|
||||
this.scope.exit();
|
||||
return this.finishNode(mod, "TSModuleDeclaration");
|
||||
}
|
||||
break;
|
||||
@@ -1568,7 +1579,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
startLoc: Position,
|
||||
noCalls: ?boolean,
|
||||
state: N.ParseSubscriptState,
|
||||
maybeAsyncArrow: boolean,
|
||||
): N.Expression {
|
||||
if (!this.hasPrecedingLineBreak() && this.match(tt.bang)) {
|
||||
this.state.exprAllowed = false;
|
||||
@@ -1631,14 +1641,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
if (result) return result;
|
||||
}
|
||||
|
||||
return super.parseSubscript(
|
||||
base,
|
||||
startPos,
|
||||
startLoc,
|
||||
noCalls,
|
||||
state,
|
||||
maybeAsyncArrow,
|
||||
);
|
||||
return super.parseSubscript(base, startPos, startLoc, noCalls, state);
|
||||
}
|
||||
|
||||
parseNewArguments(node: N.NewExpression): void {
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
lineBreakG,
|
||||
isNewLine,
|
||||
isWhitespace,
|
||||
skipWhiteSpace,
|
||||
} from "../util/whitespace";
|
||||
import State from "./state";
|
||||
|
||||
@@ -168,6 +169,18 @@ export default class Tokenizer extends LocationParser {
|
||||
return curr;
|
||||
}
|
||||
|
||||
nextTokenStart(): number {
|
||||
const thisTokEnd = this.state.pos;
|
||||
skipWhiteSpace.lastIndex = thisTokEnd;
|
||||
const skip = skipWhiteSpace.exec(this.input);
|
||||
// $FlowIgnore: The skipWhiteSpace ensures to match any string
|
||||
return thisTokEnd + skip[0].length;
|
||||
}
|
||||
|
||||
lookaheadCharCode(): number {
|
||||
return this.input.charCodeAt(this.nextTokenStart());
|
||||
}
|
||||
|
||||
// Toggle strict mode. Re-reads the next number or string to please
|
||||
// pedantic tests (`"use strict"; 010;` should fail).
|
||||
|
||||
@@ -267,13 +280,7 @@ export default class Tokenizer extends LocationParser {
|
||||
const startLoc = this.state.curPosition();
|
||||
let ch = this.input.charCodeAt((this.state.pos += startSkip));
|
||||
if (this.state.pos < this.length) {
|
||||
while (
|
||||
ch !== charCodes.lineFeed &&
|
||||
ch !== charCodes.carriageReturn &&
|
||||
ch !== charCodes.lineSeparator &&
|
||||
ch !== charCodes.paragraphSeparator &&
|
||||
++this.state.pos < this.length
|
||||
) {
|
||||
while (!isNewLine(ch) && ++this.state.pos < this.length) {
|
||||
ch = this.input.charCodeAt(this.state.pos);
|
||||
}
|
||||
}
|
||||
@@ -441,13 +448,7 @@ export default class Tokenizer extends LocationParser {
|
||||
let ch = this.input.charCodeAt(this.state.pos);
|
||||
if (ch !== charCodes.exclamationMark) return false;
|
||||
|
||||
while (
|
||||
ch !== charCodes.lineFeed &&
|
||||
ch !== charCodes.carriageReturn &&
|
||||
ch !== charCodes.lineSeparator &&
|
||||
ch !== charCodes.paragraphSeparator &&
|
||||
++this.state.pos < this.length
|
||||
) {
|
||||
while (!isNewLine(ch) && ++this.state.pos < this.length) {
|
||||
ch = this.input.charCodeAt(this.state.pos);
|
||||
}
|
||||
|
||||
@@ -1035,8 +1036,8 @@ export default class Tokenizer extends LocationParser {
|
||||
next = this.input.charCodeAt(this.state.pos);
|
||||
}
|
||||
|
||||
// disallow numeric separators in non octal decimals
|
||||
if (this.hasPlugin("numericSeparator") && isNonOctalDecimalInt) {
|
||||
// disallow numeric separators in non octal decimals and legacy octal likes
|
||||
if (this.hasPlugin("numericSeparator") && (octal || isNonOctalDecimalInt)) {
|
||||
const underscorePos = this.input
|
||||
.slice(start, this.state.pos)
|
||||
.indexOf("_");
|
||||
|
||||
@@ -97,8 +97,8 @@ export default class State {
|
||||
decoratorStack: Array<Array<N.Decorator>> = [[]];
|
||||
|
||||
// Positions to delayed-check that yield/await does not exist in default parameters.
|
||||
yieldPos: number = 0;
|
||||
awaitPos: number = 0;
|
||||
yieldPos: number = -1;
|
||||
awaitPos: number = -1;
|
||||
|
||||
// Token store.
|
||||
tokens: Array<Token | N.Comment> = [];
|
||||
|
||||
@@ -1447,5 +1447,6 @@ export type Placeholder<N: PlaceholderTypes> = NodeBase & {
|
||||
|
||||
export type ParseSubscriptState = {
|
||||
optionalChainMember: boolean,
|
||||
maybeAsyncArrow: boolean,
|
||||
stop: boolean,
|
||||
};
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
|
||||
// Each scope gets a bitset that may contain these flags
|
||||
// prettier-ignore
|
||||
export const SCOPE_OTHER = 0b000000000,
|
||||
SCOPE_PROGRAM = 0b000000001,
|
||||
SCOPE_FUNCTION = 0b000000010,
|
||||
SCOPE_ASYNC = 0b000000100,
|
||||
SCOPE_GENERATOR = 0b000001000,
|
||||
SCOPE_ARROW = 0b000010000,
|
||||
SCOPE_SIMPLE_CATCH = 0b000100000,
|
||||
SCOPE_SUPER = 0b001000000,
|
||||
SCOPE_DIRECT_SUPER = 0b010000000,
|
||||
SCOPE_CLASS = 0b100000000,
|
||||
SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION;
|
||||
export const SCOPE_OTHER = 0b0000000000,
|
||||
SCOPE_PROGRAM = 0b0000000001,
|
||||
SCOPE_FUNCTION = 0b0000000010,
|
||||
SCOPE_ASYNC = 0b0000000100,
|
||||
SCOPE_GENERATOR = 0b0000001000,
|
||||
SCOPE_ARROW = 0b0000010000,
|
||||
SCOPE_SIMPLE_CATCH = 0b0000100000,
|
||||
SCOPE_SUPER = 0b0001000000,
|
||||
SCOPE_DIRECT_SUPER = 0b0010000000,
|
||||
SCOPE_CLASS = 0b0100000000,
|
||||
SCOPE_TS_MODULE = 0b1000000000,
|
||||
SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION | SCOPE_TS_MODULE;
|
||||
|
||||
export type ScopeFlags =
|
||||
| typeof SCOPE_OTHER
|
||||
|
||||
2
packages/babel-parser/test/fixtures/comments/regression/10448/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/comments/regression/10448/input.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
function foo([foo, /* not used */, /* not used */]) {
|
||||
}
|
||||
191
packages/babel-parser/test/fixtures/comments/regression/10448/output.json
vendored
Normal file
191
packages/babel-parser/test/fixtures/comments/regression/10448/output.json
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 55,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 55,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 55,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 9,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "ArrayPattern",
|
||||
"start": 13,
|
||||
"end": 50,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 50
|
||||
}
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start": 14,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo",
|
||||
"trailingComments": [
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": " not used ",
|
||||
"start": 19,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 33
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": " not used ",
|
||||
"start": 35,
|
||||
"end": 49,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 35
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 49
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
null
|
||||
]
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 52,
|
||||
"end": 55,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 52
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
},
|
||||
"comments": [
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": " not used ",
|
||||
"start": 19,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 33
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": " not used ",
|
||||
"start": 35,
|
||||
"end": 49,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 35
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 49
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
async (a = ({ await }) => {}) => {};
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Await cannot be used as name inside an async function (1:20)"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
async function f() {
|
||||
function g(x = async(await)) {}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 56,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 56,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 56,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"identifierName": "f"
|
||||
},
|
||||
"name": "f"
|
||||
},
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 19,
|
||||
"end": 56,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 23,
|
||||
"end": 54,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 33
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 32,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 12
|
||||
},
|
||||
"identifierName": "g"
|
||||
},
|
||||
"name": "g"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start": 34,
|
||||
"end": 50,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start": 34,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 14
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "CallExpression",
|
||||
"start": 38,
|
||||
"end": 50,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 17
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 38,
|
||||
"end": 43,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 17
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
},
|
||||
"identifierName": "async"
|
||||
},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start": 44,
|
||||
"end": 49,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
},
|
||||
"identifierName": "await"
|
||||
},
|
||||
"name": "await"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 52,
|
||||
"end": 54,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 31
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 33
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
async (a = ({ await: x }) => {}) => {};
|
||||
@@ -0,0 +1,225 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 39
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 39
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 39
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start": 0,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 38
|
||||
}
|
||||
},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start": 7,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 31
|
||||
}
|
||||
},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start": 7,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start": 11,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 31
|
||||
}
|
||||
},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "ObjectPattern",
|
||||
"start": 12,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 24
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 14,
|
||||
"end": 22,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 14,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
},
|
||||
"identifierName": "await"
|
||||
},
|
||||
"name": "await"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": false,
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start": 21,
|
||||
"end": 22,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 22
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 29,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 29
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 31
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 36,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 36
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 38
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
00_0
|
||||
@@ -0,0 +1 @@
|
||||
{ "throws": "Numeric separator can not be used after leading 0 (1:2)" }
|
||||
@@ -0,0 +1,3 @@
|
||||
interface Foo {}
|
||||
|
||||
export type { Foo }
|
||||
160
packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/implements-exports/output.json
vendored
Normal file
160
packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/implements-exports/output.json
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "InterfaceDeclaration",
|
||||
"start": 0,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "Foo"
|
||||
},
|
||||
"name": "Foo"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 14,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ExportNamedDeclaration",
|
||||
"start": 18,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"specifiers": [
|
||||
{
|
||||
"type": "ExportSpecifier",
|
||||
"start": 32,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"local": {
|
||||
"type": "Identifier",
|
||||
"start": 32,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "Foo"
|
||||
},
|
||||
"name": "Foo"
|
||||
},
|
||||
"exported": {
|
||||
"type": "Identifier",
|
||||
"start": 32,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "Foo"
|
||||
},
|
||||
"name": "Foo"
|
||||
}
|
||||
}
|
||||
],
|
||||
"source": null,
|
||||
"exportKind": "type",
|
||||
"declaration": null
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/flow/multiple-declarations/class/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/multiple-declarations/class/input.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare class C1 {}
|
||||
class C1 {}
|
||||
8
packages/babel-parser/test/fixtures/flow/multiple-declarations/class/options.json
vendored
Normal file
8
packages/babel-parser/test/fixtures/flow/multiple-declarations/class/options.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"sourceType": "module",
|
||||
"plugins": [
|
||||
"jsx",
|
||||
"flow"
|
||||
],
|
||||
"throws": "Identifier 'C1' has already been declared (2:6)"
|
||||
}
|
||||
6
packages/babel-parser/test/fixtures/flow/multiple-declarations/declare-class/input.js
vendored
Normal file
6
packages/babel-parser/test/fixtures/flow/multiple-declarations/declare-class/input.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
declare class C1{}
|
||||
declare class C1{}
|
||||
|
||||
declare module M1 {
|
||||
declare class C1 {}
|
||||
}
|
||||
253
packages/babel-parser/test/fixtures/flow/multiple-declarations/declare-class/output.json
vendored
Normal file
253
packages/babel-parser/test/fixtures/flow/multiple-declarations/declare-class/output.json
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 82,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 82,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareClass",
|
||||
"start": 0,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 14,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"identifierName": "C1"
|
||||
},
|
||||
"name": "C1"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 16,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "DeclareClass",
|
||||
"start": 19,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 33,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"identifierName": "C1"
|
||||
},
|
||||
"name": "C1"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 35,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "DeclareModule",
|
||||
"start": 39,
|
||||
"end": 82,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 54,
|
||||
"end": 56,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "M1"
|
||||
},
|
||||
"name": "M1"
|
||||
},
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 57,
|
||||
"end": 82,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareClass",
|
||||
"start": 61,
|
||||
"end": 80,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 21
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 75,
|
||||
"end": 77,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 18
|
||||
},
|
||||
"identifierName": "C1"
|
||||
},
|
||||
"name": "C1"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 78,
|
||||
"end": 80,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 21
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"kind": "CommonJS"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/flow/multiple-declarations/declare-function/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/flow/multiple-declarations/declare-function/input.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare function F1(): void
|
||||
declare function F1(): void
|
||||
function F1() {}
|
||||
249
packages/babel-parser/test/fixtures/flow/multiple-declarations/declare-function/output.json
vendored
Normal file
249
packages/babel-parser/test/fixtures/flow/multiple-declarations/declare-function/output.json
vendored
Normal file
@@ -0,0 +1,249 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 72,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 72,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareFunction",
|
||||
"start": 0,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 17,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
},
|
||||
"identifierName": "F1"
|
||||
},
|
||||
"name": "F1",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 19,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start": 19,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start": 23,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"predicate": null
|
||||
},
|
||||
{
|
||||
"type": "DeclareFunction",
|
||||
"start": 28,
|
||||
"end": 55,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 45,
|
||||
"end": 55,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 17
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
},
|
||||
"identifierName": "F1"
|
||||
},
|
||||
"name": "F1",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 47,
|
||||
"end": 55,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start": 47,
|
||||
"end": 55,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start": 51,
|
||||
"end": 55,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"predicate": null
|
||||
},
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 56,
|
||||
"end": 72,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 65,
|
||||
"end": 67,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "F1"
|
||||
},
|
||||
"name": "F1"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 70,
|
||||
"end": 72,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/flow/multiple-declarations/declare-var/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/flow/multiple-declarations/declare-var/input.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare var V1;
|
||||
declare var V1;
|
||||
var V1;
|
||||
150
packages/babel-parser/test/fixtures/flow/multiple-declarations/declare-var/output.json
vendored
Normal file
150
packages/babel-parser/test/fixtures/flow/multiple-declarations/declare-var/output.json
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareVariable",
|
||||
"start": 0,
|
||||
"end": 15,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 12,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"identifierName": "V1"
|
||||
},
|
||||
"name": "V1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "DeclareVariable",
|
||||
"start": 16,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 28,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 14
|
||||
},
|
||||
"identifierName": "V1"
|
||||
},
|
||||
"name": "V1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 32,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 36,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 36,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 6
|
||||
},
|
||||
"identifierName": "V1"
|
||||
},
|
||||
"name": "V1"
|
||||
},
|
||||
"init": null
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/flow/multiple-declarations/interface/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/multiple-declarations/interface/input.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
interface I {};
|
||||
interface I {};
|
||||
8
packages/babel-parser/test/fixtures/flow/multiple-declarations/interface/options.json
vendored
Normal file
8
packages/babel-parser/test/fixtures/flow/multiple-declarations/interface/options.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"sourceType": "module",
|
||||
"plugins": [
|
||||
"jsx",
|
||||
"flow"
|
||||
],
|
||||
"throws": "Identifier 'I' has already been declared (2:10)"
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/flow/multiple-declarations/type/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/multiple-declarations/type/input.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
type T1 = string;
|
||||
type T1 = number;
|
||||
8
packages/babel-parser/test/fixtures/flow/multiple-declarations/type/options.json
vendored
Normal file
8
packages/babel-parser/test/fixtures/flow/multiple-declarations/type/options.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"sourceType": "module",
|
||||
"plugins": [
|
||||
"jsx",
|
||||
"flow"
|
||||
],
|
||||
"throws": "Identifier 'T1' has already been declared (2:5)"
|
||||
}
|
||||
8
packages/babel-parser/test/fixtures/flow/regression/issue-10044/input.js
vendored
Normal file
8
packages/babel-parser/test/fixtures/flow/regression/issue-10044/input.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
declare class C1 {}
|
||||
declare interface I1 {}
|
||||
declare type T1 = number;
|
||||
|
||||
interface I2 {}
|
||||
type T2 = number;
|
||||
|
||||
export type { C1, I1, I2, T1, T2 }
|
||||
564
packages/babel-parser/test/fixtures/flow/regression/issue-10044/output.json
vendored
Normal file
564
packages/babel-parser/test/fixtures/flow/regression/issue-10044/output.json
vendored
Normal file
@@ -0,0 +1,564 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 140,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 140,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareClass",
|
||||
"start": 0,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 14,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"identifierName": "C1"
|
||||
},
|
||||
"name": "C1"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 17,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "DeclareInterface",
|
||||
"start": 20,
|
||||
"end": 43,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 38,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
},
|
||||
"identifierName": "I1"
|
||||
},
|
||||
"name": "I1"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 41,
|
||||
"end": 43,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "DeclareTypeAlias",
|
||||
"start": 44,
|
||||
"end": 69,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 57,
|
||||
"end": 59,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 15
|
||||
},
|
||||
"identifierName": "T1"
|
||||
},
|
||||
"name": "T1"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"right": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start": 62,
|
||||
"end": 68,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 24
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "InterfaceDeclaration",
|
||||
"start": 71,
|
||||
"end": 86,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 81,
|
||||
"end": 83,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 12
|
||||
},
|
||||
"identifierName": "I2"
|
||||
},
|
||||
"name": "I2"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 84,
|
||||
"end": 86,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TypeAlias",
|
||||
"start": 87,
|
||||
"end": 104,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 92,
|
||||
"end": 94,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 7
|
||||
},
|
||||
"identifierName": "T2"
|
||||
},
|
||||
"name": "T2"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"right": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start": 97,
|
||||
"end": 103,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 16
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ExportNamedDeclaration",
|
||||
"start": 106,
|
||||
"end": 140,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"specifiers": [
|
||||
{
|
||||
"type": "ExportSpecifier",
|
||||
"start": 120,
|
||||
"end": 122,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"local": {
|
||||
"type": "Identifier",
|
||||
"start": 120,
|
||||
"end": 122,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 16
|
||||
},
|
||||
"identifierName": "C1"
|
||||
},
|
||||
"name": "C1"
|
||||
},
|
||||
"exported": {
|
||||
"type": "Identifier",
|
||||
"start": 120,
|
||||
"end": 122,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 16
|
||||
},
|
||||
"identifierName": "C1"
|
||||
},
|
||||
"name": "C1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ExportSpecifier",
|
||||
"start": 124,
|
||||
"end": 126,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"local": {
|
||||
"type": "Identifier",
|
||||
"start": 124,
|
||||
"end": 126,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 20
|
||||
},
|
||||
"identifierName": "I1"
|
||||
},
|
||||
"name": "I1"
|
||||
},
|
||||
"exported": {
|
||||
"type": "Identifier",
|
||||
"start": 124,
|
||||
"end": 126,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 20
|
||||
},
|
||||
"identifierName": "I1"
|
||||
},
|
||||
"name": "I1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ExportSpecifier",
|
||||
"start": 128,
|
||||
"end": 130,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 24
|
||||
}
|
||||
},
|
||||
"local": {
|
||||
"type": "Identifier",
|
||||
"start": 128,
|
||||
"end": 130,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 24
|
||||
},
|
||||
"identifierName": "I2"
|
||||
},
|
||||
"name": "I2"
|
||||
},
|
||||
"exported": {
|
||||
"type": "Identifier",
|
||||
"start": 128,
|
||||
"end": 130,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 24
|
||||
},
|
||||
"identifierName": "I2"
|
||||
},
|
||||
"name": "I2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ExportSpecifier",
|
||||
"start": 132,
|
||||
"end": 134,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 26
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"local": {
|
||||
"type": "Identifier",
|
||||
"start": 132,
|
||||
"end": 134,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 26
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 28
|
||||
},
|
||||
"identifierName": "T1"
|
||||
},
|
||||
"name": "T1"
|
||||
},
|
||||
"exported": {
|
||||
"type": "Identifier",
|
||||
"start": 132,
|
||||
"end": 134,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 26
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 28
|
||||
},
|
||||
"identifierName": "T1"
|
||||
},
|
||||
"name": "T1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ExportSpecifier",
|
||||
"start": 136,
|
||||
"end": 138,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 30
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"local": {
|
||||
"type": "Identifier",
|
||||
"start": 136,
|
||||
"end": 138,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 30
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 32
|
||||
},
|
||||
"identifierName": "T2"
|
||||
},
|
||||
"name": "T2"
|
||||
},
|
||||
"exported": {
|
||||
"type": "Identifier",
|
||||
"start": 136,
|
||||
"end": 138,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 30
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 32
|
||||
},
|
||||
"identifierName": "T2"
|
||||
},
|
||||
"name": "T2"
|
||||
}
|
||||
}
|
||||
],
|
||||
"source": null,
|
||||
"exportKind": "type",
|
||||
"declaration": null
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/flow/regression/issue-10314/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/flow/regression/issue-10314/input.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// @flow
|
||||
|
||||
true ? async.waterfall() : null;
|
||||
198
packages/babel-parser/test/fixtures/flow/regression/issue-10314/output.json
vendored
Normal file
198
packages/babel-parser/test/fixtures/flow/regression/issue-10314/output.json
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 10,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "ConditionalExpression",
|
||||
"start": 10,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 31
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"type": "BooleanLiteral",
|
||||
"start": 10,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"value": true
|
||||
},
|
||||
"consequent": {
|
||||
"type": "CallExpression",
|
||||
"start": 17,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 24
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "MemberExpression",
|
||||
"start": 17,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start": 17,
|
||||
"end": 22,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 12
|
||||
},
|
||||
"identifierName": "async"
|
||||
},
|
||||
"name": "async"
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 23,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 22
|
||||
},
|
||||
"identifierName": "waterfall"
|
||||
},
|
||||
"name": "waterfall"
|
||||
},
|
||||
"computed": false
|
||||
},
|
||||
"arguments": []
|
||||
},
|
||||
"alternate": {
|
||||
"type": "NullLiteral",
|
||||
"start": 37,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 27
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 31
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"leadingComments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": " @flow",
|
||||
"start": 0,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
},
|
||||
"comments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": " @flow",
|
||||
"start": 0,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Identifier 'A' has already been declared (2:12)"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Identifier 'A' has already been declared (2:9)"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Identifier 'A' has already been declared (2:4)"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Identifier 'A' has already been declared (2:14)"
|
||||
}
|
||||
147
packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-class-declare-class/output.json
vendored
Normal file
147
packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-class-declare-class/output.json
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareClass",
|
||||
"start": 0,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 14,
|
||||
"end": 15,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 15
|
||||
},
|
||||
"identifierName": "A"
|
||||
},
|
||||
"name": "A"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 16,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "DeclareClass",
|
||||
"start": 19,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 33,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"identifierName": "A"
|
||||
},
|
||||
"name": "A"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 35,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
178
packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-func-declare-var/output.json
vendored
Normal file
178
packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-func-declare-var/output.json
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 50,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 50,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareFunction",
|
||||
"start": 0,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 17,
|
||||
"end": 26,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 26
|
||||
},
|
||||
"identifierName": "A"
|
||||
},
|
||||
"name": "A",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 18,
|
||||
"end": 26,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 26
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start": 18,
|
||||
"end": 26,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 26
|
||||
}
|
||||
},
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start": 22,
|
||||
"end": 26,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 26
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"predicate": null
|
||||
},
|
||||
{
|
||||
"type": "DeclareVariable",
|
||||
"start": 28,
|
||||
"end": 50,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 40,
|
||||
"end": 49,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
},
|
||||
"identifierName": "A"
|
||||
},
|
||||
"name": "A",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 41,
|
||||
"end": 49,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start": 43,
|
||||
"end": 49,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user