499 Commits

Author SHA1 Message Date
Nicolò Ribaudo
35f4d12763 v7.7.2 2019-11-07 02:20:52 +03:00
Leonid Shevtsov
2cd5ad0c80 fix typo: identifer -> identifier (#10647) 2019-11-06 09:13:08 +01:00
Nicolò Ribaudo
42c8e0fb2f v7.7.1 2019-11-05 14:44:00 +01:00
Nicolò Ribaudo
bf48fca6a0
Revert "throw a TypeError if identifier validation fails (#106… (#10650)
This reverts commit c7d8b8a37752f42163128cf4d5e8b54c2637cec4.
2019-11-05 14:43:23 +01: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
Martin Forsgren
c7d8b8a377 throw a TypeError if identifier validation fails (#10621)
* throw a TypeError if Identifier validation fails

* Relax identifier validation, reserved words are ok
2019-11-02 12:04:16 +01:00
George Zahariev
ec3345bb57 Flow enums parsing (#10344)
* Flow enums parsing

* Parse exporting enums

* Enums parsing remove lookahead, other improvements

* Enums: add EnumBody and EnumMember aliases, change boolean members to use BooleaLiteral value

* Fix enum member init flow type, now that boolean members have a BooleanLiteral value

* Flow enums: use contextual utils, change members length checks to use logic operators, remove reserved word logic modification

* Flow enums: remove unnecessary code in generator, fix error message
2019-10-29 22:55:12 +01:00
Georgii Dolzhykov
63f9a3c946 rename assertsModifier to asserts (#10613)
see https://github.com/babel/babel/pull/10543#issuecomment-547571501
2019-10-29 16:25:42 -04:00
Tan Li Hau
38a3063111 add assertions signature for TypeScript (#10543)
* add asserts predicate

* fix flow

* babel-generator for typescript assertions

* babel-types for typescript assertions

* asserts modifier as boolean
2019-10-29 18:51:33 +01:00
Nicolò Ribaudo
d329156ebc
v7.6.3 2019-10-08 21:31:40 +02:00
Jessica Franco
bc0966a46f Add declarations for more of @babel/types exports (#10504)
This adds lots of missing declarations to the types of @babel/types,
including many utility functions useful to plugin authors.

With the typescript types, I tried to make them as useful as possible
for control flow analysis / inference, but Flow doesn't seem to
support overloads and I'm not as familiar with it anyway so it has
simpler types.
2019-10-08 19:07:57 +02:00
Michael J. Currie
66062c2a8c Template literal validation (#10492)
* add template literal validation

* avoid null/undefined error when validating

* simplify validation logic and fix tests

Co-authored-by: Michael J. Currie <michaeljcurrie136@gmail.com>
2019-09-26 19:58:36 +02:00
Huáng Jùnliàng
26be14b24d chore: add access: public where missing (#10489) [skip ci]
* @babel/types
* @babel/plugin-transform-named-capturing-groups-regex
2019-09-24 14:04:54 +02:00
Nicolò Ribaudo
381b066bd0
v7.6.1 2019-09-06 22:50:54 +02:00
Matt Forster
15b63bc89e
fix(types): correct typescript function headers (#10404)
Flow maybe types state;

> Maybe types accept the provided type as well as null or undefined. So ?number would mean number, null, or undefined.

So in this case, explicitly allow the type, null, or undefined in the
typescript definition.

Fixes #10403
2019-09-06 22:38:21 +02:00
Nicolò Ribaudo
cbd5a26e57
v7.6.0 2019-09-06 19:25:16 +02:00
Huáng Jùnliàng
da0af5fd99 V8intrinsic syntax plugin (#10148)
* feat: v8intrinsic syntax plugin

Implement V8 Intrinsic Syntax Extension. Here we check the execution branch inside the parseSubscript to make sure the V8IntrinsicIdentifier is immediately followed by a call expression.

* feat: disable combining placeholders and v8intrisic

per https://github.com/babel/babel/issues/10104#issuecomment-506950969

* test: add more error cases

* refactor: parse v8 intrinsic in parseExprAtom

This approach is identical to V8’s implementation. Move the test cases as the behaviour changes.

* fix: plugin-name typo

* test: add yield-expression test case

* feat: require startsExpr on modulo for v8intrinsic

* perf: skip eof and braceR check as they must return false

* Print V8IntrinsicIdentifier

* feat: add v8intrinsic to parser typings

* Add generated type helpers

* fix: incorrect type definition

* fix: allow V8IntrinsicIdentifier to be callee
2019-09-06 17:43:19 +02:00
Tan Li Hau
a08e856804 fix typescript for babel-types (#10098)
* fix typescript for babel-types

* fix missing typescript/flow types for babel-types

* Add cloneNode to flow.js

* Add cloneNode to typescript.js
2019-09-04 15:35:19 +02:00
Justin Ridgewell
1664cce681
Don't allow JSXNamespacedName to chain (#10366)
Eg, `namespace:foo.bar` used to parse but is invalid in the [spec](https://facebook.github.io/jsx/).

Also, allow `JSXNamespacedName` in the `JSXOpeningElement`/`JSXClosingElement` builders.
2019-08-26 13:16:22 -04:00
Nicolò Ribaudo
a2bf68981f Add TSBigIntKeyword to @babel/types (#10341) 2019-08-20 17:31:45 -05:00
Even Alander
eb3767d58b Add a builder definition including name for tsTypeParameter (#10319) 2019-08-15 19:59:08 +02:00
Nicolò Ribaudo
f0c2364d01
Do not delete "fake" source map comments from strings (#9960)
Instead of using `convert-source-map`'s `removeComments` method before
parsing the file, we can first parse the file with `@babel/parser` and then
analyze the comments.
This is needed because it is not possible to reliabily detect comments in
JavaScript without fully parsing the file:
https://github.com/thlorenz/convert-source-map/issues/63
2019-08-14 17:05:55 +02:00
Huáng Jùnliàng
22df2ae244 Commit generated code (#10331)
* update prettier generated artifacts

* chore: sync babel-helpers to artifacts
2019-08-13 16:31:28 +02:00
Daniel Tschinder
4f0840ab88
Update dev dependencies and fix linting errors (#10228)
* chore: Uppate dev dependencies

* chore: Fix lint errors

* chore: Format options.json files

* chore: Fix stupid flow errors

* Update test262 whitelist

Seems test262-stream was updated and now these tests work.
2019-07-27 15:09:30 +02:00
Yuri Karadzhov
4506590557 Add static parameter to class property builder (#10248) 2019-07-25 09:55:03 +02:00
Nicolò Ribaudo
0407f034f0
v7.5.5 2019-07-17 23:08:08 +02:00
Tan Li Hau
ee68d6d1b0 add assertShape to validate templateElement (#10198)
* add assertShape to validate templateElement

* Update packages/babel-types/src/definitions/utils.js

Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* templateElement optional cooked
2019-07-15 01:03:50 +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
cybai
42000b9907 Upgrade lodash to 4.17.13 (#10191) 2019-07-12 10:29:06 +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
Bogdan Savluk
b8bb93a838 fix exportKind declaration in babel-types (#10126)
* fix exportKind types declaration for ExportNamedDeclaration and DeclareExportAllDeclaration in babel-types

* revert `let` in exportKind in babel-parser types
2019-06-25 22:29:38 +02:00
Nicolò Ribaudo
2c88694388
v7.4.4 2019-04-26 23:00:07 +02:00
Corey Farrell
8ca99b9f09 Fix: PrivateName Identifier should not be isReferenced. (#9861) 2019-04-15 22:05:16 -05:00
E. van der Valk
165ef29416 Fix typo in cloneNode. (#9832) 2019-04-08 08:59:57 -04:00
Nicolò Ribaudo
f1328fb913
v7.4.0 2019-03-19 21:27:16 +01:00
Pelle Nielsen
a35e5a314a Fix TSFunctionType visitors definition (#9692)
When traversing a tree parsing for TypeScript syntax and hitting a `TSFunctionType` node, the `typeParameters` and `typeAnnotation` fields are correctly visited but the `parameters` field isn't. As a result visitors by default don't visit `foo` below:

```
var x: (foo) => void; // foo is never visited
```
```
module.exports = function() {
  return {
    visitor: {
      Identifier(path) {
        if (path.node.name == "foo") {
          // Never hit because it's nested within TSFunctionType.parameters
          path.node.name = "bar";
        }
      }
    }
  };
}
```

It appears to be a bug in babel-types/src/definitions/typescript.js which omits `parameters` in the visitors list for `fnOrCtr`. Fixed by adding it.
2019-03-16 09:24:23 +01:00
Nicolò Ribaudo
15dfce33df
Add placeholders support to @babel/types and @babel/generator (#9542) 2019-03-07 11:47:39 +01:00
Daniel Tschinder
fb81e8f8b4
Make babel-standalone an ESModule and enable flow (#9025)
* Make babel-standalone an ESModule and enable flow

* autogenerate plugin list

* Make config an array
2019-03-06 14:30:43 -08:00
Erik Arvidsson
fba5655a44 Parenthesized expressions (#8025)
* Add parser createParenthesizedExpressions option  …

When set to `true` we create `ParenthesizedExpression` nodes instead of
setting `extra.parenthesized`.

* Also update babel-parser.d.ts
2019-03-06 22:43:36 +01:00
Behrang Yarahmadi
c60c4dd375
Partial Application Syntax: Stage 1 (#9343)
* add partial application syntax and some tests

* remove unnecessary error message and hasPartial function from parseNewArguments

* add types for PartialExpression

* Update the tests

* rename PartialExpression to Partial

* move Partial from expressions to types and rename to ArgumentPlaceholder

* add tests for ArgumentPlaceholder in babel-generator

* rename Partial to ArgumentPlaceholder

* update the tests

* remove alias from the type and undo changes in generated folder

* adds a nice error message

* better definition for the type

* auto-generated files

* update the conditional for allowPlaceholder message and tests

* update CallExpression definition to accept ArgumentPlaceholder

* change description

* clean up

* indent ArgumentPlaceholder entry and revert unwanted changes
2019-03-05 00:34:02 +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
5c8cc0d536
Mark FOO in "var { x: FOO }˝ as a binding, not as a reference (#9492) 2019-02-27 00:17:11 +01:00
Nicolò Ribaudo
0345c1bc1d
Use for..of Object.keys instead of for..in (#9518)
In https://github.com/babel/babel/issues/9511 (and #9495 is another symptom), @PavelKastornyy reported a node crash becaue the JavaScript heap run out of memory. The problem was that their code was adding enumerable properties to `Object.prototype`: it is something that shouldn't be done, but Babel shouldn't make node crash if someone adds them.
I reduced down the problem to `for...in` loops in `@babel/traverse` that grew the memory consumption exponentially because of that unexpected properties.
2019-02-26 20:09:02 +01:00
Nicolò Ribaudo
1f6454cc90
v7.3.4 2019-02-25 19:29:12 +01:00
Justin Ridgewell
fc1ea7f496 Revert "Parenthesized expressions (#8025)"
This reverts commit dd8b700a2c4c975584c7b2ea43023aa275c16167.
2019-02-25 19:03:00 +01:00
Erik Arvidsson
dd8b700a2c Parenthesized expressions (#8025)
* Add parser createParenthesizedExpressions option  …

When set to `true` we create `ParenthesizedExpression` nodes instead of
setting `extra.parenthesized`.

* Also update babel-parser.d.ts
2019-02-23 02:45:25 -05:00
Ian Craig
417e72ebfd Fix flow and TS types of babel-types is* type checks to accept null | undefined (#9539)
* babel-types is* type checks accept null | undefiend as value TS type

* Use | null | undefined instead of any, make Flow type nullable

* Also change flow types of generated src
2019-02-22 01:48:27 -08:00
Nicolò Ribaudo
d1fe2d05f4 v7.3.3 2019-02-15 22:06:01 +01:00