Compare commits
59 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e1d6e7ff4 | ||
|
|
efb71ea12b | ||
|
|
cbbb3c7962 | ||
|
|
4fcee1751a | ||
|
|
efa571a42c | ||
|
|
bf8c4785f2 | ||
|
|
4f206b2416 | ||
|
|
504b331da4 | ||
|
|
74f969b603 | ||
|
|
4dfd801887 | ||
|
|
62233ed7c9 | ||
|
|
7b54ab620b | ||
|
|
343f776ca5 | ||
|
|
756ded4d64 | ||
|
|
b706e34fc8 | ||
|
|
5d5cd8612f | ||
|
|
afe67a7035 | ||
|
|
2fa1984635 | ||
|
|
2194842d11 | ||
|
|
e3b2c1afff | ||
|
|
b95cbc4a8e | ||
|
|
24c4901ff5 | ||
|
|
c125b1dd74 | ||
|
|
f216a7b06f | ||
|
|
c6d2f45cab | ||
|
|
1d4d760ffc | ||
|
|
d35563ee1a | ||
|
|
38397ce11f | ||
|
|
cd81b079ee | ||
|
|
e85faec47d | ||
|
|
0d9e77f559 | ||
|
|
c82750a48a | ||
|
|
de80aefece | ||
|
|
e4929e11f6 | ||
|
|
d942d47e10 | ||
|
|
84e7884d9c | ||
|
|
9d0dcedb2b | ||
|
|
b576bf4b41 | ||
|
|
e541d6031a | ||
|
|
5fa3628506 | ||
|
|
f71e4660d4 | ||
|
|
929567523c | ||
|
|
5080059138 | ||
|
|
8ee857e268 | ||
|
|
6b8261bbb7 | ||
|
|
ce1a6526e5 | ||
|
|
842c164be5 | ||
|
|
d2c75c2d38 | ||
|
|
3951acbff5 | ||
|
|
08454ece46 | ||
|
|
4b8cb75b74 | ||
|
|
3fa4f53d0a | ||
|
|
850bc1d3dd | ||
|
|
36d12b5969 | ||
|
|
2575312d1f | ||
|
|
a5b5ed928d | ||
|
|
3c87401714 | ||
|
|
07862e7272 | ||
|
|
ca89212b45 |
283
CHANGELOG.md
283
CHANGELOG.md
@@ -15,6 +15,287 @@ See [CHANGELOG - v4](/.github/CHANGELOG-v4.md), [CHANGELOG - v5](/.github/CHANGE
|
||||
See [CHANGELOG - 6to5](/.github/CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0.0-beta.29 version changelog.
|
||||
|
||||
## 7.1.2 (2018-09-28)
|
||||
|
||||
Same as v7.1.1, except compiled against Node 6 instead of Node 8 by accident (e.g had `async functions`).
|
||||
|
||||
## v7.1.1 (2018-09-28)
|
||||
|
||||
> EDIT: had a publish issue here as well where it compiled against Node 8 instead of Node 6 so 7.1.2 will fix this.
|
||||
> Also force publish `@babel/runtime` and `@babel/runtime-corejs2`. We need to fix the publishing around that since Lerna doesn't pickup the `@babel/helpers` changes as there is no "dependency"
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-generator`, `babel-parser`, `babel-types`
|
||||
* [#8755](https://github.com/babel/babel/pull/8755) TypeScript: reserve `unknown` as TSUnknownKeyword. ([@g-plane](https://github.com/g-plane))
|
||||
* `babel-plugin-transform-destructuring`
|
||||
* [#8535](https://github.com/babel/babel/pull/8535) Do not unpack array patterns that update a referenced binding. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-plugin-proposal-decorators`
|
||||
* [#8742](https://github.com/babel/babel/pull/8742) [decorators] Support async and generator methods. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-helpers`, `babel-plugin-proposal-decorators`
|
||||
* [#8761](https://github.com/babel/babel/pull/8761) [decorators] Fields are enumerable. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-generator`
|
||||
* [#8751](https://github.com/babel/babel/pull/8751) Fix some missing parens cases with OptionalMemberExpression in generator. ([@existentialism](https://github.com/existentialism))
|
||||
* [#8727](https://github.com/babel/babel/pull/8727) Handle throw expressions in generator. ([@existentialism](https://github.com/existentialism))
|
||||
|
||||
#### :house: Internal
|
||||
* Other
|
||||
* [#8780](https://github.com/babel/babel/pull/8780) Run test262 tests for exportNamespaceFrom. ([@existentialism](https://github.com/existentialism))
|
||||
* `babel-helper-transform-fixture-test-runner`
|
||||
* [#8768](https://github.com/babel/babel/pull/8768) Use babel-check-duplicated-nodes. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
## v7.1.0 (2018-09-17)
|
||||
|
||||
Check http://babeljs.io/blog/2018/09/17/7.1.0
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-cli`, `babel-core`
|
||||
* [#8660](https://github.com/babel/babel/pull/8660) Better support monorepos by allowing users to opt into automatically resolving 'root' with `rootMode: "upward"`.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-helper-transform-fixture-test-runner`
|
||||
* [#7582](https://github.com/babel/babel/pull/7582) Allow regular plugins/presets resolution algorithm for packages outsi…. ([@Andarist](https://github.com/Andarist))
|
||||
* `babel-helpers`, `babel-plugin-proposal-decorators`, `babel-plugin-syntax-decorators`
|
||||
* [#7976](https://github.com/babel/babel/pull/7976) Add support for the new decorators proposal. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-helpers`, `babel-plugin-proposal-class-properties`
|
||||
* [#8205](https://github.com/babel/babel/pull/8205) Private Static Fields Features: Stage 3. ([@rricard](https://github.com/rricard))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-parser`
|
||||
* [#8698](https://github.com/babel/babel/pull/8698) Fix parsing of newline between 'async' and 'function'. ([@existentialism](https://github.com/existentialism))
|
||||
* [#8677](https://github.com/babel/babel/pull/8677) Fix typescript parsing typed object shorthand methods. ([@existentialism](https://github.com/existentialism))
|
||||
* `babel-plugin-transform-typescript`
|
||||
* [#8682](https://github.com/babel/babel/pull/8682) Fix TSParameterProperty getting lost with transform-classes. ([@existentialism](https://github.com/existentialism))
|
||||
* [#8695](https://github.com/babel/babel/pull/8695) Adjust TSParameterProperty handling to work with transform-parameters. ([@existentialism](https://github.com/existentialism))
|
||||
* [#8666](https://github.com/babel/babel/pull/8666) Fix typescript import elision. ([@Retsam](https://github.com/Retsam))
|
||||
* `babel-preset-env`
|
||||
* [#8693](https://github.com/babel/babel/pull/8693) Fix es6.string.iterator mapping in babel-preset-env. ([@existentialism](https://github.com/existentialism))
|
||||
* `babel-core`, `babel-plugin-proposal-class-properties`, `babel-plugin-proposal-decorators`, `babel-plugin-transform-runtime`
|
||||
* [#8659](https://github.com/babel/babel/pull/8659) Fix version checks in .availableHelper and transform-runtime definitions.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* Other
|
||||
* [#8627](https://github.com/babel/babel/pull/8627) ts generator: allow reserved keywords in interfaces. ([@43081j](https://github.com/43081j))
|
||||
* `babel-plugin-transform-parameters`
|
||||
* [#8414](https://github.com/babel/babel/pull/8414) Allow patterns as argument of RestElement. ([@microbouji](https://github.com/microbouji))
|
||||
* `babel-core`, `babel-plugin-transform-runtime`
|
||||
* [#8624](https://github.com/babel/babel/pull/8624) Verify 'sourceMap' option with hasOwnProperty, and verify string-typed 'version'. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-helpers`, `babel-plugin-proposal-class-properties`
|
||||
* [#8614](https://github.com/babel/babel/pull/8614) [static private] Unify loose handling of static and instance props. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-plugin-transform-runtime`
|
||||
* [#8581](https://github.com/babel/babel/pull/8581) Fix grammar in error message at @babel/plugin-transform-runtime. ([@tricknotes](https://github.com/tricknotes))
|
||||
* `babel-parser`
|
||||
* [#8576](https://github.com/babel/babel/pull/8576) More helpful errorr message for missing decoratorsBeforeExport in parser. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
#### :memo: Documentation
|
||||
* [#8561](https://github.com/babel/babel/pull/8561) Added pronounciation of babel. ([@siddhant1](https://github.com/siddhant1))
|
||||
|
||||
#### :house: Internal
|
||||
* `babel-core`
|
||||
* [#8714](https://github.com/babel/babel/pull/8714) Fix Flow error with new versionRange test.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* Other
|
||||
* [#8679](https://github.com/babel/babel/pull/8679) remove force publish, temp tag [skip ci]. ([@hzoo](https://github.com/hzoo))
|
||||
* `babel-plugin-transform-runtime`
|
||||
* [#8661](https://github.com/babel/babel/pull/8661) Makefile: run fix json on fix. ([@xtuc](https://github.com/xtuc))
|
||||
* `babel-*`
|
||||
* [#8658](https://github.com/babel/babel/pull/8658) Format fixture options.json with Prettier.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-parser`
|
||||
* [#8630](https://github.com/babel/babel/pull/8630) Bump flow to 0.80 and fix sourceType error. ([@existentialism](https://github.com/existentialism))
|
||||
* [#8610](https://github.com/babel/babel/pull/8610) types: missing `unambiguous` sourceType. ([@xtuc](https://github.com/xtuc))
|
||||
* [#8170](https://github.com/babel/babel/pull/8170) @babel/parser: expose a TypeScript definition file from package. ([@AviVahl](https://github.com/AviVahl))
|
||||
* `babel-*`
|
||||
* [#8573](https://github.com/babel/babel/pull/8573) add access public to all packages [skip ci]. ([@hzoo](https://github.com/hzoo))
|
||||
|
||||
## v7.0.1 (2018-09-11)
|
||||
|
||||
Doing a quick patch regarding helpers versioning to prevent future issues: https://github.com/babel/babel/pull/8659
|
||||
|
||||
## v7.0.0 (2018-08-27)
|
||||
|
||||
No change from rc.4. Finally released as https://babeljs.io/blog/2018/08/27/7.0.0!
|
||||
|
||||
## v7.0.0-rc.4 (2018-08-27)
|
||||
|
||||
> Similar to removing proposals in `@babel/polyfill`, we are removing them in `transform-runtime`
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-plugin-transform-runtime`
|
||||
* [#8547](https://github.com/babel/babel/pull/8547) Remove nonstandard functions and fake prototype methods from babel-runtime. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-parser`
|
||||
* [#8539](https://github.com/babel/babel/pull/8539) Update parser whitespace for clarity. ([@jridgewell](https://github.com/jridgewell))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-register`
|
||||
* [#8553](https://github.com/babel/babel/pull/8553) bump source-map-support. ([@hzoo](https://github.com/hzoo))
|
||||
* `babel-core`
|
||||
* [#8546](https://github.com/babel/babel/pull/8546) Default highlightCode:true for the parser highlighting.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :house: Internal
|
||||
* Other
|
||||
* [#8554](https://github.com/babel/babel/pull/8554) Lerna: remove exact [skip ci]. ([@hzoo](https://github.com/hzoo))
|
||||
* `babel-parser`
|
||||
* [#8540](https://github.com/babel/babel/pull/8540) Cleanup getLineInfo. ([@jridgewell](https://github.com/jridgewell))
|
||||
* [#8541](https://github.com/babel/babel/pull/8541) Update to ES6 String methods. ([@jridgewell](https://github.com/jridgewell))
|
||||
* [#8537](https://github.com/babel/babel/pull/8537) Flatten TokenType class hierarchy. ([@jridgewell](https://github.com/jridgewell))
|
||||
* [#8539](https://github.com/babel/babel/pull/8539) Update parser whitespace for clarity. ([@jridgewell](https://github.com/jridgewell))
|
||||
|
||||
## v7.0.0-rc.3 (2018-08-24)
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-preset-env`
|
||||
* [#8509](https://github.com/babel/babel/pull/8509) Add browserslist 4 support.. ([@yavorsky](https://github.com/yavorsky))
|
||||
* `babel-plugin-transform-runtime`
|
||||
* [#8518](https://github.com/babel/babel/pull/8518) Make 'useESModules' only toggle CJS vs ESM helpers when importing file is ESM.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-plugin-transform-runtime`
|
||||
* [#8520](https://github.com/babel/babel/pull/8520) Expose opt-in useESModules:"auto" from transform-runtime to toggle based on 'supportsStaticESM'. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-helpers`, `babel-plugin-transform-classes`, `babel-preset-env`
|
||||
* [#8501](https://github.com/babel/babel/pull/8501) [_wrapNativeSuper] Don't wrap non-native constructors. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-generator`, `babel-traverse`, `babel-types`
|
||||
* [#8478](https://github.com/babel/babel/pull/8478) Fix path.scope.rename() to not change break clauses. ([@rafeca](https://github.com/rafeca))
|
||||
* `babel-plugin-proposal-object-rest-spread`
|
||||
* [#8514](https://github.com/babel/babel/pull/8514) fix: object rest with default values bug. ([@jquense](https://github.com/jquense))
|
||||
* `babel-traverse`
|
||||
* [#8505](https://github.com/babel/babel/pull/8505) Rename exported functions where name conflicts with param.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :house: Internal
|
||||
* `babel-plugin-transform-object-set-prototype-of-to-assign`
|
||||
* [#8409](https://github.com/babel/babel/pull/8409) Add LICENSE file to published npm packages [skip ci]. ([@opichals](https://github.com/opichals))
|
||||
* Other
|
||||
* [#8504](https://github.com/babel/babel/pull/8504) Update Babel to rc.2. ([@hzoo](https://github.com/hzoo))
|
||||
|
||||
## v7.0.0-rc.2 (2018-08-21)
|
||||
|
||||
A notable change is the addition of https://github.com/babel/babel/pull/8485 which enables https://github.com/babel/babel-loader/pull/660 (automatically doing `modules: false` for `@babel/preset-env` when using `babel-loader`.
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-core`
|
||||
* [#8470](https://github.com/babel/babel/pull/8470) Remove File#resolveModuleSource. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* [#8473](https://github.com/babel/babel/pull/8473) Allow babel-plugin/preset prefix to not be a prefix, when used in a scope.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-core`, `babel-parser`, `babel-plugin-syntax-decorators`
|
||||
* [#8465](https://github.com/babel/babel/pull/8465) Require decoratorsBeforeExport option for decorators. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-preset-env`
|
||||
* [#8500](https://github.com/babel/babel/pull/8500) Add missing es7.promise.finally polyfill when using useBuiltIns: usage. ([@jsnajdr](https://github.com/jsnajdr))
|
||||
* `babel-cli`, `babel-core`, `babel-node`, `babel-preset-env`, `babel-register`
|
||||
* [#8485](https://github.com/babel/babel/pull/8485) Allow preset-env to toggle module handling based on flags from the caller (like babel-loader). ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-core`
|
||||
* [#8474](https://github.com/babel/babel/pull/8474) Preserve 'false'-options for disabled plugins/presets.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* [#8473](https://github.com/babel/babel/pull/8473) Allow babel-plugin/preset prefix to not be a prefix, when used in a scope.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-helper-transform-fixture-test-runner`, `babel-plugin-transform-runtime`
|
||||
* [#8435](https://github.com/babel/babel/pull/8435) Allow transform-runtime to insert runtime references with absolute paths.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-parser`
|
||||
* [#8488](https://github.com/babel/babel/pull/8488) Fix trailingComments for FunctionExpression that is CallExpression arguments. ([@jiaxuan](https://github.com/jiaxuan))
|
||||
* `babel-core`
|
||||
* [#8493](https://github.com/babel/babel/pull/8493) Take top-level config source into consideration when processing nested env/overrides.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-helpers`, `babel-plugin-proposal-decorators`
|
||||
* [#7429](https://github.com/babel/babel/pull/7429) Fix default descriptor setting for class properties with decorators. ([@yhpark](https://github.com/yhpark))
|
||||
* `babel-plugin-transform-parameters`
|
||||
* [#8479](https://github.com/babel/babel/pull/8479) Fixes setter paratemer default value. ([@nikolayemrikh](https://github.com/nikolayemrikh))
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-core`
|
||||
* [#8494](https://github.com/babel/babel/pull/8494) Cache individual programmatic descriptors along with the overall list.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* [#8493](https://github.com/babel/babel/pull/8493) Take top-level config source into consideration when processing nested env/overrides.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :house: Internal
|
||||
* `babel-core`
|
||||
* [#8493](https://github.com/babel/babel/pull/8493) Take top-level config source into consideration when processing nested env/overrides.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-plugin-transform-classes`
|
||||
* [#8472](https://github.com/babel/babel/pull/8472) Remove unused file. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
## v7.0.0-rc.1 (2018-08-09)
|
||||
|
||||
Same as rc.0 but fixes the peerDep issue #8443. It's changed to just be ^7.0.0-0
|
||||
|
||||
## v7.0.0-rc.0 (2018-08-09)
|
||||
|
||||
> This had an issue with `peerDependencies` so please use `rc.1`.
|
||||
|
||||
Alright finally at the end 🙂. Shouldn't have anymore breaking changes and going to wait some time to fix bugs/regressions
|
||||
|
||||
> Summary: `@babel/polyfill` will not include proposal polyfills by default and fixed a regression.
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-polyfill`
|
||||
* [#8440](https://github.com/babel/babel/pull/8440) remove proposals polyfills from default import [skip ci]. ([@hzoo](https://github.com/hzoo))
|
||||
|
||||
> Will add this to the upgrade guide/polyfill docs. I guess we could include a `babel-upgrade` for this too, not sure.
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-cli`
|
||||
* [#8436](https://github.com/babel/babel/pull/8436) Require v1.1.0 so that correct filter params are passed.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
## v7.0.0-beta.56 (2018-08-03)
|
||||
|
||||
- Separate `@babel/runtime`: should work for helpers alone and opt-into core-js if necessary.
|
||||
- More details in http://babeljs.io/docs/en/next/babel-runtime, http://babeljs.io/docs/en/next/babel-plugin-transform-runtime (via https://github.com/babel/babel/pull/8266, https://github.com/babel/website/pull/1714)
|
||||
- `babel-upgrade` issue: https://github.com/babel/babel-upgrade/issues/70
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-plugin-transform-regenerator`, `babel-plugin-transform-runtime`, `babel-runtime-corejs2`, `babel-runtime`
|
||||
* [#8266](https://github.com/babel/babel/pull/8266) Split @babel/runtime into 2 modules via @babel/runtime-corejs2. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-core`, `babel-helper-module-imports`, `babel-helpers`, `babel-plugin-external-helpers`, `babel-plugin-transform-runtime`
|
||||
* [#8398](https://github.com/babel/babel/pull/8398) Only reference helpers from external/runtime helpers if they are known to be available.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-plugin-transform-regenerator`, `babel-plugin-transform-runtime`, `babel-runtime-corejs2`, `babel-runtime`
|
||||
* [#8266](https://github.com/babel/babel/pull/8266) Split @babel/runtime into 2 modules via @babel/runtime-corejs2. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-parser`, `babel-plugin-transform-typescript`
|
||||
* [#8408](https://github.com/babel/babel/pull/8408) Allow TSInterfaceDeclaration to be default export. ([@existentialism](https://github.com/existentialism))
|
||||
* `babel-preset-env`
|
||||
* [#8403](https://github.com/babel/babel/pull/8403) Ensure esmodule targets are parsed by browserslist. ([@existentialism](https://github.com/existentialism))
|
||||
* Other
|
||||
* [#8024](https://github.com/babel/babel/pull/8024) Run transform-runtime on the standalone bundle so it stays ES5-compatible.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :memo: Documentation
|
||||
* [#8412](https://github.com/babel/babel/pull/8412) Update Documentation[skip ci]. ([@leongjiameng](https://github.com/leongjiameng))
|
||||
|
||||
## v7.0.0-beta.55 (2018-07-28)
|
||||
|
||||
Breaking Change in beta:
|
||||
|
||||
> Throws an error on using Stage presets: https://babeljs.io/blog/2018/07/27/removing-babels-stage-presets
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-core`, `babel-plugin-proposal-class-properties`, `babel-plugin-proposal-decorators`, `babel-preset-stage-0`, `babel-preset-stage-1`, `babel-preset-stage-2`, `babel-preset-stage-3`, `babel-standalone`
|
||||
* [#8293](https://github.com/babel/babel/pull/8293) Remove Stage presets. ([@hzoo](https://github.com/hzoo))
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-generator`, `babel-parser`, `babel-plugin-transform-typescript`, `babel-types`
|
||||
* [#7754](https://github.com/babel/babel/pull/7754) TypeScript: Support type arguments on tagged templates. ([@andy-ms](https://github.com/andy-ms))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-cli`, `babel-core`, `babel-generator`
|
||||
* [#8380](https://github.com/babel/babel/pull/8380) Ensure that Identifier source mappings explicitly start and stop on the generated range. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-preset-env`
|
||||
* [#8391](https://github.com/babel/babel/pull/8391) Ensure preset-env doesn't clobber browserslist defaults. ([@existentialism](https://github.com/existentialism))
|
||||
* `babel-core`
|
||||
* [#8376](https://github.com/babel/babel/pull/8376) Fix order of optional argument reordering. ([@Qix-](https://github.com/Qix-))
|
||||
* [#8381](https://github.com/babel/babel/pull/8381) Allow an Array for `babelrcRoots`.. ([@wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg))
|
||||
* [#8342](https://github.com/babel/babel/pull/8342) Do not mutate ast. ([@thiagoarrais](https://github.com/thiagoarrais))
|
||||
* `babel-parser`
|
||||
* [#8374](https://github.com/babel/babel/pull/8374) Correctly parse interface methods named 'static'. ([@bakkot](https://github.com/bakkot))
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-parser`
|
||||
* [#8355](https://github.com/babel/babel/pull/8355) remove .then from `dynamic import` parser exception message. ([@dnalborczyk](https://github.com/dnalborczyk))
|
||||
|
||||
#### :house: Internal
|
||||
* `babel-core`, `babel-preset-stage-0`, `babel-preset-stage-1`, `babel-preset-stage-2`, `babel-preset-stage-3`, `babel-standalone`
|
||||
* [#8397](https://github.com/babel/babel/pull/8397) Remove our own use of stage presets. ([@hzoo](https://github.com/hzoo))
|
||||
* `babel-helpers`, `babel-plugin-proposal-class-properties`
|
||||
* [#8318](https://github.com/babel/babel/pull/8318) Save full descriptor instead of only value for private fields.. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-core`
|
||||
* [#8381](https://github.com/babel/babel/pull/8381) Allow an Array for `babelrcRoots`.. ([@wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg))
|
||||
* `babel-cli`, `babel-core`, `babel-generator`, `babel-helper-define-map`, `babel-helper-fixtures`, `babel-helper-module-imports`, `babel-helper-module-transforms`, `babel-helper-regex`, `babel-helper-simple-access`, `babel-helper-transform-fixture-test-runner`, `babel-node`, `babel-plugin-transform-block-scoping`, `babel-register`, `babel-template`, `babel-traverse`, `babel-types`
|
||||
* [#8377](https://github.com/babel/babel/pull/8377) Bumped lodash to 4.17.10. ([@Berkmann18](https://github.com/Berkmann18))
|
||||
|
||||
## v7.0.0-beta.54 (2018-07-16)
|
||||
|
||||
> Regarding https://github.com/babel/babel/issues/8184, we aren't using `micromatch` for paths, just basic `*/**` substitution now. For anything more complicated we will recommend using a regex/`.js` config.
|
||||
@@ -2261,7 +2542,7 @@ Also started Babel to compile itself with Babel 7! (We'll be working on making i
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-register`
|
||||
* [#5411](https://github.com/babel/babel/pull/5411) Seperate version env cache files. ([@pwmckenna](https://github.com/pwmckenna))
|
||||
* [#5411](https://github.com/babel/babel/pull/5411) Separate version env cache files. ([@pwmckenna](https://github.com/pwmckenna))
|
||||
|
||||
#### :memo: Documentation
|
||||
* `babel-plugin-transform-runtime`
|
||||
|
||||
@@ -310,7 +310,7 @@ Note that the code shown in Chrome DevTools is compiled code and therefore diffe
|
||||
- Create a new issue that describes the proposal (ex: [#538](https://github.com/babel/babylon/issues/538)). Include any relevant information like proposal repo/author, examples, parsing approaches, meeting notes, presentation slides, and more.
|
||||
- The pull request should include:
|
||||
- [ ] An update to the [plugins](https://github.com/babel/babel/tree/master/packages/babel-parser#plugins) part of the readme. Add a new entry to that list for the new plugin flag (and link to the proposal)
|
||||
- [ ] If any new nodes or modifications need to be added to the AST, update [ast/spec.md](https://github.com/babel/babel/bloc/master/packages/babel-parser/ast/spec.md)
|
||||
- [ ] If any new nodes or modifications need to be added to the AST, update [ast/spec.md](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md)
|
||||
- [ ] Make sure you use the `this.hasPlugin("plugin-name-here")` check in the babel parser so that your new plugin code only runs when that flag is turned on (not default behavior)
|
||||
- [ ] Add failing/passing tests according to spec behavior
|
||||
- Start working about the Babel transform itself!
|
||||
|
||||
10
Makefile
10
Makefile
@@ -1,6 +1,6 @@
|
||||
MAKEFLAGS = -j1
|
||||
FLOW_COMMIT = bea8b83f50f597454941d2a7ecef6e93a881e576
|
||||
TEST262_COMMIT = 06c2f019019cf7850923de4d56828e6dfd9212b8
|
||||
FLOW_COMMIT = e192e1a4793dd8e43415fbfe8046d832cb513c8b
|
||||
TEST262_COMMIT = 69c1efd325deedf54db92a23008399e2b00fa51e
|
||||
|
||||
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
|
||||
export FORCE_COLOR = true
|
||||
@@ -82,7 +82,7 @@ test-ci-coverage:
|
||||
bootstrap-flow:
|
||||
rm -rf ./build/flow
|
||||
mkdir -p ./build
|
||||
git clone --branch=master --single-branch --shallow-since=2017-01-01 https://github.com/facebook/flow.git ./build/flow
|
||||
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:
|
||||
@@ -96,7 +96,7 @@ test-flow-update-whitelist:
|
||||
bootstrap-test262:
|
||||
rm -rf ./build/test262
|
||||
mkdir -p ./build
|
||||
git clone --branch=master --single-branch --shallow-since=2017-01-01 https://github.com/tc39/test262.git ./build/test262
|
||||
git clone --branch=master --single-branch --shallow-since=2018-11-01 https://github.com/tc39/test262.git ./build/test262
|
||||
cd build/test262 && git checkout $(TEST262_COMMIT)
|
||||
|
||||
test-test262:
|
||||
@@ -125,7 +125,7 @@ prepublish:
|
||||
|
||||
publish: prepublish
|
||||
# --only-explicit-updates
|
||||
./node_modules/.bin/lerna publish
|
||||
./node_modules/.bin/lerna publish --force-publish="@babel/runtime,@babel/runtime-corejs2" --dangerously-only-publish-explicit-updates-this-is-a-custom-flag-for-babel-and-you-should-not-be-using-it-just-deal-with-more-packages-being-published-it-is-not-a-big-deal
|
||||
make clean
|
||||
|
||||
bootstrap: clean-all
|
||||
|
||||
@@ -107,7 +107,7 @@ Mostly a handful of volunteers! Please check out our [team page](https://babeljs
|
||||
|
||||
### Looking for support?
|
||||
|
||||
For questions and support please visit join our [Slack Community](https://slack.babeljs.io/) (you can sign-up [here](https://slack.babeljs.io/) for an invite), ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs).
|
||||
For questions and support please join our [Slack Community](https://slack.babeljs.io/) (you can sign-up [here](https://slack.babeljs.io/) for an invite), ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs).
|
||||
|
||||
### Is there a Babel song?
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"lerna": "2.11.0",
|
||||
"version": "7.1.2",
|
||||
"version": "7.1.6",
|
||||
"changelog": {
|
||||
"repo": "babel/babel",
|
||||
"cacheDir": ".changelog",
|
||||
|
||||
@@ -2,12 +2,6 @@
|
||||
* Basic declarations for the npm modules we use.
|
||||
*/
|
||||
|
||||
declare module "micromatch" {
|
||||
declare module.exports: {
|
||||
(Array<string>, Array<string>, ?{ nocase: boolean }): Array<string>,
|
||||
};
|
||||
}
|
||||
|
||||
declare module "resolve" {
|
||||
declare export default {
|
||||
sync: (string, {| basedir: string |}) => string;
|
||||
|
||||
16
package.json
16
package.json
@@ -9,8 +9,8 @@
|
||||
"test": "make test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.1.0",
|
||||
"@babel/core": "^7.1.0",
|
||||
"@babel/cli": "^7.1.2",
|
||||
"@babel/core": "^7.1.2",
|
||||
"@babel/plugin-proposal-class-properties": "^7.1.0",
|
||||
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
|
||||
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
|
||||
@@ -19,11 +19,11 @@
|
||||
"@babel/preset-env": "^7.1.0",
|
||||
"@babel/preset-flow": "^7.0.0",
|
||||
"@babel/register": "^7.0.0",
|
||||
"@babel/runtime": "^7.0.0",
|
||||
"@babel/runtime": "^7.1.2",
|
||||
"babel-core": "^7.0.0-0",
|
||||
"babel-eslint": "^9.0.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-jest": "^23.6.0",
|
||||
"babel-loader": "^8.0.2",
|
||||
"babel-loader": "^8.0.4",
|
||||
"babel-plugin-transform-charcodes": "^0.1.0",
|
||||
"browserify": "^16.2.2",
|
||||
"bundle-collapser": "^1.2.1",
|
||||
@@ -32,11 +32,11 @@
|
||||
"derequire": "^2.0.2",
|
||||
"enhanced-resolve": "^3.0.0",
|
||||
"eslint": "^5.6.0",
|
||||
"eslint-config-babel": "^8.0.0",
|
||||
"eslint-config-babel": "^8.0.1",
|
||||
"eslint-plugin-flowtype": "^2.50.1",
|
||||
"eslint-plugin-local-rules": "0.1.0",
|
||||
"eslint-plugin-prettier": "^2.6.2",
|
||||
"flow-bin": "^0.80.0",
|
||||
"flow-bin": "^0.82.0",
|
||||
"graceful-fs": "^4.1.11",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-babel": "^8.0.0-beta.2",
|
||||
@@ -55,7 +55,7 @@
|
||||
"lodash": "^4.17.10",
|
||||
"merge-stream": "^1.0.1",
|
||||
"output-file-sync": "^2.0.0",
|
||||
"prettier": "^1.14.3",
|
||||
"prettier": "^1.15.1",
|
||||
"pump": "^1.0.2",
|
||||
"rimraf": "^2.4.3",
|
||||
"rollup-plugin-babel": "^4.0.0-beta.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/cli",
|
||||
"version": "7.1.2",
|
||||
"version": "7.1.5",
|
||||
"description": "Babel command line.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -36,7 +36,7 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.0.0",
|
||||
"@babel/core": "^7.1.5",
|
||||
"@babel/helper-fixtures": "^7.0.0"
|
||||
},
|
||||
"bin": {
|
||||
|
||||
@@ -81,7 +81,7 @@ commander.option(
|
||||
"print a comment after any injected non-user code",
|
||||
);
|
||||
|
||||
// General soucemap formatting.
|
||||
// General source map formatting.
|
||||
commander.option("-s, --source-maps [true|false|inline|both]", "", booleanify);
|
||||
commander.option(
|
||||
"--source-map-target [string]",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/core",
|
||||
"version": "7.1.2",
|
||||
"version": "7.1.6",
|
||||
"description": "Babel compiler core.",
|
||||
"main": "lib/index.js",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
@@ -34,15 +34,15 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"@babel/generator": "^7.1.2",
|
||||
"@babel/helpers": "^7.1.2",
|
||||
"@babel/parser": "^7.1.2",
|
||||
"@babel/generator": "^7.1.6",
|
||||
"@babel/helpers": "^7.1.5",
|
||||
"@babel/parser": "^7.1.6",
|
||||
"@babel/template": "^7.1.2",
|
||||
"@babel/traverse": "^7.1.0",
|
||||
"@babel/types": "^7.1.2",
|
||||
"@babel/traverse": "^7.1.6",
|
||||
"@babel/types": "^7.1.6",
|
||||
"convert-source-map": "^1.1.0",
|
||||
"debug": "^3.1.0",
|
||||
"json5": "^0.5.0",
|
||||
"debug": "^4.1.0",
|
||||
"json5": "^2.1.0",
|
||||
"lodash": "^4.17.10",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.4.1",
|
||||
|
||||
@@ -155,6 +155,7 @@ export function buildRootChain(
|
||||
}
|
||||
|
||||
let { babelrc, babelrcRoots } = opts;
|
||||
let babelrcRootsDirectory = context.cwd;
|
||||
|
||||
const configFileChain = emptyChain();
|
||||
if (configFile) {
|
||||
@@ -168,6 +169,7 @@ export function buildRootChain(
|
||||
babelrc = validatedFile.options.babelrc;
|
||||
}
|
||||
if (babelrcRoots === undefined) {
|
||||
babelrcRootsDirectory = validatedFile.dirname;
|
||||
babelrcRoots = validatedFile.options.babelrcRoots;
|
||||
}
|
||||
|
||||
@@ -185,7 +187,7 @@ export function buildRootChain(
|
||||
if (
|
||||
(babelrc === true || babelrc === undefined) &&
|
||||
pkgData &&
|
||||
babelrcLoadEnabled(context, pkgData, babelrcRoots)
|
||||
babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)
|
||||
) {
|
||||
({ ignore: ignoreFile, config: babelrcFile } = findRelativeConfig(
|
||||
pkgData,
|
||||
@@ -229,6 +231,7 @@ function babelrcLoadEnabled(
|
||||
context: ConfigContext,
|
||||
pkgData: FilePackageData,
|
||||
babelrcRoots: BabelrcSearch | void,
|
||||
babelrcRootsDirectory: string,
|
||||
): boolean {
|
||||
if (typeof babelrcRoots === "boolean") return babelrcRoots;
|
||||
|
||||
@@ -243,7 +246,9 @@ function babelrcLoadEnabled(
|
||||
let babelrcPatterns = babelrcRoots;
|
||||
if (!Array.isArray(babelrcPatterns)) babelrcPatterns = [babelrcPatterns];
|
||||
babelrcPatterns = babelrcPatterns.map(pat => {
|
||||
return typeof pat === "string" ? path.resolve(context.cwd, pat) : pat;
|
||||
return typeof pat === "string"
|
||||
? path.resolve(babelrcRootsDirectory, pat)
|
||||
: pat;
|
||||
});
|
||||
|
||||
// Fast path to avoid having to match patterns if the babelrc is just
|
||||
@@ -253,10 +258,12 @@ function babelrcLoadEnabled(
|
||||
}
|
||||
|
||||
return babelrcPatterns.some(pat => {
|
||||
if (typeof pat === "string") pat = pathPatternToRegex(pat, context.cwd);
|
||||
if (typeof pat === "string") {
|
||||
pat = pathPatternToRegex(pat, babelrcRootsDirectory);
|
||||
}
|
||||
|
||||
return pkgData.directories.some(directory => {
|
||||
return matchPattern(pat, context.cwd, directory, context);
|
||||
return matchPattern(pat, babelrcRootsDirectory, directory, context);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ function resolveStandardizedName(
|
||||
} catch (e2) {}
|
||||
|
||||
if (resolvedOppositeType) {
|
||||
e.message += `\n- Did you accidentally pass a ${type} as a ${oppositeType}?`;
|
||||
e.message += `\n- Did you accidentally pass a ${oppositeType} as a ${type}?`;
|
||||
}
|
||||
|
||||
throw e;
|
||||
|
||||
@@ -1,14 +1,29 @@
|
||||
// @flow
|
||||
import type { FileResult } from "./transformation";
|
||||
|
||||
export default function transformFile(
|
||||
filename: string,
|
||||
opts?: Object = {},
|
||||
callback: (?Error, FileResult | null) => void,
|
||||
// duplicated from transform-file so we do not have to import anything here
|
||||
type TransformFile = {
|
||||
(filename: string, callback: Function): void,
|
||||
(filename: string, opts: ?Object, callback: Function): void,
|
||||
};
|
||||
|
||||
export const transformFile: TransformFile = (function transformFile(
|
||||
filename,
|
||||
opts,
|
||||
callback,
|
||||
) {
|
||||
if (typeof opts === "function") {
|
||||
callback = opts;
|
||||
}
|
||||
|
||||
callback(new Error("Transforming files is not supported in browsers"), null);
|
||||
}: Function);
|
||||
|
||||
export function transformFileSync() {
|
||||
throw new Error("Transforming files is not supported in browsers");
|
||||
}
|
||||
|
||||
export function transformFileAsync() {
|
||||
return Promise.reject(
|
||||
new Error("Transforming files is not supported in browsers"),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
// @flow
|
||||
|
||||
export default function transformFileSync() {
|
||||
throw new Error("Transforming files is not supported in browsers");
|
||||
}
|
||||
@@ -9,6 +9,14 @@ import {
|
||||
type FileResultCallback,
|
||||
} from "./transformation";
|
||||
|
||||
import typeof * as transformFileBrowserType from "./transform-file-browser";
|
||||
import typeof * as transformFileType from "./transform-file";
|
||||
|
||||
// Kind of gross, but essentially asserting that the exports of this module are the same as the
|
||||
// exports of transform-file-browser, since this file may be replaced at bundle time with
|
||||
// transform-file-browser.
|
||||
((({}: any): $Exact<transformFileBrowserType>): $Exact<transformFileType>);
|
||||
|
||||
type TransformFile = {
|
||||
(filename: string, callback: FileResultCallback): void,
|
||||
(filename: string, opts: ?InputOptions, callback: FileResultCallback): void,
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
// @flow
|
||||
|
||||
const pluginNameMap = {
|
||||
asyncGenerators: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-async-generators",
|
||||
url: "https://git.io/vb4SY",
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-async-generator-functions",
|
||||
url: "https://git.io/vb4yp",
|
||||
},
|
||||
},
|
||||
classProperties: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-class-properties",
|
||||
@@ -143,26 +133,6 @@ const pluginNameMap = {
|
||||
url: "https://git.io/vb4yS",
|
||||
},
|
||||
},
|
||||
objectRestSpread: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-object-rest-spread",
|
||||
url: "https://git.io/vb4y5",
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-object-rest-spread",
|
||||
url: "https://git.io/vb4Ss",
|
||||
},
|
||||
},
|
||||
optionalCatchBinding: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-optional-catch-binding",
|
||||
url: "https://git.io/vb4Sn",
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-optional-catch-binding",
|
||||
url: "https://git.io/vb4SI",
|
||||
},
|
||||
},
|
||||
optionalChaining: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-optional-chaining",
|
||||
@@ -203,6 +173,41 @@ const pluginNameMap = {
|
||||
url: "https://git.io/vb4Sm",
|
||||
},
|
||||
},
|
||||
|
||||
// TODO: This plugins are now supported by default by @babel/parser: they can
|
||||
// be removed from this list. Although removing them isn't a breaking change,
|
||||
// it's better to keep a nice error message for users using older versions of
|
||||
// the parser. They can be removed in Babel 8.
|
||||
asyncGenerators: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-async-generators",
|
||||
url: "https://git.io/vb4SY",
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-async-generator-functions",
|
||||
url: "https://git.io/vb4yp",
|
||||
},
|
||||
},
|
||||
objectRestSpread: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-object-rest-spread",
|
||||
url: "https://git.io/vb4y5",
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-object-rest-spread",
|
||||
url: "https://git.io/vb4Ss",
|
||||
},
|
||||
},
|
||||
optionalCatchBinding: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-optional-catch-binding",
|
||||
url: "https://git.io/vb4Sn",
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-optional-catch-binding",
|
||||
url: "https://git.io/vb4SI",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const getNameURLCombination = ({ name, url }) => `${name} (${url})`;
|
||||
|
||||
@@ -769,10 +769,10 @@ describe("api", function() {
|
||||
options,
|
||||
function(err) {
|
||||
expect(err.message).toMatch(
|
||||
"Support for the experimental syntax 'asyncGenerators' isn't currently enabled (1:15):",
|
||||
"Support for the experimental syntax 'logicalAssignment' isn't currently enabled (1:3):",
|
||||
);
|
||||
expect(err.message).toMatch(
|
||||
"Add @babel/plugin-proposal-async-generator-functions (https://git.io/vb4yp) to the " +
|
||||
"Add @babel/plugin-proposal-logical-assignment-operators (https://git.io/vAlRe) to the " +
|
||||
"'plugins' section of your Babel config to enable transformation.",
|
||||
);
|
||||
done();
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
async function* agf() {
|
||||
await 1;
|
||||
yield 2;
|
||||
}
|
||||
a ||= 2;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
{
|
||||
"compact": false,
|
||||
"presets": ["env"],
|
||||
"plugins": ["external-helpers", "proposal-object-rest-spread"]
|
||||
"plugins": [
|
||||
["external-helpers", { "helperVersion": "7.1.5" }],
|
||||
"proposal-object-rest-spread"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ describe("addon resolution", function() {
|
||||
presets: ["testplugin"],
|
||||
});
|
||||
}).toThrow(
|
||||
/Cannot find module 'babel-preset-testplugin'.*\n- Did you accidentally pass a preset as a plugin\?/,
|
||||
/Cannot find module 'babel-preset-testplugin'.*\n- Did you accidentally pass a plugin as a preset\?/,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -414,7 +414,7 @@ describe("addon resolution", function() {
|
||||
plugins: ["testpreset"],
|
||||
});
|
||||
}).toThrow(
|
||||
/Cannot find module 'babel-plugin-testpreset'.*\n- Did you accidentally pass a plugin as a preset\?/,
|
||||
/Cannot find module 'babel-plugin-testpreset'.*\n- Did you accidentally pass a preset as a plugin\?/,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/generator",
|
||||
"version": "7.1.2",
|
||||
"version": "7.1.6",
|
||||
"description": "Turns an AST into code.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -14,7 +14,7 @@
|
||||
"lib"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.1.2",
|
||||
"@babel/types": "^7.1.6",
|
||||
"jsesc": "^2.5.1",
|
||||
"lodash": "^4.17.10",
|
||||
"source-map": "^0.5.0",
|
||||
@@ -22,6 +22,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-fixtures": "^7.0.0",
|
||||
"@babel/parser": "^7.0.0"
|
||||
"@babel/parser": "^7.1.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,25 @@ export function ArrowFunctionExpression(node: Object) {
|
||||
t.isIdentifier(firstParam) &&
|
||||
!hasTypes(node, firstParam)
|
||||
) {
|
||||
this.print(firstParam, node);
|
||||
if (
|
||||
this.format.retainLines &&
|
||||
node.loc &&
|
||||
node.body.loc &&
|
||||
node.loc.start.line < node.body.loc.start.line
|
||||
) {
|
||||
this.token("(");
|
||||
if (firstParam.loc && firstParam.loc.start.line > node.loc.start.line) {
|
||||
this.indent();
|
||||
this.print(firstParam, node);
|
||||
this.dedent();
|
||||
this._catchUp("start", node.body.loc);
|
||||
} else {
|
||||
this.print(firstParam, node);
|
||||
}
|
||||
this.token(")");
|
||||
} else {
|
||||
this.print(firstParam, node);
|
||||
}
|
||||
} else {
|
||||
this._params(node);
|
||||
}
|
||||
|
||||
@@ -241,6 +241,16 @@ export function TSTupleType(node) {
|
||||
this.token("]");
|
||||
}
|
||||
|
||||
export function TSOptionalType(node) {
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.token("?");
|
||||
}
|
||||
|
||||
export function TSRestType(node) {
|
||||
this.token("...");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
export function TSUnionType(node) {
|
||||
this.tsPrintUnionOrIntersectionType(node, "|");
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{ "plugins": ["objectRestSpread"] }
|
||||
@@ -1 +1 @@
|
||||
{ "plugins": ["asyncGenerators", "classProperties"] }
|
||||
{ "plugins": ["classProperties"] }
|
||||
|
||||
11
packages/babel-generator/test/fixtures/edgecase/single-arg-async-arrow-with-retainlines/input.js
vendored
Normal file
11
packages/babel-generator/test/fixtures/edgecase/single-arg-async-arrow-with-retainlines/input.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
var fn = async (
|
||||
arg
|
||||
) => {}
|
||||
|
||||
async (x)
|
||||
=> {}
|
||||
|
||||
async x => {}
|
||||
|
||||
async (x
|
||||
) => {};
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"retainLines": true
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
var fn = async (
|
||||
arg
|
||||
) => {};
|
||||
|
||||
async (x) =>
|
||||
{};
|
||||
|
||||
async x => {};
|
||||
|
||||
async (x) =>
|
||||
{};
|
||||
@@ -1 +0,0 @@
|
||||
{ "plugins": ["optionalCatchBinding"] }
|
||||
@@ -1 +0,0 @@
|
||||
{ "plugins": ["objectRestSpread"] }
|
||||
1
packages/babel-generator/test/fixtures/typescript/tuple-empty/input.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/tuple-empty/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let x: [];
|
||||
1
packages/babel-generator/test/fixtures/typescript/tuple-empty/output.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/tuple-empty/output.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let x: [];
|
||||
1
packages/babel-generator/test/fixtures/typescript/tuple-optional/input.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/tuple-optional/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let x: [string, number?, (string | number)?]
|
||||
1
packages/babel-generator/test/fixtures/typescript/tuple-optional/output.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/tuple-optional/output.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let x: [string, number?, (string | number)?];
|
||||
1
packages/babel-generator/test/fixtures/typescript/tuple-rest/input.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/tuple-rest/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let x: [string, ...number[]]
|
||||
1
packages/babel-generator/test/fixtures/typescript/tuple-rest/output.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/tuple-rest/output.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let x: [string, ...number[]];
|
||||
1
packages/babel-generator/test/fixtures/typescript/tuple/input.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/tuple/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let x: [number, number, number];
|
||||
1
packages/babel-generator/test/fixtures/typescript/tuple/output.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/tuple/output.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let x: [number, number, number];
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helpers",
|
||||
"version": "7.1.2",
|
||||
"version": "7.1.5",
|
||||
"description": "Collection of helper functions used by Babel transforms.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -12,8 +12,8 @@
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/template": "^7.1.2",
|
||||
"@babel/traverse": "^7.1.0",
|
||||
"@babel/types": "^7.1.2"
|
||||
"@babel/traverse": "^7.1.5",
|
||||
"@babel/types": "^7.1.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-plugin-test-runner": "^7.0.0"
|
||||
|
||||
@@ -935,13 +935,28 @@ helpers.skipFirstGeneratorNext = helper("7.0.0-beta.0")`
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.toPropertyKey = helper("7.0.0-beta.0")`
|
||||
export default function _toPropertyKey(key) {
|
||||
if (typeof key === "symbol") {
|
||||
return key;
|
||||
} else {
|
||||
return String(key);
|
||||
helpers.toPrimitive = helper("7.1.5")`
|
||||
export default function _toPrimitive(
|
||||
input,
|
||||
hint /*: "default" | "string" | "number" | void */
|
||||
) {
|
||||
if (typeof input !== "object" || input === null) return input;
|
||||
var prim = input[Symbol.toPrimitive];
|
||||
if (prim !== undefined) {
|
||||
var res = prim.call(input, hint || "default");
|
||||
if (typeof res !== "object") return res;
|
||||
throw new TypeError("@@toPrimitive must return a primitive value.");
|
||||
}
|
||||
return (hint === "string" ? String : Number)(input);
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.toPropertyKey = helper("7.1.5")`
|
||||
import toPrimitive from "toPrimitive";
|
||||
|
||||
export default function _toPropertyKey(arg) {
|
||||
var key = toPrimitive(arg, "string");
|
||||
return typeof key === "symbol" ? key : String(key);
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -1077,10 +1092,12 @@ helpers.classStaticPrivateFieldSpecSet = helper("7.0.2")`
|
||||
descriptor.value = value;
|
||||
return value;
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
helpers.decorate = helper("7.0.2")`
|
||||
helpers.decorate = helper("7.1.5")`
|
||||
import toArray from "toArray";
|
||||
import toPropertyKey from "toPropertyKey";
|
||||
|
||||
// These comments are stripped by @babel/template
|
||||
/*::
|
||||
@@ -1219,6 +1236,8 @@ helpers.decorate = helper("7.0.2")`
|
||||
function _createElementDescriptor(
|
||||
def /*: ElementDefinition */,
|
||||
) /*: ElementDescriptor */ {
|
||||
var key = toPropertyKey(def.key);
|
||||
|
||||
var descriptor /*: PropertyDescriptor */;
|
||||
if (def.kind === "method") {
|
||||
descriptor = {
|
||||
@@ -1227,6 +1246,10 @@ helpers.decorate = helper("7.0.2")`
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
};
|
||||
Object.defineProperty(def.value, "name", {
|
||||
value: typeof key === "symbol" ? "" : key,
|
||||
configurable: true,
|
||||
});
|
||||
} else if (def.kind === "get") {
|
||||
descriptor = { get: def.value, configurable: true, enumerable: false };
|
||||
} else if (def.kind === "set") {
|
||||
@@ -1237,7 +1260,7 @@ helpers.decorate = helper("7.0.2")`
|
||||
|
||||
var element /*: ElementDescriptor */ = {
|
||||
kind: def.kind === "field" ? "field" : "method",
|
||||
key: def.key,
|
||||
key: key,
|
||||
placement: def.static
|
||||
? "static"
|
||||
: def.kind === "field"
|
||||
@@ -1574,8 +1597,7 @@ helpers.decorate = helper("7.0.2")`
|
||||
);
|
||||
}
|
||||
|
||||
var key = elementObject.key;
|
||||
if (typeof key !== "string" && typeof key !== "symbol") key = String(key);
|
||||
var key = toPropertyKey(elementObject.key);
|
||||
|
||||
var placement = String(elementObject.placement);
|
||||
if (
|
||||
@@ -1716,4 +1738,4 @@ helpers.decorate = helper("7.0.2")`
|
||||
}
|
||||
return constructor;
|
||||
}
|
||||
`;
|
||||
`;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/parser",
|
||||
"version": "7.1.2",
|
||||
"version": "7.1.6",
|
||||
"description": "A JavaScript parser",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
|
||||
@@ -23,6 +23,7 @@ import * as N from "../types";
|
||||
import LValParser from "./lval";
|
||||
import { reservedWords } from "../util/identifier";
|
||||
import type { Pos, Position } from "../util/location";
|
||||
import * as charCodes from "charcodes";
|
||||
|
||||
export default class ExpressionParser extends LValParser {
|
||||
// Forward-declaration: defined in statement.js
|
||||
@@ -331,8 +332,8 @@ export default class ExpressionParser extends LValParser {
|
||||
this.finishNode(
|
||||
node,
|
||||
op === tt.logicalOR ||
|
||||
op === tt.logicalAND ||
|
||||
op === tt.nullishCoalescing
|
||||
op === tt.logicalAND ||
|
||||
op === tt.nullishCoalescing
|
||||
? "LogicalExpression"
|
||||
: "BinaryExpression",
|
||||
);
|
||||
@@ -522,10 +523,15 @@ export default class ExpressionParser extends LValParser {
|
||||
}
|
||||
return this.finishNode(node, "MemberExpression");
|
||||
} else if (!noCalls && this.match(tt.parenL)) {
|
||||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||||
const oldYOAIPAP = this.state.yieldOrAwaitInPossibleArrowParameters;
|
||||
this.state.maybeInArrowParameters = true;
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters = null;
|
||||
|
||||
const possibleAsync = this.atPossibleAsync(base);
|
||||
this.next();
|
||||
|
||||
const node = this.startNodeAt(startPos, startLoc);
|
||||
let node = this.startNodeAt(startPos, startLoc);
|
||||
node.callee = base;
|
||||
|
||||
// TODO: Clean up/merge this into `this.state` or a class like acorn's
|
||||
@@ -554,13 +560,22 @@ export default class ExpressionParser extends LValParser {
|
||||
);
|
||||
}
|
||||
|
||||
return this.parseAsyncArrowFromCallExpression(
|
||||
node = this.parseAsyncArrowFromCallExpression(
|
||||
this.startNodeAt(startPos, startLoc),
|
||||
node,
|
||||
);
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters = oldYOAIPAP;
|
||||
} else {
|
||||
this.toReferencedList(node.arguments);
|
||||
|
||||
// We keep the old value if it isn't null, for cases like
|
||||
// (x = async(yield)) => {}
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters =
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters || oldYOAIPAP;
|
||||
}
|
||||
|
||||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||||
|
||||
return node;
|
||||
} else if (this.match(tt.backQuote)) {
|
||||
return this.parseTaggedTemplateExpression(
|
||||
@@ -685,11 +700,8 @@ export default class ExpressionParser extends LValParser {
|
||||
node: N.ArrowFunctionExpression,
|
||||
call: N.CallExpression,
|
||||
): N.ArrowFunctionExpression {
|
||||
const oldYield = this.state.yieldInPossibleArrowParameters;
|
||||
this.state.yieldInPossibleArrowParameters = null;
|
||||
this.expect(tt.arrow);
|
||||
this.parseArrowExpression(node, call.arguments, true);
|
||||
this.state.yieldInPossibleArrowParameters = oldYield;
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -707,6 +719,10 @@ export default class ExpressionParser extends LValParser {
|
||||
// or `{}`.
|
||||
|
||||
parseExprAtom(refShorthandDefaultPos?: ?Pos): N.Expression {
|
||||
// If a division operator appears in an expression position, the
|
||||
// tokenizer got confused, and we force it to read a regexp instead.
|
||||
if (this.state.type === tt.slash) this.readRegexp();
|
||||
|
||||
const canBeArrow = this.state.potentialArrowAt === this.state.start;
|
||||
let node;
|
||||
|
||||
@@ -794,22 +810,30 @@ export default class ExpressionParser extends LValParser {
|
||||
) {
|
||||
this.next();
|
||||
return this.parseFunction(node, false, false, true);
|
||||
} else if (canBeArrow && id.name === "async" && this.match(tt.name)) {
|
||||
const oldYield = this.state.yieldInPossibleArrowParameters;
|
||||
this.state.yieldInPossibleArrowParameters = null;
|
||||
} else if (
|
||||
canBeArrow &&
|
||||
!this.canInsertSemicolon() &&
|
||||
id.name === "async" &&
|
||||
this.match(tt.name)
|
||||
) {
|
||||
const oldYOAIPAP = this.state.yieldOrAwaitInPossibleArrowParameters;
|
||||
const oldInAsync = this.state.inAsync;
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters = null;
|
||||
this.state.inAsync = true;
|
||||
const params = [this.parseIdentifier()];
|
||||
this.expect(tt.arrow);
|
||||
// let foo = bar => {};
|
||||
// let foo = async bar => {};
|
||||
this.parseArrowExpression(node, params, true);
|
||||
this.state.yieldInPossibleArrowParameters = oldYield;
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters = oldYOAIPAP;
|
||||
this.state.inAsync = oldInAsync;
|
||||
return node;
|
||||
}
|
||||
|
||||
if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {
|
||||
const oldYield = this.state.yieldInPossibleArrowParameters;
|
||||
this.state.yieldInPossibleArrowParameters = null;
|
||||
const oldYOAIPAP = this.state.yieldOrAwaitInPossibleArrowParameters;
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters = null;
|
||||
this.parseArrowExpression(node, [id]);
|
||||
this.state.yieldInPossibleArrowParameters = oldYield;
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters = oldYOAIPAP;
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -923,7 +947,19 @@ export default class ExpressionParser extends LValParser {
|
||||
if (isPrivate) {
|
||||
this.expectOnePlugin(["classPrivateProperties", "classPrivateMethods"]);
|
||||
const node = this.startNode();
|
||||
const columnHashEnd = this.state.end;
|
||||
this.next();
|
||||
const columnIdentifierStart = this.state.start;
|
||||
|
||||
const spacesBetweenHashAndIdentifier =
|
||||
columnIdentifierStart - columnHashEnd;
|
||||
if (spacesBetweenHashAndIdentifier != 0) {
|
||||
this.raise(
|
||||
columnIdentifierStart,
|
||||
"Unexpected space between # and identifier",
|
||||
);
|
||||
}
|
||||
|
||||
node.id = this.parseIdentifier(true);
|
||||
return this.finishNode(node, "PrivateName");
|
||||
} else {
|
||||
@@ -933,7 +969,16 @@ export default class ExpressionParser extends LValParser {
|
||||
|
||||
parseFunctionExpression(): N.FunctionExpression | N.MetaProperty {
|
||||
const node = this.startNode();
|
||||
const meta = this.parseIdentifier(true);
|
||||
|
||||
// We do not do parseIdentifier here because when parseFunctionExpression
|
||||
// is called we already know that the current token is a "name" with the value "function"
|
||||
// This will improve perf a tiny little bit as we do not do validation but more importantly
|
||||
// here is that parseIdentifier will remove an item from the expression stack
|
||||
// if "function" or "class" is parsed as identifier (in objects e.g.), which should not happen here.
|
||||
let meta = this.startNode();
|
||||
this.next();
|
||||
meta = this.createIdentifier(meta, "function");
|
||||
|
||||
if (this.state.inGenerator && this.eat(tt.dot)) {
|
||||
return this.parseMetaProperty(node, meta, "sent");
|
||||
}
|
||||
@@ -1032,9 +1077,9 @@ export default class ExpressionParser extends LValParser {
|
||||
this.expect(tt.parenL);
|
||||
|
||||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||||
const oldYield = this.state.yieldInPossibleArrowParameters;
|
||||
const oldYOAIPAP = this.state.yieldOrAwaitInPossibleArrowParameters;
|
||||
this.state.maybeInArrowParameters = true;
|
||||
this.state.yieldInPossibleArrowParameters = null;
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters = null;
|
||||
|
||||
const innerStartPos = this.state.start;
|
||||
const innerStartLoc = this.state.startLoc;
|
||||
@@ -1107,11 +1152,14 @@ export default class ExpressionParser extends LValParser {
|
||||
}
|
||||
|
||||
this.parseArrowExpression(arrowNode, exprList);
|
||||
this.state.yieldInPossibleArrowParameters = oldYield;
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters = oldYOAIPAP;
|
||||
return arrowNode;
|
||||
}
|
||||
|
||||
this.state.yieldInPossibleArrowParameters = oldYield;
|
||||
// We keep the old value if it isn't null, for cases like
|
||||
// (x = (yield)) => {}
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters =
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters || oldYOAIPAP;
|
||||
|
||||
if (!exprList.length) {
|
||||
this.unexpected(this.state.lastTokStart);
|
||||
@@ -1305,7 +1353,6 @@ export default class ExpressionParser extends LValParser {
|
||||
}
|
||||
|
||||
if (this.match(tt.ellipsis)) {
|
||||
this.expectPlugin("objectRestSpread");
|
||||
prop = this.parseSpread(isPattern ? { start: 0 } : undefined);
|
||||
if (isPattern) {
|
||||
this.toAssignable(prop, true, "object pattern");
|
||||
@@ -1365,11 +1412,7 @@ export default class ExpressionParser extends LValParser {
|
||||
prop.computed = false;
|
||||
} else {
|
||||
isAsync = true;
|
||||
if (this.match(tt.star)) {
|
||||
this.expectPlugin("asyncGenerators");
|
||||
this.next();
|
||||
isGenerator = true;
|
||||
}
|
||||
isGenerator = this.eat(tt.star);
|
||||
this.parsePropertyName(prop);
|
||||
}
|
||||
} else {
|
||||
@@ -1608,9 +1651,11 @@ export default class ExpressionParser extends LValParser {
|
||||
): T {
|
||||
const oldInFunc = this.state.inFunction;
|
||||
const oldInMethod = this.state.inMethod;
|
||||
const oldInAsync = this.state.inAsync;
|
||||
const oldInGenerator = this.state.inGenerator;
|
||||
this.state.inFunction = true;
|
||||
this.state.inMethod = node.kind || true;
|
||||
this.state.inAsync = isAsync;
|
||||
this.state.inGenerator = isGenerator;
|
||||
|
||||
this.initFunction(node, isAsync);
|
||||
@@ -1621,6 +1666,7 @@ export default class ExpressionParser extends LValParser {
|
||||
|
||||
this.state.inFunction = oldInFunc;
|
||||
this.state.inMethod = oldInMethod;
|
||||
this.state.inAsync = oldInAsync;
|
||||
this.state.inGenerator = oldInGenerator;
|
||||
|
||||
return node;
|
||||
@@ -1636,12 +1682,21 @@ export default class ExpressionParser extends LValParser {
|
||||
): N.ArrowFunctionExpression {
|
||||
// if we got there, it's no more "yield in possible arrow parameters";
|
||||
// it's just "yield in arrow parameters"
|
||||
if (this.state.yieldInPossibleArrowParameters) {
|
||||
this.raise(
|
||||
this.state.yieldInPossibleArrowParameters.start,
|
||||
"yield is not allowed in the parameters of an arrow function" +
|
||||
" inside a generator",
|
||||
);
|
||||
const yOAIPAP = this.state.yieldOrAwaitInPossibleArrowParameters;
|
||||
if (yOAIPAP) {
|
||||
if (yOAIPAP.type === "YieldExpression") {
|
||||
this.raise(
|
||||
yOAIPAP.start,
|
||||
"yield is not allowed in the parameters of an arrow function" +
|
||||
" inside a generator",
|
||||
);
|
||||
} else {
|
||||
this.raise(
|
||||
yOAIPAP.start,
|
||||
"await is not allowed in the parameters of an arrow function" +
|
||||
" inside an async function",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const oldInFunc = this.state.inFunction;
|
||||
@@ -1649,11 +1704,14 @@ export default class ExpressionParser extends LValParser {
|
||||
this.initFunction(node, isAsync);
|
||||
if (params) this.setArrowFunctionParameters(node, params);
|
||||
|
||||
const oldInAsync = this.state.inAsync;
|
||||
const oldInGenerator = this.state.inGenerator;
|
||||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||||
this.state.inAsync = true;
|
||||
this.state.inGenerator = false;
|
||||
this.state.maybeInArrowParameters = false;
|
||||
this.parseFunctionBody(node, true);
|
||||
this.state.inAsync = oldInAsync;
|
||||
this.state.inGenerator = oldInGenerator;
|
||||
this.state.inFunction = oldInFunc;
|
||||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||||
@@ -1701,9 +1759,7 @@ export default class ExpressionParser extends LValParser {
|
||||
const isExpression = allowExpression && !this.match(tt.braceL);
|
||||
|
||||
const oldInParameters = this.state.inParameters;
|
||||
const oldInAsync = this.state.inAsync;
|
||||
this.state.inParameters = false;
|
||||
this.state.inAsync = node.async;
|
||||
|
||||
if (isExpression) {
|
||||
node.body = this.parseMaybeAssign();
|
||||
@@ -1721,7 +1777,6 @@ export default class ExpressionParser extends LValParser {
|
||||
this.state.inGenerator = oldInGen;
|
||||
this.state.labels = oldLabels;
|
||||
}
|
||||
this.state.inAsync = oldInAsync;
|
||||
|
||||
this.checkFunctionNameAndParams(node, allowExpression);
|
||||
this.state.inParameters = oldInParameters;
|
||||
@@ -1822,8 +1877,14 @@ export default class ExpressionParser extends LValParser {
|
||||
parseIdentifier(liberal?: boolean): N.Identifier {
|
||||
const node = this.startNode();
|
||||
const name = this.parseIdentifierName(node.start, liberal);
|
||||
|
||||
return this.createIdentifier(node, name);
|
||||
}
|
||||
|
||||
createIdentifier(node: N.Identifier, name: string): N.Identifier {
|
||||
node.name = name;
|
||||
node.loc.identifierName = name;
|
||||
|
||||
return this.finishNode(node, "Identifier");
|
||||
}
|
||||
|
||||
@@ -1843,6 +1904,19 @@ export default class ExpressionParser extends LValParser {
|
||||
name = this.state.value;
|
||||
} else if (this.state.type.keyword) {
|
||||
name = this.state.type.keyword;
|
||||
|
||||
// `class` and `function` keywords push new context into this.context.
|
||||
// But there is no chance to pop the context if the keyword is consumed
|
||||
// as an identifier such as a property name.
|
||||
// If the previous token is a dot, this does not apply because the
|
||||
// context-managing code already ignored the keyword
|
||||
if (
|
||||
(name === "class" || name === "function") &&
|
||||
(this.state.lastTokEnd !== this.state.lastTokStart + 1 ||
|
||||
this.input.charCodeAt(this.state.lastTokStart) !== charCodes.dot)
|
||||
) {
|
||||
this.state.context.pop();
|
||||
}
|
||||
} else {
|
||||
throw this.unexpected();
|
||||
}
|
||||
@@ -1898,12 +1972,27 @@ export default class ExpressionParser extends LValParser {
|
||||
) {
|
||||
this.unexpected();
|
||||
}
|
||||
if (this.state.inParameters) {
|
||||
this.raise(
|
||||
node.start,
|
||||
"await is not allowed in async function parameters",
|
||||
);
|
||||
}
|
||||
if (this.match(tt.star)) {
|
||||
this.raise(
|
||||
node.start,
|
||||
"await* has been removed from the async functions proposal. Use Promise.all() instead.",
|
||||
);
|
||||
}
|
||||
if (
|
||||
this.state.maybeInArrowParameters &&
|
||||
// We only set yieldOrAwaitInPossibleArrowParameters if we haven't already
|
||||
// found a possible invalid AwaitExpression.
|
||||
!this.state.yieldOrAwaitInPossibleArrowParameters
|
||||
) {
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters = node;
|
||||
}
|
||||
|
||||
node.argument = this.parseMaybeUnary();
|
||||
return this.finishNode(node, "AwaitExpression");
|
||||
}
|
||||
@@ -1918,11 +2007,11 @@ export default class ExpressionParser extends LValParser {
|
||||
}
|
||||
if (
|
||||
this.state.maybeInArrowParameters &&
|
||||
// We only set yieldInPossibleArrowParameters if we haven't already
|
||||
// We only set yieldOrAwaitInPossibleArrowParameters if we haven't already
|
||||
// found a possible invalid YieldExpression.
|
||||
!this.state.yieldInPossibleArrowParameters
|
||||
!this.state.yieldOrAwaitInPossibleArrowParameters
|
||||
) {
|
||||
this.state.yieldInPossibleArrowParameters = node;
|
||||
this.state.yieldOrAwaitInPossibleArrowParameters = node;
|
||||
}
|
||||
|
||||
this.next();
|
||||
|
||||
@@ -177,6 +177,7 @@ export default class LValParser extends NodeUtils {
|
||||
|
||||
toReferencedList(
|
||||
exprList: $ReadOnlyArray<?Expression>,
|
||||
isInParens?: boolean, // eslint-disable-line no-unused-vars
|
||||
): $ReadOnlyArray<?Expression> {
|
||||
return exprList;
|
||||
}
|
||||
|
||||
@@ -305,15 +305,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.eat(tt.parenL)) {
|
||||
const node = this.startNodeAt(startPos, startLoc);
|
||||
node.callee = expr;
|
||||
node.arguments = this.parseCallExpressionArguments(tt.parenR, false);
|
||||
this.toReferencedList(node.arguments);
|
||||
expr = this.finishNode(node, "CallExpression");
|
||||
}
|
||||
|
||||
node.expression = expr;
|
||||
node.expression = this.parseMaybeDecoratorArguments(expr);
|
||||
this.state.decoratorStack.pop();
|
||||
} else {
|
||||
node.expression = this.parseMaybeAssign();
|
||||
@@ -321,6 +313,18 @@ export default class StatementParser extends ExpressionParser {
|
||||
return this.finishNode(node, "Decorator");
|
||||
}
|
||||
|
||||
parseMaybeDecoratorArguments(expr: N.Expression): N.Expression {
|
||||
if (this.eat(tt.parenL)) {
|
||||
const node = this.startNodeAtNode(expr);
|
||||
node.callee = expr;
|
||||
node.arguments = this.parseCallExpressionArguments(tt.parenR, false);
|
||||
this.toReferencedList(node.arguments);
|
||||
return this.finishNode(node, "CallExpression");
|
||||
}
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
parseBreakContinueStatement(
|
||||
node: N.BreakStatement | N.ContinueStatement,
|
||||
keyword: string,
|
||||
@@ -387,7 +391,6 @@ export default class StatementParser extends ExpressionParser {
|
||||
|
||||
let forAwait = false;
|
||||
if (this.state.inAsync && this.isContextual("await")) {
|
||||
this.expectPlugin("asyncGenerators");
|
||||
forAwait = true;
|
||||
this.next();
|
||||
}
|
||||
@@ -552,7 +555,6 @@ export default class StatementParser extends ExpressionParser {
|
||||
this.checkLVal(clause.param, true, clashes, "catch clause");
|
||||
this.expect(tt.parenR);
|
||||
} else {
|
||||
this.expectPlugin("optionalCatchBinding");
|
||||
clause.param = null;
|
||||
}
|
||||
clause.body = this.parseBlock();
|
||||
@@ -617,8 +619,8 @@ export default class StatementParser extends ExpressionParser {
|
||||
const kind = this.state.type.isLoop
|
||||
? "loop"
|
||||
: this.match(tt._switch)
|
||||
? "switch"
|
||||
: null;
|
||||
? "switch"
|
||||
: null;
|
||||
for (let i = this.state.labels.length - 1; i >= 0; i--) {
|
||||
const label = this.state.labels[i];
|
||||
if (label.statementStart === node.start) {
|
||||
@@ -840,6 +842,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
): T {
|
||||
const oldInFunc = this.state.inFunction;
|
||||
const oldInMethod = this.state.inMethod;
|
||||
const oldInAsync = this.state.inAsync;
|
||||
const oldInGenerator = this.state.inGenerator;
|
||||
const oldInClassProperty = this.state.inClassProperty;
|
||||
this.state.inFunction = true;
|
||||
@@ -849,9 +852,6 @@ export default class StatementParser extends ExpressionParser {
|
||||
this.initFunction(node, isAsync);
|
||||
|
||||
if (this.match(tt.star)) {
|
||||
if (node.async) {
|
||||
this.expectPlugin("asyncGenerators");
|
||||
}
|
||||
node.generator = true;
|
||||
this.next();
|
||||
}
|
||||
@@ -873,11 +873,18 @@ export default class StatementParser extends ExpressionParser {
|
||||
// valid because yield is parsed as if it was outside the generator.
|
||||
// Therefore, this.state.inGenerator is set before or after parsing the
|
||||
// function id according to the "isStatement" parameter.
|
||||
if (!isStatement) this.state.inGenerator = node.generator;
|
||||
// The same applies to await & async functions.
|
||||
if (!isStatement) {
|
||||
this.state.inAsync = isAsync;
|
||||
this.state.inGenerator = node.generator;
|
||||
}
|
||||
if (this.match(tt.name) || this.match(tt._yield)) {
|
||||
node.id = this.parseBindingIdentifier();
|
||||
}
|
||||
if (isStatement) this.state.inGenerator = node.generator;
|
||||
if (isStatement) {
|
||||
this.state.inAsync = isAsync;
|
||||
this.state.inGenerator = node.generator;
|
||||
}
|
||||
|
||||
this.parseFunctionParams(node);
|
||||
this.parseFunctionBodyAndFinish(
|
||||
@@ -888,6 +895,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
|
||||
this.state.inFunction = oldInFunc;
|
||||
this.state.inMethod = oldInMethod;
|
||||
this.state.inAsync = oldInAsync;
|
||||
this.state.inGenerator = oldInGenerator;
|
||||
this.state.inClassProperty = oldInClassProperty;
|
||||
|
||||
@@ -1149,11 +1157,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
}
|
||||
} else if (isSimple && key.name === "async" && !this.isLineTerminator()) {
|
||||
// an async method
|
||||
const isGenerator = this.match(tt.star);
|
||||
if (isGenerator) {
|
||||
this.expectPlugin("asyncGenerators");
|
||||
this.next();
|
||||
}
|
||||
const isGenerator = this.eat(tt.star);
|
||||
|
||||
method.kind = "method";
|
||||
// The so-called parsed name would have been "async": get the real name.
|
||||
|
||||
@@ -6,10 +6,11 @@ import * as N from "../types";
|
||||
import type { Options } from "../options";
|
||||
import type { Pos, Position } from "../util/location";
|
||||
import type State from "../tokenizer/state";
|
||||
import { types as tc } from "../tokenizer/context";
|
||||
import * as charCodes from "charcodes";
|
||||
import { isIteratorStart } from "../util/identifier";
|
||||
|
||||
const primitiveTypes = [
|
||||
const reservedTypes = [
|
||||
"any",
|
||||
"bool",
|
||||
"boolean",
|
||||
@@ -23,6 +24,9 @@ const primitiveTypes = [
|
||||
"true",
|
||||
"typeof",
|
||||
"void",
|
||||
"interface",
|
||||
"extends",
|
||||
"_",
|
||||
];
|
||||
|
||||
function isEsModuleType(bodyElement: N.Node): boolean {
|
||||
@@ -463,7 +467,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
} while (this.eat(tt.comma));
|
||||
}
|
||||
|
||||
node.body = this.flowParseObjectType(isClass, false, false, isClass);
|
||||
node.body = this.flowParseObjectType({
|
||||
allowStatic: isClass,
|
||||
allowExact: false,
|
||||
allowSpread: false,
|
||||
allowProto: isClass,
|
||||
allowInexact: false,
|
||||
});
|
||||
}
|
||||
|
||||
flowParseInterfaceExtends(): N.FlowInterfaceExtends {
|
||||
@@ -484,9 +494,18 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return this.finishNode(node, "InterfaceDeclaration");
|
||||
}
|
||||
|
||||
checkNotUnderscore(word: string) {
|
||||
if (word === "_") {
|
||||
throw this.unexpected(
|
||||
null,
|
||||
"`_` is only allowed as a type argument to call or new",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
checkReservedType(word: string, startLoc: number) {
|
||||
if (primitiveTypes.indexOf(word) > -1) {
|
||||
this.raise(startLoc, `Cannot overwrite primitive type ${word}`);
|
||||
if (reservedTypes.indexOf(word) > -1) {
|
||||
this.raise(startLoc, `Cannot overwrite reserved type ${word}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -632,12 +651,36 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
this.state.inType = true;
|
||||
|
||||
this.expectRelational("<");
|
||||
const oldNoAnonFunctionType = this.state.noAnonFunctionType;
|
||||
this.state.noAnonFunctionType = false;
|
||||
while (!this.isRelational(">")) {
|
||||
node.params.push(this.flowParseType());
|
||||
if (!this.isRelational(">")) {
|
||||
this.expect(tt.comma);
|
||||
}
|
||||
}
|
||||
this.state.noAnonFunctionType = oldNoAnonFunctionType;
|
||||
this.expectRelational(">");
|
||||
|
||||
this.state.inType = oldInType;
|
||||
|
||||
return this.finishNode(node, "TypeParameterInstantiation");
|
||||
}
|
||||
|
||||
flowParseTypeParameterInstantiationCallOrNew(): N.TypeParameterInstantiation {
|
||||
const node = this.startNode();
|
||||
const oldInType = this.state.inType;
|
||||
node.params = [];
|
||||
|
||||
this.state.inType = true;
|
||||
|
||||
this.expectRelational("<");
|
||||
while (!this.isRelational(">")) {
|
||||
node.params.push(this.flowParseTypeOrImplicitInstantiation());
|
||||
if (!this.isRelational(">")) {
|
||||
this.expect(tt.comma);
|
||||
}
|
||||
}
|
||||
this.expectRelational(">");
|
||||
|
||||
this.state.inType = oldInType;
|
||||
@@ -656,7 +699,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
} while (this.eat(tt.comma));
|
||||
}
|
||||
|
||||
node.body = this.flowParseObjectType(false, false, false, false);
|
||||
node.body = this.flowParseObjectType({
|
||||
allowStatic: false,
|
||||
allowExact: false,
|
||||
allowSpread: false,
|
||||
allowProto: false,
|
||||
allowInexact: false,
|
||||
});
|
||||
|
||||
return this.finishNode(node, "InterfaceTypeAnnotation");
|
||||
}
|
||||
@@ -754,12 +803,19 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return this.finishNode(node, "ObjectTypeCallProperty");
|
||||
}
|
||||
|
||||
flowParseObjectType(
|
||||
flowParseObjectType({
|
||||
allowStatic,
|
||||
allowExact,
|
||||
allowSpread,
|
||||
allowProto,
|
||||
allowInexact,
|
||||
}: {
|
||||
allowStatic: boolean,
|
||||
allowExact: boolean,
|
||||
allowSpread: boolean,
|
||||
allowProto: boolean,
|
||||
): N.FlowObjectTypeAnnotation {
|
||||
allowInexact: boolean,
|
||||
}): N.FlowObjectTypeAnnotation {
|
||||
const oldInType = this.state.inType;
|
||||
this.state.inType = true;
|
||||
|
||||
@@ -772,6 +828,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
|
||||
let endDelim;
|
||||
let exact;
|
||||
let inexact = false;
|
||||
if (allowExact && this.match(tt.braceBarL)) {
|
||||
this.expect(tt.braceBarL);
|
||||
endDelim = tt.braceBarR;
|
||||
@@ -852,16 +909,21 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
}
|
||||
|
||||
nodeStart.properties.push(
|
||||
this.flowParseObjectTypeProperty(
|
||||
node,
|
||||
isStatic,
|
||||
protoStart,
|
||||
variance,
|
||||
kind,
|
||||
allowSpread,
|
||||
),
|
||||
const propOrInexact = this.flowParseObjectTypeProperty(
|
||||
node,
|
||||
isStatic,
|
||||
protoStart,
|
||||
variance,
|
||||
kind,
|
||||
allowSpread,
|
||||
allowInexact,
|
||||
);
|
||||
|
||||
if (propOrInexact === null) {
|
||||
inexact = true;
|
||||
} else {
|
||||
nodeStart.properties.push(propOrInexact);
|
||||
}
|
||||
}
|
||||
|
||||
this.flowObjectTypeSemicolon();
|
||||
@@ -869,6 +931,15 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
|
||||
this.expect(endDelim);
|
||||
|
||||
/* The inexact flag should only be added on ObjectTypeAnnotations that
|
||||
* are not the body of an interface, declare interface, or declare class.
|
||||
* Since spreads are only allowed in objec types, checking that is
|
||||
* sufficient here.
|
||||
*/
|
||||
if (allowSpread) {
|
||||
nodeStart.inexact = inexact;
|
||||
}
|
||||
|
||||
const out = this.finishNode(nodeStart, "ObjectTypeAnnotation");
|
||||
|
||||
this.state.inType = oldInType;
|
||||
@@ -883,7 +954,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
variance: ?N.FlowVariance,
|
||||
kind: string,
|
||||
allowSpread: boolean,
|
||||
): N.FlowObjectTypeProperty | N.FlowObjectTypeSpreadProperty {
|
||||
allowInexact: boolean,
|
||||
): (N.FlowObjectTypeProperty | N.FlowObjectTypeSpreadProperty) | null {
|
||||
if (this.match(tt.ellipsis)) {
|
||||
if (!allowSpread) {
|
||||
this.unexpected(
|
||||
@@ -901,8 +973,30 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
);
|
||||
}
|
||||
this.expect(tt.ellipsis);
|
||||
node.argument = this.flowParseType();
|
||||
const isInexactToken = this.eat(tt.comma) || this.eat(tt.semi);
|
||||
|
||||
if (this.match(tt.braceR)) {
|
||||
if (allowInexact) return null;
|
||||
this.unexpected(
|
||||
null,
|
||||
"Explicit inexact syntax is only allowed inside inexact objects",
|
||||
);
|
||||
}
|
||||
|
||||
if (this.match(tt.braceBarR)) {
|
||||
this.unexpected(
|
||||
null,
|
||||
"Explicit inexact syntax cannot appear inside an explicit exact object type",
|
||||
);
|
||||
}
|
||||
|
||||
if (isInexactToken) {
|
||||
this.unexpected(
|
||||
null,
|
||||
"Explicit inexact syntax must appear at the end of an inexact object",
|
||||
);
|
||||
}
|
||||
node.argument = this.flowParseType();
|
||||
return this.finishNode(node, "ObjectTypeSpreadProperty");
|
||||
} else {
|
||||
node.key = this.flowParseObjectPropertyKey();
|
||||
@@ -1116,6 +1210,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return this.finishNode(node, "StringTypeAnnotation");
|
||||
|
||||
default:
|
||||
this.checkNotUnderscore(id.name);
|
||||
return this.flowParseGenericType(startPos, startLoc, id);
|
||||
}
|
||||
}
|
||||
@@ -1146,10 +1241,22 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
);
|
||||
|
||||
case tt.braceL:
|
||||
return this.flowParseObjectType(false, false, true, false);
|
||||
return this.flowParseObjectType({
|
||||
allowStatic: false,
|
||||
allowExact: false,
|
||||
allowSpread: true,
|
||||
allowProto: false,
|
||||
allowInexact: true,
|
||||
});
|
||||
|
||||
case tt.braceBarL:
|
||||
return this.flowParseObjectType(false, true, true, false);
|
||||
return this.flowParseObjectType({
|
||||
allowStatic: false,
|
||||
allowExact: true,
|
||||
allowSpread: true,
|
||||
allowProto: false,
|
||||
allowInexact: false,
|
||||
});
|
||||
|
||||
case tt.bracketL:
|
||||
return this.flowParseTupleType();
|
||||
@@ -1359,6 +1466,17 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return type;
|
||||
}
|
||||
|
||||
flowParseTypeOrImplicitInstantiation(): N.FlowTypeAnnotation {
|
||||
if (this.state.type === tt.name && this.state.value === "_") {
|
||||
const startPos = this.state.start;
|
||||
const startLoc = this.state.startLoc;
|
||||
const node = this.parseIdentifier();
|
||||
return this.flowParseGenericType(startPos, startLoc, node);
|
||||
} else {
|
||||
return this.flowParseType();
|
||||
}
|
||||
}
|
||||
|
||||
flowParseTypeAnnotation(): N.FlowTypeAnnotation {
|
||||
const node = this.startNode();
|
||||
node.typeAnnotation = this.flowParseTypeInitialiser();
|
||||
@@ -1859,40 +1977,26 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
// type casts that we've found that are illegal in this context
|
||||
toReferencedList(
|
||||
exprList: $ReadOnlyArray<?N.Expression>,
|
||||
isInParens?: boolean,
|
||||
): $ReadOnlyArray<?N.Expression> {
|
||||
for (let i = 0; i < exprList.length; i++) {
|
||||
const expr = exprList[i];
|
||||
if (expr && expr._exprListItem && expr.type === "TypeCastExpression") {
|
||||
this.raise(expr.start, "Unexpected type cast");
|
||||
if (
|
||||
expr &&
|
||||
expr.type === "TypeCastExpression" &&
|
||||
(!expr.extra || !expr.extra.parenthesized) &&
|
||||
(exprList.length > 1 || !isInParens)
|
||||
) {
|
||||
this.raise(
|
||||
expr.typeAnnotation.start,
|
||||
"The type cast expression is expected to be wrapped with parenthesis",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return exprList;
|
||||
}
|
||||
|
||||
// parse an item inside a expression list eg. `(NODE, NODE)` where NODE represents
|
||||
// the position where this function is called
|
||||
parseExprListItem(
|
||||
allowEmpty: ?boolean,
|
||||
refShorthandDefaultPos: ?Pos,
|
||||
refNeedsArrowPos: ?Pos,
|
||||
): ?N.Expression {
|
||||
const container = this.startNode();
|
||||
const node = super.parseExprListItem(
|
||||
allowEmpty,
|
||||
refShorthandDefaultPos,
|
||||
refNeedsArrowPos,
|
||||
);
|
||||
if (this.match(tt.colon)) {
|
||||
container._exprListItem = true;
|
||||
container.expression = node;
|
||||
container.typeAnnotation = this.flowParseTypeAnnotation();
|
||||
return this.finishNode(container, "TypeCastExpression");
|
||||
} else {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
checkLVal(
|
||||
expr: N.Expression,
|
||||
isBinding: ?boolean,
|
||||
@@ -2289,7 +2393,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
refNeedsArrowPos?: ?Pos,
|
||||
): N.Expression {
|
||||
let jsxError = null;
|
||||
if (tt.jsxTagStart && this.match(tt.jsxTagStart)) {
|
||||
if (
|
||||
this.hasPlugin("jsx") &&
|
||||
(this.match(tt.jsxTagStart) || this.isRelational("<"))
|
||||
) {
|
||||
const state = this.state.clone();
|
||||
try {
|
||||
return super.parseMaybeAssign(
|
||||
@@ -2305,7 +2412,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
// Remove `tc.j_expr` and `tc.j_oTag` from context added
|
||||
// by parsing `jsxTagStart` to stop the JSX plugin from
|
||||
// messing with the tokens
|
||||
this.state.context.length -= 2;
|
||||
const cLength = this.state.context.length;
|
||||
if (this.state.context[cLength - 1] === tc.j_oTag) {
|
||||
this.state.context.length -= 2;
|
||||
}
|
||||
|
||||
jsxError = err;
|
||||
} else {
|
||||
@@ -2510,7 +2620,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node.callee = base;
|
||||
const state = this.state.clone();
|
||||
try {
|
||||
node.typeArguments = this.flowParseTypeParameterInstantiation();
|
||||
node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();
|
||||
this.expect(tt.parenL);
|
||||
node.arguments = this.parseCallExpressionArguments(tt.parenR, false);
|
||||
if (subscriptState.optionalChainMember) {
|
||||
@@ -2541,7 +2651,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
if (this.shouldParseTypes() && this.isRelational("<")) {
|
||||
const state = this.state.clone();
|
||||
try {
|
||||
targs = this.flowParseTypeParameterInstantiation();
|
||||
targs = this.flowParseTypeParameterInstantiationCallOrNew();
|
||||
} catch (e) {
|
||||
if (e instanceof SyntaxError) {
|
||||
this.state = state;
|
||||
|
||||
@@ -506,6 +506,15 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return this.parseLiteral(this.state.value, "JSXText");
|
||||
} else if (this.match(tt.jsxTagStart)) {
|
||||
return this.jsxParseElement();
|
||||
} else if (
|
||||
this.isRelational("<") &&
|
||||
this.state.input.charCodeAt(this.state.pos) !==
|
||||
charCodes.exclamationMark
|
||||
) {
|
||||
// In case we encounter an lt token here it will always be the start of
|
||||
// jsx as the lt sign is not allowed in places that expect an expression
|
||||
this.finishToken(tt.jsxTagStart);
|
||||
return this.jsxParseElement();
|
||||
} else {
|
||||
return super.parseExprAtom(refShortHandDefaultPos);
|
||||
}
|
||||
@@ -538,7 +547,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
}
|
||||
|
||||
if (code === charCodes.lessThan && this.state.exprAllowed) {
|
||||
if (
|
||||
code === charCodes.lessThan &&
|
||||
this.state.exprAllowed &&
|
||||
this.state.input.charCodeAt(this.state.pos + 1) !==
|
||||
charCodes.exclamationMark
|
||||
) {
|
||||
++this.state.pos;
|
||||
return this.finishToken(tt.jsxTagStart);
|
||||
}
|
||||
|
||||
@@ -503,13 +503,55 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
const node: N.TsTupleType = this.startNode();
|
||||
node.elementTypes = this.tsParseBracketedList(
|
||||
"TupleElementTypes",
|
||||
this.tsParseType.bind(this),
|
||||
this.tsParseTupleElementType.bind(this),
|
||||
/* bracket */ true,
|
||||
/* skipFirstToken */ false,
|
||||
);
|
||||
|
||||
// Validate the elementTypes to ensure:
|
||||
// No mandatory elements may follow optional elements
|
||||
// If there's a rest element, it must be at the end of the tuple
|
||||
let seenOptionalElement = false;
|
||||
node.elementTypes.forEach((elementNode, i) => {
|
||||
if (elementNode.type === "TSRestType") {
|
||||
if (i !== node.elementTypes.length - 1) {
|
||||
this.raise(
|
||||
elementNode.start,
|
||||
"A rest element must be last in a tuple type.",
|
||||
);
|
||||
}
|
||||
} else if (elementNode.type === "TSOptionalType") {
|
||||
seenOptionalElement = true;
|
||||
} else if (seenOptionalElement) {
|
||||
this.raise(
|
||||
elementNode.start,
|
||||
"A required element cannot follow an optional element.",
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return this.finishNode(node, "TSTupleType");
|
||||
}
|
||||
|
||||
tsParseTupleElementType(): N.TsType {
|
||||
// parses `...TsType[]`
|
||||
if (this.match(tt.ellipsis)) {
|
||||
const restNode: N.TsRestType = this.startNode();
|
||||
this.next(); // skips ellipsis
|
||||
restNode.typeAnnotation = this.tsParseType();
|
||||
return this.finishNode(restNode, "TSRestType");
|
||||
}
|
||||
|
||||
const type = this.tsParseType();
|
||||
// parses `TsType?`
|
||||
if (this.eat(tt.question)) {
|
||||
const optionalTypeNode: N.TsOptionalType = this.startNodeAtNode(type);
|
||||
optionalTypeNode.typeAnnotation = type;
|
||||
return this.finishNode(optionalTypeNode, "TSOptionalType");
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
tsParseParenthesizedType(): N.TsParenthesizedType {
|
||||
const node = this.startNode();
|
||||
this.expect(tt.parenL);
|
||||
@@ -555,8 +597,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
const type = this.match(tt._void)
|
||||
? "TSVoidKeyword"
|
||||
: this.match(tt._null)
|
||||
? "TSNullKeyword"
|
||||
: keywordTypeFromName(this.state.value);
|
||||
? "TSNullKeyword"
|
||||
: keywordTypeFromName(this.state.value);
|
||||
if (type !== undefined && this.lookahead().type !== tt.dot) {
|
||||
const node: N.TsKeywordType = this.startNode();
|
||||
this.next();
|
||||
@@ -649,8 +691,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return operator
|
||||
? this.tsParseTypeOperator(operator)
|
||||
: this.isContextual("infer")
|
||||
? this.tsParseInferType()
|
||||
: this.tsParseArrayTypeOrHigher();
|
||||
? this.tsParseInferType()
|
||||
: this.tsParseArrayTypeOrHigher();
|
||||
}
|
||||
|
||||
tsParseUnionOrIntersectionType(
|
||||
@@ -1339,8 +1381,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
type === "FunctionDeclaration"
|
||||
? "TSDeclareFunction"
|
||||
: type === "ClassMethod"
|
||||
? "TSDeclareMethod"
|
||||
: undefined;
|
||||
? "TSDeclareMethod"
|
||||
: undefined;
|
||||
if (bodilessType && !this.match(tt.braceL) && this.isLineTerminator()) {
|
||||
this.finishNode(node, bodilessType);
|
||||
return;
|
||||
@@ -1368,10 +1410,11 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return this.finishNode(nonNullExpression, "TSNonNullExpression");
|
||||
}
|
||||
|
||||
// There are number of things we are going to "maybe" parse, like type arguments on
|
||||
// tagged template expressions. If any of them fail, walk it back and continue.
|
||||
const result = this.tsTryParseAndCatch(() => {
|
||||
if (this.isRelational("<")) {
|
||||
if (this.isRelational("<")) {
|
||||
// tsTryParseAndCatch is expensive, so avoid if not necessary.
|
||||
// There are number of things we are going to "maybe" parse, like type arguments on
|
||||
// tagged template expressions. If any of them fail, walk it back and continue.
|
||||
const result = this.tsTryParseAndCatch(() => {
|
||||
if (!noCalls && this.atPossibleAsync(base)) {
|
||||
// Almost certainly this is a generic async function `async <T>() => ...
|
||||
// But it might be a call with a type argument `async<T>();`
|
||||
@@ -1409,12 +1452,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.unexpected();
|
||||
});
|
||||
this.unexpected();
|
||||
});
|
||||
|
||||
if (result) return result;
|
||||
if (result) return result;
|
||||
}
|
||||
|
||||
return super.parseSubscript(base, startPos, startLoc, noCalls, state);
|
||||
}
|
||||
@@ -2046,6 +2089,22 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
}
|
||||
|
||||
parseMaybeDecoratorArguments(expr: N.Expression): N.Expression {
|
||||
if (this.isRelational("<")) {
|
||||
const typeArguments = this.tsParseTypeArguments();
|
||||
|
||||
if (this.match(tt.parenL)) {
|
||||
const call = super.parseMaybeDecoratorArguments(expr);
|
||||
call.typeParameters = typeArguments;
|
||||
return call;
|
||||
}
|
||||
|
||||
this.unexpected(this.state.start, tt.parenL);
|
||||
}
|
||||
|
||||
return super.parseMaybeDecoratorArguments(expr);
|
||||
}
|
||||
|
||||
// === === === === === === === === === === === === === === === ===
|
||||
// Note: All below methods are duplicates of something in flow.js.
|
||||
// Not sure what the best way to combine these is.
|
||||
@@ -2115,6 +2174,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
|
||||
toReferencedList(
|
||||
exprList: $ReadOnlyArray<?N.Expression>,
|
||||
isInParens?: boolean, // eslint-disable-line no-unused-vars
|
||||
): $ReadOnlyArray<?N.Expression> {
|
||||
for (let i = 0; i < exprList.length; i++) {
|
||||
const expr = exprList[i];
|
||||
|
||||
@@ -12,7 +12,7 @@ export class TokContext {
|
||||
token: string,
|
||||
isExpr?: boolean,
|
||||
preserveSpace?: boolean,
|
||||
override?: Function, // Takes a Tokenizer as a this-parameter, and returns void.
|
||||
override?: ?Function, // Takes a Tokenizer as a this-parameter, and returns void.
|
||||
) {
|
||||
this.token = token;
|
||||
this.isExpr = !!isExpr;
|
||||
@@ -31,11 +31,12 @@ export const types: {
|
||||
} = {
|
||||
braceStatement: new TokContext("{", false),
|
||||
braceExpression: new TokContext("{", true),
|
||||
templateQuasi: new TokContext("${", true),
|
||||
templateQuasi: new TokContext("${", false),
|
||||
parenStatement: new TokContext("(", false),
|
||||
parenExpression: new TokContext("(", true),
|
||||
template: new TokContext("`", true, true, p => p.readTmplToken()),
|
||||
functionExpression: new TokContext("function", true),
|
||||
functionStatement: new TokContext("function", false),
|
||||
};
|
||||
|
||||
// Token-specific context update code
|
||||
@@ -46,33 +47,26 @@ tt.parenR.updateContext = tt.braceR.updateContext = function() {
|
||||
return;
|
||||
}
|
||||
|
||||
const out = this.state.context.pop();
|
||||
if (
|
||||
out === types.braceStatement &&
|
||||
this.curContext() === types.functionExpression
|
||||
) {
|
||||
this.state.context.pop();
|
||||
this.state.exprAllowed = false;
|
||||
} else if (out === types.templateQuasi) {
|
||||
this.state.exprAllowed = true;
|
||||
} else {
|
||||
this.state.exprAllowed = !out.isExpr;
|
||||
let out = this.state.context.pop();
|
||||
if (out === types.braceStatement && this.curContext().token === "function") {
|
||||
out = this.state.context.pop();
|
||||
}
|
||||
|
||||
this.state.exprAllowed = !out.isExpr;
|
||||
};
|
||||
|
||||
tt.name.updateContext = function(prevType) {
|
||||
if (this.state.value === "of" && this.curContext() === types.parenStatement) {
|
||||
this.state.exprAllowed = !prevType.beforeExpr;
|
||||
return;
|
||||
}
|
||||
|
||||
this.state.exprAllowed = false;
|
||||
|
||||
if (prevType === tt._let || prevType === tt._const || prevType === tt._var) {
|
||||
if (lineBreak.test(this.input.slice(this.state.end))) {
|
||||
this.state.exprAllowed = true;
|
||||
let allowed = false;
|
||||
if (prevType !== tt.dot) {
|
||||
if (
|
||||
(this.state.value === "of" && !this.state.exprAllowed) ||
|
||||
(this.state.value === "yield" && this.state.inGenerator)
|
||||
) {
|
||||
allowed = true;
|
||||
}
|
||||
}
|
||||
this.state.exprAllowed = allowed;
|
||||
|
||||
if (this.state.isIterator) {
|
||||
this.state.isIterator = false;
|
||||
}
|
||||
@@ -106,9 +100,23 @@ tt.incDec.updateContext = function() {
|
||||
// tokExprAllowed stays unchanged
|
||||
};
|
||||
|
||||
tt._function.updateContext = function(prevType) {
|
||||
if (this.state.exprAllowed && !this.braceIsBlock(prevType)) {
|
||||
tt._function.updateContext = tt._class.updateContext = function(prevType) {
|
||||
if (
|
||||
prevType.beforeExpr &&
|
||||
prevType !== tt.semi &&
|
||||
prevType !== tt._else &&
|
||||
!(
|
||||
prevType === tt._return &&
|
||||
lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start))
|
||||
) &&
|
||||
!(
|
||||
(prevType === tt.colon || prevType === tt.braceL) &&
|
||||
this.curContext() === types.b_stat
|
||||
)
|
||||
) {
|
||||
this.state.context.push(types.functionExpression);
|
||||
} else {
|
||||
this.state.context.push(types.functionStatement);
|
||||
}
|
||||
|
||||
this.state.exprAllowed = false;
|
||||
|
||||
@@ -881,10 +881,10 @@ export default class Tokenizer extends LocationParser {
|
||||
radix === 16
|
||||
? allowedNumericSeparatorSiblings.hex
|
||||
: radix === 10
|
||||
? allowedNumericSeparatorSiblings.dec
|
||||
: radix === 8
|
||||
? allowedNumericSeparatorSiblings.oct
|
||||
: allowedNumericSeparatorSiblings.bin;
|
||||
? allowedNumericSeparatorSiblings.dec
|
||||
: radix === 8
|
||||
? allowedNumericSeparatorSiblings.oct
|
||||
: allowedNumericSeparatorSiblings.bin;
|
||||
|
||||
let total = 0;
|
||||
|
||||
@@ -1070,7 +1070,6 @@ export default class Tokenizer extends LocationParser {
|
||||
readString(quote: number): void {
|
||||
let out = "",
|
||||
chunkStart = ++this.state.pos;
|
||||
const hasJsonStrings = this.hasPlugin("jsonStrings");
|
||||
for (;;) {
|
||||
if (this.state.pos >= this.input.length) {
|
||||
this.raise(this.state.start, "Unterminated string constant");
|
||||
@@ -1083,10 +1082,11 @@ export default class Tokenizer extends LocationParser {
|
||||
out += this.readEscapedChar(false);
|
||||
chunkStart = this.state.pos;
|
||||
} else if (
|
||||
hasJsonStrings &&
|
||||
(ch === charCodes.lineSeparator || ch === charCodes.paragraphSeparator)
|
||||
ch === charCodes.lineSeparator ||
|
||||
ch === charCodes.paragraphSeparator
|
||||
) {
|
||||
++this.state.pos;
|
||||
++this.state.curLine;
|
||||
} else if (isNewLine(ch)) {
|
||||
this.raise(this.state.start, "Unterminated string constant");
|
||||
} else {
|
||||
@@ -1324,14 +1324,25 @@ export default class Tokenizer extends LocationParser {
|
||||
}
|
||||
|
||||
braceIsBlock(prevType: TokenType): boolean {
|
||||
if (prevType === tt.colon) {
|
||||
const parent = this.curContext();
|
||||
if (parent === ct.braceStatement || parent === ct.braceExpression) {
|
||||
return !parent.isExpr;
|
||||
}
|
||||
const parent = this.curContext();
|
||||
if (parent === ct.functionExpression || parent === ct.functionStatement) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
prevType === tt.colon &&
|
||||
(parent === ct.braceStatement || parent === ct.braceExpression)
|
||||
) {
|
||||
return !parent.isExpr;
|
||||
}
|
||||
|
||||
if (prevType === tt._return) {
|
||||
// The check for `tt.name && exprAllowed` detects whether we are
|
||||
// after a `yield` or `of` construct. See the `updateContext` for
|
||||
// `tt.name`.
|
||||
if (
|
||||
prevType === tt._return ||
|
||||
prevType === tt._yield ||
|
||||
(prevType === tt.name && this.state.exprAllowed)
|
||||
) {
|
||||
return lineBreak.test(
|
||||
this.input.slice(this.state.lastTokEnd, this.state.start),
|
||||
);
|
||||
@@ -1341,13 +1352,22 @@ export default class Tokenizer extends LocationParser {
|
||||
prevType === tt._else ||
|
||||
prevType === tt.semi ||
|
||||
prevType === tt.eof ||
|
||||
prevType === tt.parenR
|
||||
prevType === tt.parenR ||
|
||||
prevType === tt.arrow
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (prevType === tt.braceL) {
|
||||
return this.curContext() === ct.braceStatement;
|
||||
return parent === ct.braceStatement;
|
||||
}
|
||||
|
||||
if (
|
||||
prevType === tt._var ||
|
||||
prevType === tt._let ||
|
||||
prevType === tt._const
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (prevType === tt.relational) {
|
||||
|
||||
@@ -39,7 +39,7 @@ export default class State {
|
||||
|
||||
this.decoratorStack = [[]];
|
||||
|
||||
this.yieldInPossibleArrowParameters = null;
|
||||
this.yieldOrAwaitInPossibleArrowParameters = null;
|
||||
|
||||
this.tokens = [];
|
||||
|
||||
@@ -126,10 +126,10 @@ export default class State {
|
||||
// where @foo belongs to the outer class and @bar to the inner
|
||||
decoratorStack: Array<Array<N.Decorator>>;
|
||||
|
||||
// The first yield expression inside parenthesized expressions and arrow
|
||||
// function parameters. It is used to disallow yield in arrow function
|
||||
// parameters.
|
||||
yieldInPossibleArrowParameters: ?N.YieldExpression;
|
||||
// The first yield or await expression inside parenthesized expressions
|
||||
// and arrow function parameters. It is used to disallow yield and await in
|
||||
// arrow function parameters.
|
||||
yieldOrAwaitInPossibleArrowParameters: ?N.YieldExpression;
|
||||
|
||||
// Token store.
|
||||
tokens: Array<Token | N.Comment>;
|
||||
|
||||
@@ -174,7 +174,7 @@ export const keywords = {
|
||||
new: new KeywordTokenType("new", { beforeExpr, startsExpr }),
|
||||
this: new KeywordTokenType("this", { startsExpr }),
|
||||
super: new KeywordTokenType("super", { startsExpr }),
|
||||
class: new KeywordTokenType("class"),
|
||||
class: new KeywordTokenType("class", { startsExpr }),
|
||||
extends: new KeywordTokenType("extends", { beforeExpr }),
|
||||
export: new KeywordTokenType("export"),
|
||||
import: new KeywordTokenType("import", { startsExpr }),
|
||||
|
||||
@@ -398,7 +398,7 @@ export type ObjectMemberBase = NodeBase & {
|
||||
decorators: $ReadOnlyArray<Decorator>,
|
||||
kind?: "get" | "set" | "method",
|
||||
method: boolean, // TODO: Not in spec
|
||||
|
||||
typeParameters?: ?TypeParameterInstantiationBase, // TODO: Not in spec
|
||||
variance?: ?FlowVariance, // TODO: Not in spec
|
||||
};
|
||||
|
||||
@@ -1104,6 +1104,8 @@ export type TsType =
|
||||
| TsTypeLiteral
|
||||
| TsArrayType
|
||||
| TsTupleType
|
||||
| TsOptionalType
|
||||
| TsRestType
|
||||
| TsUnionOrIntersectionType
|
||||
| TsConditionalType
|
||||
| TsInferType
|
||||
@@ -1184,6 +1186,16 @@ export type TsTupleType = TsTypeBase & {
|
||||
elementTypes: $ReadOnlyArray<TsType>,
|
||||
};
|
||||
|
||||
export type TsOptionalType = TsTypeBase & {
|
||||
type: "TSOptionalType",
|
||||
typeAnnotation: TsType,
|
||||
};
|
||||
|
||||
export type TsRestType = TsTypeBase & {
|
||||
type: "TSRestType",
|
||||
typeAnnotation: TsType,
|
||||
};
|
||||
|
||||
export type TsUnionOrIntersectionType = TsUnionType | TsIntersectionType;
|
||||
|
||||
export type TsUnionOrIntersectionTypeBase = TsTypeBase & {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"plugins": ["objectRestSpread"]
|
||||
}
|
||||
9
packages/babel-parser/test/fixtures/es2015/class/division/input.js
vendored
Normal file
9
packages/babel-parser/test/fixtures/es2015/class/division/input.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
x = class{} / foo
|
||||
|
||||
x = class{}
|
||||
/ foo / g
|
||||
|
||||
(x = class{} / foo)
|
||||
|
||||
(x = class{}
|
||||
/ foo / g)
|
||||
561
packages/babel-parser/test/fixtures/es2015/class/division/output.json
vendored
Normal file
561
packages/babel-parser/test/fixtures/es2015/class/division/output.json
vendored
Normal file
@@ -0,0 +1,561 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 86,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 86,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "AssignmentExpression",
|
||||
"start": 0,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start": 0,
|
||||
"end": 1,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 1
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "BinaryExpression",
|
||||
"start": 4,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"left": {
|
||||
"type": "ClassExpression",
|
||||
"start": 4,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 9,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
},
|
||||
"operator": "/",
|
||||
"right": {
|
||||
"type": "Identifier",
|
||||
"start": 14,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 19,
|
||||
"end": 86,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "AssignmentExpression",
|
||||
"start": 19,
|
||||
"end": 86,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "BinaryExpression",
|
||||
"start": 23,
|
||||
"end": 86,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"left": {
|
||||
"type": "BinaryExpression",
|
||||
"start": 23,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 5
|
||||
}
|
||||
},
|
||||
"left": {
|
||||
"type": "ClassExpression",
|
||||
"start": 23,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 28,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
},
|
||||
"operator": "/",
|
||||
"right": {
|
||||
"type": "Identifier",
|
||||
"start": 33,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 5
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
},
|
||||
"operator": "/",
|
||||
"right": {
|
||||
"type": "CallExpression",
|
||||
"start": 39,
|
||||
"end": 86,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 39,
|
||||
"end": 61,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 39,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 9
|
||||
},
|
||||
"identifierName": "g"
|
||||
},
|
||||
"name": "g"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "AssignmentExpression",
|
||||
"start": 43,
|
||||
"end": 60,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start": 43,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 2
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "BinaryExpression",
|
||||
"start": 47,
|
||||
"end": 60,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"left": {
|
||||
"type": "ClassExpression",
|
||||
"start": 47,
|
||||
"end": 54,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 52,
|
||||
"end": 54,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
},
|
||||
"operator": "/",
|
||||
"right": {
|
||||
"type": "Identifier",
|
||||
"start": 57,
|
||||
"end": 60,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 18
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "AssignmentExpression",
|
||||
"start": 64,
|
||||
"end": 85,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 9
|
||||
}
|
||||
},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start": 64,
|
||||
"end": 65,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 2
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "BinaryExpression",
|
||||
"start": 68,
|
||||
"end": 85,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 9
|
||||
}
|
||||
},
|
||||
"left": {
|
||||
"type": "BinaryExpression",
|
||||
"start": 68,
|
||||
"end": 81,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 5
|
||||
}
|
||||
},
|
||||
"left": {
|
||||
"type": "ClassExpression",
|
||||
"start": 68,
|
||||
"end": 75,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 73,
|
||||
"end": 75,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
},
|
||||
"operator": "/",
|
||||
"right": {
|
||||
"type": "Identifier",
|
||||
"start": 78,
|
||||
"end": 81,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 9,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 5
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
},
|
||||
"operator": "/",
|
||||
"right": {
|
||||
"type": "Identifier",
|
||||
"start": 84,
|
||||
"end": 85,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 9,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 9
|
||||
},
|
||||
"identifierName": "g"
|
||||
},
|
||||
"name": "g"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2015/for-of/brackets-const/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2015/for-of/brackets-const/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
for (const {a} of /b/) {}
|
||||
194
packages/babel-parser/test/fixtures/es2015/for-of/brackets-const/output.json
vendored
Normal file
194
packages/babel-parser/test/fixtures/es2015/for-of/brackets-const/output.json
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ForOfStatement",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"await": false,
|
||||
"left": {
|
||||
"type": "VariableDeclaration",
|
||||
"start": 5,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 11,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "ObjectPattern",
|
||||
"start": 11,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 12,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 12,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": true,
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start": 12,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"init": null
|
||||
}
|
||||
],
|
||||
"kind": "const"
|
||||
},
|
||||
"right": {
|
||||
"type": "RegExpLiteral",
|
||||
"start": 18,
|
||||
"end": 21,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"raw": "/b/"
|
||||
},
|
||||
"pattern": "b",
|
||||
"flags": ""
|
||||
},
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 23,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2015/for-of/brackets-let/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2015/for-of/brackets-let/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
for (let {a} of /b/) {}
|
||||
194
packages/babel-parser/test/fixtures/es2015/for-of/brackets-let/output.json
vendored
Normal file
194
packages/babel-parser/test/fixtures/es2015/for-of/brackets-let/output.json
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ForOfStatement",
|
||||
"start": 0,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"await": false,
|
||||
"left": {
|
||||
"type": "VariableDeclaration",
|
||||
"start": 5,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 9,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "ObjectPattern",
|
||||
"start": 9,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": true,
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"init": null
|
||||
}
|
||||
],
|
||||
"kind": "let"
|
||||
},
|
||||
"right": {
|
||||
"type": "RegExpLiteral",
|
||||
"start": 16,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"raw": "/b/"
|
||||
},
|
||||
"pattern": "b",
|
||||
"flags": ""
|
||||
},
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 21,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2015/for-of/brackets-var/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2015/for-of/brackets-var/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
for (var {a} of /b/) {}
|
||||
194
packages/babel-parser/test/fixtures/es2015/for-of/brackets-var/output.json
vendored
Normal file
194
packages/babel-parser/test/fixtures/es2015/for-of/brackets-var/output.json
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ForOfStatement",
|
||||
"start": 0,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"await": false,
|
||||
"left": {
|
||||
"type": "VariableDeclaration",
|
||||
"start": 5,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 9,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "ObjectPattern",
|
||||
"start": 9,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": true,
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"init": null
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
},
|
||||
"right": {
|
||||
"type": "RegExpLiteral",
|
||||
"start": 16,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"raw": "/b/"
|
||||
},
|
||||
"pattern": "b",
|
||||
"flags": ""
|
||||
},
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 21,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/es2015/yield/asi2/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/es2015/yield/asi2/input.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
function *f() { yield
|
||||
{}/1/g
|
||||
}
|
||||
172
packages/babel-parser/test/fixtures/es2015/yield/asi2/output.json
vendored
Normal file
172
packages/babel-parser/test/fixtures/es2015/yield/asi2/output.json
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "f"
|
||||
},
|
||||
"name": "f"
|
||||
},
|
||||
"generator": true,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 14,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 16,
|
||||
"end": 21,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "YieldExpression",
|
||||
"start": 16,
|
||||
"end": 21,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
}
|
||||
},
|
||||
"delegate": false,
|
||||
"argument": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "BlockStatement",
|
||||
"start": 22,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
},
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 24,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "RegExpLiteral",
|
||||
"start": 24,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"raw": "/1/g"
|
||||
},
|
||||
"pattern": "1",
|
||||
"flags": "g"
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2015/yield/yield class/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2015/yield/yield class/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
function* bar() { yield class {} }
|
||||
152
packages/babel-parser/test/fixtures/es2015/yield/yield class/output.json
vendored
Normal file
152
packages/babel-parser/test/fixtures/es2015/yield/yield class/output.json
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "bar"
|
||||
},
|
||||
"name": "bar"
|
||||
},
|
||||
"generator": true,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 16,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 18,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "YieldExpression",
|
||||
"start": 18,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"delegate": false,
|
||||
"argument": {
|
||||
"type": "ClassExpression",
|
||||
"start": 24,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 24
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 30,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 30
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/es2017/async-functions/newline-arrow/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/es2017/async-functions/newline-arrow/input.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
async
|
||||
x => x
|
||||
136
packages/babel-parser/test/fixtures/es2017/async-functions/newline-arrow/output.json
vendored
Normal file
136
packages/babel-parser/test/fixtures/es2017/async-functions/newline-arrow/output.json
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 5,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "Identifier",
|
||||
"start": 0,
|
||||
"end": 5,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"identifierName": "async"
|
||||
},
|
||||
"name": "async"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 6,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start": 6,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start": 6,
|
||||
"end": 7,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 1
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "Identifier",
|
||||
"start": 11,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user