Compare commits

...

81 Commits

Author SHA1 Message Date
Nicolò Ribaudo
759ff4d6df v7.5.3 2019-07-09 16:41:44 +02:00
Nicolò Ribaudo
9e65472377 [_objectSpread2] Do not use hoisted var from prev iteration (#10180) 2019-07-09 16:38:40 +02:00
Babel Bot
25f040caa4 Add v7.5.2 to CHANGELOG.md [skip ci] 2019-07-08 19:53:06 +00:00
Nicolò Ribaudo
0dbf99bedb v7.5.2 2019-07-08 21:46:49 +02:00
Nicolò Ribaudo
f48b47c1f7 Do not trust Scope when removing TypeScript types (#10174)
* Do not trust Scope when removing TypeScript types

* Warn

* Update warning message

Co-Authored-By: Brian Ng <bng412@gmail.com>

* Add test

* Node 6
2019-07-08 21:44:26 +02:00
Nicolò Ribaudo
406a65c894 Don't rely on getOwnPropertyDescriptors in objectSpread2 (#10171) 2019-07-07 11:24:36 +02:00
Huáng Jùnliàng
075a50242d fix: register injected importDeclaration (#10172) 2019-07-06 10:44:14 -05:00
Babel Bot
c777e81e06 Add v7.5.1 to CHANGELOG.md [skip ci] 2019-07-06 08:13:08 +00:00
Nicolò Ribaudo
d0519fa907 v7.5.1 2019-07-06 10:07:59 +02:00
Nicolò Ribaudo
019fbca3f6 Update lerna 2019-07-06 09:57:20 +02:00
Nicolò Ribaudo
24dde2e8e8 Fix objectSpread2 backward compatibility (#10170) 2019-07-06 09:48:36 +02:00
Wesley Wolfe
bff79e198a Retain typescript export-from-source (#10167) 2019-07-05 20:47:55 +02:00
Henry Zhu
106bb41d47 change pkg name back from used-by [skip ci] 2019-07-04 12:30:56 -04:00
Babel Bot
d19f053482 Add v7.5.0 to CHANGELOG.md [skip ci] 2019-07-04 13:00:18 +00:00
Nicolò Ribaudo
49da9a07c8 v7.5.0 2019-07-04 14:52:17 +02:00
Lidor Avitan
b06663320e Update babel-preset-stage (0,1,2,3) readme files (#10111) [skip ci]
* chore: update docs babel-preset-stage readme [ci skip]

* fix:  by PR request change [ci skip]
2019-07-04 12:24:42 +02:00
Tan Li Hau
d50e78d45b fix await and yield for do expression (#10072) 2019-07-03 09:54:39 -05:00
Artem Butusov
5b86353b35 Added es3 backward compatibility for react helper code (#10155)
* Added es3 backward compatibility for react helper code

* tweak comment [skip ci]
2019-07-03 16:49:20 +02:00
Tan Li Hau
f588e4ec47 BigInt type for Flow (#10091)
* flow BigIntLiteralTypeAnnotation

* numericSeparator for flow test plugins

* fix flow tuple

* fix code review
2019-07-03 16:48:46 +02:00
Brian Ng
cbb482e2f9 Bump compat-table and update preset-env mappings (#10127) 2019-07-03 09:37:06 -05:00
Sebastian Johansson
595a349174 Fix incorrect usage of $o instead of %o in debug (#10157)
It would end up printing the literal "$o" instead of the directory name.
2019-07-03 16:04:31 +02:00
Min ho Kim
0bf0ae3410 Fix typos (#10153) 2019-07-03 15:51:48 +02:00
Nicolò Ribaudo
ef3f555be9 Add proposal-dynamic-import to preset-env (#10109) 2019-06-30 13:58:50 +02:00
Nicolò Ribaudo
38f8bbac1a Create @babel/plugin-proposal-dynamic-import (#9552)
* Create @babel/plugin-proposal-dynamic-import

* Use airbnb/babel-plugin-dynamic-import-node

Do not duplicate code, which will unavoidably lead
to bugs being fixed in one plugin and not in the other.

* Update error message

* Add error callback to amd interop

* Update babel-plugin-dynamic-import-node
2019-06-30 13:21:46 +02:00
Thiago Arrais
a4170b5e32 Transform for F# Pipeline (#9984)
* Transform for F#-style await

Inludes support for optimizing single-parameter arrow functions

* Wait until optimization before pushing placeholder into scope
2019-06-30 12:53:22 +02:00
James DiGioia
6b8a37c413 Implement f# pipeline in parser (#9450) 2019-06-30 12:53:22 +02:00
Wesley Wolfe
0a98814329 Implement TypeScript namespace support (#9785)
* Add module tests for typescript namespace transform

Fixes #8244, fixes #10038
2019-06-30 12:15:09 +02:00
Nicolò Ribaudo
8bf9714d69 [legacy decorators] Allow decorating generator methods (#9912)
* [legacy decorators] Allow decorating generator methods

The old proposal used LeftHandSideExpression (instead of
AssignmentExpression) to satisfy this usecase:
e240cbc91a

* Update flow whitelist
2019-06-30 11:32:16 +02:00
Nicolò Ribaudo
ca67637da4 [@babel/parser] Add "allowUndeclaredExports" option (#9864)
Ref: https://github.com/babel/notes/blob/master/2019/04/09.md#export-changes-in-scope-pr-break-meteor-issue
2019-06-30 11:16:05 +02:00
Brian Ng
77fd7cd4c4 Allow defaults query in preset-env (#8897) 2019-06-30 11:00:43 +02:00
Tan Li Hau
1d3f9815df fix import typeof in declare module (#10132) 2019-06-26 13:37:16 -05:00
Letladi Sebesho
31fc1d06bc Babel cli test correction (#10128) 2019-06-25 15:38:32 -05:00
Bogdan Savluk
b8bb93a838 fix exportKind declaration in babel-types (#10126)
* fix exportKind types declaration for ExportNamedDeclaration and DeclareExportAllDeclaration in babel-types

* revert `let` in exportKind in babel-parser types
2019-06-25 22:29:38 +02:00
Erik Arvidsson
8f8a457798 Simplify the helpers for classPrivateField{Get,Set} (#10117)
No need to do the hash lookup twice. If the descriptor is not in the
WeakMap `get` returns `undefined`.
2019-06-22 00:23:26 +02:00
Pig Fang
11fa2461ce Disallow "let" as name at lexical bindings (#10099)
* Disallow "let" as name at lexical bindings

* Simplify

* Clean up
2019-06-18 23:17:00 +02:00
Paul Comanici
505b2cc18d Upgrade jest dependency (#10107) 2019-06-18 16:29:51 +02:00
Sven Sauleau
dcdf7c8fdd [skip ci] docs: update readmes (#10103)
Using our READMEs auto generation, two packages were updated.
2019-06-17 10:57:28 +02:00
Tan Li Hau
fdbbb743b6 flow - allow type parameter defaults in function declarations (#10084)
* flow - allow type parameter defaults in function declarations

* fix flow test

* add intern_comments option

* fix flow parser test

* remove allowdefault from flowParseTypeParameterDeclaration

* rename test cases
2019-06-15 12:31:12 +02:00
Letladi Sebesho
6852bf6415 Change duplicate tests for @babel/highlight getChalk method (#10093)
* removed duplicate tests for @babel/highlight getChalk method

* changed second 'getChalk' test case for when colors are not supported
2019-06-15 09:04:35 +02:00
Jamie Kyle
f92c2ae830 Change root package.json#name (#10021)
* Change root package.json#name

I'm pretty sure GitHub's new Dependants feature is based on this package.json. I'm updating it here so it will reflect the new name for the core package.

* Update package.json
2019-06-04 23:57:38 +02:00
Maël Nison
d7801c644c Prevents exception on PnP (#9951) 2019-06-02 00:55:44 +02:00
Mateusz Burzyński
84961ebb05 Refactor isImportTypeOnly helper function (#10047) 2019-05-31 23:54:44 +02:00
Blaine Bublitz
3144ed131a Use FUNDING.yml in babel/.github repo [ci skip] (#10032) 2019-05-30 09:52:43 +02:00
Martin Zlámal
ce4c374924 Fix printer for explicitly inexact Flow types (#10041)
Closes: https://github.com/babel/babel/issues/10040
2019-05-29 21:17:12 +02:00
Wesley Wolfe
8d492b159b Use scope for typescript export removals. Fixes #10033 (#10034)
This also fixes enum not adding the respective declaration to the scope
during the typescript visitation.

Rewrites:

2080042808 #9944

a6392bd636 #10019
2019-05-29 08:36:04 +02:00
Tan Li Hau
b4c9cb0222 Fixed computed keys for class expression (#10029)
* test case for insertBefore for jsx

* fix unshiftContainer and insertBefore

* use path.scope.push

* add test making sure computedKeys var declaration at the right block

* add comment

* nit [skip ci]
2019-05-28 23:07:55 +02:00
Kagami Sascha Rosylight
a596da2822 Retry to fix object spread helper compatibility (#9384)
This reverts commit 43b83f8ed7.

Fix objectSpread helper breaking old codes

remove tests to regenerate later

renamed output

new name

try using word

add comment as requested

revert inline name changes

add 2 for consistency

Update packages/babel-helpers/src/helpers.js

Co-Authored-By: Daniel Tschinder <daniel@tschinder.de>
2019-05-25 12:57:13 +02:00
Daniel Tschinder
1cfb92d66a Create SECURITY.md (#10018) 2019-05-25 12:46:59 +02:00
Nicolò Ribaudo
888b9f6940 Remove unused code in the TS parser plugin (#10025) 2019-05-25 08:46:01 +02:00
Tan Li Hau
b6486a22cb fix destructuring rest with template literal (#10013)
* fix destructuring rest with template literal

* update test
2019-05-24 00:03:27 +02:00
Airat Aminev
a6392bd636 fix(typescript): erase default export if exporting a TS type (#10019) 2019-05-23 16:58:24 -05:00
Henry Zhu
9dd8825eff Create funding.yml [skip ci] (#10016) 2019-05-23 21:02:16 +02:00
Nicolò Ribaudo
ecf4667305 Add "PR: Performance" label for the changelog (#10011) [skip ci] 2019-05-21 23:17:18 -04:00
Nicolò Ribaudo
87fb6c4a8b Use injectInitialization to generate ts parameter properties (#9610) 2019-05-21 22:28:55 +02:00
Brian Ng
58cf1a7d48 Bump deps (#10007) 2019-05-21 15:10:29 -05:00
Sebastian Silbermann
c96aef17e1 Add #9902 to changelog (#10010) [skip ci] 2019-05-21 21:33:27 +02:00
Babel Bot
fc38638aeb Add v7.4.5 to CHANGELOG.md [skip ci] 2019-05-21 17:49:18 +00:00
Nicolò Ribaudo
33ab4f1661 v7.4.5 2019-05-21 19:38:26 +02:00
Daniel Tschinder
54d257c105 Fix location for optional params in arrow functions (#9998)
* Fix location with optional params in arrow functions

* add test

* Ensure rollup replaces NODE_ENV and create sourcemap in dev

* Ensure finishNod*() is never called twice on a node

* Fix check for already finished nodes
2019-05-21 18:53:13 +02:00
Matthew Robertson
9c06e4ed4d avoid exceptions for control flow (#9974)
* avoid exceptions for control flow

* review feedback: remove conditional because we know it is "<"

* drop tsTryParseTypeArguments method
2019-05-21 17:23:53 +02:00
Daniel Tschinder
f5b8140580 Do not use lookahead when parsing construct signature declarations (#9995) 2019-05-20 23:27:41 -07:00
Daniel Tschinder
0430a48775 Update preset-env dependencies and fix fixtures (#10002)
* Fix fixtures after core-js update

* Update core-js, caniuse and compat-table
2019-05-20 23:27:19 -07:00
Matthew Schupack
45ca6751fa use console.warn for warning (#9992)
* use console.warn for warning

* fix tests
2019-05-18 00:36:18 +02:00
Daniel Tschinder
b1826bf0a0 Only compute Position if not already in state (#9989)
* Only compute Position if not already in state

* Prioritize start locations
2019-05-17 15:32:34 -07:00
Airat Aminev
2080042808 fix(typescript): erase type exports (#9944)
* fix(typescript): erase type exports

* use Set instead of array for tracking and checking TS type declarations

* add a test for an interface exported before its declaration
2019-05-17 07:22:52 +02:00
Daniel Tschinder
3f0590de2a Do not use lookahead when parsing jsx expression containers (#9988) 2019-05-16 17:27:07 -07:00
Daniel Tschinder
5661de5908 Do not use lookahead when parsing imports in declare module in flow (#9987) 2019-05-16 02:31:37 -07:00
Daniel Tschinder
c2d303f8be Do not use lookahead when parsing declare module or declare module.exports in flow (#9985)
* Do not use lookahead when parsing declare module or declare module.exports in flow

* Improve code
2019-05-16 02:31:21 -07:00
Daniel Tschinder
4da7a01aa9 Avoid unnecessary work during lookahead (#9982)
* Do not call pushComment when doing lookahead

* Do no updateContext when doing lookahead

* Do not clone contexts anymore
2019-05-15 17:02:12 -07:00
Daniel Tschinder
47eb1ddfe0 Do not use lookahead when parsing dynamic import or import.meta (#9983) 2019-05-15 16:34:16 -07:00
Nicolò Ribaudo
9febf63882 Fix mobile browsers support in preset-env (#9978)
* Fix mobile browsers support in preset-env

* Update fixtures

* Alias other mobile browsers, since they aren't included by compat-table
2019-05-15 14:05:37 +02:00
Daniel Tschinder
85432e2c44 Remove guardedHandlers from ASTs (#9979) 2019-05-15 03:37:22 -07:00
Nicolò Ribaudo
1969e6b6aa Update regenerator-transform (#9941) 2019-05-07 15:42:12 -04:00
Divyam Bhasin
7942dc0f07 Fixed null error in plugin opts and added a test for it (#9945)
* Fixed null error in plugin opts and added a test for it

* Remove !opts and add opts === null check to avoid confusion with false and undefined cases

Co-Authored-By: divbhasin <divbest99@gmail.com>
2019-05-07 16:23:01 +02:00
Tan Li Hau
354666aa17 fix: allow shebang directive (#9922)
* fix: allow shebang directive

* Update packages/babel-parser/src/plugins/flow.js

* chore: prettier
2019-05-07 16:22:25 +02:00
Nicolò Ribaudo
9e9b62f77a Update regexp-tree (#9940) 2019-05-06 20:11:46 +02:00
Nicolò Ribaudo
5da94bff87 [babel-node] Do not hardcode node flags (#9914) 2019-05-04 23:40:06 +02:00
Sebastian Silbermann
eae7a33316 Fix destructuring assignments being transpiled for edge 15 (#9902)
* Current behavior for preset-env destructuring and edge

* fix(preset-env): destructuring transpiled in edge 15
2019-05-03 23:35:28 +02:00
Pablo Navarro
16e17c560b Add missing space in error messages (#9909) 2019-04-29 19:52:13 +02:00
Nicolò Ribaudo
555d50a08c Generate missing test output 2019-04-26 23:57:06 +02:00
Babel Bot
18ace84b88 Add v7.4.4 to CHANGELOG.md [skip ci] 2019-04-26 21:06:49 +00:00
535 changed files with 12068 additions and 2716 deletions

View File

@@ -84,7 +84,7 @@
* More performance improvements.
* Parsing is now ~30% faster thanks to [marijnh/acorn@7264bc0178e7e6af7cfe02e9e0c6b26ee0e6007f](https://github.com/marijnh/acorn/commit/7264bc0178e7e6af7cfe02e9e0c6b26ee0e6007f).
* **New Feature**
* Optional `es6.blockScopingTDZ` is now completely functional and handles all edgecases.
* Optional `es6.blockScopingTDZ` is now completely functional and handles all edge cases.
* `super` in object literals.
* Tail call optimisation. Thanks [@RReverser](https://github.com/RReverser)!
@@ -474,7 +474,7 @@
* **Polish**
* Rest parameters now allocate the array before populating.
* **Internal**
* `for...in` loops have been changed to optimized `for` loops - better performance and no enumeration of protoype keys.
* `for...in` loops have been changed to optimized `for` loops - better performance and no enumeration of prototype keys.
* Parts of the code generator have now been optimized thanks to [gaearon](https://github.com/gaearon).
## 2.12.3
@@ -643,7 +643,7 @@
* **Bug Fix**
* Better handling of number literal property keys.
* Handle `NewExpression` paren insertion edegcases better.
* Handle `NewExpression` paren insertion edge cases better.
* **Internal**
* Fix incorrect AST node `identifier("this")`.
* Better `toIdentifier` method that handles reserved words.
@@ -850,7 +850,7 @@
## 1.14.10
* Fix let scoping unneccesary override.
* Fix let scoping unnecessary override.
## 1.14.6
@@ -973,7 +973,7 @@
## 1.12.21
* Fix unneccesary let scoping replacement.
* Fix unnecessary let scoping replacement.
* Add `commonInterop` module formatter. Thanks [@Naddiseo](https://github.com/Naddiseo).
* Fix `return` outside of function body bug. Thanks [@brentburg](https://github.com/brentburg).
* Add more flexible option types.
@@ -1020,7 +1020,7 @@
## 1.12.12
* Make scope tracker more reliable to handle all edgecases.
* Make scope tracker more reliable to handle all edge cases.
## 1.12.11

View File

@@ -127,7 +127,7 @@
## 4.6.4
* **Bug Fix**
* Fix `ForOfStatement` not proplery inheriting labels.
* Fix `ForOfStatement` not properly inheriting labels.
* When in closure mode in block scoping transformer, properly check for variable shadowing.
* **New Feature**
* New `utility.inlineEnvironmentVariables` and `utility.inlineExpression` transformers.
@@ -153,7 +153,7 @@
* **Spec Compliancy**
* `for...of` now outputs in a lengthy `try...catch` this is to ensure spec compliancy in regards to iterator returns and abrupt completions. See [google/traceur-compiler#1773](https://github.com/google/traceur-compiler/issues/1773) and [babel/babel/#838](https://github.com/babel/babel/issues/838) for more information.
* **Polish**
* Rest parameters that are only refered to via number properties on member expressions are desugared into a direct `arguments` reference. Thanks [@neVERberleRfellerER](https://github.com/neVERberleRfellerER)!
* Rest parameters that are only referred to via number properties on member expressions are desugared into a direct `arguments` reference. Thanks [@neVERberleRfellerER](https://github.com/neVERberleRfellerER)!
* `$ babel` no longer exits on syntax errors.
* **Internal**
* Upgrade `browserify`.

View File

@@ -262,8 +262,8 @@ Issues with publish process.
* Register labels as bindings to fix undeclared variable checks.
* **Polish**
* Remove unnecessary string binary expressions when transforming template literals.
* Support module live bindings in arbitary positions not in Program statement position.
* Throw error when attemping to replace a `Program` root node with another node not of type `Program`.
* Support module live bindings in arbitrary positions not in Program statement position.
* Throw error when attempting to replace a `Program` root node with another node not of type `Program`.
* Optimise rest parameters in spread element position and allocate rest array at the earliest common ancestor of all references.
* Generate original number representation when value was not changed.
* Check for invalid binding identifiers when generating inferred method names.
@@ -543,12 +543,12 @@ Issues with publish process.
* **Internal**
* Removed native inheritance support from classes.
* Added `replaceWithSourceString` path API.
* Split up `es3.propertyLiterals` and `es3.memberExpressionLiterals` transformers to `minfication.propertyLiterals` and `es3.memberExpressionLiterals`.
* Split up `es3.propertyLiterals` and `es3.memberExpressionLiterals` transformers to `minification.propertyLiterals` and `es3.memberExpressionLiterals`.
## 5.2.6
* **Internal**
* Fix transformer aliases being accidently set as deprecated ones.
* Fix transformer aliases being accidentally set as deprecated ones.
* Expose `Pipeline` as `TransformerPipeline` instead.
## 5.2.5
@@ -824,10 +824,10 @@ Issues with publish process.
* Save register cache on tick instead of `SIGINT`.
* Enable strict mode on babel-node eval flag.
* **Bug Fixes**
* Add support for live bindings. This change also increases the reliablity of export specifier renaming.
* Add support for live bindings. This change also increases the reliability of export specifier renaming.
* Add support for super update and non equals assignment expressions.
* Rename shadow constructor binding in classes.
* Seed next iteration bindings with previous fresh bindings when reassinging loop block scoped variables.
* Seed next iteration bindings with previous fresh bindings when reassigning loop block scoped variables.
* Fix new expression spread referencing the wrong constructor.
* Call `resolveModuleSource` on dynamic imports.
* Added `param` to list of duplicate declaration kinds.
@@ -836,4 +836,3 @@ Issues with publish process.
* ES7 Abstract References have been removed.
* Experimental option has been removed in favor of a stage option.
* Rename `returnUsedHelpers` to `metadataUsedHelpers`.

View File

@@ -19,7 +19,7 @@
## 6.26.0 (2017-08-16)
> Backports for some folks (also other's when we accidently merged PRs from both 6.x/master)
> Backports for some folks (also other's when we accidentally merged PRs from both 6.x/master)
> Lesson learned: just use `master` and backport on another branch.
#### :eyeglasses: Spec Compliancy
@@ -1767,7 +1767,7 @@ typeof Symbol.prototype === 'object'
* [#3456](https://github.com/babel/babel/pull/3456) Use the real sourcemap API and handle input sourcemaps - Fixes [#7259](https://github.com/babel/babel/issues/7259). ([@loganfsmyth](https://github.com/loganfsmyth))
* [#4507](https://github.com/babel/babel/pull/4507) Only set options in cli if different from default. ([@danez](https://github.com/danez))
Fix an issue with defaults not being overidden. This was causing options like `comments: false` not to work correctly.
Fix an issue with defaults not being overridden. This was causing options like `comments: false` not to work correctly.
* [#4508](https://github.com/babel/babel/pull/4508) Support custom ports for V8 --inspect. ([@andykant](https://github.com/andykant))
* [#4562](https://github.com/babel/babel/pull/4562) Fixes [#2299](https://github.com/babel/babel/issues/2299): Prevent REPL from printing implicit 'use strict'. ([@hzoo](https://github.com/hzoo))
@@ -2084,7 +2084,7 @@ Also added more tests and will update Babel to use the new preset options after
## v6.13.1 (2016-08-04)
We had a regression in our new babel-preset-es2015@6.13.0 that made it unexpectedly backward-incompatible. This release introduces a new alternative plugin-options approach that is uglier but supports backward-compatiblity. Ideally new plugins would use the new `module.exports = function(babel, options){ }` approach and simple skip supporting `babel-core@<6.13.x`.
We had a regression in our new babel-preset-es2015@6.13.0 that made it unexpectedly backward-incompatible. This release introduces a new alternative plugin-options approach that is uglier but supports backward-compatibility. Ideally new plugins would use the new `module.exports = function(babel, options){ }` approach and simple skip supporting `babel-core@<6.13.x`.
#### Bug Fix
* `babel-core`, `babel-preset-es2015`
@@ -2092,7 +2092,7 @@ We had a regression in our new babel-preset-es2015@6.13.0 that made it unexpecte
## v6.13.0 (2016-08-04)
> Since the last release we've created https://github.com/babel/notes to track discussions on our slack and high level features/changes that could be added - definetely check it out if you're interested in Babel's development!
> Since the last release we've created https://github.com/babel/notes to track discussions on our slack and high level features/changes that could be added - definitely check it out if you're interested in Babel's development!
Some small but very important additions in this release:
@@ -3817,7 +3817,7 @@ Thanks to @samwgoldman for all the new flow support!
* **New Feature**
* Add support for `function.sent`.
* **Internal**
* Bump `invariant` depenency version.
* Bump `invariant` dependency version.
* **Polish**
* Infer filename from the base directory when resolving plugins and presets.
* Allow JSX pragma to be specified in line comments.
@@ -3887,7 +3887,7 @@ Thanks to @samwgoldman for all the new flow support!
## 6.1.2
* **Bug Fix**
* Fix bug where the parser wouldn't allow typed annotated default parametesr in arrow functions.
* Fix bug where the parser wouldn't allow typed annotated default parameters in arrow functions.
* Add existence check to `NodePath#has` to ensure safeness when making comparisons.
* Protect against replacing a class expression with a name inferred version that would
result in it never being transformed.
@@ -3976,7 +3976,7 @@ Thanks to @samwgoldman for all the new flow support!
* Fix SystemJS module formatter exporting function parameters.
* Ensure that invalid identifier JSX attribute keys are quoted when transforming to calls.
* Fix ES3 property literal plugin.
* Fix parameters after defaults in arrow functions refering to the wrong `arguments`.
* Fix parameters after defaults in arrow functions referring to the wrong `arguments`.
## 6.0.13

View File

@@ -18,6 +18,139 @@ See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0
<!-- DO NOT CHANGE THESE COMMENTS - See .github/actions/trigger-github-release/update-changelog.js -->
<!-- insert-new-changelog-here -->
## v7.5.2 (2019-07-08)
#### :bug: Bug Fix
* `babel-plugin-transform-typescript`
* [#10174](https://github.com/babel/babel/pull/10174) Do not trust Scope when removing TypeScript types ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
* [#10171](https://github.com/babel/babel/pull/10171) Don't rely on getOwnPropertyDescriptors in objectSpread2 ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-proposal-export-default-from`, `babel-plugin-proposal-export-namespace-from`
* [#10172](https://github.com/babel/babel/pull/10172) fix: register injected importDeclaration ([@JLHwung](https://github.com/JLHwung))
## v7.5.1 (2019-07-06)
#### :bug: Bug Fix
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`
* [#10170](https://github.com/babel/babel/pull/10170) Fix objectSpread2 backward compatibility ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-transform-typescript`
* [#10167](https://github.com/babel/babel/pull/10167) Retain typescript export-from-source ([@Wolvereness](https://github.com/Wolvereness))
## v7.5.0 (2019-07-04)
#### :eyeglasses: Spec Compliance
* `babel-parser`
* [#10099](https://github.com/babel/babel/pull/10099) Disallow "let" as name at lexical bindings ([@g-plane](https://github.com/g-plane))
#### :rocket: New Feature
* `babel-parser`
* [#10091](https://github.com/babel/babel/pull/10091) BigInt type for Flow ([@tanhauhau](https://github.com/tanhauhau))
* [#9450](https://github.com/babel/babel/pull/9450) Implement f# pipeline in parser ([@mAAdhaTTah](https://github.com/mAAdhaTTah))
* [#9912](https://github.com/babel/babel/pull/9912) [legacy decorators] Allow decorating generator methods ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* [#9864](https://github.com/babel/babel/pull/9864) [@babel/parser] Add "allowUndeclaredExports" option ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-proposal-dynamic-import`, `babel-preset-env-standalone`, `babel-preset-env`
* [#10109](https://github.com/babel/babel/pull/10109) Add @babel/plugin-proposal-dynamic-import to @babel/preset-env ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-proposal-dynamic-import`, `babel-plugin-transform-modules-amd`, `babel-plugin-transform-modules-commonjs`, `babel-plugin-transform-modules-systemjs`
* [#9552](https://github.com/babel/babel/pull/9552) Create @babel/plugin-proposal-dynamic-import ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-proposal-pipeline-operator`, `babel-plugin-syntax-pipeline-operator`
* [#9984](https://github.com/babel/babel/pull/9984) Transform for F# Pipeline ([@thiagoarrais](https://github.com/thiagoarrais))
* `babel-plugin-transform-typescript`, `babel-types`
* [#9785](https://github.com/babel/babel/pull/9785) Implement TypeScript namespace support ([@Wolvereness](https://github.com/Wolvereness))
#### :bug: Bug Fix
* `babel-plugin-proposal-do-expressions`, `babel-traverse`
* [#10072](https://github.com/babel/babel/pull/10072) fix await and yield for do expression ([@tanhauhau](https://github.com/tanhauhau))
* `babel-helpers`, `babel-plugin-transform-react-constant-elements`
* [#10155](https://github.com/babel/babel/pull/10155) Added es3 backward compatibility for react helper code ([@sormy](https://github.com/sormy))
* `babel-preset-env`
* [#10127](https://github.com/babel/babel/pull/10127) Bump compat-table and updating preset-env mappings ([@existentialism](https://github.com/existentialism))
* [#8897](https://github.com/babel/babel/pull/8897) Allow `defaults` query in preset-env ([@existentialism](https://github.com/existentialism))
* `babel-parser`
* [#10132](https://github.com/babel/babel/pull/10132) fix import typeof in declare module ([@tanhauhau](https://github.com/tanhauhau))
* [#10084](https://github.com/babel/babel/pull/10084) flow - allow type parameter defaults in function declarations ([@tanhauhau](https://github.com/tanhauhau))
* `babel-types`
* [#10126](https://github.com/babel/babel/pull/10126) fix exportKind declaration in babel-types ([@zxbodya](https://github.com/zxbodya))
* `babel-node`
* [#9951](https://github.com/babel/babel/pull/9951) Prevents exception on PnP ([@arcanis](https://github.com/arcanis))
* `babel-generator`
* [#10041](https://github.com/babel/babel/pull/10041) Fix printer for explicitly inexact Flow types ([@mrtnzlml](https://github.com/mrtnzlml))
* `babel-plugin-transform-typescript`
* [#10034](https://github.com/babel/babel/pull/10034) Use scope for typescript export removals ([@Wolvereness](https://github.com/Wolvereness))
* [#10019](https://github.com/babel/babel/pull/10019) fix(typescript): erase default export if exporting a TS type ([@airato](https://github.com/airato))
* `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-class-properties`, `babel-traverse`
* [#10029](https://github.com/babel/babel/pull/10029) Fixed computed keys for class expression ([@tanhauhau](https://github.com/tanhauhau))
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
* [#9384](https://github.com/babel/babel/pull/9384) Retry to fix object spread helper compatibility ([@saschanaz](https://github.com/saschanaz))
* `babel-plugin-transform-destructuring`
* [#10013](https://github.com/babel/babel/pull/10013) fix destructuring rest with template literal ([@tanhauhau](https://github.com/tanhauhau))
* `babel-helper-create-class-features-plugin`, `babel-plugin-transform-typescript`
* [#9610](https://github.com/babel/babel/pull/9610) Use `injectInitialization` to generate ts parameter properties ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
#### :nail_care: Polish
* `babel-core`
* [#10157](https://github.com/babel/babel/pull/10157) Fix incorrect usage of $o instead of %o in debug ([@ChlorideCull](https://github.com/ChlorideCull))
* `babel-helpers`
* [#10117](https://github.com/babel/babel/pull/10117) Simplify the helpers for classPrivateField{Get,Set} ([@arv](https://github.com/arv))
* `babel-plugin-transform-typescript`
* [#10047](https://github.com/babel/babel/pull/10047) Refactor isImportTypeOnly helper function ([@Andarist](https://github.com/Andarist))
#### :memo: Documentation
* `babel-plugin-proposal-partial-application`, `babel-plugin-syntax-partial-application`
* [#10103](https://github.com/babel/babel/pull/10103) docs: update readmes ([@xtuc](https://github.com/xtuc))
## v7.4.5 (2019-05-21)
#### :bug: Bug Fix
* `babel-parser`
* [#9998](https://github.com/babel/babel/pull/9998) Fix location for optional params in arrow functions ([@danez](https://github.com/danez))
* [#9982](https://github.com/babel/babel/pull/9982) Avoid unnecessary work during lookahead ([@danez](https://github.com/danez))
* [#9922](https://github.com/babel/babel/pull/9922) fix: allow shebang directive ([@tanhauhau](https://github.com/tanhauhau))
* `babel-preset-env`
* [#10002](https://github.com/babel/babel/pull/10002) Update preset-env dependencies and fix fixtures ([@danez](https://github.com/danez))
* [#9978](https://github.com/babel/babel/pull/9978) Fix mobile browsers support in preset-env ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* [#9902](https://github.com/babel/babel/pull/9902) Fix destructuring assignments being transpiled for edge 15 ([@eps1lon](https://github.com/eps1lon))
* `babel-plugin-transform-typescript`
* [#9944](https://github.com/babel/babel/pull/9944) fix(typescript): erase type exports ([@airato](https://github.com/airato))
#### :nail_care: Polish
* `babel-parser`
* [#9995](https://github.com/babel/babel/pull/9995) Do not use lookahead when parsing construct signature declarations in TS ([@danez](https://github.com/danez))
* [#9989](https://github.com/babel/babel/pull/9989) Only compute Position if not already in state ([@danez](https://github.com/danez))
* [#9988](https://github.com/babel/babel/pull/9988) Do not use lookahead when parsing jsx expression containers ([@danez](https://github.com/danez))
* [#9987](https://github.com/babel/babel/pull/9987) Do not use lookahead when parsing imports in declare module in flow ([@danez](https://github.com/danez))
* [#9985](https://github.com/babel/babel/pull/9985) Do not use lookahead when parsing declare module or declare module.exports in flow ([@danez](https://github.com/danez))
* [#9983](https://github.com/babel/babel/pull/9983) Do not use lookahead when parsing dynamic import or import.meta ([@danez](https://github.com/danez))
* [#9979](https://github.com/babel/babel/pull/9979) Remove guardedHandlers from ASTs ([@danez](https://github.com/danez))
* `babel-preset-env`
* [#9992](https://github.com/babel/babel/pull/9992) use console.warn for warning ([@schu34](https://github.com/schu34))
* `babel-core`
* [#9945](https://github.com/babel/babel/pull/9945) Fixed null error in plugin opts and added a test for it ([@divbhasin](https://github.com/divbhasin))
* `babel-core`, `babel-traverse`
* [#9909](https://github.com/babel/babel/pull/9909) Add missing space in error messages ([@pnavarrc](https://github.com/pnavarrc))
#### :house: Internal
* `babel-node`
* [#9914](https://github.com/babel/babel/pull/9914) [babel-node] Do not hardcode node flags ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
## v7.4.4 (2019-04-26)
#### :bug: Bug Fix
* `babel-plugin-transform-flow-comments`
* [#9897](https://github.com/babel/babel/pull/9897) fix flow-comments - class type paramters and implements ([@tanhauhau](https://github.com/tanhauhau))
* [#9893](https://github.com/babel/babel/pull/9893) fix flow-comment - object destructuring ([@tanhauhau](https://github.com/tanhauhau))
* `babel-parser`
* [#9766](https://github.com/babel/babel/pull/9766) Add TS support to @babel/parser's Scope ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* [#9865](https://github.com/babel/babel/pull/9865) Always register global bindings as exportable ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* [#9887](https://github.com/babel/babel/pull/9887) Fix TypeScript readonly error location ([@existentialism](https://github.com/existentialism))
* [#9869](https://github.com/babel/babel/pull/9869) ! remove constant context assertions ([@tanhauhau](https://github.com/tanhauhau))
* [#9890](https://github.com/babel/babel/pull/9890) Fix parsing typescript bodiless methods with the estree plugin also enabled ([@devongovett](https://github.com/devongovett))
* `babel-traverse`
* [#9870](https://github.com/babel/babel/pull/9870) Fix flow types in traverse/path/family and enable flow ([@danez](https://github.com/danez))
* `babel-plugin-proposal-class-properties`, `babel-plugin-transform-modules-commonjs`, `babel-types`
* [#9861](https://github.com/babel/babel/pull/9861) Fix: PrivateName Identifier should not be isReferenced. ([@coreyfarrell](https://github.com/coreyfarrell))
* `babel-types`
* [#9832](https://github.com/babel/babel/pull/9832) Fix typo in cloneNode. ([@evandervalk](https://github.com/evandervalk))
## v7.4.3 (2019-04-02)
@@ -351,7 +484,7 @@ Thanks to @jamesgeorge007 and @armano2 for their first PR!
* [#9271](https://github.com/babel/babel/pull/9271) Bump license years for 2019. ([@berlamhenderson](https://github.com/berlamhenderson))
* `babel-helpers`
* [#9166](https://github.com/babel/babel/pull/9166) Add mixins support to the _decorate helper. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
## v7.2.5 (2018-12-21)
`@babel/polyfill` didn't get published correctly in v7.2.3 (#9227).
@@ -382,7 +515,7 @@ Half of the commits in this release are made by first time contributors! Thanks
## v7.2.2 (2018-12-15)
Mostrly bug fixes and internal changes.
Mostly bug fixes and internal changes.
Thanks to @paleite, @saschanaz and @joeldenning for their first PRs!
#### :bug: Bug Fix
@@ -724,7 +857,7 @@ No change from rc.4. Finally released as https://babeljs.io/blog/2018/08/27/7.0.
## 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`.
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`
@@ -879,7 +1012,7 @@ Breaking Change in beta:
## v7.0.0-beta.53 (2018-07-11)
- Fix for regression with paths on windows due to micromatch upgrade, remove yearly presets (not published)
- (There was an issue with the Stage presets in this release, but it is also deprecated)
- (There was an issue with the Stage presets in this release, but it is also deprecated)
#### :boom: Breaking Change
* `babel-*`
@@ -2533,7 +2666,7 @@ Initial release of typescript equivalent of how Babel handles flow with a new `b
* `babel-plugin-check-es2015-constants`
* [#5930](https://github.com/babel/babel/pull/5930) Spec compliancy of check-es2015-constants plugin. ([@maurobringolf](https://github.com/maurobringolf))
> Instead of throwing a compile time error when const is violated, Babel should insert a throw statement before the violation.
> Instead of throwing a compile time error when const is violated, Babel should insert a throw statement before the violation.
#### :boom: Breaking Change
* `babel-plugin-transform-flow-comments`

View File

@@ -15,6 +15,7 @@ const merge = require("merge-stream");
const rollup = require("rollup");
const rollupBabel = require("rollup-plugin-babel");
const rollupNodeResolve = require("rollup-plugin-node-resolve");
const rollupReplace = require("rollup-plugin-replace");
const { registerStandalonePackageTask } = require("./scripts/gulp-tasks");
const sources = ["codemods", "packages"];
@@ -92,6 +93,9 @@ function buildRollup(packages) {
.rollup({
input,
plugins: [
rollupReplace({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
}),
rollupBabel({
envName: "babel-parser",
}),
@@ -103,6 +107,7 @@ function buildRollup(packages) {
file: path.join(pkg, "lib/index.js"),
format: "cjs",
name: "babel-parser",
sourcemap: process.env.NODE_ENV !== "production",
});
});
})

View File

@@ -1,5 +1,5 @@
MAKEFLAGS = -j1
FLOW_COMMIT = 2ac56861e3ceff9ca406ae586fbafb3480c6c0b7
FLOW_COMMIT = 09669846b7a7ca5a6c23c12d56bb3bebdafd67e9
TEST262_COMMIT = de567d3aa5de4eaa11e00131d26b9fe77997dfb0
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
@@ -124,7 +124,7 @@ prepublish-build:
rm -rf packages/babel-runtime/helpers
rm -rf packages/babel-runtime-corejs2/helpers
rm -rf packages/babel-runtime-corejs2/core-js
BABEL_ENV=production make build-dist
NODE_ENV=production BABEL_ENV=production make build-dist
make clone-license
prepublish:

19
SECURITY.md Normal file
View File

@@ -0,0 +1,19 @@
# Security Policy
## Supported Versions
This is the list of versions of `babel` which are
currently being supported with security updates.
| Version | Supported |
| -------- | ------------------ |
| 7.x | :white_check_mark: |
| 6.26.x | :white_check_mark: |
| < 6.26.0 | :x: |
## Reporting a Vulnerability
To report a vulnerability please send an email with the details to security@babeljs.io.
This will help us to assess the risk and start the necessary steps.
Thanks for helping to keep babel secure.

View File

@@ -123,7 +123,7 @@ module.exports = function(api) {
],
plugins: [
includeRuntime
? ["@babel/transform-runtime", { version: "7.4.0" }]
? ["@babel/transform-runtime", { version: "7.4.4" }]
: null,
].filter(Boolean),
},

View File

@@ -1,5 +1,5 @@
{
"version": "7.4.4",
"version": "7.5.3",
"changelog": {
"repo": "babel/babel",
"cacheDir": ".changelog",
@@ -10,7 +10,8 @@
"PR: Bug Fix :bug:": ":bug: Bug Fix",
"PR: Polish :nail_care:": ":nail_care: Polish",
"PR: Docs :memo:": ":memo: Documentation",
"PR: Internal :house:": ":house: Internal"
"PR: Internal :house:": ":house: Internal",
"PR: Performance :running_woman:": ":running_woman: Performance"
}
},
"command": {

View File

@@ -9,38 +9,38 @@
"test": "make test"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.4.0",
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/eslint-plugin-development": "^1.0.1",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
"@babel/plugin-proposal-numeric-separator": "^7.2.0",
"@babel/plugin-transform-modules-commonjs": "^7.4.0",
"@babel/plugin-transform-runtime": "^7.4.0",
"@babel/preset-env": "^7.4.1",
"@babel/plugin-transform-modules-commonjs": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@babel/preset-flow": "^7.0.0",
"@babel/register": "^7.4.0",
"@babel/runtime": "^7.4.0",
"@babel/register": "^7.4.4",
"@babel/runtime": "^7.4.5",
"babel-eslint": "^11.0.0-beta.0",
"babel-jest": "^24.5.0",
"babel-loader": "^8.0.5",
"babel-jest": "^24.8.0",
"babel-loader": "^8.0.6",
"babel-plugin-transform-charcodes": "^0.2.0",
"browserify": "^16.2.3",
"bundle-collapser": "^1.2.1",
"chalk": "^2.3.2",
"chalk": "^2.4.2",
"charcodes": "^0.2.0",
"derequire": "^2.0.2",
"duplicate-package-checker-webpack-plugin": "^2.1.0",
"enhanced-resolve": "^3.0.0",
"eslint": "^5.15.1",
"eslint": "^5.16.0",
"eslint-config-babel": "^9.0.0",
"eslint-plugin-flowtype": "^3.2.1",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-flowtype": "^3.8.2",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-prettier": "^3.1.0",
"fancy-log": "^1.3.3",
"flow-bin": "^0.94.0",
"graceful-fs": "^4.1.15",
"gulp": "^4.0.0",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-filter": "^5.1.0",
"gulp-newer": "^1.0.0",
@@ -48,20 +48,21 @@
"gulp-rename": "^1.4.0",
"gulp-uglify": "^3.0.2",
"gulp-watch": "^5.0.1",
"husky": "^1.3.1",
"jest": "^24.5.0",
"lerna": "^3.6.0",
"husky": "^2.3.0",
"jest": "^24.8.0",
"lerna": "^3.14.2",
"lerna-changelog": "^0.5.0",
"lint-staged": "^8.1.0",
"lint-staged": "^8.1.7",
"lodash": "^4.17.11",
"merge-stream": "^1.0.1",
"output-file-sync": "^2.0.0",
"prettier": "^1.16.1",
"prettier": "^1.17.1",
"pump": "^3.0.0",
"rimraf": "^2.6.3",
"rollup": "^1.6.0",
"rollup": "^1.12.0",
"rollup-plugin-babel": "^4.0.0",
"rollup-plugin-node-resolve": "^4.0.1",
"rollup-plugin-node-resolve": "^5.0.0",
"rollup-plugin-replace": "^2.2.0",
"test262-stream": "^1.2.0",
"through2": "^2.0.0",
"warnings-to-errors-webpack-plugin": "^2.0.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/cli",
"version": "7.4.4",
"version": "7.5.0",
"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.4.4",
"@babel/core": "^7.5.0",
"@babel/helper-fixtures": "^7.4.4"
},
"bin": {

View File

@@ -86,7 +86,7 @@ const assertTest = function(stdout, stderr, opts, cwd) {
}
if (opts.outFiles) {
const actualFiles = readDir(path.join(tmpLoc), fileFilter);
const actualFiles = readDir(tmpLoc, fileFilter);
Object.keys(actualFiles).forEach(function(filename) {
if (
@@ -171,12 +171,12 @@ const buildTest = function(binName, testName, opts) {
};
fs.readdirSync(fixtureLoc).forEach(function(binName) {
if (binName[0] === ".") return;
if (binName.startsWith(".")) return;
const suiteLoc = path.join(fixtureLoc, binName);
describe("bin/" + binName, function() {
fs.readdirSync(suiteLoc).forEach(function(testName) {
if (testName[0] === ".") return;
if (testName.startsWith(".")) return;
const testLoc = path.join(suiteLoc, testName);

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/core",
"version": "7.4.4",
"version": "7.5.0",
"description": "Babel compiler core.",
"main": "lib/index.js",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
@@ -34,12 +34,12 @@
},
"dependencies": {
"@babel/code-frame": "^7.0.0",
"@babel/generator": "^7.4.4",
"@babel/helpers": "^7.4.4",
"@babel/parser": "^7.4.4",
"@babel/generator": "^7.5.0",
"@babel/helpers": "^7.5.0",
"@babel/parser": "^7.5.0",
"@babel/template": "^7.4.4",
"@babel/traverse": "^7.4.4",
"@babel/types": "^7.4.4",
"@babel/traverse": "^7.5.0",
"@babel/types": "^7.5.0",
"convert-source-map": "^1.1.0",
"debug": "^4.1.0",
"json5": "^2.1.0",
@@ -49,7 +49,7 @@
"source-map": "^0.5.0"
},
"devDependencies": {
"@babel/helper-transform-fixture-test-runner": "^7.4.4",
"@babel/helper-transform-fixture-test-runner": "^7.5.0",
"@babel/register": "^7.4.4"
}
}

View File

@@ -114,7 +114,7 @@ export function findRootConfig(
const conf = readConfig(filepath, envName, caller);
if (conf) {
debug("Found root config %o in $o.", BABEL_CONFIG_JS_FILENAME, dirname);
debug("Found root config %o in %o.", BABEL_CONFIG_JS_FILENAME, dirname);
}
return conf;
}
@@ -132,7 +132,7 @@ export function loadConfig(
throw new Error(`Config file ${filepath} contains no configuration data`);
}
debug("Loaded config %o from $o.", name, dirname);
debug("Loaded config %o from %o.", name, dirname);
return conf;
}

View File

@@ -202,7 +202,7 @@ const loadDescriptor = makeWeakCache(
if (typeof item.then === "function") {
throw new Error(
`You appear to be using an async plugin, ` +
`which your current version of Babel does not support.` +
`which your current version of Babel does not support. ` +
`If you're using a published plugin, ` +
`you may need to upgrade your @babel/core version.`,
);

View File

@@ -231,7 +231,7 @@ function assertIgnoreItem(loc: GeneralPath, value: mixed): IgnoreItem {
throw new Error(
`${msg(
loc,
)} must be an array of string/Funtion/RegExp values, or undefined`,
)} must be an array of string/Function/RegExp values, or undefined`,
);
}
return value;
@@ -337,7 +337,7 @@ function assertPluginItem(loc: GeneralPath, value: mixed): PluginItem {
if (
opts !== undefined &&
opts !== false &&
(typeof opts !== "object" || Array.isArray(opts))
(typeof opts !== "object" || Array.isArray(opts) || opts === null)
) {
throw new Error(
`${msg(access(loc, 1))} must be an object, false, or undefined`,

View File

@@ -183,7 +183,7 @@ export default class File {
// and this fails because a prerelease version can only satisfy a range
// if it is a prerelease within the same major/minor/patch range.
//
// Note: If this is found to have issues, please also revist the logic in
// Note: If this is found to have issues, please also revisit the logic in
// transform-runtime's definitions.js file.
if (semver.valid(versionRange)) versionRange = `^${versionRange}`;

View File

@@ -93,7 +93,7 @@ function transformFile(file: File, pluginPasses: PluginPasses): void {
if (isThenable(result)) {
throw new Error(
`You appear to be using an plugin with an async .pre, ` +
`which your current version of Babel does not support.` +
`which your current version of Babel does not support. ` +
`If you're using a published plugin, you may need to upgrade ` +
`your @babel/core version.`,
);
@@ -117,7 +117,7 @@ function transformFile(file: File, pluginPasses: PluginPasses): void {
if (isThenable(result)) {
throw new Error(
`You appear to be using an plugin with an async .post, ` +
`which your current version of Babel does not support.` +
`which your current version of Babel does not support. ` +
`If you're using a published plugin, you may need to upgrade ` +
`your @babel/core version.`,
);

View File

@@ -38,6 +38,17 @@ describe("option-manager", () => {
expect(calls).toEqual([]);
});
it("throws for null options", () => {
const { calls, plugin } = makePlugin();
expect(() => {
loadOptions({
plugins: [[plugin, null]],
}).toThrow(/.plugins[0][1] must be an object, false, or undefined/);
});
expect(calls).toEqual([]);
});
it("should not throw if a repeated plugin has a different name", () => {
const { calls: calls1, plugin: plugin1 } = makePlugin();
const { calls: calls2, plugin: plugin2 } = makePlugin();
@@ -87,7 +98,6 @@ describe("option-manager", () => {
expect(calls1).toEqual([{ arg: 1 }]);
expect(calls2).toEqual([{ arg: 2 }]);
});
it("should merge .env[] presets with parent presets", () => {
const { calls: calls1, plugin: preset1 } = makePlugin();
const { calls: calls2, plugin: preset2 } = makePlugin();

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/generator",
"version": "7.4.4",
"version": "7.5.0",
"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.4.4",
"@babel/types": "^7.5.0",
"jsesc": "^2.5.1",
"lodash": "^4.17.11",
"source-map": "^0.5.0",
@@ -22,6 +22,6 @@
},
"devDependencies": {
"@babel/helper-fixtures": "^7.4.4",
"@babel/parser": "^7.4.4"
"@babel/parser": "^7.5.0"
}
}

View File

@@ -235,7 +235,7 @@ export default class Buffer {
source(prop: string, loc: Location, force?: boolean): void {
if (prop && !loc) return;
// Since this is called extremly often, we re-use the same _sourcePosition
// Since this is called extremely often, we re-use the same _sourcePosition
// object for the whole lifetime of the buffer.
this._normalizePosition(prop, loc, this._sourcePosition, force);
}

View File

@@ -409,7 +409,7 @@ export function ObjectTypeAnnotation(node: Object) {
indent: true,
statement: true,
iterator: () => {
if (props.length !== 1) {
if (props.length !== 1 || node.inexact) {
this.token(",");
this.space();
}
@@ -419,6 +419,15 @@ export function ObjectTypeAnnotation(node: Object) {
this.space();
}
if (node.inexact) {
this.indent();
this.token("...");
if (props.length) {
this.newline();
}
this.dedent();
}
if (node.exact) {
this.token("|}");
} else {

View File

@@ -0,0 +1,4 @@
type T1 = { ... };
type T2 = { a: { b: { c: {...}, ... }, ... } }
type T3 = { foo: number, ... };
type T4 = { foo: number, bar: string, ... };

View File

@@ -0,0 +1,3 @@
{
"compact": true
}

View File

@@ -0,0 +1 @@
type T1={...};type T2={a:{b:{c:{...},...},...}};type T3={foo:number,...};type T4={foo:number,bar:string,...};

View File

@@ -9,3 +9,7 @@ type T6 = { foo(): number }
type T7 = { foo: () => number }
type T8 = { [string]: U };
type T9 = { [param: string]: U };
type T10 = { ... };
type T11 = { a: { b: { c: {...}, ... }, ... } }
type T12 = { foo: number, ... };
type T13 = { foo: number, bar: string, ... };

View File

@@ -27,4 +27,23 @@ type T8 = {
};
type T9 = {
[param: string]: U
};
};
type T10 = {...};
type T11 = {
a: {
b: {
c: {...},
...
},
...
}
};
type T12 = {
foo: number,
...
};
type T13 = {
foo: number,
bar: string,
...
};

View File

@@ -427,7 +427,7 @@ describe("programmatic generation", function() {
});
});
describe("typescript generate parantheses if necessary", function() {
describe("typescript generate parentheses if necessary", function() {
it("wraps around union for array", () => {
const typeStatement = t.TSArrayType(
t.TSUnionType([

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-create-class-features-plugin",
"version": "7.4.4",
"version": "7.5.0",
"author": "The Babel Team (https://babeljs.io/team)",
"license": "MIT",
"description": "Compile class public and private fields, private methods and decorators to ES6",
@@ -25,7 +25,7 @@
"@babel/core": "^7.0.0"
},
"devDependencies": {
"@babel/core": "^7.4.4",
"@babel/core": "^7.5.0",
"@babel/helper-plugin-test-runner": "^7.0.0"
}
}

View File

@@ -21,11 +21,11 @@ import {
import pkg from "../package.json";
export { FEATURES };
export { FEATURES, injectInitialization };
// Note: Versions are represented as an integer. e.g. 7.1.5 is represented
// as 70000100005. This method is easier than using a semver-parsing
// package, but it breaks if we relese x.y.z where x, y or z are
// package, but it breaks if we release x.y.z where x, y or z are
// greater than 99_999.
const version = pkg.version.split(".").reduce((v, x) => v * 1e5 + +x, 0);
const versionKey = "@babel/plugin-class-features/version";

View File

@@ -98,10 +98,16 @@ export function extractComputedKeys(ref, path, computedPaths, file) {
const ident = path.scope.generateUidIdentifierBasedOnNode(
computedNode.key,
);
// Declaring in the same block scope
// Ref: https://github.com/babel/babel/pull/10029/files#diff-fbbdd83e7a9c998721c1484529c2ce92
path.scope.push({
id: ident,
kind: "let",
});
declarations.push(
t.variableDeclaration("var", [
t.variableDeclarator(ident, computedNode.key),
]),
t.expressionStatement(
t.assignmentExpression("=", t.cloneNode(ident), computedNode.key),
),
);
computedNode.key = t.cloneNode(ident);
}

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-transform-fixture-test-runner",
"version": "7.4.4",
"version": "7.5.0",
"description": "Transform test runner for @babel/helper-fixtures module",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -12,12 +12,12 @@
"main": "lib/index.js",
"dependencies": {
"@babel/code-frame": "^7.0.0",
"@babel/core": "^7.4.4",
"@babel/core": "^7.5.0",
"@babel/helper-fixtures": "^7.4.4",
"@babel/polyfill": "^7.4.4",
"babel-check-duplicated-nodes": "^1.0.0",
"jest": "^22.4.2",
"jest-diff": "^22.4.0",
"jest": "^24.8.0",
"jest-diff": "^24.8.0",
"lodash": "^4.17.11",
"resolve": "^1.3.2",
"source-map": "^0.5.0"

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helpers",
"version": "7.4.4",
"version": "7.5.3",
"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.4.4",
"@babel/traverse": "^7.4.4",
"@babel/types": "^7.4.4"
"@babel/traverse": "^7.5.0",
"@babel/types": "^7.5.0"
},
"devDependencies": {
"@babel/helper-plugin-test-runner": "^7.0.0"

View File

@@ -26,13 +26,14 @@ helpers.typeof = helper("7.0.0-beta.0")`
}
`;
// "for" is a reserved keyword in ES3 so escaping it here for backward compatibility
helpers.jsx = helper("7.0.0-beta.0")`
var REACT_ELEMENT_TYPE;
export default function _createRawReactElement(type, props, key, children) {
if (!REACT_ELEMENT_TYPE) {
REACT_ELEMENT_TYPE = (
typeof Symbol === "function" && Symbol.for && Symbol.for("react.element")
typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element")
) || 0xeac7;
}
@@ -384,6 +385,7 @@ helpers.extends = helper("7.0.0-beta.0")`
}
`;
// This old helper can be removed in babel v8
helpers.objectSpread = helper("7.0.0-beta.0")`
import defineProperty from "defineProperty";
@@ -404,6 +406,43 @@ helpers.objectSpread = helper("7.0.0-beta.0")`
}
`;
helpers.objectSpread2 = helper("7.5.0")`
import defineProperty from "defineProperty";
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
keys.push.apply(keys, Object.getOwnPropertySymbols(object));
}
if (enumerableOnly) keys = keys.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
return keys;
}
export default function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
if (i % 2) {
var source = (arguments[i] != null) ? arguments[i] : {};
ownKeys(source, true).forEach(function (key) {
defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(arguments[i]));
} else {
ownKeys(arguments[i]).forEach(function (key) {
Object.defineProperty(
target,
key,
Object.getOwnPropertyDescriptor(arguments[i], key)
);
});
}
}
return target;
}
`;
helpers.inherits = helper("7.0.0-beta.0")`
import setPrototypeOf from "setPrototypeOf";
@@ -1045,10 +1084,10 @@ helpers.classPrivateFieldLooseBase = helper("7.0.0-beta.0")`
helpers.classPrivateFieldGet = helper("7.0.0-beta.0")`
export default function _classPrivateFieldGet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to get private field on non-instance");
}
var descriptor = privateMap.get(receiver);
if (descriptor.get) {
return descriptor.get.call(receiver);
}
@@ -1058,10 +1097,10 @@ helpers.classPrivateFieldGet = helper("7.0.0-beta.0")`
helpers.classPrivateFieldSet = helper("7.0.0-beta.0")`
export default function _classPrivateFieldSet(receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to set private field on non-instance");
}
var descriptor = privateMap.get(receiver);
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/highlight",
"version": "7.0.0",
"version": "7.5.0",
"description": "Syntax highlight JavaScript strings for output in terminals.",
"author": "suchipi <me@suchipi.com>",
"homepage": "https://babeljs.io/",

View File

@@ -94,8 +94,8 @@ describe("@babel/highlight", function() {
});
});
describe("when colors are supported", function() {
stubColorSupport(true);
describe("when colors are not supported", function() {
stubColorSupport(false);
describe("when forceColor is not passed", function() {
it("returns a Chalk instance", function() {

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/node",
"version": "7.2.2",
"version": "7.5.0",
"description": "Babel command line",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -23,13 +23,14 @@
"@babel/register": "^7.0.0",
"commander": "^2.8.1",
"lodash": "^4.17.11",
"node-environment-flags": "^1.0.5",
"v8flags": "^3.1.1"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/core": "^7.5.0",
"@babel/helper-fixtures": "^7.2.0",
"fs-readdir-recursive": "^1.0.0",
"output-file-sync": "^2.0.0"

View File

@@ -6,6 +6,10 @@
import getV8Flags from "v8flags";
import path from "path";
// TODO: When support for node < 10.10 will be dropped, this package
// can be replaced with process.allowedNodeEnvironmentFlags
import allowedNodeEnvironmentFlags from "node-environment-flags";
let args = [path.join(__dirname, "_babel-node")];
let babelArgs = process.argv.slice(2);
@@ -24,7 +28,9 @@ if (argSeparator > -1) {
* that only the flag is returned.
*/
function getNormalizedV8Flag(arg) {
const matches = arg.match(/--(.+)/);
// v8 uses the "no" prefix to negate boolean flags (e.g. --nolazy),
// but they are not listed by v8flags
const matches = arg.match(/--(?:no)?(.+)/);
if (matches) {
return `--${matches[1].replace(/-/g, "_")}`;
@@ -33,51 +39,30 @@ function getNormalizedV8Flag(arg) {
return arg;
}
// These are aliases for node options defined by babel-node.
const aliases = new Map([["-d", "--debug"], ["-gc", "--expose-gc"]]);
getV8Flags(function(err, v8Flags) {
babelArgs.forEach(function(arg, index) {
for (let i = 0; i < babelArgs.length; i++) {
const arg = babelArgs[i];
const flag = arg.split("=")[0];
switch (flag) {
case "-d":
args.unshift("--debug");
break;
case "debug":
case "--debug":
case "--debug-brk":
case "--inspect":
case "--inspect-brk":
case "--experimental-modules":
args.unshift(arg);
break;
case "-r":
case "--require":
args.push(flag);
args.push(babelArgs[index + 1]);
delete babelArgs[index + 1];
break;
case "-gc":
args.unshift("--expose-gc");
break;
case "--nolazy":
args.unshift(flag);
break;
default:
if (
v8Flags.indexOf(getNormalizedV8Flag(flag)) >= 0 ||
arg.indexOf("--trace") === 0
) {
args.unshift(arg);
} else {
args.push(arg);
}
break;
if (flag === "-r" || flag === "--require") {
args.push(flag);
args.push(babelArgs[++i]);
} else if (aliases.has(flag)) {
args.unshift(aliases.get(flag));
} else if (
flag === "debug" || // node debug foo.js
flag === "inspect" ||
v8Flags.indexOf(getNormalizedV8Flag(flag)) >= 0 ||
allowedNodeEnvironmentFlags.has(flag)
) {
args.unshift(arg);
} else {
args.push(arg);
}
});
}
// append arguments passed after --
if (argSeparator > -1) {
@@ -88,7 +73,12 @@ getV8Flags(function(err, v8Flags) {
const kexec = require("kexec");
kexec(process.argv[0], args);
} catch (err) {
if (err.code !== "MODULE_NOT_FOUND") throw err;
if (
err.code !== "MODULE_NOT_FOUND" &&
err.code !== "UNDECLARED_DEPENDENCY"
) {
throw err;
}
const child_process = require("child_process");
const proc = child_process.spawn(process.argv[0], args, {

View File

@@ -178,7 +178,7 @@ The returned AST will only consist of the expression. The options are the same a
Add startLine option ([#346](https://github.com/babel/babylon/pull/346)) (Raphael Mu)
A new option was added to babylon allowing to change the intial linenumber for the first line which is usually `1`.
A new option was added to babylon allowing to change the initial linenumber for the first line which is usually `1`.
Changing this for example to `100` will make line `1` of the input source to be marked as line `100`, line `2` as `101`, line `3` as `102`, ...
Function predicate declaration ([#103](https://github.com/babel/babylon/pull/103)) (Panagiotis Vekris)
@@ -224,7 +224,7 @@ import { a as debugger } from "foo";
Do not allow overwritting of primitive types ([#314](https://github.com/babel/babylon/pull/314)) (Daniel Tschinder)
In flow it is now forbidden to overwrite the primitve types `"any"`, `"mixed"`, `"empty"`, `"bool"`, `"boolean"`, `"number"`, `"string"`, `"void"` and `"null"` with your own type declaration.
In flow it is now forbidden to overwrite the primitive types `"any"`, `"mixed"`, `"empty"`, `"bool"`, `"boolean"`, `"number"`, `"string"`, `"void"` and `"null"` with your own type declaration.
Disallow import type { type a } from … ([#305](https://github.com/babel/babylon/pull/305)) (Daniel Tschinder)
@@ -628,7 +628,7 @@ Annotate more errors with expected token ([#172](https://github.com/babel/babylo
Remove kcheck ([#173](https://github.com/babel/babylon/pull/173))) (Daniel Tschinder)
Also run flow, linting, babel tests on seperate instances (add back node 0.10)
Also run flow, linting, babel tests on separate instances (add back node 0.10)
## v6.11.6 (2016-10-12)

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/parser",
"version": "7.4.4",
"version": "7.5.0",
"description": "A JavaScript parser",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",

View File

@@ -15,6 +15,7 @@ export type Options = {
allowReturnOutsideFunction: boolean,
allowImportExportEverywhere: boolean,
allowSuperOutsideMethod: boolean,
allowUndeclaredExports: boolean,
plugins: PluginList,
strictMode: ?boolean,
ranges: boolean,
@@ -41,6 +42,8 @@ export const defaultOptions: Options = {
allowImportExportEverywhere: false,
// TODO
allowSuperOutsideMethod: false,
// When enabled, export statements can reference undeclared variables.
allowUndeclaredExports: false,
// An array of plugins to enable
plugins: [],
// TODO

View File

@@ -331,8 +331,11 @@ export default class ExpressionParser extends LValParser {
const prec = this.state.type.binop;
if (prec != null && (!noIn || !this.match(tt._in))) {
if (prec > minPrec) {
const node = this.startNodeAt(leftStartPos, leftStartLoc);
const operator = this.state.value;
if (operator === "|>" && this.state.inFSharpPipelineDirectBody) {
return left;
}
const node = this.startNodeAt(leftStartPos, leftStartLoc);
node.left = left;
node.operator = operator;
if (
@@ -406,18 +409,23 @@ export default class ExpressionParser extends LValParser {
prec: number,
noIn: ?boolean,
): N.Expression {
const startPos = this.state.start;
const startLoc = this.state.startLoc;
switch (op) {
case tt.pipeline:
if (this.getPluginOption("pipelineOperator", "proposal") === "smart") {
const startPos = this.state.start;
const startLoc = this.state.startLoc;
return this.withTopicPermittingContext(() => {
return this.parseSmartPipelineBody(
this.parseExprOpBaseRightExpr(op, prec, noIn),
startPos,
startLoc,
);
});
switch (this.getPluginOption("pipelineOperator", "proposal")) {
case "smart":
return this.withTopicPermittingContext(() => {
return this.parseSmartPipelineBody(
this.parseExprOpBaseRightExpr(op, prec, noIn),
startPos,
startLoc,
);
});
case "fsharp":
return this.withSoloAwaitPermittingContext(() => {
return this.parseFSharpPipelineBody(prec, noIn);
});
}
// falls through
@@ -766,6 +774,8 @@ export default class ExpressionParser extends LValParser {
const elts = [];
let innerParenStart;
let first = true;
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
this.state.inFSharpPipelineDirectBody = false;
while (!this.eat(close)) {
if (first) {
@@ -804,6 +814,8 @@ export default class ExpressionParser extends LValParser {
this.unexpected();
}
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
return elts;
}
@@ -875,19 +887,19 @@ export default class ExpressionParser extends LValParser {
return this.finishNode(node, "Super");
case tt._import:
if (this.lookahead().type === tt.dot) {
return this.parseImportMetaProperty();
}
this.expectPlugin("dynamicImport");
node = this.startNode();
this.next();
if (this.match(tt.dot)) {
return this.parseImportMetaProperty(node);
}
this.expectPlugin("dynamicImport", node.start);
if (!this.match(tt.parenL)) {
this.unexpected(null, tt.parenL);
}
return this.finishNode(node, "Import");
case tt._this:
node = this.startNode();
this.next();
@@ -969,7 +981,10 @@ export default class ExpressionParser extends LValParser {
case tt.parenL:
return this.parseParenAndDistinguishExpression(canBeArrow);
case tt.bracketL:
case tt.bracketL: {
const oldInFSharpPipelineDirectBody = this.state
.inFSharpPipelineDirectBody;
this.state.inFSharpPipelineDirectBody = false;
node = this.startNode();
this.next();
node.elements = this.parseExprList(
@@ -985,11 +1000,17 @@ export default class ExpressionParser extends LValParser {
// expression by calling toReferencedListDeep.
this.toReferencedList(node.elements);
}
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
return this.finishNode(node, "ArrayExpression");
case tt.braceL:
return this.parseObj(false, refShorthandDefaultPos);
}
case tt.braceL: {
const oldInFSharpPipelineDirectBody = this.state
.inFSharpPipelineDirectBody;
this.state.inFSharpPipelineDirectBody = false;
const ret = this.parseObj(false, refShorthandDefaultPos);
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
return ret;
}
case tt._function:
return this.parseFunctionExpression();
@@ -1125,20 +1146,17 @@ export default class ExpressionParser extends LValParser {
return this.finishNode(node, "MetaProperty");
}
parseImportMetaProperty(): N.MetaProperty {
const node = this.startNode();
const id = this.parseIdentifier(true);
parseImportMetaProperty(node: N.MetaProperty): N.MetaProperty {
const id = this.createIdentifier(this.startNodeAtNode(node), "import");
this.expect(tt.dot);
if (id.name === "import") {
if (this.isContextual("meta")) {
this.expectPlugin("importMeta");
} else if (!this.hasPlugin("importMeta")) {
this.raise(
id.start,
`Dynamic imports require a parameter: import('a.js')`,
);
}
if (this.isContextual("meta")) {
this.expectPlugin("importMeta");
} else if (!this.hasPlugin("importMeta")) {
this.raise(
id.start,
`Dynamic imports require a parameter: import('a.js')`,
);
}
if (!this.inModule) {
@@ -1180,9 +1198,11 @@ export default class ExpressionParser extends LValParser {
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
const oldYieldPos = this.state.yieldPos;
const oldAwaitPos = this.state.awaitPos;
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
this.state.maybeInArrowParameters = true;
this.state.yieldPos = 0;
this.state.awaitPos = 0;
this.state.inFSharpPipelineDirectBody = false;
const innerStartPos = this.state.start;
const innerStartLoc = this.state.startLoc;
@@ -1236,6 +1256,7 @@ export default class ExpressionParser extends LValParser {
this.expect(tt.parenR);
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
let arrowNode = this.startNodeAt(startPos, startLoc);
if (
@@ -2117,7 +2138,9 @@ export default class ExpressionParser extends LValParser {
);
}
node.argument = this.parseMaybeUnary();
if (!this.state.soloAwait) {
node.argument = this.parseMaybeUnary();
}
return this.finishNode(node, "AwaitExpression");
}
@@ -2307,6 +2330,17 @@ export default class ExpressionParser extends LValParser {
}
}
withSoloAwaitPermittingContext<T>(callback: () => T): T {
const outerContextSoloAwaitState = this.state.soloAwait;
this.state.soloAwait = true;
try {
return callback();
} finally {
this.state.soloAwait = outerContextSoloAwaitState;
}
}
// Register the use of a primary topic reference (`#`) within the current
// topic context.
registerTopicReference(): void {
@@ -2323,4 +2357,25 @@ export default class ExpressionParser extends LValParser {
this.state.topicContext.maxTopicIndex >= 0
);
}
parseFSharpPipelineBody(prec: number, noIn: ?boolean): N.Expression {
const startPos = this.state.start;
const startLoc = this.state.startLoc;
this.state.potentialArrowAt = this.state.start;
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
this.state.inFSharpPipelineDirectBody = true;
const ret = this.parseExprOp(
this.parseMaybeUnary(),
startPos,
startLoc,
prec,
noIn,
);
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
return ret;
}
}

View File

@@ -10,6 +10,17 @@ import CommentsParser from "./comments";
// message.
export default class LocationParser extends CommentsParser {
getLocationForPosition(pos: number): Position {
let loc;
if (pos === this.state.start) loc = this.state.startLoc;
else if (pos === this.state.lastTokStart) loc = this.state.lastTokStartLoc;
else if (pos === this.state.end) loc = this.state.endLoc;
else if (pos === this.state.lastTokEnd) loc = this.state.lastTokEndLoc;
else loc = getLineInfo(this.input, pos);
return loc;
}
raise(
pos: number,
message: string,
@@ -21,7 +32,8 @@ export default class LocationParser extends CommentsParser {
code?: string,
} = {},
): empty {
const loc = getLineInfo(this.input, pos);
const loc = this.getLocationForPosition(pos);
message += ` (${loc.line}:${loc.column})`;
// $FlowIgnore
const err: SyntaxError & { pos: number, loc: Position } = new SyntaxError(

View File

@@ -16,7 +16,7 @@ import type {
import type { Pos, Position } from "../util/location";
import { isStrictBindReservedWord } from "../util/identifier";
import { NodeUtils } from "./node";
import { type BindingTypes, BIND_NONE } from "../util/scopeflags";
import { type BindingTypes, BIND_NONE, BIND_LEXICAL } from "../util/scopeflags";
export default class LValParser extends NodeUtils {
// Forward-declaration: defined in expression.js
@@ -363,6 +363,12 @@ export default class LValParser extends NodeUtils {
checkClashes[key] = true;
}
}
if (bindingType === BIND_LEXICAL && expr.name === "let") {
this.raise(
expr.start,
"'let' is not allowed to be used as a name in 'let' or 'const' declarations.",
);
}
if (!(bindingType & BIND_NONE)) {
this.scope.declareName(expr.name, bindingType, expr.start);
}

View File

@@ -83,6 +83,12 @@ export class NodeUtils extends UtilParser {
pos: number,
loc: Position,
): T {
if (process.env.NODE_ENV !== "production" && node.end > 0) {
throw new Error(
"Do not call finishNode*() twice on the same node." +
" Instead use resetEndLocation() or change type directly.",
);
}
node.type = type;
node.end = pos;
node.loc.end = loc;
@@ -97,6 +103,16 @@ export class NodeUtils extends UtilParser {
if (this.options.ranges) node.range[0] = start;
}
resetEndLocation(
node: NodeBase,
end?: number = this.state.lastTokEnd,
endLoc?: Position = this.state.lastTokEndLoc,
): void {
node.end = end;
node.loc.end = endLoc;
if (this.options.ranges) node.range[1] = end;
}
/**
* Reset the start location of node to the start location of locationNode
*/

View File

@@ -22,10 +22,6 @@ import {
SCOPE_SUPER,
} from "../util/scopeflags";
// Reused empty array added for node fields that are always empty.
const empty = [];
const loopLabel = { kind: "loop" },
switchLabel = { kind: "switch" };
@@ -49,7 +45,11 @@ export default class StatementParser extends ExpressionParser {
this.parseBlockBody(program, true, true, tt.eof);
if (this.inModule && this.scope.undefinedExports.size > 0) {
if (
this.inModule &&
!this.options.allowUndeclaredExports &&
this.scope.undefinedExports.size > 0
) {
for (const [name] of Array.from(this.scope.undefinedExports)) {
const pos = this.scope.undefinedExports.get(name);
// $FlowIssue
@@ -390,7 +390,7 @@ export default class StatementParser extends ExpressionParser {
node.expression = this.parseMaybeDecoratorArguments(expr);
this.state.decoratorStack.pop();
} else {
node.expression = this.parseMaybeAssign();
node.expression = this.parseExprSubscripts();
}
return this.finishNode(node, "Decorator");
}
@@ -683,7 +683,6 @@ export default class StatementParser extends ExpressionParser {
node.handler = this.finishNode(clause, "CatchClause");
}
node.guardedHandlers = empty;
node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null;
if (!node.handler && !node.finalizer) {
@@ -1015,9 +1014,6 @@ export default class StatementParser extends ExpressionParser {
}
parseVarId(decl: N.VariableDeclarator, kind: "var" | "let" | "const"): void {
if ((kind === "const" || kind === "let") && this.isContextual("let")) {
this.unexpected(null, "let is disallowed as a lexically bound name");
}
decl.id = this.parseBindingAtom();
this.checkLVal(
decl.id,

View File

@@ -38,7 +38,7 @@ export function getPluginOption(
return null;
}
const PIPELINE_PROPOSALS = ["minimal", "smart"];
const PIPELINE_PROPOSALS = ["minimal", "smart", "fsharp"];
export function validatePlugins(plugins: PluginList) {
if (hasPlugin(plugins, "decorators")) {

View File

@@ -96,7 +96,11 @@ export default (superClass: Class<Parser>): Class<Parser> =>
}
finishToken(type: TokenType, val: any): void {
if (!(type === tt.string || type === tt.semi)) {
if (
type !== tt.string &&
type !== tt.semi &&
type !== tt.interpreterDirective
) {
if (this.flowPragma === undefined) {
this.flowPragma = null;
}
@@ -218,8 +222,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
this.finishNode(id, id.type);
this.resetEndLocation(id);
this.semicolon();
return this.finishNode(node, "DeclareFunction");
@@ -235,13 +238,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>
return this.flowParseDeclareFunction(node);
} else if (this.match(tt._var)) {
return this.flowParseDeclareVariable(node);
} else if (this.isContextual("module")) {
if (this.lookahead().type === tt.dot) {
} else if (this.eatContextual("module")) {
if (this.match(tt.dot)) {
return this.flowParseDeclareModuleExports(node);
} else {
if (insideModule) {
this.unexpected(
null,
this.state.lastTokStart,
"`declare module` cannot be used inside another `declare module`",
);
}
@@ -272,8 +275,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
}
flowParseDeclareModule(node: N.FlowDeclareModule): N.FlowDeclareModule {
this.next();
this.scope.enter(SCOPE_OTHER);
if (this.match(tt.string)) {
@@ -289,14 +290,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>
let bodyNode = this.startNode();
if (this.match(tt._import)) {
const lookahead = this.lookahead();
if (lookahead.value !== "type" && lookahead.value !== "typeof") {
this.next();
if (!this.isContextual("type") && !this.match(tt._typeof)) {
this.unexpected(
null,
this.state.lastTokStart,
"Imports within a `declare module` body must always be `import type` or `import typeof`",
);
}
this.next();
this.parseImport(bodyNode);
} else {
this.expectContextual(
@@ -418,8 +418,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
flowParseDeclareModuleExports(
node: N.FlowDeclareModuleExports,
): N.FlowDeclareModuleExports {
this.expectContextual("module");
this.expect(tt.dot);
this.next();
this.expectContextual("exports");
node.typeAnnotation = this.flowParseTypeAnnotation();
this.semicolon();
@@ -432,7 +431,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
): N.FlowDeclareTypeAlias {
this.next();
this.flowParseTypeAlias(node);
return this.finishNode(node, "DeclareTypeAlias");
// Don't do finishNode as we don't want to process comments twice
node.type = "DeclareTypeAlias";
return node;
}
flowParseDeclareOpaqueType(
@@ -440,7 +441,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
): N.FlowDeclareOpaqueType {
this.next();
this.flowParseOpaqueType(node, true);
return this.finishNode(node, "DeclareOpaqueType");
// Don't do finishNode as we don't want to process comments twice
node.type = "DeclareOpaqueType";
return node;
}
flowParseDeclareInterface(
@@ -585,16 +588,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
// Type annotations
flowParseTypeParameter(
allowDefault?: boolean = true,
requireDefault?: boolean = false,
): N.TypeParameter {
if (!allowDefault && requireDefault) {
throw new Error(
"Cannot disallow a default value (`allowDefault`) while also requiring it (`requireDefault`).",
);
}
flowParseTypeParameter(requireDefault?: boolean = false): N.TypeParameter {
const nodeStart = this.state.start;
const node = this.startNode();
@@ -607,12 +601,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
node.bound = ident.typeAnnotation;
if (this.match(tt.eq)) {
if (allowDefault) {
this.eat(tt.eq);
node.default = this.flowParseType();
} else {
this.unexpected();
}
this.eat(tt.eq);
node.default = this.flowParseType();
} else {
if (requireDefault) {
this.unexpected(
@@ -626,9 +616,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
return this.finishNode(node, "TypeParameter");
}
flowParseTypeParameterDeclaration(
allowDefault?: boolean = true,
): N.TypeParameterDeclaration {
flowParseTypeParameterDeclaration(): N.TypeParameterDeclaration {
const oldInType = this.state.inType;
const node = this.startNode();
node.params = [];
@@ -645,10 +633,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
let defaultRequired = false;
do {
const typeParameter = this.flowParseTypeParameter(
allowDefault,
defaultRequired,
);
const typeParameter = this.flowParseTypeParameter(defaultRequired);
node.params.push(typeParameter);
@@ -795,9 +780,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
node.typeParameters = null;
if (this.isRelational("<")) {
node.typeParameters = this.flowParseTypeParameterDeclaration(
/* allowDefault */ false,
);
node.typeParameters = this.flowParseTypeParameterDeclaration();
}
this.expect(tt.parenL);
@@ -1280,13 +1263,14 @@ export default (superClass: Class<Parser>): Class<Parser> =>
});
case tt.bracketL:
return this.flowParseTupleType();
this.state.noAnonFunctionType = false;
type = this.flowParseTupleType();
this.state.noAnonFunctionType = oldNoAnonFunctionType;
return type;
case tt.relational:
if (this.state.value === "<") {
node.typeParameters = this.flowParseTypeParameterDeclaration(
/* allowDefault */ false,
);
node.typeParameters = this.flowParseTypeParameterDeclaration();
this.expect(tt.parenL);
tmp = this.flowParseFunctionTypeParams();
node.params = tmp.params;
@@ -1371,15 +1355,27 @@ export default (superClass: Class<Parser>): Class<Parser> =>
case tt.plusMin:
if (this.state.value === "-") {
this.next();
if (!this.match(tt.num)) {
this.unexpected(null, `Unexpected token, expected "number"`);
if (this.match(tt.num)) {
return this.parseLiteral(
-this.state.value,
"NumberLiteralTypeAnnotation",
node.start,
node.loc.start,
);
}
return this.parseLiteral(
-this.state.value,
"NumberLiteralTypeAnnotation",
node.start,
node.loc.start,
if (this.match(tt.bigint)) {
return this.parseLiteral(
-this.state.value,
"BigIntLiteralTypeAnnotation",
node.start,
node.loc.start,
);
}
this.unexpected(
null,
`Unexpected token, expected "number" or "bigint"`,
);
}
@@ -1390,6 +1386,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
"NumberLiteralTypeAnnotation",
);
case tt.bigint:
return this.parseLiteral(
this.state.value,
"BigIntLiteralTypeAnnotation",
);
case tt._void:
this.next();
return this.finishNode(node, "VoidTypeAnnotation");
@@ -1520,7 +1522,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
: this.flowParseRestrictedIdentifier();
if (this.match(tt.colon)) {
ident.typeAnnotation = this.flowParseTypeAnnotation();
this.finishNode(ident, ident.type);
this.resetEndLocation(ident);
}
return ident;
}
@@ -1528,12 +1530,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>
typeCastToParameter(node: N.Node): N.Node {
node.expression.typeAnnotation = node.typeAnnotation;
return this.finishNodeAt(
this.resetEndLocation(
node.expression,
node.expression.type,
node.typeAnnotation.end,
node.typeAnnotation.loc.end,
);
return node.expression;
}
flowParseVariance(): ?N.FlowVariance {
@@ -1848,6 +1851,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
node = super.parseParenItem(node, startPos, startLoc);
if (this.eat(tt.question)) {
node.optional = true;
// Include questionmark in location of node
// Don't use this.finishNode() as otherwise we might process comments twice and
// include already consumed parens
this.resetEndLocation(node);
}
if (this.match(tt.colon)) {
@@ -2084,9 +2091,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
}
delete (method: $FlowFixMe).variance;
if (this.isRelational("<")) {
method.typeParameters = this.flowParseTypeParameterDeclaration(
/* allowDefault */ false,
);
method.typeParameters = this.flowParseTypeParameterDeclaration();
}
super.pushClassMethod(
@@ -2168,9 +2173,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
// method shorthand
if (this.isRelational("<")) {
typeParameters = this.flowParseTypeParameterDeclaration(
/* allowDefault */ false,
);
typeParameters = this.flowParseTypeParameterDeclaration();
if (!this.match(tt.parenL)) this.unexpected();
}
@@ -2205,7 +2208,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
if (this.match(tt.colon)) {
param.typeAnnotation = this.flowParseTypeAnnotation();
}
this.finishNode(param, param.type);
this.resetEndLocation(param);
return param;
}
@@ -2378,9 +2381,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
// $FlowFixMe
const kind = node.kind;
if (kind !== "get" && kind !== "set" && this.isRelational("<")) {
node.typeParameters = this.flowParseTypeParameterDeclaration(
/* allowDefault */ false,
);
node.typeParameters = this.flowParseTypeParameterDeclaration();
}
super.parseFunctionParams(node, allowModifiers);
}
@@ -2393,7 +2394,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
super.parseVarId(decl, kind);
if (this.match(tt.colon)) {
decl.id.typeAnnotation = this.flowParseTypeAnnotation();
this.finishNode(decl.id, decl.id.type);
this.resetEndLocation(decl.id); // set end position to end of type
}
}

View File

@@ -269,7 +269,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
let node;
switch (this.state.type) {
case tt.braceL:
node = this.jsxParseExpressionContainer();
node = this.startNode();
this.next();
node = this.jsxParseExpressionContainer(node);
if (node.expression.type === "JSXEmptyExpression") {
throw this.raise(
node.start,
@@ -310,10 +312,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
// Parse JSX spread child
jsxParseSpreadChild(): N.JSXSpreadChild {
const node = this.startNode();
this.expect(tt.braceL);
this.expect(tt.ellipsis);
jsxParseSpreadChild(node: N.JSXSpreadChild): N.JSXSpreadChild {
this.next(); // ellipsis
node.expression = this.parseExpression();
this.expect(tt.braceR);
@@ -322,9 +322,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
// Parses JSX expression enclosed into curly brackets.
jsxParseExpressionContainer(): N.JSXExpressionContainer {
const node = this.startNode();
this.next();
jsxParseExpressionContainer(
node: N.JSXExpressionContainer,
): N.JSXExpressionContainer {
if (this.match(tt.braceR)) {
node.expression = this.jsxParseEmptyExpression();
} else {
@@ -423,15 +423,17 @@ export default (superClass: Class<Parser>): Class<Parser> =>
children.push(this.parseExprAtom());
break;
case tt.braceL:
if (this.lookahead().type === tt.ellipsis) {
children.push(this.jsxParseSpreadChild());
case tt.braceL: {
const node = this.startNode();
this.next();
if (this.match(tt.ellipsis)) {
children.push(this.jsxParseSpreadChild(node));
} else {
children.push(this.jsxParseExpressionContainer());
children.push(this.jsxParseExpressionContainer(node));
}
break;
}
// istanbul ignore next - should never happen
default:
throw this.unexpected();

View File

@@ -71,8 +71,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
node: N.Node,
expectedNode: T,
): /*N.Placeholder<T>*/ MaybePlaceholder<T> {
const isFinished = !!(node.expectedNode && node.type === "Placeholder");
node.expectedNode = expectedNode;
return this.finishNode(node, "Placeholder");
return isFinished ? node : this.finishNode(node, "Placeholder");
}
/* ============================================================ *

View File

@@ -161,17 +161,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
);
}
tsTryParseDelimitedList<T: N.Node>(
kind: ParsingContext,
parseElement: () => ?T,
): ?(T[]) {
return this.tsParseDelimitedListWorker(
kind,
parseElement,
/* expectSuccess */ false,
);
}
/**
* If !expectSuccess, returns undefined instead of failing to parse.
* If expectSuccess, parseElement should always return a defined value.
@@ -397,13 +386,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
tsParseSignatureMember(
kind: "TSCallSignatureDeclaration" | "TSConstructSignatureDeclaration",
node: N.TsCallSignatureDeclaration | N.TsConstructSignatureDeclaration,
): N.TsCallSignatureDeclaration | N.TsConstructSignatureDeclaration {
const node:
| N.TsCallSignatureDeclaration
| N.TsConstructSignatureDeclaration = this.startNode();
if (kind === "TSConstructSignatureDeclaration") {
this.expect(tt._new);
}
this.tsFillSignature(tt.colon, node);
this.tsParseTypeMemberSemicolon();
return this.finishNode(node, kind);
@@ -427,7 +411,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
this.expect(tt.bracketL);
const id = this.parseIdentifier();
id.typeAnnotation = this.tsParseTypeAnnotation();
this.finishNode(id, "Identifier"); // set end position to end of type
this.resetEndLocation(id); // set end position to end of type
this.expect(tt.bracketR);
node.parameters = [id];
@@ -442,7 +426,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
node: N.TsPropertySignature | N.TsMethodSignature,
readonly: boolean,
): N.TsPropertySignature | N.TsMethodSignature {
this.parsePropertyName(node);
if (this.eat(tt.question)) node.optional = true;
const nodeAny: any = node;
@@ -462,17 +445,26 @@ export default (superClass: Class<Parser>): Class<Parser> =>
}
tsParseTypeMember(): N.TsTypeElement {
if (this.match(tt.parenL) || this.isRelational("<")) {
return this.tsParseSignatureMember("TSCallSignatureDeclaration");
}
if (
this.match(tt._new) &&
this.tsLookAhead(this.tsIsStartOfConstructSignature.bind(this))
) {
return this.tsParseSignatureMember("TSConstructSignatureDeclaration");
}
// Instead of fullStart, we create a node here.
const node: any = this.startNode();
if (this.match(tt.parenL) || this.isRelational("<")) {
return this.tsParseSignatureMember("TSCallSignatureDeclaration", node);
}
if (this.match(tt._new)) {
const id: N.Identifier = this.startNode();
this.next();
if (this.match(tt.parenL) || this.isRelational("<")) {
return this.tsParseSignatureMember(
"TSConstructSignatureDeclaration",
node,
);
} else {
node.key = this.createIdentifier(id, "new");
return this.tsParsePropertyOrMethodSignature(node, false);
}
}
const readonly = !!this.tsParseModifier(["readonly"]);
const idx = this.tsTryParseIndexSignature(node);
@@ -480,12 +472,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
if (readonly) node.readonly = true;
return idx;
}
return this.tsParsePropertyOrMethodSignature(node, readonly);
}
tsIsStartOfConstructSignature() {
this.next();
return this.match(tt.parenL) || this.isRelational("<");
this.parsePropertyName(node);
return this.tsParsePropertyOrMethodSignature(node, readonly);
}
tsParseTypeLiteral(): N.TsTypeLiteral {
@@ -1270,23 +1259,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
}
}
nodeWithSamePosition<T: N.Node>(original: N.Node, type: string): T {
const node = this.startNodeAtNode(original);
node.type = type;
node.end = original.end;
node.loc.end = original.loc.end;
if (original.leadingComments) {
node.leadingComments = original.leadingComments;
}
if (original.trailingComments) {
node.trailingComments = original.trailingComments;
}
if (original.innerComments) node.innerComments = original.innerComments;
return node;
}
tsTryParseDeclare(nany: any): ?N.Declaration {
if (this.isLineTerminator()) {
return;
@@ -1442,6 +1414,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
startPos: number,
startLoc: Position,
): ?N.ArrowFunctionExpression {
if (!this.isRelational("<")) {
return undefined;
}
const res: ?N.ArrowFunctionExpression = this.tsTryParseAndCatch(() => {
const node: N.ArrowFunctionExpression = this.startNodeAt(
startPos,
@@ -1958,6 +1933,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
node = super.parseParenItem(node, startPos, startLoc);
if (this.eat(tt.question)) {
node.optional = true;
// Include questionmark in location of node
// Don't use this.finishNode() as otherwise we might process comments twice and
// include already consumed parens
this.resetEndLocation(node);
}
if (this.match(tt.colon)) {
@@ -1971,7 +1950,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
return this.finishNode(typeCastNode, "TSTypeCastExpression");
}
return this.finishNode(node, node.type);
return node;
}
parseExportDeclaration(node: N.ExportNamedDeclaration): ?N.Declaration {
@@ -2092,7 +2071,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
const type = this.tsTryParseTypeAnnotation();
if (type) {
decl.id.typeAnnotation = type;
this.finishNode(decl.id, decl.id.type); // set end position to end of type
this.resetEndLocation(decl.id); // set end position to end of type
}
}
@@ -2204,8 +2183,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
const returnType = this.tsParseTypeOrTypePredicateAnnotation(
tt.colon,
);
if (this.canInsertSemicolon()) this.unexpected();
if (!this.match(tt.arrow)) this.unexpected();
if (this.canInsertSemicolon() || !this.match(tt.arrow)) {
this.state = state;
return undefined;
}
node.returnType = returnType;
} catch (err) {
if (err instanceof SyntaxError) {
@@ -2234,7 +2215,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
}
const type = this.tsTryParseTypeAnnotation();
if (type) param.typeAnnotation = type;
return this.finishNode(param, param.type);
this.resetEndLocation(param);
return param;
}
toAssignable(
@@ -2396,12 +2379,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>
typeCastToParameter(node: N.TsTypeCastExpression): N.Node {
node.expression.typeAnnotation = node.typeAnnotation;
return this.finishNodeAt(
this.resetEndLocation(
node.expression,
node.expression.type,
node.typeAnnotation.end,
node.typeAnnotation.loc.end,
);
return node.expression;
}
toReferencedList(
@@ -2438,10 +2422,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
jsxParseOpeningElementAfterName(
node: N.JSXOpeningElement,
): N.JSXOpeningElement {
const typeArguments = this.tsTryParseAndCatch(() =>
this.tsParseTypeArguments(),
);
if (typeArguments) node.typeParameters = typeArguments;
if (this.isRelational("<")) {
const typeArguments = this.tsTryParseAndCatch(() =>
this.tsParseTypeArguments(),
);
if (typeArguments) node.typeParameters = typeArguments;
}
return super.jsxParseOpeningElementAfterName(node);
}

View File

@@ -226,11 +226,9 @@ export default class Tokenizer extends LocationParser {
loc: new SourceLocation(startLoc, endLoc),
};
if (!this.isLookahead) {
if (this.options.tokens) this.state.tokens.push(comment);
this.state.comments.push(comment);
this.addComment(comment);
}
if (this.options.tokens) this.state.tokens.push(comment);
this.state.comments.push(comment);
this.addComment(comment);
}
skipBlockComment(): void {
@@ -250,6 +248,10 @@ export default class Tokenizer extends LocationParser {
this.state.lineStart = match.index + match[0].length;
}
// If we are doing a lookahead right now we need to advance the position (above code)
// but we do not want to push the comment to the state.
if (this.isLookahead) return;
this.pushComment(
true,
this.input.slice(start + 2, end),
@@ -276,6 +278,10 @@ export default class Tokenizer extends LocationParser {
}
}
// If we are doing a lookahead right now we need to advance the position (above code)
// but we do not want to push the comment to the state.
if (this.isLookahead) return;
this.pushComment(
false,
this.input.slice(start + startSkip, this.state.pos),
@@ -350,7 +356,7 @@ export default class Tokenizer extends LocationParser {
this.state.type = type;
this.state.value = val;
this.updateContext(prevType);
if (!this.isLookahead) this.updateContext(prevType);
}
// ### Token reading

View File

@@ -77,6 +77,10 @@ export default class State {
maxTopicIndex: null,
};
// For the F# plugin
soloAwait: boolean = false;
inFSharpPipelineDirectBody: boolean = false;
// Check whether we are in a (nested) class or not.
classLevel: number = 0;
@@ -170,7 +174,7 @@ export default class State {
// $FlowIgnore
let val = this[key];
if ((!skipArrays || key === "context") && Array.isArray(val)) {
if (!skipArrays && Array.isArray(val)) {
val = val.slice();
}

View File

@@ -263,8 +263,6 @@ export type TryStatement = NodeBase & {
block: BlockStatement,
handler: CatchClause | null,
finalizer: BlockStatement | null,
guardedHandlers: $ReadOnlyArray<empty>, // TODO: Not in spec
};
export type CatchClause = NodeBase & {

View File

@@ -0,0 +1 @@
export { foo };

View File

@@ -0,0 +1,4 @@
{
"sourceType": "module",
"allowUndeclaredExports": true
}

View File

@@ -0,0 +1,103 @@
{
"type": "File",
"start": 0,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"program": {
"type": "Program",
"start": 0,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ExportNamedDeclaration",
"start": 0,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"specifiers": [
{
"type": "ExportSpecifier",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
}
},
"local": {
"type": "Identifier",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "foo"
},
"name": "foo"
},
"exported": {
"type": "Identifier",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "foo"
},
"name": "foo"
}
}
],
"source": null,
"declaration": null
}
],
"directives": []
}
}

View File

@@ -198,7 +198,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
},
{

View File

@@ -238,14 +238,12 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
},
{

View File

@@ -161,7 +161,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -176,7 +176,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -61,7 +61,6 @@
"directives": []
},
"handler": null,
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 16,

View File

@@ -225,7 +225,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -225,7 +225,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 47,

View File

@@ -0,0 +1 @@
let { let } = {};

View File

@@ -0,0 +1,3 @@
{
"throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:6)"
}

View File

@@ -0,0 +1 @@
const { let } = {};

View File

@@ -0,0 +1,3 @@
{
"throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:8)"
}

View File

@@ -0,0 +1 @@
let [let] = [];

View File

@@ -0,0 +1,3 @@
{
"throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:5)"
}

View File

@@ -0,0 +1 @@
const [let] = [];

View File

@@ -0,0 +1,3 @@
{
"throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:7)"
}

View File

@@ -0,0 +1 @@
let let

View File

@@ -0,0 +1,3 @@
{
"throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:4)"
}

View File

@@ -0,0 +1 @@
const let = ''

View File

@@ -0,0 +1,3 @@
{
"throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:6)"
}

View File

@@ -164,7 +164,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -93,7 +93,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 28,

View File

@@ -93,7 +93,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -108,7 +108,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -476,7 +476,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -161,7 +161,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -108,7 +108,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -176,7 +176,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -61,7 +61,6 @@
"directives": []
},
"handler": null,
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 16,

View File

@@ -225,7 +225,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],

View File

@@ -225,7 +225,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 47,

View File

@@ -523,7 +523,6 @@
"directives": []
},
"handler": null,
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 173,

View File

@@ -0,0 +1,4 @@
class Foo {
@deco
*generatorMethod() {}
}

View File

@@ -0,0 +1,175 @@
{
"type": "File",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 9
},
"identifierName": "Foo"
},
"name": "Foo"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 10,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 14,
"end": 43,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 3,
"column": 23
}
},
"decorators": [
{
"type": "Decorator",
"start": 14,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 7
}
},
"expression": {
"type": "Identifier",
"start": 15,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 7
},
"identifierName": "deco"
},
"name": "deco"
}
}
],
"static": false,
"kind": "method",
"key": {
"type": "Identifier",
"start": 23,
"end": 38,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 18
},
"identifierName": "generatorMethod"
},
"name": "generatorMethod"
},
"computed": false,
"id": null,
"generator": true,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 41,
"end": 43,
"loc": {
"start": {
"line": 3,
"column": 21
},
"end": {
"line": 3,
"column": 23
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

Some files were not shown because too many files have changed in this diff Show More