Bogdan Savluk
4ee6a27780
convert @babel/helper-create-class-features-plugin to TS ( #13214 )
...
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-05-26 15:49:35 +02:00
Nicolò Ribaudo
989aac2a4c
Don't duplicate the base class when using constantSuper ( #13303 )
2021-05-15 00:02:46 +02:00
Nicolò Ribaudo
8732dd39c6
Compile static blocks without the intermediate priv field step ( #13297 )
...
* Remove ordering constraints for `static-blocks` plugin
* Handle static blocks directly in `helper-create-class-features-plugin`
2021-05-14 11:35:59 -04:00
Sosuke Suzuki
b2d9156cc6
Update to Prettier 2.3 ( #13288 )
2021-05-10 15:34:13 +02:00
aancer-rca
3b55e8877c
fix: Typo in @babel/helper-create-class-features-plugin ( #13237 )
2021-04-30 17:40:28 +02:00
Nicolò Ribaudo
f30c99aa24
Mark WeakMaps of private fields as pure ( #13194 )
2021-04-28 18:25:17 +02:00
Nicolò Ribaudo
2fc288576e
Allow compiling #foo in obj without compiling private fields ( #13172 )
2021-04-28 18:25:17 +02:00
Nicolò Ribaudo
8ad6b75cde
Use function rather than var to compile private methods ( #12990 )
2021-03-11 02:08:31 +01:00
Nicolò Ribaudo
c702895256
Update min Babel version for #12917 ( #12977 )
2021-03-07 21:09:05 +01:00
Huáng Jùnliàng
ac758f7d70
Ensure static private method init run before static property ( #12918 )
2021-03-04 00:02:23 +01:00
Huáng Jùnliàng
bdb207cb75
Class static private field destructure set ( #12917 )
...
* fix: support static private field destructure set ([C.#p] = [0])
* 🚧
* fix: add compatibility warning for older @babel/helper versions
* refactor: extract common routines among classPrivateFiled helpers
* More 🚧
2021-03-03 16:38:16 -05:00
Huáng Jùnliàng
82e089c7dd
Evaluate object and initializer when setting a private method ( #12707 )
...
* fix: evaluate initializer when a private method is set as a field
* make legacy node happy
* add accessor test cases
* fix: evaluate object before RHS
* fix: evaluate object before throwing writeOnlyError
2021-03-01 17:49:59 -05:00
Nicolò Ribaudo
9a1b59f1f9
Do not warn for loose of class features in preset-env ( #12898 )
2021-02-25 21:15:48 +01:00
Huáng Jùnliàng
33fbf84fa3
Optimās: respect noDocumentAll when transforming obj?.#p ( #12762 )
2021-02-21 17:09:46 +01:00
Nicolò Ribaudo
6ef7b51a11
Implement assumptions defined in the babel/rfcs#5 RFC
...
- `mutableTemplateObject` and `ignoreToPrimitiveHint` (#12408 )
- `setClassMethods` (#12407 )
- `setComputedProperties` (#12490 )
- `ignoreFunctionLength` (#12491 )
- `noDocumentAll` (#12481 )
- `iterableIsArray` and `arrayLikeIsIterable` (#12489 )
- `pureGetters` (#12504 )
- `skipForOfIteratorClosing` (#12496 )
- `objectRestNoSymbols`, `setSpreadProperties` and `pureGetters` (#12505 )
- `noNewArrows` (#12613 , #12793 )
- `setPublicClassFields` and `privateFieldsAsProperties` (#12497 )
- `constantReexports` and `enumerableModuleMeta` (#12618 )
- `constantSuper`, `superIsCallableConstructor` and `noClassCalls` (#12726 )
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
Co-authored-by: Huáng Jùnliàng <JLHwung@users.noreply.github.com>
2021-02-21 17:09:45 +01:00
Nicolò Ribaudo
8063fde0d8
Reuse the readOnlyError helper for private methods ( #12792 )
2021-02-12 14:33:23 +01:00
Nicolò Ribaudo
e735266dee
Avoid importing .json files ( #12759 )
...
* Avoid importing `.json` files
* Use ESold in babel.config.json
* Use `import/extensions` eslint plugin
2021-02-05 23:34:36 +01:00
Nicolò Ribaudo
3d69dc9471
Add # to the private name in "write-only" errors ( #12713 )
2021-01-29 17:58:13 +01:00
Federico Ciardi
5a020b24b7
fix: throw error when accessing private method without a getter ( #12689 )
...
* fix: class private accessor without getter
* Provide default return if 'writeOnlyError' is not available
* Add warning for old `@babel/helpers`
* Add missing helper call
2021-01-26 11:16:47 -05:00
Zen
cba64f9a09
Correctly access shadowed class binding in super.* ( #12544 )
...
* rename own binding inside methods if it collides with class ref. fix #11994
* fix name collisions in constructor
* do fix name collisions in constructor
* move logic in ReplaceSupers
* fix tests of helper-create-class-features-plugin
* remove replaceSupers in pushConstructor
* use environmentVisitor
* skip classLike nodes
* fix super ref in computed key
2021-01-12 02:31:06 +01:00
Huáng Jùnliàng
f697e7995d
Transform class static block ( #12143 )
...
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Brian Ng <bng412@gmail.com>
2020-10-14 21:16:24 +02:00
Huáng Jùnliàng
5dd64ecc4a
Disallow duplicated AST nodes ( #11807 )
2020-07-14 08:32:16 -05:00
Huáng Jùnliàng
1e115aed33
fix: ensure (a?.b)() has proper this ( #11623 )
...
* fix: ensure (a?.b)() has proper this
* let test be more restrictive
* fix: transformed member call should preserve computed
* chore: revamp test files
* refactor: simplify
* fix: unwrap parthenthesizedExpression
* add loose test cases
* add `(a?.#b)()` support
* add with-transform test cases
* Update packages/babel-plugin-proposal-optional-chaining/src/index.js
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
* address review comments
* update test fixtures
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2020-06-01 10:25:22 -04:00
Ajay Poshak
b1923fd140
Add a check for privateMap's existence ( #11571 )
...
Co-authored-by: Ajay Poshak <ajay.poshak@bookmyshow.com>
2020-05-30 22:38:15 +02:00
Nicolò Ribaudo
e6d873e061
Class features loose should have precedence over preset-env ( #11634 )
...
* Class features loose should have precedence over preset-env
* Comment
* Update packages/babel-helper-create-class-features-plugin/src/features.js
[skip ci]
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
* Future proof
* Add warning when loose mode changes automatically
* Better message
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
2020-05-29 23:56:32 +02:00
Justin Ridgewell
bda759ac3d
Handle private access chained on an optional chain ( #11248 )
...
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
2020-05-26 22:18:17 +02:00
Justin Ridgewell
7459038db8
Add private-property-in-object support ( #11372 )
...
https://github.com/tc39/proposal-private-fields-in-in
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-Authored-By: Huáng Jùnliàng <jlhwung@gmail.com>
2020-05-26 22:18:17 +02:00
Justin Ridgewell
d6efed5b22
Fix redeclaring private in nested class's superClass ( #11424 )
...
If a nested class's `superClass` redeclares the outer class's private field and access it in a computed key, that should fail.
Follow up to #11405 .
2020-04-20 16:54:14 +02:00
Justin Ridgewell
9b48a8ead7
Fix nested classes reference private fields ( #11405 )
...
* Fix nested classes reference private fields
* Process only visible private fields when redeclaring
* Comments
* Skip class traversal if there are no private fields
* Handle redeclared private field in computed key
2020-04-14 21:51:51 +02:00
Oliver Dunk
71e7a7b1e0
Ignore abstract methods when decorating class ( #11345 )
...
* Ignore abstract methods when decorating class
* Address Nico's feedback
* Add input/output test
* Update test output to account for _nonIterableRest changes
2020-03-29 00:17:29 +01:00
Siddhant N Trivedi
3fc904e1d4
Fix classNameTDZError in computed prototype methods with class fields ( #11068 )
...
* Draft fix for TDZError in computed prototype methods
* Added tests for loose:false and also extracted handleClassTDZ
* Added state parameter to handleClassTDZ function
* Extracted the state object to a variable
* Added helper comments for environmentVisitor
* Added else condition to traverse computed Path
* Cached computed path key into a variable
2020-02-12 11:55:38 +01:00
Brian Ng
c37361ba2e
Bump prettier@1.19.1 ( #10728 )
2019-11-16 16:05:40 +01:00
Nicolò Ribaudo
e9c1bce50f
Add support for TS declare modifier on fields ( #10545 )
...
* [parser] Add support for TS declare modifier on fields (#10484 )
* [parser] Add support for TS declare modifier on fields
* Use Object.create(null)
* Comment
* Add support for TS declare types to types and generator (#10544 )
* Transform TypeScript "declare" fields (#10546 )
* Transform TypeScript "declare" fields
* Remove multiple spaces
* declareFields -> allowDeclareFields
* Update after rebase
2019-11-05 10:56:57 +01:00
Tim McClure
3e4889d649
Class Private Static Accessors ( #10217 )
...
* Remove error for static private accessors
* Private static accessors strict
* Add loose mode support
* Move `value` decl for early return
* Reuse getter/setter template
* Reuse getter/setter templates
* Use `buildUndefinedNode` in accessor templates
* Extract `isAccessor` variable
2019-09-06 18:08:10 +02:00
Tan Li Hau
d3fe22f0e1
destructuring private fields with array pattern / object patte… ( #10017 )
...
* destructuring private fields with array pattern / object pattern
* wip: new test cases
* destrucuring and rest for private properties
* test case for loose private-loose
* add transform-desturcturing for exec
* update test case
* remove getPrototypeOf imports from get and set
* wip: destructure super assignment
* throw "Destructuring to a super field is not supported yet."
* fix tests and fix assignment pattern
* remove CallExpression from AssignmentPattern
2019-07-15 01:00:20 +02:00
Min ho Kim
0bf0ae3410
Fix typos ( #10153 )
2019-07-03 15:51:48 +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
Nicolò Ribaudo
87fb6c4a8b
Use injectInitialization to generate ts parameter properties ( #9610 )
2019-05-21 22:28:55 +02:00
Mattias Buelens
3c11a4a930
Fix super method call in private instance method calling overridden method ( #9801 )
...
* Fix super method call in private instance method calling overridden method
* Change return value in test fixtures
* Update tests to verify that overridden method is not called
2019-03-31 18:50:29 -04:00
pnowak
3aaafae053
proper feature call isLoose function #9424
2019-03-24 10:21:44 +01:00
Tim McClure
e068281e28
Fix super Method Calls in Class Private Methods ( #9704 )
...
This fixes an issue with the use of super method calls in class private methods. See https://github.com/babel/babel/issues/9580 for more info re: behavior of the bug.
2019-03-19 18:43:02 +01:00
Tim McClure
81c130ffc9
Private Static Class Methods (Stage 3) ( #9446 )
2019-03-13 00:11:16 +01:00
Nicolò Ribaudo
0b01b5217b
Use correct "this" in static fields ( #9508 )
2019-02-24 08:14:49 +01:00
Nicolò Ribaudo
d37c958637
Transform private async and generator functions ( #9423 )
2019-02-04 15:10:46 +01:00
Tim McClure
e8de6fa5d4
Private Class Methods Stage 3: Private Accessors ( #9101 )
...
* Add accessor loose support
* Add private accessors spec support
* Fix private dupe name check
* Changes from code review
* Add duplicated names tests
* Add get/set-only tests
* Move accessors tests
* Split out updates tests
* Add helper change tests
* Update test output
* Update test options
2019-01-21 22:05:37 +01:00
Nicolò Ribaudo
a24206eb96
Fix error for decorators not enabled ( #9321 )
...
* Fix error for decorators not enabled
* Update error message
2019-01-13 00:35:22 +01:00
Nicolò Ribaudo
8e051cae46
[decorators] Set method names at compile time instead of at runtime ( #9244 )
2019-01-10 00:45:02 +01:00
Nicolò Ribaudo
865eb93c2d
[private methods] Define private methods before executing initializers ( #9248 )
2019-01-03 20:33:44 +01:00
Nicolò Ribaudo
d1d3c823cc
Move decorators transform to @babel/helper-create-class-features-plugin ( #9059 )
...
* Move decorators to @babel/plugin-class-features
* Minor refactoring
* Use the new helper package
2018-12-09 12:30:25 +01:00
Nicolò Ribaudo
b927fb2a7e
Don't use isClassPrivateMethod because is isn't supported in <7.2.0 ( #9121 )
2018-12-04 08:35:10 +01:00