44 Commits

Author SHA1 Message Date
骗你是小猫咪
e15a5c7509
Fix innercomments (#11697) 2020-06-12 20:22:47 -05:00
Nicolò Ribaudo
d21e2217d5
Skip newlines around inline #__PURE__ annotations (#11133)
* Skip newlines around #__PURE__ annotations

* Update tests
2020-02-13 19:16:33 +01:00
Huáng Jùnliàng
fa5057f9fb Flow: interface identifier should be declared in the scope (#10220)
* fix: typo

* declare name for flow interface

* add test case for export overload function, typescript

* test: add test

Fixes #10044

* test: update test

* test(flow): add multiple declarations regression test

* re-enable flow test case

# Conflicts:
#	packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js
#	packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-declare-statements/input.js
#	packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-interfaces-module-and-script/input.js
#	packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-iterator/input.js

* test: disable two flow dupl-decl test

* fix: do not declare name for declare function until we figure out a better way

* test: duplicate declare function and function would not throw
2019-10-02 07:32:42 +02:00
Ziad El Khoury Hanna
64041e1669 Fix flow comments plugin issues (#10329)
* Fix issues in flow-comments to preserve comments and there order (fixes #10324)

* Add support in flow-comments for extends in class declarations (fixes #10323, #10321)

* Refactoring and cleanup of flow-comments plugin

* Fix comments preservation logic of flow-comments

* Fix flow-comments where comments are class identifier and extends keyword
2019-08-14 15:46:26 +02:00
Tan Li Hau
8b9af1be2f fix transform-flow-comments for import types (#9901)
* fix transform-flow-comments for import types

* update: dependencies
2019-07-13 16:06:42 +02:00
Tan Li Hau
ca3c53ae0b fix flow-comments - class type paramters and implements (#9897) 2019-04-26 22:23:13 +02:00
Tan Li Hau
71013088ef fix flow-comment - object destructuring (#9893) 2019-04-26 22:22:41 +02: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
Logan Smyth
79b2af5997
Format fixture JSON with Prettier. (#8658) 2018-09-09 17:57:52 -07:00
Henry Zhu
10910a10f5
Remove yearly presets from repo, inline in standalone (#8274)
These were already deprecated in v6, just didn't remove the folders?
2018-07-09 14:23:25 -04:00
Markus Török
6597a472b3 Add "use strict" directive (#7411)
* #7349
- Add "use strict" directive to transformed class bodies

* Update tests (#7349)

* Add test for program with use strict directive (#7349)

* Update tests (#7349)

* Update source mapping (#7349)

* Add test for parent blockStatement with use strict directive (#7349)

* Update tests (#7349)

* Update tests (#7349)

* Update tests (#7349)

* Add test for constructor-only class (#7349)

* Constructor only classes are strict, too

But constructor only that use non-simple parameters must use a strict function wrapper.

* Fix test

* Wrapper not needed if class is already strict

* Revert change to lerna.json
2018-04-10 17:33:38 -04:00
Logan Smyth
7cc00cce0d Require output fixture extension to match sourceType output. 2018-03-04 13:31:33 -08:00
Logan Smyth
beb99dfda1 Rename test fixtures using module syntax to .mjs files. 2018-03-04 13:31:32 -08:00
Nicolò Ribaudo
8659e1a88c Remove old expected.{js,json} files (#7187) 2018-01-09 13:10:30 -06:00
Raja Sekar
0f42accb87 Renamed files 2018-01-09 15:36:42 +01:00
Henry Zhu
9ac326b075
remove es20xx prefixes from plugins and rename folders (#6575) 2017-10-28 20:43:15 -04:00
Henry Zhu
c41abd79a1
Rename all proposal plugins to -proposal- from -transform- (#6570) 2017-10-27 15:26:38 -04:00
Henry Zhu
691f90a774 Scoped: change test imports to @babel/ [skip ci] 2017-10-16 22:49:56 -04:00
Logan Smyth
2b88e079ef Only transform this/use strict if a module. 2017-09-20 10:19:35 -07:00
Mateusz Burzyński
c47258d68c Annotating transformed classes with #__PURE__ comment (#6209) 2017-09-11 11:18:37 -04:00
Oliver Don
960151c876 Fix #4840: Alias class prototype for methods in loose mode (#5560)
* Fix #4840: Alias class prototype for methods in loose mode

* Cleanup
2017-08-26 21:15:45 -04:00
Noah Lemen
4fdd75695b Update Class Fields to Stage 3 and change default behavior (#6076)
* add transform-class-properties to stage 3, set spec mode to default

* update readme with examples; use `buildUndefinedNode()`; change behavior to always define both static and nonstatic class properties regardless of spec/loose mode; update tests
2017-08-10 11:19:49 -04:00
jbrown215
4e9a25e34a Flow opaque type aliases (#5990) 2017-08-02 16:30:19 -05:00
Henry Zhu
0f823beeb1 Newlines in fixtures (#6044)
* write newlines for fixtures

* rerun fixtures
2017-08-02 15:35:29 -04:00
Justin Ridgewell
78544417fc Remove noop (#5970)
It’s ugly, but it gets the job done. And it unblocks my babel-type
changes.
2017-07-20 11:36:13 -04:00
Daniel Tschinder
b3372a572d Remove whitespace generation (#5833)
* Remove whitespace generation and rely on default printing

Changes to printing:
* Add newline after last empty SwitchCase
* Add newlines around block comments if they are non-flow comments or contain newlines

* Fix a few more fixtures
2017-06-27 21:57:02 -05:00
Henry Zhu
cdca54aed3 remove possibleConstructorReturn in loose mode as well 2017-06-09 18:42:52 -04:00
Henry Zhu
123dce5fcd Hardcode to double quotes, indent to 2 spaces (#5824) 2017-06-05 22:14:37 -05:00
James Lal
6928695735 Flow comments import export (#5675)
* Add failing test for `export type .. from ...; `

* Add support for flow comment : `export ... from '...'`
2017-05-20 09:10:39 -04:00
Chau Nguyen
d710e6dd5b [7.0] Drop flowUsesCommas option from babel-generator (#5123) 2017-01-19 22:24:13 -05:00
Sergey Rubanov
292c3ca206 Refactor test packages to use ES modules instead of CJS (#5138) 2017-01-16 11:25:04 -05:00
Dan Harper
d90aaf2c76 Print Flow optional & type annotations in function params with defaults (#4872)
Fixes #4863
2016-12-16 15:31:05 -05:00
Dan Harper
9e17aaf043 retain return types on ObjectMethods in transform-es2015-shorthand-properties (#4670) 2016-10-04 21:32:43 -04:00
Dan Harper
7f772e94ce retain method return types on transform-es2015-classes (closes #4665) (#4668) 2016-10-04 18:22:29 -04:00
Dan Harper
0e02a18216 fix regression in transform-flow-comments for class properties (#4623) 2016-10-01 00:56:09 -04:00
Dan Harper
8709899b42 fix flow-strip-types/flow-comments removing entire ClassProperty (#4587) 2016-09-28 18:25:33 +02:00
Dan Harper
41f2bbc104 Flow: Fix generating arrow functions with param (#4504)
* transform-flow-comments, single arrow param support #4503

* further tests for printing single arrow func param flow code

* cleanup
2016-09-12 08:27:49 -04:00
Sam Goldman
a38a58bad8 Add support for Flow def-site variance syntax
This syntax allows you to specify whether a type variable can appear in
a covariant or contravariant position, and is super useful for, say,
Promise.

Right now this is hacked in jankily, but in the next major release we
should stop using Identifier nodes for type parameters.
2016-03-06 14:44:09 -08:00
Jeff Morrison
e6951e99f0 Add support for leading pipes in Flow type alias RHS syntax 2016-02-05 13:23:55 -05:00
Sam Goldman
17d19a0056 Add export interface Flow syntax support
An interface export is just like a type export. In fact, it's a syntax affordance which makes the following equivalent:

```javascript
interface I_ { ... }
export type I = I_;
```

```javascript
export interface I { ... }
```

See facebook/flow#1145
2016-01-05 15:57:45 -08:00
Sam Goldman
26c97c4069 Add support for "declare interface" Flow syntax
This has been a feature in Flow for a long time (couldn't easily find a
specific commit adding this). Interfaces are basically undocumented, though, so
it's easy to see how this was missed.
2016-01-04 11:50:12 -08:00
Sam Goldman
e764346d5f Add support for "declare type" Flow syntax
See facebook/flow#1105
2016-01-04 11:42:43 -08:00
Sam Goldman
ef60fed7d6 Add test ensuring declare statements are transformed to comments 2015-12-23 16:49:18 -05:00
Henry Zhu
33ce926c7f rename flow-comments plugin 2015-12-15 20:14:47 -05:00