155 Commits

Author SHA1 Message Date
Justin Ridgewell
070ec201bb
Speed up the createSuper helper (#11401) 2020-04-10 16:00:20 +02:00
Nicolò Ribaudo
67609a1232
Don't call createSuper in loose mode (it was unused) (#11358)
* Don't call `createSuper` in loose mode (it was unused)

* Update fixtures
2020-04-01 23:08:21 +02:00
Nicolò Ribaudo
d3cf5fb5f4 v7.9.4 2020-03-24 09:26:12 +01:00
Vlad Rindevich
2f549886e4
[preset-typescript] Fix private members type annotations (#11315) 2020-03-23 19:33:16 +01:00
Kai Cataldo
7ca814489a
fix: parse value imports named type as values (#11296)
* fix: parse value imports named type as values

* Address feedback

* Add plugin tests

* Add isContextual() check

* Remove importKind: value from extraneous nodes

* Ensure importKind is correct for more nodes

* Add additional test

* Address feedback

* Revert formatting

* Fix tests
2020-03-21 01:38:07 +01:00
Nicolò Ribaudo
8d5e422be2 v7.9.0 2020-03-20 16:32:55 +01:00
Nicolò Ribaudo
f6c7bf36ce
Allow extending untranspiled classes (#8656) 2020-03-16 23:59:15 +01:00
Nicolò Ribaudo
740260b236
Add import type and export type support to TypeScript (#11171)
* Add support for type only imports in TS (#11053)
* Implement "export type {}" (#11122)
* Add "exportKind: type" when needed with TS (#11157)
* Add `onlyRemoveTypeImports` option to `transform-typescript` (#11173)
* Add onlyRemoveTypeImports to preset-typescript (#11179)

Co-authored-by: Brian Ng <bng412@gmail.com>
Co-authored-by: Raja Sekar <rajasekarm.dev@gmail.com>
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Kai Cataldo <kai@kaicataldo.com>
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
Co-authored-by: Henry Zhu <smiley.we@gmail.com>
Co-authored-by: Siddhant N Trivedi <sidntrivedi012@gmail.com>
2020-03-16 22:58:51 +01:00
Nicolò Ribaudo
595f65f33b v7.8.7 2020-03-05 02:52:13 +01:00
James C. Davis
a5f63299eb
TypeScript: Preserve decorated definite class properties (#11129)
* test: update fixture with decorated definite class property

* fix: don't remove decorated definite class properties
2020-02-27 21:31:23 +01: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
Nicolò Ribaudo
a7620bd266 v7.8.3 2020-01-13 22:36:19 +01:00
Nicolò Ribaudo
8fce431d88
Revert "chore: specify package type (#10849)" (#11003)
This reverts commit e8dac621de9dba27b47646169562c0a0c2e02c96.

Fixes installs when using npm <= 3.9.5 (Node.js <= 6.2.2)
2020-01-13 21:18:42 +01:00
Nicolò Ribaudo
2486615a74 v7.8.0 2020-01-12 01:09:29 +01:00
Huáng Jùnliàng
e8dac621de
chore: specify package type (#10849) 2020-01-09 21:40:15 -05:00
Nicolò Ribaudo
75767d87cb v7.7.4 2019-11-23 00:05:58 +01:00
Kai Cataldo
a6d134804a Unify build step for ESLint packages (#10723) 2019-11-16 10:15:15 +01:00
Nicolò Ribaudo
35f4d12763 v7.7.2 2019-11-07 02:20:52 +03:00
Huáng Jùnliàng
2640e5a27c fix: remove accessibility of constructor (#10658) 2019-11-05 13:52:57 -06:00
Nicolò Ribaudo
97faa83953 v7.7.0 2019-11-05 11:27:14 +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
Nicolò Ribaudo
abce0ef49d [TS] Correctly transform computed strings and templates in enums (#10555)
* [TS] Correctly transform computed strings and templates in enums

* Typo [skip ci]
2019-11-04 13:22:49 -05:00
Chris Garrett
5c0d8a9de7 add legacy decorators support to strict class fields (#10616)
This PR allows legacy decorators to work with strict class fields, which
are now stage 3 and have shipped in a number of browsers. Allowing this will
allow users of the legacy transform (which is currently recommended by the
champions of the decorator proposal) to use the proper class field semantics
for non-decorated fields, which should help prevent breakage later on.

This change is not a breaking change, since users had to explicitly opt into
loose mode in class fields before. This just gives them the option to remove
that opt-in.
2019-11-04 13:05:42 -05:00
Nicolò Ribaudo
d329156ebc
v7.6.3 2019-10-08 21:31:40 +02: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
Nicolò Ribaudo
cbd5a26e57
v7.6.0 2019-09-06 19:25:16 +02:00
Nicolò Ribaudo
a2bf68981f Add TSBigIntKeyword to @babel/types (#10341) 2019-08-20 17:31:45 -05:00
Nicolò Ribaudo
0407f034f0
v7.5.5 2019-07-17 23:08:08 +02:00
Daniel Tschinder
d8da63c929 Use correct extension for typescript fixtures (#10014)
* Use correct extension for typescript fixtures

* Change transform fixtures

* Adjust editorconfig for ts files

* Rename new tests

Co-authored-by: Nicolò Ribaudo (nicolo.ribaudo@gmail.com)
2019-07-15 22:46:03 +02: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
d0519fa907
v7.5.1 2019-07-06 10:07:59 +02:00
Wesley Wolfe
bff79e198a Retain typescript export-from-source (#10167) 2019-07-05 20:47:55 +02:00
Nicolò Ribaudo
49da9a07c8
v7.5.0 2019-07-04 14:52:17 +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
Mateusz Burzyński
84961ebb05 Refactor isImportTypeOnly helper function (#10047) 2019-05-31 23:54:44 +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:

2080042808b18b005fb54aeaf9ab708f64cb1005 #9944

a6392bd636d07c41579ea5ab443152a09943e096 #10019
2019-05-29 08:36:04 +02:00
Airat Aminev
a6392bd636 fix(typescript): erase default export if exporting a TS type (#10019) 2019-05-23 16:58:24 -05:00
Nicolò Ribaudo
87fb6c4a8b
Use injectInitialization to generate ts parameter properties (#9610) 2019-05-21 22:28:55 +02:00
Nicolò Ribaudo
33ab4f1661
v7.4.5 2019-05-21 19:38:26 +02: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
Nicolò Ribaudo
2c88694388
v7.4.4 2019-04-26 23:00:07 +02:00
Samy Pessé
66be4aa5e3 Prevent JSX pragma detection in transform-typescript from leaking between files (#9798)
This PR fixes a bug in support of JSX pragma in Typescript (introduced in https://github.com/babel/babel/pull/9095).

We've noticed this bug while building a large codebase with webpack+babel+typescript. Some files from our projects are using `/** @jsx h*/` to use a custom function for JSX syntax; and some others are using the React syntax.

We've noticed that our react imports were being removed by babel because the plugin instance was being reused by `babel-loader` and webpack; and it was causing an error :

```
ReferenceError: React is not defined
```

This PR resets the `jsxPragma` being used to the initial value for each new file being processed.

I can't add a unit test for this bug because it requires processing 2 files (one with `/** @jsx something */` then one with the react syntax).

I've tested a build of this PR and it correctly fixes the issue for us.
2019-04-15 22:46:19 +02:00
Nicolò Ribaudo
f1328fb913
v7.4.0 2019-03-19 21:27:16 +01:00
Denis Pushkarev
3303b079c5 Update to core-js@3 (#7646)
### `@babel/runtime`
- Added `@babel/runtime-corejs3` package and `corejs: 3` options to `@babel/plugin-transform-runtime`.
- Added support of instance methods, fixes #8928.
- Added flag `proposals` (in `corejs: { version: 3, proposals: true }` format) for support all proposals polyfills from `core-js`.
- Used separate directories in runtime for `core-js` entry points with proposals and without.
- Used `get-iterator-method` helper for getting iterators, fixes #2500.
- As a cheap bonus, added support of IE8- (except some cases of `regenerator`).

### `@babel/polyfill`
- Should be deprecated in favor of separate usage required features from `core-js` and `regenerator-runtime` with an informative message.

### `@babel/preset-env`
- Uses for built-ins data from [`core-js-compat`](https://github.com/zloirock/core-js/tree/master/packages/core-js-compat) instead of `compat-table` since information from `compat-table` [is not enough](https://github.com/zloirock/core-js/tree/master/packages/core-js-compat).
- `useBuilIns` now requires direct setting of `corejs` version option, without it will be used `2` by default and shown deprecation warning.
- Added support of minor `core-js` versions for simplify updating in the future.
- For preventing some order-related problems, polyfills in the both `core-js@3` plugins added on `post` stage in the order of `core-js-compat` data.
- Divided plugins and polyfills parts of `preset-env`, instead of 2 internal plugins for adding polyfills, we have 6: usage and entry versions of plugins for `core-js@2`, ### Current state:
`core-js@3`, `regenerator-runtime`.
- Added support `samsung` target (for Samsung Internet) since `core-js-compat` and `compat-table` now contains mapping for this, fixes #6602.

#### `useBuilIns: entry` with `corejs: 3`
- No longer transforms `@babel/polyfill`.
- Transforms **all possible** `core-js` entry points to import of related modules (based on data from [`core-js-compat`](https://unpkg.com/core-js-compat@3.0.0-beta.15/entries.json)).
- Since of this, we no longer need `shippedProposals` / `proposals` flags with `useBuilIns: entry`.
- Removes `regenerator-runtime/runtime` import where it's not required.

#### `useBuilIns: usage` with `corejs: 3`
- In addition to `shippedProposals`, added flag `proposals`  (in `corejs: { version: 3, proposals: true }` format) for polyfill all proposals from `core-js`.
- Fixed list of dependencies in built-in definitions.
- Improved the way of determination method / built-in name and source of this method.
- Adds import of required polyfills on `MemberExpression`, `ObjectPattern`, `in` operator.
- Adds import of required polyfills on access to global object properties.
- Adds import of all required common iterators on all syntax features which use iterators protocol (`for-of`, destructuring, spread, `yield` delegation, etc.).
- Adds import of promises on syntax features which use promises (async functions/generators, dynamic import, etc.), fixes #9250, #7402, etc.

### `core-js@2` stuff
I didn't want to tough `core-js@2`-related stuff, however
- Fixed some serious errors in definitions which breaks `Object.getOwnPropertySymbols`, `Symbol.toStringTag` logic, `Promise#finally`, `Array#forEach`, etc.
- `Array#flatMap` and trim methods moved to stable features as a part of ES2019 and loaded by deprecated `@babel/polyfill` and `@babel/preset-env` with `corejs: 2` option.
2019-03-19 21:07:45 +01:00
Andrew Goldis
efd2ca9040 Move abstract removal ClassDeclaration > Class. (#9693)
Usage of "@babel/plugin-proposal-decorators" with legacy
support causes "abstract" keyword to be preserved.
This fixes it by moving "abstract" node property removal
from "ClassDeclaration" visitor to "Class". Resolves #8172
2019-03-17 20:44:50 +01:00
Matt Tingen
e53be4b387 [TS] Allow context type annotation on getters/setters (#9641)
* Allow context type annotation on getters/setters

* Extract getAccessorsExpectedParamCount
2019-03-06 22:54:42 +01:00
Evan Henley
d72f3aa758 [plugin-transform-typescript] Strip type imports used in Enums and object types (#9605)
* fix: strip type imports used in Enums and object types

* chore: update failing snapshot

* docs: correct TSPropertySignature comment

* fix: enum value should be considered a reference

* chore: add tests for TSPropertySignature and TSEnumMember
2019-02-28 22:03:12 +01:00
Nicolò Ribaudo
d896ce2b53 v7.3.2 2019-02-04 23:20:05 +01:00
Nicolò Ribaudo
4c4c22a316 Run prettier 2019-01-30 11:30:31 +01:00