138 Commits

Author SHA1 Message Date
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
Brian Ng
7c4509e280 Retry flow tests in script mode only if it is supposed to succeed 2018-05-02 08:56:54 -05:00
Logan Smyth
acf509bab5
Upgrade Babel to self-host with beta.46 (#7784) 2018-04-27 15:04:37 -07:00
Justin Ridgewell
2afe9404fe
Use Object Spread Syntax (#7777)
* Use Object Spread Syntax

* Nits
2018-04-23 21:44:27 -04:00
Brian Ng
3299086955
Add support for flow implements (#7741) 2018-04-18 08:54:30 -05:00
Brian Ng
840ba187a7
Prevent duplicate regex flags (#7617) 2018-03-22 10:25:26 -05:00
Logan Smyth
6d6fe844fd
Centralize Babel's own compilation config to make it easier to follow. (#7599) 2018-03-19 21:49:17 -07:00
Logan Smyth
353d3199c2
Re-add TEST_ONLY and use Jest's -t for TEST_GREP. (#7556) 2018-03-12 15:12:39 -07:00
Daniel Tschinder
24a07fc790
Use jest workers on travis-ci and circleCI (#7510) 2018-03-08 22:15:54 +01:00
Logan Smyth
828e9a8538
Skip minification of large bundles during CI builds. (#7528) 2018-03-08 12:36:47 -08:00
Brian Ng
f97d4313c9
Update test262 test script and a few keyword escape fixes (#7503)
* Update test262 and whitelist

* Use test262-stream

* Check escapes in contextual keywords

* Check escapes when parsing new.target

* Check escapes for getters/setters

* Check escapes for static class methods

* Check escapes on async arrow and functions
2018-03-08 09:10:00 -06:00
K Sashi Kumar
d187c26748 Spec Violation: Fix var initializer in for-in loop (#7392) 2018-03-04 16:18:32 -08:00
Nicolò Ribaudo
5cd8b5b7f0 Add eslint plugin to disallow t.clone and t.cloneDeep (#7191)
* Add eslint plugin to disallow `t.clone` and `t.cloneDeep`

* Make it better and add flow

* Other cases

* Superpowers

* Fix
2018-03-04 15:47:11 -08:00
Daniel Tschinder
3e95830646
Migrate to jest (#7455) 2018-03-03 10:58:19 +01:00
Daniel Tschinder
007f8d19b3 Remove unused dependencies (#7454)
Replace util.promisify with node internal version
2018-02-28 10:59:28 -05:00
Raja Sekar
6aed8e944f updated node debugger usage command in test (#7376) [skip ci] 2018-02-13 11:17:19 -05:00
Nicolò Ribaudo
f19d559ff3
Compile Babylon with Gulp (#7240) 2018-01-30 23:13:40 +01:00
Brian Ng
fa5eb4f605 Make comment props more consistent (#7246) 2018-01-26 10:39:52 -05:00
Boris Cherny
c3654d83c8 Generate TypeScript typings, and improve generated Flow typings (#7101)
* generate typescript types

* improve type generator output

* move generator scripts to scripts/generators

* use new stringifier for generating flow types too

* export summary types

* add support for oneOfNodeOrValueTypes to improve type generation

* export typescript types from top level, and remove module declaration

* generate typescript/flow types and copy typescript types to babel-types/lib as part of make build

* copy flow types to babel-types/lib as part of make build (fix #6839)

* improve typing: Identifier->name should be a string, not any

* avoid destructuring, to support node 4

* update doc generator to share more code, regenerate babel-types readme, pipe all generator output to stdout

* regenerate babel-types readme as part of make build

* improve typing: ClassProperty->key should be Identifier | StringLiteral | NumericLiteral | Expression, not any

* improve typing: optional node properties are nullable, not undefinedable

* improve docs: FlowClassImplements should be ClassImplements

* make ts usage more friendly: when using babel-types api, make optional params | undefined, and when reading nodes keep optional params | null

* rm lib/types.d.ts and lib/types.js in favor of packages/babel-types/lib

* add missing variance node type, address review comments

* add tests for flow variance

* Comment should be a disjoint union of tagged types

* update .flowconfig
2018-01-17 10:31:46 -05:00
Peri Nikhil
c3352ad2e0 Fix: unicode characters not allowed in regexes (#7179)
Issue #6691
2018-01-10 15:33:21 +01:00
Raja Sekar
f3410e761c Flow comment parsing (#7007) 2017-12-30 23:53:08 +01:00
Brian Ng
2b065350b5 Treat import type * as a parser error (#7061) 2017-12-19 10:54:20 -05:00
Brian Ng
f5ef928586
Add method property to ObjectTypeProperty (#7005) 2017-12-11 09:32:16 -06:00
Brian Ng
c7980b2b90 Bump prettier (#6991) 2017-12-07 17:36:49 -05:00
K Sashi Kumar
ac745ded0d Fix destructuring assignment spec violation (#6986) 2017-12-07 09:14:03 -06:00
Brian Ng
d8bbaaae0a Split exportExtensions into exportDefault and exportNamespace plugins… (#6920)
* Split exportExtensions into two plugins in babylon
* rename proposal-export-default to proposal-export-default-from
* rename proposal-export-namespace to proposal-export-namespace-from
2017-11-30 17:46:36 -05:00
Henry Zhu
70361f1200 Remove the experimental folder 2017-11-21 20:03:16 -05:00
Brian Ng
0f2ab2fe20
Fix some reserved type handling and declare class with multiple extends (#6725) 2017-11-15 16:16:15 -06:00
Artem Yavorsky
262d7518bd Move babel-preset-env-standalone to the monorepo. (#6438) 2017-11-15 09:50:36 -06:00
Daniel Tschinder
3b540e3f5a
Integrate babylon into babel workflow 2017-11-01 23:26:51 +01:00
Henry Zhu
bede73122d
fixup places that aren not scoped [skip ci] (#6646) 2017-10-30 16:47:13 -04:00
Logan Smyth
191624d800 Add a new utility for traversing the AST. 2017-10-18 13:55:14 -07:00
Logan Smyth
cc22ea04bb Add type declaration for t.validate. 2017-10-18 13:55:13 -07:00
Logan Smyth
ad05c9935e Generate types with %checks annotations. 2017-10-18 13:55:13 -07:00
Logan Smyth
e6beb7cb61 Regenerate flow types and add more types. 2017-10-18 13:55:13 -07:00
Henry Zhu
ef467a3887 move eslint_rules to scripts/eslint_rules [skip ci] 2017-10-07 08:54:54 -04:00
Henry Zhu
35646f15a4 reomve unused packages, unused file 2017-10-07 08:51:38 -04:00
Brian Ng
38355d9230
Tweak babel-preset-env for monorepo 2017-10-05 17:35:16 -05:00
Brian Ng
c821d3a591 Updates for handling codemods folder (#6279)
* add codemod folder to gitignore, update build/test scripts to handle codemods, lerna config
2017-09-26 10:38:18 -04:00
Nicolò Ribaudo
4e7961dcf8 Use /bin/bash instead of /bin/sh in scripts
`/bin/sh` isn't always an alias of `/bin/bash`, so bash-specific syntax broke the scripts.
(like 777a9ae6e4/scripts/_get-test-directories.sh (L7))
2017-09-07 17:19:40 -07:00
Daniel Tschinder
44f6ff5e85 Update prettier, eslint + plugins, flow, husky and lint-staged (#6183) 2017-08-31 22:56:29 +02:00
Daniel Lo Nigro
a04c18af71 Move babel-standalone into main Babel repo (#6029)
* Move babel-standalone into main Babel repo

* Don't try to gather coverage data for babel-standalone test

* Fix JSX test

* Always use npm v4 on Travis

* Include pull request number as part of version number

* Cherry-picking 5721b2e43e

Remove deprecated packages to prevent Babel v6 files from being pulled in

* Use RootMostResolvePlugin to dedupe packages

* Avoid destructuring so the build works on archaic Node.js versions

* - Fix version number
- Remove Babili packages (they should be in separate babili-standalone)
- Remove deprecated  syntax-class-constructor-call

* - Remove more Babili packages
- Remove `babel-plugin-inline-replace-variables` for now as it pulls in Babel 6 stuff

* Actually remove reference to babel-plugin-undeclared-variables-check

* Add Babylon to root package.json so we hoist the right version. This fixes the tests.
2017-08-11 23:36:19 -07:00
Karl Cheng
3a55e1326c Allow substrings for TEST_ONLY in make (#6079)
This allows TEST_ONLY to match substrings of the package directory name
instead of having to use the full package directory name.
2017-08-10 10:55:46 -04:00