64 Commits

Author SHA1 Message Date
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
Daniel Tschinder
491b0a8e33
Update test262 (#9806) 2019-04-01 21:47:07 -07:00
Daniel Tschinder
c7587c016e
Don't accept '\08' or '\09' in strict mode (#9769) 2019-04-01 19:41:50 -07:00
Daniel Tschinder
6bc9e7ebda
Correctly check for-in and for-of loop for invalid left-hand side (#9768)
* Correctly check for-in and for-of loop for invalid left-hand side

* Overwrite with env variable
2019-03-26 15:32:14 -07:00
Daniel Tschinder
7f4427432c
Parse right-hand-side of for/of as an assignment expression (#9767) 2019-03-25 18:14:56 -07:00
Daniel Tschinder
29999007f6
Disallow escape sequences in contextual keywords (#9618)
* Disallow escape sequences in async

* Disallow escape sequences in get, set and async in class

* invalid escape tests

* Update whitelist

* tests for async in parens

* Add test for invalid newline between params and arrow

* Move canInsertSemilcolon() into shouldPArseAsyncArrow
2019-03-05 17:20:36 -08:00
Daniel Tschinder
98ab1b6428
Refactor parsing object members (#9607)
* Refactor parsing object members

* Ensure decorators on rest don’t swallow decorators silently

* Use hasPrecedingLineBreak

* Add test for async with linebreak

* Update flow whitelist
2019-02-28 11:42:12 -08:00
Daniel Tschinder
208195f425
Disallow duplicate params in methods (#9599)
* Disallow duplicate params in methods

* Fix plugins
2019-02-27 15:54:07 -08:00
Daniel Tschinder
43eed1ac92
Check exported bindings are defined (#9589)
* Check exported bindings are defined

* Add tests

* Update flow whitelist

* Add tests for builtins
2019-02-26 13:28:10 -08:00
Daniel Tschinder
d0e196d210
Treat for loop body as part of loop scope (#9586) 2019-02-25 18:30:51 -08:00
Daniel Tschinder
45c96908e9
Update test262 (#9587)
* Update test262

* Also remove unrecognized tests from the whitelist
2019-02-25 15:10:48 -08:00
Daniel Tschinder
a7391144b3
Introduce scope tracking in the parser (#9493)
* Introduce scope tracking

* Fix tests

* Add new tests

* Remove constructor-super check from transform as it is now in parser

* Correctly handle class properties and class scope

* Fix duplicate name check

* Convert scope identifier storage to array

* Enter a new scope in typescript module blocks

* Add test for duplicate declaration

* Rename error for duplicate exports

* Treat class declarations as lexical declaration

* Update whitelist

* Add tests

* Fix scope tracking for function declarations

* Migrate try-catch duplicate error

* Fix test

* More tests

* One more test

* Make scope a separate class and fix review comments

* Do not allow new.target in top scope arrow function

* Correctly enter new scope for declare module and treat type aliases as lexical declarations

* Tests for typescript scope tracking to not mark type aliases as duplicate

* Fix flow scope tracking

* Remove ident from test names as redundant

* Add test case for var and function

* Improve error messages

* Improve literal regex
2019-02-25 11:04:52 -08:00
Daniel Tschinder
2817844e89
Fix regression with let (#9477)
* Fix corner cases with let

* Handle generators correctly

* Fix flow plugin

* Fix typescript plugin
2019-02-08 13:36:37 -08:00
Daniel Tschinder
46ba5940c2
Make yield a contextual keyword (#9400) 2019-01-23 14:33:23 -08:00
Daniel Tschinder
42c5d3fc4b
Correctly fail for invalid yield in for (#9398) 2019-01-23 13:39:30 -08:00
Daniel Tschinder
4f69699b71 Fix parsing in non-declaration places 2019-01-22 13:12:03 -08:00
Daniel Tschinder
f4f5ca2aaa Parse class name in strict mode
The specification defines that the whole class declaration is parsed in strict mode
2019-01-22 13:12:03 -08:00
Daniel Tschinder
8071dca9ad Disallow const let or let let 2019-01-22 13:12:02 -08:00
Daniel Tschinder
96a7343142
Merge pull request #9348 from danez/perf
Parser Performance Collection
2019-01-21 02:27:42 -08:00
Nicolò Ribaudo
4ce37b7aca
Update test262 sha (#9365) 2019-01-19 18:10:28 +01:00
Daniel Tschinder
2d6231fd3d Update flow whitelist 2019-01-17 16:16:32 -08:00
Nicolò Ribaudo
0a88230ec4 Disallow async functions as loop bodies (#9314) 2019-01-17 17:07:48 -05:00
Nicolò Ribaudo
3e4b608a80
Parse class heritage as strict mode code (#9315) 2019-01-12 14:54:23 +01:00
Nicolò Ribaudo
5889620a6a
Disallow new import(x) and import(x,) (#9313)
* Disallow "new import(...)"

* Disallow trailing comma inside dynamic import

* Rename test

* Update error message
2019-01-11 18:59:51 +01:00
Nicolò Ribaudo
9764718c32
Disallow trailing comma after rest (#9311)
* Add new tests

* Use state instead of param and disallow comma in [...a,]=[]

* Unify error messages

* Object destructuring

* Update whitelist
2019-01-11 13:08:38 +01:00
Brian Ng
a55382e4ad
Test262 update (#9288) 2019-01-07 08:52:36 -06:00
Daniel Tschinder
5cb38995c0
Allow keywords to be used in type annotations (#9184) 2018-12-15 12:51:24 -08:00
Vikram Rangaraj
72471aff63 Handle flow comments with leading spaces (#9168)
* check for spaces and tabs before a flow comment

* fix issue with using string index and shift interchangably

* update tests

* Use update charcodes version

* Disallow flow-comments in flow-comments and check for unterminated comments
2018-12-13 22:10:01 -08:00
Nicolò Ribaudo
61f2aed5b0
Disallow await inside arrow functions (#9074)
* Disallow await inside arrow functions

* Update test262 whitelist
2018-11-26 12:43:04 +01:00
Daniel Tschinder
1af57e6f71
Fix test262 tests again! 2018-11-14 23:29:17 -08:00
Nicolò Ribaudo
2fa1984635
Fix await in function name and parameters (#7727)
* Disallow await in function parameters

* Fix await as function name

* Update test whitelists
2018-11-06 08:30:06 +01:00
Daniel Tschinder
e3b2c1afff
fix: Do not allow TypeCastExpressions w/o parens (#8956) 2018-11-05 15:34:24 -08:00
Nicolò Ribaudo
24c4901ff5
Remove Babylon plugins for features already merged to the ECMAScript spec (#8448)
These are now enabled by default:
- objectRestSpread (2018)
- asyncGenerators (2018)
- optionalCatchBInding (2019)
- jsonStrings (2019)

TODO (after this commit):
- [ ] Deprecate the `@babel/plugin-syntax-*` packages.
- [ ] Deprecate the `@babel/plugin-proposal-*` packages.
- [ ] Create the `@babel/plugin-transform-*` packages.
2018-11-05 23:48:06 +01:00
Daniel Tschinder
c125b1dd74
Update test262 commit, as old commit broke for some reason 2018-11-05 10:53:34 -08:00
Daniel Tschinder
1d4d760ffc Update test262 to latest commit and enable mapping for features
Also added an automated check for new features which are not mapped or ignored
2018-11-04 18:49:53 +01:00
Brian Ng
55faa27b93
Run test262 tests for exportNamespaceFrom (#8780) 2018-09-27 14:48:58 -05:00
Justin Ridgewell
5899940156
Update parser whitespace for clarity (#8539)
* Update parser whitespace for clarity

Has the nice benefit of not requiring a charCode to String conversion.

* Remove test262 exceptions

Per https://github.com/tc39/ecma262/pull/1218#issuecomment-395340891,
ECMA262 follows whatever the latest Unicode version specifies for Zs
Space_Separator category. MONGOLIAN VOWEL SEPARATOR was moved to the Cf
Other_Format category in Unicode 8.
2018-08-25 19:12:38 -04:00
kalenikalexander
5c728ea609 Fix private property parsing in Flow (#8340)
* Fix private property parsing in Flow

* Flow tests updated

* Fix type error

* Appropriate name was given to test folder

* Fix

* Empty

* Correct type annotation

* Add required changes in generator package

* Add required changes in flow-strip-types
2018-08-02 08:38:58 +02:00
Brian Ng
ab928713af Bump test262-stream and update test262 tests (#8139) 2018-06-10 10:55:40 +02:00
Brian Ng
5895277b32 Bump prettier to v1.13.2 2018-06-03 07:54:39 -05:00
Sam Goldman
f0283572a5 Support Flow's proto modifier syntax for declared classes (#7978)
<!--
Before making a PR please make sure to read our contributing guidelines
https://github.com/babel/babel/blob/master/CONTRIBUTING.md

For issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR. It should be underlined in the preview if done correctly.
-->

| Q                        | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues?            | <!-- remove the (`) quotes to link the issues -->
| Patch: Bug Fix?          |
| Major: Breaking Change?  | No
| Minor: New Feature?      | Yes
| Tests Added + Pass?      | Yes
| Documentation PR         | <!-- If so, add `[skip ci]` to your commit message to skip CI -->
| Any Dependency Changes?  |
| License                  | MIT

See eb815be907 for more information about this feature.
    
The proto modifier indicates that a property declared using `x: T` syntax is actually present on the prototype object of the class, rather than an own property.
    
The proto and static modifiers are mutually exclusive, as class declarations don't simultaneously define the static prototype object, as they do the instance prototype.
    
This syntax is only supported on declared classes, not object types, interfaces, or runtime class declarations, and as such should only appear in library definitions.
2018-05-25 15:40:56 -05:00
Chaitanya Kumar Kamatham
daf0ca8680 Rename "babylon" to "@babel/parser" (#7937) 🎉 2018-05-19 00:03:05 -04:00
Sam Goldman
a40f54f847 Add support for explicit type arguments in new and call expressions (#7934)
* Add all option to babel-plugin-syntax-flow

The Flow parser has some conditional logic based on whether types should
be parsed or not, which is based on either (a) the @flow pragma in the
docblock of the file of (b) the `all` configuration, provided via
command line or .flowconfig.

This commit adds the ability to provide the `all` configuration to
Babel as well, via the syntax-flow plugin. This should be set to `true`
if the project uses all=true.

* Parse @flow pragma

The Flow parser has some conditional logic based on whether types should
be parsed or not, which is based on either (a) the @flow pragma in the
docblock of the file of (b) the `all` configuration, provided via
command line or .flowconfig.

This commit parses the @flow (or @noflow) pragma from the first comment
in the source file. Directives are allowed to appear before the comment.

* WIP: add tests for explicit type arguments

This commit includes tests which have unexpected output, but will change
to the expected output as later commits add parsing support for various
features.

* Parse type arguments in new expressions

* Parse type arguments in call expressions

* Parse optional call expressions with explicit type args

* Add explicit type arguments to babel-types

Flow calls these typeArguments instead of typeParameters, which clearly
separates formal/actual parameters, and mirrors the existing arguments
key.

The existing definitions to support TypeScript also included Flow's
TypeParameterInstantiation node type, which I've moved to the the new
field.

* Add support for explicit type arguments to babel-generator

* Add test for explicit type args to transform-flow-strip-types plugin

* Oops. Forgot to regenerate the babel-types README.

* Fix Flow parser shouldParseTypes() function

I was looking at `options.all`, but the correct property ws
`options.flowAll`. Oops!

* Remove typeapp_call from whitelist of expected failures

Now that Babylon parses this syntax extension, we can remove the
typeapp_call tests from the list of expected differences.

Note that I am using the `flowAll` option, mirroring the behavior of the
Flow tests, which assume types without requiring the `@flow` pragma.

* Use Babylon plugin options instead of parser options

* Parse optional call expressions type arguments unambiguously
2018-05-18 08:05:16 -05:00
Sam Goldman
b396cdcbe5 Internal slot properties (#7947)
* Support internalSlots to babel-types and babel-generator

* Parsing support for internal slot properties

* Print internal slots in babel-generator

* Add whitespace before first internal slot property
2018-05-16 22:48:12 -05:00
Nicolò Ribaudo
ba11d9fa7c Update test262 and flow tests (#7925) 2018-05-14 12:26:28 -05:00
Nicolò Ribaudo
0a8367c979
Use the correct Babylon plugins for Test262 tests (#7916) 2018-05-13 10:52:19 +02:00
Nicolò Ribaudo
25c3f0d689
Rename decorators&decorators2 plugins to decorators-legacy&decorators. (#7821)
Reasons:
1) Naming consistency with Babel plugins
2) Sooner or later the decorators2 plugin should become decorators anyway
2018-05-10 20:01:35 +02:00
Brian Ng
0353ce9ed5 Disallow flow type parameter defaults in some cases 2018-05-02 08:56:54 -05:00
Brian Ng
65ca968f8b Allow static? as identifier in ObjectTypeProperty 2018-05-02 08:56:54 -05:00
Brian Ng
77445cb044 Enable dynamicImport plugin for flow tests 2018-05-02 08:56:54 -05:00