117 Commits

Author SHA1 Message Date
Nicolò Ribaudo
cd050e1405 Parse parameters inside function's env (#652)
* Parse parameters inside function context

* Add test for new.target inside parameters
2017-10-31 16:31:35 +01:00
M Behzad
fee7de2c1d white lists getter and setter acceseors for having stage-2 decorators (#766)
- adds `get` and `set` kind in addition to `method` to the list of allowed class members for having a decorator,
- adds tests for this two cases (decorator + set and decorator + get)
2017-10-31 16:13:04 +01:00
Daniel Tschinder
86abc16b37
Fix decorators2 to support export @decorator class A {} (#767)
* Fix decorators2 to support `export @decorator class A {}`

* change to better error message

Also ensure that null/undefined options get default value
2017-10-29 12:20:15 +01:00
Logan Smyth
e4bcd1d0ff
Allow Flowtype's imports and exports when sourceType:script is set. (#771) 2017-10-27 11:55:24 -07:00
Andy
0fbf3a61fb Fix new type errors (#754) 2017-10-10 16:11:28 -05:00
Nicolò Ribaudo
664ff37b36 Fix flow errors (#735) 2017-09-27 14:33:11 -04:00
Karl Cheng
65bea96544 Add support for class private methods (#703)
* Add support for class private methods

This commit adds parser support for the TC39 Stage 2 Private Methods
proposal.

This commit also changes "key" in ClassPrivateProperty from an
Identifier to a PrivateName, as well as disallowing #constructor as a
valid private field name.

* Add tests for string literal get/set/async

These should be treated as regular methods and not special get/set/async
behaviour.

* Add tests for class private methods

This also removes a test from the Test262 whitelist that failed before
the changes for private methods support and now passes.

* Modify class private prop tests for PrivateName

* Add class private prop tests for #constructor

* Fix existing ASI test case failure
2017-09-06 18:09:12 -04:00
Daniel Tschinder
19c099d116 Use expectPlugin 2017-08-28 17:31:58 -04:00
Henry Zhu
de47b0423f rename folders, add more 2017-08-28 17:30:10 -04:00
Henry Zhu
2dbba25d1a change some things to expectPlugin 2017-08-28 17:30:10 -04:00
James Henry
acf0e65090 Apply location data fix to decorators plugin (#699) 2017-08-26 11:38:11 -04:00
Brian Ng
5e60ad6688
Fix some cases of invalid labeled declarations 2017-08-24 19:00:52 -05:00
Andy
d565eca976 Don't enable class properties just because "typescript" plugin is enabled (#666) 2017-08-08 20:51:57 -05:00
MarckK
c88af90c0a Add optionality to catch bindings (#634)
* Add optionality to catch bindings (plus tests)

* Update ast/spec, README, set param to null if no param with plugin optionalCatchBinding

* Fix: wrap param = null in else case

* Fix tests for optional catch binding; add tests which include finally clause
2017-07-21 10:18:57 -04:00
Brian Ng
a46f87f726 Check for function when parsing export async (#639) 2017-07-19 14:03:49 -04:00
Nicolò Ribaudo
b0c3a9dcdd Add support for flow's export type * from (#617) 2017-07-11 22:56:04 -05:00
Justin Ridgewell
62d313e753 Fix function.sent parsing 2017-07-07 23:14:20 -04:00
Justin Ridgewell
9c9f9e2adb Add static private class field support 2017-07-02 01:44:12 -04:00
Brian Ng
5180ecdca4 Use prettier (#600) 2017-06-28 12:41:42 -04:00
Andy
97c23461f9 TypeScript parser plugin (#523) 2017-06-28 10:57:50 -04:00
Henry Zhu
f7547fd35a Use the string "module" in err message (#598) 2017-06-28 10:46:30 -04:00
Daniel Tschinder
fecdb6feeb Make tokens optional (#563)
Adding tokens to the ast is significant slower and most tools
don't ever use them anyway
2017-06-27 23:26:24 -04:00
Henry Zhu
39447b1cca Merge pull request #590 from peey/decorators-followup
Follow-up on Decorators PR
2017-06-27 15:34:44 -04:00
Peeyush Kushwaha
f2ad94d0e3 Incorporate suggestions from review 2017-06-27 22:46:43 +05:30
Peeyush Kushwaha
c3b992e031 Minor change in an error message 2017-06-23 22:04:35 +05:30
Peeyush Kushwaha
37fa77e84f Support decorator in decorator
Fixes #524
2017-06-23 18:10:16 +05:30
Karl Cheng
b4e06aa279 Fix parsing of nested classes with private fields
The parsing of private fields checks whether or not it is within a
class to determine if it is valid or not. However, the state.inClass
property is incorrect as it marks it as outside a class when the inner
class is closed.

This commit fixes this problem by replacing the state.inClass property
with a class nesting counter.
2017-06-23 18:34:59 +10:00
Peeyush Kushwaha
add8e4ad13 Helpful error message for @dec export class 2017-06-23 02:19:08 +05:30
Peeyush Kushwaha
e5fdb3448d rename decoratorsStage2 -> decorators2 2017-06-22 02:00:36 +05:30
Peeyush Kushwaha
e1972baff5 Decorated classes/methods start where the decorator starts 2017-06-22 01:45:53 +05:30
Peeyush Kushwaha
38c417e971 Reorganize tests; camelCase plugin name 2017-06-18 01:25:54 +05:30
Peeyush Kushwaha
b5e23835ce Disallow exports between decorator & class body
For stage 2 decorators
2017-06-17 18:12:14 +05:30
Peeyush Kushwaha
9c639743dd Disallow in object literals, params, class props
And add tests to reflect the same
2017-06-17 17:49:33 +05:30
Peeyush Kushwaha
a24dc6e630 Let decorator stage 2 parsing be under a new plugin name
Parse stage 0 decorators when "decorators" plugin is active and
parse stage 2 decorators when "decorators-stage-2" plugin is active
2017-06-17 13:25:21 +05:30
Kevin Gibbons
06afa0761b Update decorator parsing to match current spec
Refer to PR #353
2017-06-17 13:23:30 +05:30
Daniel Tschinder
69cba43f82 Fix parsing of private fields (#566)
The computed key is not part of the spec.
key for ClassProperties is an Expression
Do not parse computed and literal keys for PrivateClassProperties
2017-06-06 11:42:07 -04:00
Daniel Tschinder
775dcfa6d6 Improve performance by removing all spread/rest usages (#561) 2017-06-05 19:21:41 +02:00
Jan Olaf Krems
d4e842d4eb Add plugin for import.meta proposal (#544)
* Add plugin for import.meta proposal

Fixes https://github.com/babel/babylon/issues/539

* Tests for assignment/mutation of import.meta

* Use correct identifier in failure message

* Simpler & more consistent script errors for import.meta
2017-05-30 19:28:51 -04:00
Andy
50694f99b1 Extract 'parseClassMember' method (#533) 2017-05-26 23:44:56 -04:00
Diego Ferreiro Val
01da62283c Modify grammar to support Private Fields proposal: (#260)
* Modify grammar to support Private Fields proposal:
- Adding optional plugin `classPrivateProperties`
- Adding PrivateName type identifier
- Adding ClassPrivateProperty to ClassBody
- Allow PrivateName in MemberExpression
- Allow PrivateName as a reference
- Adding tests

* Remove unnecesary liberal parameter

* Guarding for plugin dependecy for future versioning

* update spec.md [skip ci]

* move comment [skip ci]

* remove unused param [skip ci]

* Refactor PrivateName to contain Identifier in name property
2017-05-22 11:33:48 -04:00
Kevin Gibbons
6c4acecf00 Fix #437: only prohibit 'export type from "module" ' when flow is enabled (#438)
* Only prohibit 'export type' when flow is enabled

* Fix lint
2017-05-19 10:05:44 +02:00
Andy
aa78011666 Fix type check errors (#521) 2017-05-14 19:59:56 +02:00
Andy
7a8b64c0d3 Type-check StatementParser (#489) 2017-05-11 16:28:12 +02:00
Alex Rattray
4e776bf00b Better error message for anonymous class declarations (#509) 2017-05-10 21:26:38 +02:00
Brian Ng
d33c82781a Allow super in class properties (#499) 2017-05-02 14:41:10 -04:00
Andy
3a6b77f374 Don't add 'await' property to ForInStatement (#504) 2017-05-02 14:37:58 -04:00
Andy
c4fb3fe742 Convert each file with parser methods to a class in an inheritance chain (#481) 2017-04-24 00:40:49 +02:00
Daniel Tschinder
d1a5220b89 Add support for declare export + fixes (#224)
* Add support for declare export

* Do not allow declare module inside declare module

* Reallow module exports outside module

* Add handling of `declare export default`

Add check for multiple module.export declarations

* Disallow export let/const/type

Refactor parsing object properties to share more code and add support
for getters and setters

* Rename tests

* Update test fixtures

* Optimize for performance

* disallow declare export interface outside of module

* Refactor code to be more readable and less lookahead

* Add comments

* Add test for export star as

* Test for number literal getter/setter

* Add more tests

* Fix tests

* Allow union types and correctly eat semi after type

* Use non computed keys

* Fix tests
2017-04-21 14:41:59 +02:00
Brian Ng
17f2a2036c Allow namespace exotic to be exported as default (#474) 2017-04-19 13:59:49 +02:00
Daniel Tschinder
68e8550e84
Merge branch 'master' into 7.0
* master:
  Upgrade flow to 0.41
  Throw error if new.target is used outside of a function (#402)
  Fix watch command (#403)
  Update yarn lock
  Fix parsing of class properties (#351)

# Conflicts:
#	src/parser/statement.js
#	test/fixtures/experimental/class-constructor-call/illegal-key/options.json
2017-03-10 13:47:45 +01:00