Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5080059138 | ||
|
|
8ee857e268 | ||
|
|
6b8261bbb7 | ||
|
|
ce1a6526e5 | ||
|
|
842c164be5 | ||
|
|
d2c75c2d38 | ||
|
|
3951acbff5 | ||
|
|
08454ece46 | ||
|
|
4b8cb75b74 | ||
|
|
3fa4f53d0a | ||
|
|
850bc1d3dd | ||
|
|
36d12b5969 | ||
|
|
2575312d1f | ||
|
|
a5b5ed928d | ||
|
|
3c87401714 | ||
|
|
07862e7272 | ||
|
|
ca89212b45 |
281
CHANGELOG.md
281
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.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"lerna": "2.11.0",
|
||||
"version": "7.1.2",
|
||||
"version": "7.1.4",
|
||||
"changelog": {
|
||||
"repo": "babel/babel",
|
||||
"cacheDir": ".changelog",
|
||||
|
||||
14
package.json
14
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",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/generator",
|
||||
"version": "7.1.2",
|
||||
"version": "7.1.3",
|
||||
"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.3",
|
||||
"jsesc": "^2.5.1",
|
||||
"lodash": "^4.17.10",
|
||||
"source-map": "^0.5.0",
|
||||
|
||||
@@ -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
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/parser",
|
||||
"version": "7.1.2",
|
||||
"version": "7.1.3",
|
||||
"description": "A JavaScript parser",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
|
||||
@@ -794,7 +794,12 @@ 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)) {
|
||||
} else if (
|
||||
canBeArrow &&
|
||||
!this.canInsertSemicolon() &&
|
||||
id.name === "async" &&
|
||||
this.match(tt.name)
|
||||
) {
|
||||
const oldYield = this.state.yieldInPossibleArrowParameters;
|
||||
this.state.yieldInPossibleArrowParameters = null;
|
||||
const params = [this.parseIdentifier()];
|
||||
@@ -923,7 +928,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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -503,13 +503,32 @@ 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,
|
||||
);
|
||||
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);
|
||||
@@ -1368,10 +1387,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 +1429,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 +2066,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.
|
||||
|
||||
@@ -106,7 +106,7 @@ tt.incDec.updateContext = function() {
|
||||
// tokExprAllowed stays unchanged
|
||||
};
|
||||
|
||||
tt._function.updateContext = function(prevType) {
|
||||
tt._function.updateContext = tt._class.updateContext = function(prevType) {
|
||||
if (this.state.exprAllowed && !this.braceIsBlock(prevType)) {
|
||||
this.state.context.push(types.functionExpression);
|
||||
}
|
||||
|
||||
@@ -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 & {
|
||||
|
||||
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": []
|
||||
}
|
||||
}
|
||||
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": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Spaces {
|
||||
# wrongSpaces() {
|
||||
return fail();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "Unexpected space between # and identifier (2:5)",
|
||||
"plugins": ["classPrivateMethods"]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Spaces {
|
||||
# wrongSpaces;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "Unexpected space between # and identifier (2:5)",
|
||||
"plugins": ["classPrivateMethods"]
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/typescript/decorators/type-arguments-invalid/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/typescript/decorators/type-arguments-invalid/input.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
@decorator<string>
|
||||
class Test {}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"plugins": [
|
||||
"typescript",
|
||||
["decorators", { "decoratorsBeforeExport": true }]
|
||||
],
|
||||
"throws": "Unexpected token, expected \"(\" (2:0)"
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/typescript/decorators/type-arguments/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/typescript/decorators/type-arguments/input.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
@decorator<string>()
|
||||
class Test {}
|
||||
6
packages/babel-parser/test/fixtures/typescript/decorators/type-arguments/options.json
vendored
Normal file
6
packages/babel-parser/test/fixtures/typescript/decorators/type-arguments/options.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
"typescript",
|
||||
["decorators", { "decoratorsBeforeExport": true }]
|
||||
]
|
||||
}
|
||||
166
packages/babel-parser/test/fixtures/typescript/decorators/type-arguments/output.json
vendored
Normal file
166
packages/babel-parser/test/fixtures/typescript/decorators/type-arguments/output.json
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 0,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start": 1,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 10,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"identifierName": "decorator"
|
||||
},
|
||||
"name": "decorator"
|
||||
},
|
||||
"arguments": [],
|
||||
"typeParameters": {
|
||||
"type": "TSTypeParameterInstantiation",
|
||||
"start": 10,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"params": [
|
||||
{
|
||||
"type": "TSStringKeyword",
|
||||
"start": 11,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 27,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"identifierName": "Test"
|
||||
},
|
||||
"name": "Test"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 32,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/typescript/legacy-decorators/type-arguments/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/typescript/legacy-decorators/type-arguments/input.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
@decorator<string>()
|
||||
class Test {}
|
||||
3
packages/babel-parser/test/fixtures/typescript/legacy-decorators/type-arguments/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/legacy-decorators/type-arguments/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["typescript", "decorators-legacy"]
|
||||
}
|
||||
166
packages/babel-parser/test/fixtures/typescript/legacy-decorators/type-arguments/output.json
vendored
Normal file
166
packages/babel-parser/test/fixtures/typescript/legacy-decorators/type-arguments/output.json
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 0,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start": 1,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 10,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"identifierName": "decorator"
|
||||
},
|
||||
"name": "decorator"
|
||||
},
|
||||
"arguments": [],
|
||||
"typeParameters": {
|
||||
"type": "TSTypeParameterInstantiation",
|
||||
"start": 10,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"params": [
|
||||
{
|
||||
"type": "TSStringKeyword",
|
||||
"start": 11,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 27,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"identifierName": "Test"
|
||||
},
|
||||
"name": "Test"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 32,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/typescript/types/tuple-empty/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/types/tuple-empty/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let x: [];
|
||||
117
packages/babel-parser/test/fixtures/typescript/types/tuple-empty/output.json
vendored
Normal file
117
packages/babel-parser/test/fixtures/typescript/types/tuple-empty/output.json
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 10,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 10,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 0,
|
||||
"end": 10,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 4,
|
||||
"end": 9,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 4,
|
||||
"end": 9,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start": 5,
|
||||
"end": 9,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TSTupleType",
|
||||
"start": 7,
|
||||
"end": 9,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
}
|
||||
},
|
||||
"elementTypes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"init": null
|
||||
}
|
||||
],
|
||||
"kind": "let"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/typescript/types/tuple-optional/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/types/tuple-optional/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let x: [string, number?, (string | number)?]
|
||||
240
packages/babel-parser/test/fixtures/typescript/types/tuple-optional/output.json
vendored
Normal file
240
packages/babel-parser/test/fixtures/typescript/types/tuple-optional/output.json
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 44
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 44
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 0,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 44
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 4,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 44
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 4,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 44
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start": 5,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 44
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TSTupleType",
|
||||
"start": 7,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 44
|
||||
}
|
||||
},
|
||||
"elementTypes": [
|
||||
{
|
||||
"type": "TSStringKeyword",
|
||||
"start": 8,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TSOptionalType",
|
||||
"start": 16,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TSNumberKeyword",
|
||||
"start": 16,
|
||||
"end": 22,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 22
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TSOptionalType",
|
||||
"start": 25,
|
||||
"end": 43,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 43
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TSParenthesizedType",
|
||||
"start": 25,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 42
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TSUnionType",
|
||||
"start": 26,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 26
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 41
|
||||
}
|
||||
},
|
||||
"types": [
|
||||
{
|
||||
"type": "TSStringKeyword",
|
||||
"start": 26,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 26
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TSNumberKeyword",
|
||||
"start": 35,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 35
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 41
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"init": null
|
||||
}
|
||||
],
|
||||
"kind": "let"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/typescript/types/tuple-rest/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/types/tuple-rest/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let x: [string, ...number[]]
|
||||
178
packages/babel-parser/test/fixtures/typescript/types/tuple-rest/output.json
vendored
Normal file
178
packages/babel-parser/test/fixtures/typescript/types/tuple-rest/output.json
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 4,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 4,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 28
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start": 5,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TSTupleType",
|
||||
"start": 7,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"elementTypes": [
|
||||
{
|
||||
"type": "TSStringKeyword",
|
||||
"start": 8,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TSRestType",
|
||||
"start": 16,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TSArrayType",
|
||||
"start": 19,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"elementType": {
|
||||
"type": "TSNumberKeyword",
|
||||
"start": 19,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"init": null
|
||||
}
|
||||
],
|
||||
"kind": "let"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/typescript/types/tuple/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/types/tuple/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let x: [number, number, number];
|
||||
163
packages/babel-parser/test/fixtures/typescript/types/tuple/output.json
vendored
Normal file
163
packages/babel-parser/test/fixtures/typescript/types/tuple/output.json
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 0,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 4,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 31
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 4,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 31
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start": 5,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 31
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TSTupleType",
|
||||
"start": 7,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 31
|
||||
}
|
||||
},
|
||||
"elementTypes": [
|
||||
{
|
||||
"type": "TSNumberKeyword",
|
||||
"start": 8,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TSNumberKeyword",
|
||||
"start": 16,
|
||||
"end": 22,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 22
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TSNumberKeyword",
|
||||
"start": 24,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 24
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 30
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"init": null
|
||||
}
|
||||
],
|
||||
"kind": "let"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-transform-destructuring",
|
||||
"version": "7.1.2",
|
||||
"version": "7.1.3",
|
||||
"description": "Compile ES2015 destructuring to ES5",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-destructuring",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -170,7 +170,8 @@ export default declare((api, options) => {
|
||||
pushObjectRest(pattern, objRef, spreadProp, spreadPropIndex) {
|
||||
// get all the keys that appear in this object before the current spread
|
||||
|
||||
let keys = [];
|
||||
const keys = [];
|
||||
let allLiteral = true;
|
||||
|
||||
for (let i = 0; i < pattern.properties.length; i++) {
|
||||
const prop = pattern.properties[i];
|
||||
@@ -182,11 +183,15 @@ export default declare((api, options) => {
|
||||
// ignore other spread properties
|
||||
if (t.isRestElement(prop)) continue;
|
||||
|
||||
let key = prop.key;
|
||||
const key = prop.key;
|
||||
if (t.isIdentifier(key) && !prop.computed) {
|
||||
key = t.stringLiteral(prop.key.name);
|
||||
keys.push(t.stringLiteral(key.name));
|
||||
} else if (t.isLiteral(key)) {
|
||||
keys.push(t.stringLiteral(String(key.value)));
|
||||
} else {
|
||||
keys.push(t.cloneNode(key));
|
||||
allLiteral = false;
|
||||
}
|
||||
keys.push(t.cloneNode(key));
|
||||
}
|
||||
|
||||
let value;
|
||||
@@ -196,11 +201,18 @@ export default declare((api, options) => {
|
||||
t.cloneNode(objRef),
|
||||
]);
|
||||
} else {
|
||||
keys = t.arrayExpression(keys);
|
||||
let keyExpression = t.arrayExpression(keys);
|
||||
|
||||
if (!allLiteral) {
|
||||
keyExpression = t.callExpression(
|
||||
t.memberExpression(keyExpression, t.identifier("map")),
|
||||
[this.addHelper("toPropertyKey")],
|
||||
);
|
||||
}
|
||||
|
||||
value = t.callExpression(
|
||||
this.addHelper(`objectWithoutProperties${loose ? "Loose" : ""}`),
|
||||
[t.cloneNode(objRef), keys],
|
||||
[t.cloneNode(objRef), keyExpression],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ var _z2 = z,
|
||||
y = babelHelpers.objectWithoutProperties(_z2, ["x"]);
|
||||
var _z3 = z,
|
||||
x = _z3[x],
|
||||
y = babelHelpers.objectWithoutProperties(_z3, [x]);
|
||||
y = babelHelpers.objectWithoutProperties(_z3, [x].map(babelHelpers.toPropertyKey));
|
||||
|
||||
(function (_ref) {
|
||||
var x = _ref.x,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
function _toPropertyKey(key) { if (typeof key === "symbol") { return key; } else { return String(key); } }
|
||||
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
||||
|
||||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
@@ -13,7 +15,7 @@ var _z2 = z,
|
||||
|
||||
var _z3 = z,
|
||||
x = _z3[x],
|
||||
y = _objectWithoutPropertiesLoose(_z3, [x]);
|
||||
y = _objectWithoutPropertiesLoose(_z3, [x].map(_toPropertyKey));
|
||||
|
||||
(function (_ref) {
|
||||
let x = _ref.x,
|
||||
|
||||
@@ -6,7 +6,7 @@ var _z2 = z,
|
||||
y = babelHelpers.objectWithoutProperties(_z2, ["x"]);
|
||||
var _z3 = z,
|
||||
x = _z3[x],
|
||||
y = babelHelpers.objectWithoutProperties(_z3, [x]);
|
||||
y = babelHelpers.objectWithoutProperties(_z3, [x].map(babelHelpers.toPropertyKey));
|
||||
|
||||
(function (_ref) {
|
||||
var x = _ref.x,
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
const { [(() => 1)()]: a, ...rest } = { 1: "a" };
|
||||
|
||||
expect(a).toBe("a");
|
||||
expect(rest).toEqual({});
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["transform-destructuring", "proposal-object-rest-spread"]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
const foo = {
|
||||
1: "a",
|
||||
2: "b",
|
||||
3: "c",
|
||||
};
|
||||
|
||||
const { [1]: bar, ...rest } = foo;
|
||||
|
||||
expect(bar).toBe("a");
|
||||
expect(rest).toEqual({ 2: "b", 3: "c" });
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["transform-destructuring", "proposal-object-rest-spread"]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-transform-modules-systemjs",
|
||||
"version": "7.0.0",
|
||||
"version": "7.1.3",
|
||||
"description": "This plugin transforms ES2015 modules to SystemJS",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-modules-systemjs",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -332,8 +332,23 @@ export default declare((api, options) => {
|
||||
const nodes = [];
|
||||
|
||||
for (const specifier of specifiers) {
|
||||
// only globals exported this way
|
||||
if (!path.scope.getBinding(specifier.local.name)) {
|
||||
const binding = path.scope.getBinding(
|
||||
specifier.local.name,
|
||||
);
|
||||
// hoisted function export
|
||||
if (
|
||||
binding &&
|
||||
t.isFunctionDeclaration(binding.path.node)
|
||||
) {
|
||||
beforeBody.push(
|
||||
buildExportCall(
|
||||
specifier.exported.name,
|
||||
t.cloneNode(specifier.local),
|
||||
),
|
||||
);
|
||||
}
|
||||
// only globals also exported this way
|
||||
else if (!binding) {
|
||||
nodes.push(
|
||||
buildExportCall(
|
||||
specifier.exported.name,
|
||||
|
||||
10
packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-fn-decl/input.mjs
vendored
Normal file
10
packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-fn-decl/input.mjs
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
var testProp = 'test property';
|
||||
|
||||
function testFunc() {
|
||||
return 'test function';
|
||||
}
|
||||
|
||||
export {
|
||||
testFunc,
|
||||
testProp
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
System.register([], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var testProp;
|
||||
|
||||
function testFunc() {
|
||||
return 'test function';
|
||||
}
|
||||
|
||||
_export("testFunc", testFunc);
|
||||
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
_export("testProp", testProp = 'test property');
|
||||
}
|
||||
};
|
||||
});
|
||||
1
packages/babel-plugin-transform-typescript/test/fixtures/function/tuple-parameter/input.js
vendored
Normal file
1
packages/babel-plugin-transform-typescript/test/fixtures/function/tuple-parameter/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
function foo(...args: [number, string?, ...number[]]) {}
|
||||
1
packages/babel-plugin-transform-typescript/test/fixtures/function/tuple-parameter/output.js
vendored
Normal file
1
packages/babel-plugin-transform-typescript/test/fixtures/function/tuple-parameter/output.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
function foo(...args) {}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/traverse",
|
||||
"version": "7.1.0",
|
||||
"version": "7.1.4",
|
||||
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -12,11 +12,11 @@
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"@babel/generator": "^7.0.0",
|
||||
"@babel/generator": "^7.1.3",
|
||||
"@babel/helper-function-name": "^7.1.0",
|
||||
"@babel/helper-split-export-declaration": "^7.0.0",
|
||||
"@babel/parser": "^7.1.0",
|
||||
"@babel/types": "^7.0.0",
|
||||
"@babel/parser": "^7.1.3",
|
||||
"@babel/types": "^7.1.3",
|
||||
"debug": "^3.1.0",
|
||||
"globals": "^11.1.0",
|
||||
"lodash": "^4.17.10"
|
||||
|
||||
@@ -107,7 +107,7 @@ export function insertAfter(nodes) {
|
||||
) {
|
||||
return parentPath.insertAfter(nodes);
|
||||
} else if (
|
||||
this.isNodeType("Expression") ||
|
||||
(this.isNodeType("Expression") && !this.isJSXElement()) ||
|
||||
(parentPath.isForStatement() && this.key === "init")
|
||||
) {
|
||||
if (this.node) {
|
||||
|
||||
@@ -200,6 +200,32 @@ describe("modification", function() {
|
||||
);
|
||||
});
|
||||
|
||||
it("returns inserted path with nested JSXElement", function() {
|
||||
const ast = parse("<div><span>foo</span></div>", {
|
||||
plugins: ["jsx"],
|
||||
});
|
||||
let path;
|
||||
traverse(ast, {
|
||||
Program: function(_path) {
|
||||
path = _path.get("body.0");
|
||||
},
|
||||
JSXElement: function(path) {
|
||||
const tagName = path.node.openingElement.name.name;
|
||||
if (tagName !== "span") return;
|
||||
path.insertAfter(
|
||||
t.JSXElement(
|
||||
t.JSXOpeningElement(t.JSXIdentifier("div"), [], false),
|
||||
t.JSXClosingElement(t.JSXIdentifier("div")),
|
||||
[],
|
||||
),
|
||||
);
|
||||
},
|
||||
});
|
||||
expect(generateCode(path)).toBe(
|
||||
"<div><span>foo</span><div></div></div>;",
|
||||
);
|
||||
});
|
||||
|
||||
describe("when the parent is an export declaration inserts the node after", function() {
|
||||
it("the ExportNamedDeclaration", function() {
|
||||
const bodyPath = getPath("export function a() {}", {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/types",
|
||||
"version": "7.1.2",
|
||||
"version": "7.1.3",
|
||||
"description": "Babel Types is a Lodash-esque utility library for AST nodes",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
|
||||
@@ -825,6 +825,12 @@ export function assertTSArrayType(node: Object, opts?: Object = {}): void {
|
||||
export function assertTSTupleType(node: Object, opts?: Object = {}): void {
|
||||
assert("TSTupleType", node, opts);
|
||||
}
|
||||
export function assertTSOptionalType(node: Object, opts?: Object = {}): void {
|
||||
assert("TSOptionalType", node, opts);
|
||||
}
|
||||
export function assertTSRestType(node: Object, opts?: Object = {}): void {
|
||||
assert("TSRestType", node, opts);
|
||||
}
|
||||
export function assertTSUnionType(node: Object, opts?: Object = {}): void {
|
||||
assert("TSUnionType", node, opts);
|
||||
}
|
||||
|
||||
@@ -793,6 +793,16 @@ export function TSTupleType(...args: Array<any>): Object {
|
||||
}
|
||||
export { TSTupleType as tsTupleType };
|
||||
export { TSTupleType as tSTupleType };
|
||||
export function TSOptionalType(...args: Array<any>): Object {
|
||||
return builder("TSOptionalType", ...args);
|
||||
}
|
||||
export { TSOptionalType as tsOptionalType };
|
||||
export { TSOptionalType as tSOptionalType };
|
||||
export function TSRestType(...args: Array<any>): Object {
|
||||
return builder("TSRestType", ...args);
|
||||
}
|
||||
export { TSRestType as tsRestType };
|
||||
export { TSRestType as tSRestType };
|
||||
export function TSUnionType(...args: Array<any>): Object {
|
||||
return builder("TSUnionType", ...args);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ defineType("JSXExpressionContainer", {
|
||||
aliases: ["JSX", "Immutable"],
|
||||
fields: {
|
||||
expression: {
|
||||
validate: assertNodeType("Expression"),
|
||||
validate: assertNodeType("Expression", "JSXEmptyExpression"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -213,6 +213,22 @@ defineType("TSTupleType", {
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TSOptionalType", {
|
||||
aliases: ["TSType"],
|
||||
visitor: ["typeAnnotation"],
|
||||
fields: {
|
||||
typeAnnotation: validateType("TSType"),
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TSRestType", {
|
||||
aliases: ["TSType"],
|
||||
visitor: ["typeAnnotation"],
|
||||
fields: {
|
||||
typeAnnotation: validateType("TSType"),
|
||||
},
|
||||
});
|
||||
|
||||
const unionOrIntersection = {
|
||||
aliases: ["TSType"],
|
||||
visitor: ["types"],
|
||||
|
||||
@@ -2672,6 +2672,34 @@ export function isTSTupleType(node: Object, opts?: Object): boolean {
|
||||
|
||||
return false;
|
||||
}
|
||||
export function isTSOptionalType(node: Object, opts?: Object): boolean {
|
||||
if (!node) return false;
|
||||
|
||||
const nodeType = node.type;
|
||||
if (nodeType === "TSOptionalType") {
|
||||
if (typeof opts === "undefined") {
|
||||
return true;
|
||||
} else {
|
||||
return shallowEqual(node, opts);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
export function isTSRestType(node: Object, opts?: Object): boolean {
|
||||
if (!node) return false;
|
||||
|
||||
const nodeType = node.type;
|
||||
if (nodeType === "TSRestType") {
|
||||
if (typeof opts === "undefined") {
|
||||
return true;
|
||||
} else {
|
||||
return shallowEqual(node, opts);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
export function isTSUnionType(node: Object, opts?: Object): boolean {
|
||||
if (!node) return false;
|
||||
|
||||
@@ -4149,6 +4177,8 @@ export function isTSType(node: Object, opts?: Object): boolean {
|
||||
"TSTypeLiteral" === nodeType ||
|
||||
"TSArrayType" === nodeType ||
|
||||
"TSTupleType" === nodeType ||
|
||||
"TSOptionalType" === nodeType ||
|
||||
"TSRestType" === nodeType ||
|
||||
"TSUnionType" === nodeType ||
|
||||
"TSIntersectionType" === nodeType ||
|
||||
"TSConditionalType" === nodeType ||
|
||||
|
||||
92
yarn.lock
92
yarn.lock
@@ -2,9 +2,9 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@babel/cli@^7.1.0":
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.1.0.tgz#a9429fd63911711b0fa93ae50d73beee6c42aef8"
|
||||
"@babel/cli@^7.1.2":
|
||||
version "7.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.1.2.tgz#fc2853ae96824b3779ca85de4fd025ce3cf62a5e"
|
||||
dependencies:
|
||||
commander "^2.8.1"
|
||||
convert-source-map "^1.1.0"
|
||||
@@ -30,17 +30,17 @@
|
||||
dependencies:
|
||||
"@babel/highlight" "^7.0.0"
|
||||
|
||||
"@babel/core@^7.1.0":
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.1.0.tgz#08958f1371179f62df6966d8a614003d11faeb04"
|
||||
"@babel/core@^7.1.2":
|
||||
version "7.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.1.2.tgz#f8d2a9ceb6832887329a7b60f9d035791400ba4e"
|
||||
dependencies:
|
||||
"@babel/code-frame" "^7.0.0"
|
||||
"@babel/generator" "^7.0.0"
|
||||
"@babel/helpers" "^7.1.0"
|
||||
"@babel/parser" "^7.1.0"
|
||||
"@babel/template" "^7.1.0"
|
||||
"@babel/generator" "^7.1.2"
|
||||
"@babel/helpers" "^7.1.2"
|
||||
"@babel/parser" "^7.1.2"
|
||||
"@babel/template" "^7.1.2"
|
||||
"@babel/traverse" "^7.1.0"
|
||||
"@babel/types" "^7.0.0"
|
||||
"@babel/types" "^7.1.2"
|
||||
convert-source-map "^1.1.0"
|
||||
debug "^3.1.0"
|
||||
json5 "^0.5.0"
|
||||
@@ -69,6 +69,16 @@
|
||||
source-map "^0.5.0"
|
||||
trim-right "^1.0.1"
|
||||
|
||||
"@babel/generator@^7.1.2":
|
||||
version "7.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.1.2.tgz#fde75c072575ce7abbd97322e8fef5bae67e4630"
|
||||
dependencies:
|
||||
"@babel/types" "^7.1.2"
|
||||
jsesc "^2.5.1"
|
||||
lodash "^4.17.10"
|
||||
source-map "^0.5.0"
|
||||
trim-right "^1.0.1"
|
||||
|
||||
"@babel/helper-annotate-as-pure@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz#323d39dd0b50e10c7c06ca7d7638e6864d8c5c32"
|
||||
@@ -234,13 +244,13 @@
|
||||
"@babel/traverse" "^7.1.0"
|
||||
"@babel/types" "^7.0.0"
|
||||
|
||||
"@babel/helpers@^7.1.0":
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.1.0.tgz#429bf0f0020be56a4242883432084e3d70a8a141"
|
||||
"@babel/helpers@^7.1.2":
|
||||
version "7.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.1.2.tgz#ab752e8c35ef7d39987df4e8586c63b8846234b5"
|
||||
dependencies:
|
||||
"@babel/template" "^7.1.0"
|
||||
"@babel/template" "^7.1.2"
|
||||
"@babel/traverse" "^7.1.0"
|
||||
"@babel/types" "^7.0.0"
|
||||
"@babel/types" "^7.1.2"
|
||||
|
||||
"@babel/highlight@7.0.0-beta.40":
|
||||
version "7.0.0-beta.40"
|
||||
@@ -266,6 +276,10 @@
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.1.0.tgz#a7cd42cb3c12aec52e24375189a47b39759b783e"
|
||||
|
||||
"@babel/parser@^7.1.2":
|
||||
version "7.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.1.2.tgz#85c5c47af6d244fab77bce6b9bd830e38c978409"
|
||||
|
||||
"@babel/plugin-proposal-async-generator-functions@^7.1.0":
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.1.0.tgz#41c1a702e10081456e23a7b74d891922dd1bb6ce"
|
||||
@@ -645,9 +659,9 @@
|
||||
pirates "^4.0.0"
|
||||
source-map-support "^0.5.9"
|
||||
|
||||
"@babel/runtime@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.0.0.tgz#adeb78fedfc855aa05bc041640f3f6f98e85424c"
|
||||
"@babel/runtime@^7.1.2":
|
||||
version "7.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.1.2.tgz#81c89935f4647706fc54541145e6b4ecfef4b8e3"
|
||||
dependencies:
|
||||
regenerator-runtime "^0.12.0"
|
||||
|
||||
@@ -676,6 +690,14 @@
|
||||
"@babel/parser" "^7.1.0"
|
||||
"@babel/types" "^7.0.0"
|
||||
|
||||
"@babel/template@^7.1.2":
|
||||
version "7.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.1.2.tgz#090484a574fef5a2d2d7726a674eceda5c5b5644"
|
||||
dependencies:
|
||||
"@babel/code-frame" "^7.0.0"
|
||||
"@babel/parser" "^7.1.2"
|
||||
"@babel/types" "^7.1.2"
|
||||
|
||||
"@babel/traverse@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.0.0.tgz#b1fe9b6567fdf3ab542cfad6f3b31f854d799a61"
|
||||
@@ -742,6 +764,14 @@
|
||||
lodash "^4.17.10"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@babel/types@^7.1.2":
|
||||
version "7.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.1.2.tgz#183e7952cf6691628afdc2e2b90d03240bac80c0"
|
||||
dependencies:
|
||||
esutils "^2.0.2"
|
||||
lodash "^4.17.10"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@samverschueren/stream-to-observable@^0.3.0":
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f"
|
||||
@@ -1310,9 +1340,9 @@ babel-core@^7.0.0-0:
|
||||
version "7.0.0-bridge.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece"
|
||||
|
||||
babel-eslint@^9.0.0:
|
||||
version "9.0.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-9.0.0.tgz#7d9445f81ed9f60aff38115f838970df9f2b6220"
|
||||
babel-eslint@^10.0.1:
|
||||
version "10.0.1"
|
||||
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.1.tgz#919681dc099614cd7d31d45c8908695092a1faed"
|
||||
dependencies:
|
||||
"@babel/code-frame" "^7.0.0"
|
||||
"@babel/parser" "^7.0.0"
|
||||
@@ -1348,9 +1378,9 @@ babel-jest@^23.6.0:
|
||||
babel-plugin-istanbul "^4.1.6"
|
||||
babel-preset-jest "^23.2.0"
|
||||
|
||||
babel-loader@^8.0.2:
|
||||
version "8.0.2"
|
||||
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.0.2.tgz#2079b8ec1628284a929241da3d90f5b3de2a5ae5"
|
||||
babel-loader@^8.0.4:
|
||||
version "8.0.4"
|
||||
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.0.4.tgz#7bbf20cbe4560629e2e41534147692d3fecbdce6"
|
||||
dependencies:
|
||||
find-cache-dir "^1.0.0"
|
||||
loader-utils "^1.0.2"
|
||||
@@ -3038,9 +3068,9 @@ escope@^3.6.0:
|
||||
esrecurse "^4.1.0"
|
||||
estraverse "^4.1.1"
|
||||
|
||||
eslint-config-babel@^8.0.0:
|
||||
version "8.0.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-config-babel/-/eslint-config-babel-8.0.0.tgz#4f7398ed2772a24a36467d05f25262ab8121e714"
|
||||
eslint-config-babel@^8.0.1:
|
||||
version "8.0.1"
|
||||
resolved "https://registry.yarnpkg.com/eslint-config-babel/-/eslint-config-babel-8.0.1.tgz#394a1d24aa9f725a2d33c43d33dddd5bdae89f79"
|
||||
|
||||
eslint-plugin-flowtype@^2.50.1:
|
||||
version "2.50.1"
|
||||
@@ -3508,9 +3538,9 @@ flat-cache@^1.2.1:
|
||||
graceful-fs "^4.1.2"
|
||||
write "^0.2.1"
|
||||
|
||||
flow-bin@^0.80.0:
|
||||
version "0.80.0"
|
||||
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.80.0.tgz#04cc1ee626a6f50786f78170c92ebe1745235403"
|
||||
flow-bin@^0.82.0:
|
||||
version "0.82.0"
|
||||
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.82.0.tgz#fbec84c0d6cab7877565eca8214d655f3aefb8db"
|
||||
|
||||
flush-write-stream@^1.0.2:
|
||||
version "1.0.3"
|
||||
|
||||
Reference in New Issue
Block a user