362 Commits

Author SHA1 Message Date
Federico Ciardi
8e9143f06f
fix(ts): parse multiline declarations correctly (#12776)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-02-16 23:51:24 +01:00
Sosuke Suzuki
c22e72eb24
Raise recoverable error for type members with invalid modifiers (#12785) 2021-02-12 17:20:06 +01:00
Nicolò Ribaudo
c07185207c
[parser] Fix scope handling of Flow declared functions (#12735) 2021-02-10 21:07:14 +01:00
Sosuke Suzuki
f1a327506e
ts: Throw recoverable for duplicates access modifier (#12775)
* Support parsing for duplicates access modifiers

Support parsing for duplicates access modifiers

* Fix lint problems

* Address reviews
2021-02-09 09:59:06 +01:00
Sosuke Suzuki
d242ea04c8
babel-parser(ts): Raise recoverable error for abstract interface (#12771)
* Support parsing abstract interface

* Address review

Address reviews

Address reviews

* Fix types

* Add hasFollowingLineBreak
2021-02-09 09:56:18 +01:00
Federico Ciardi
bf523da0b0
fix(ts): include asserts in TSTypePredicate location (#12763) 2021-02-05 20:02:41 +01:00
Federico Ciardi
eccbcca948
[TS] Create TSUnionType or TSIntersectionType when typealias has a leading operator (#12758)
* Create `TSUnionType` or `TSIntersectionType` when typealias has a leading operator

* Apply code review suggestions

* Test `TSIntersectionType`
2021-02-05 20:00:27 +01:00
Federico Ciardi
d1cf66e8c1
fix(ts): include leading operator in TSUnionType and TSIntersectionType locations (#12757) 2021-02-04 19:24:35 +01:00
Federico Ciardi
94ba66c89b
fix(ts): allow abstract methods with export default abstract class (#12748) 2021-02-03 09:48:41 -05:00
Stuart Cook
20664a430e
Permit %%placeholder%% in left-hand-side of a let declaration (#12725)
* Permit %%placeholder%% in left-hand-side of a let declaration

* Test that "let" followed by modulo is still treated as an identifier

* More tests for edge-case handling of "let" with placeholders enabled
2021-02-01 20:00:21 -05:00
Huáng Jùnliàng
ecfe20395b
spec: disable await binding identifier within static block (#12661) 2021-02-01 21:55:43 +01:00
Huáng Jùnliàng
108564fdad
refactor: raise AwaitNotInAsyncContext when an AwaitExpression will be parsed (#12716)
* refactor: raise AwaitNotInAsyncContext when an AwaitExpression will be parsed

* tweak logic

* early exit when errors are before thrown error position

* fix: always return true in assert.throws callback

See https://nodejs.org/api/assert.html#assert_assert_throws_fn_error_message

* update test fixtures

* fix flow error
2021-02-01 10:46:43 -05:00
Nicolò Ribaudo
8cf0a757d5
Recover from "missing semicolon" errors (#12437)
* Recover from "missing semicolon" errors

* Update other tests

* Fix flow

* Fix windows test

* Add back deleted test
2021-02-01 10:08:43 +01:00
Sosuke Suzuki
45fdde0ce2
(ts) Throw for abstract methods in a non-abstract class (#12686) 2021-01-27 18:56:55 +01:00
Federico Ciardi
fbfd1b2aa6
fix(parser): throw error with wrong typescript 'export declare' (#12684) 2021-01-26 22:51:12 -06:00
Sosuke Suzuki
8fcba6eb55
Raise recoverable error for await expressions in sync functions (#12520) 2021-01-24 01:45:27 +01:00
Huáng Jùnliàng
568679e301
fix: start TypePredicate node after returnToken (#12678) 2021-01-23 11:06:54 -06:00
Huáng Jùnliàng
62290aa1ba
[babel 8] Don't create TSParenthesizedType nodes by default (#12608)
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
Co-authored-by: Sergey Melyukov <s.melukov@gmail.com>
2021-01-13 01:13:09 +01:00
Zen
6c9a481e83
@babel/preset-typescript: fix tsx assigment issue (#12599) 2021-01-10 09:21:39 -06:00
Sosuke Suzuki
c1473e30b2
[ts]Add optional property to OptionalCallExpression node that has type arguments (#12562) 2021-01-06 08:41:45 -06:00
Nicolò Ribaudo
fbef603c43
Report a SyntaxError for } and > in JSX text (#12451)
cherry-pick  #11046

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

Co-authored-by: Brad Zacher <brad.zacher@gmail.com>
Co-authored-by: Kai Cataldo <kai@kaicataldo.com>
2020-12-28 19:04:54 +01:00
Huáng Jùnliàng
a0c1a9a9e4
Disallow non octal decimal escape before use strict (#12366) 2020-12-15 12:24:32 +01:00
Nicolò Ribaudo
b422c7f0ef
[babel 8] Disallow sequence expressions in JSX expression containers (#12447)
* jsx: fix sequence expression at JSXAttributeValue (#8787)

* jsx: fix sequence expression at JSXAttributeValue

* Change logic for detecting unparenthesized expressions

* use parseMaybeAssign instead of custom error handling

Co-authored-by: Daniel Tschinder <daniel@tschinder.de>
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* I'm not good at booleans

* Format

* Throw a recoverable error

Co-authored-by: Bruno Macabeus <macabeus@users.noreply.github.com>
Co-authored-by: Daniel Tschinder <daniel@tschinder.de>
2020-12-08 10:15:03 +01:00
Huáng Jùnliàng
3bd6a3d781
Make sure estree test should not throw if babel parser does not throw (#12443)
* test: run estree on tests that does not expect an errors

* fix: record the directive expression value to extra AST properties
2020-12-04 13:58:01 -05:00
Huáng Jùnliàng
8478027d1a
Make sure babel parser throws exactly same recoverable errors when estree plugin is enabled (#12375)
* refactor: introduce isPrivateName and getPrivateNameSV

* feat: check recoverable errors on estree-throw

* fix: pass through all params of parseBlockBody

* fix: set bigInt to null when invalid bigInt value is parsed

e.g. 0.1n

* fix: use string literal value in error message

When estree plugin is enabled, stringLiteral#extra.raw is not accessible. Use StringLiteral#value instead.

* refactor: introduce hasPropertyAsPrivateName

* fix: adapt to ChainExpression

* fix: port checkLVal early return for method in object pattern

* fix: throw new a?.() on estree

* fix: early return for __proto__ in accessors

* fix: test record element via isObjectProperty

* fix: pass through isLHS in toAssignable

* refactor: introduce isObjectMethod methods
2020-12-03 08:36:54 +00:00
Sosuke Suzuki
94d116052f
[ts] Allow modifiers as names of methods with type parameters (#12356) 2020-11-18 15:29:02 +01:00
Sosuke Suzuki
a4e4aede14
[ts]Set false to default value of TsTypePredicate.asserts (#12352) 2020-11-16 09:51:27 -06:00
Huáng Jùnliàng
5bbad8936b
fix: disallow all parenthesized pattern except parsing LHS (#12327)
* fix: disallow all parenthesized pattern except parsing LHS

* fix: forStatement requires LHS

* simplify toAssignable

* add more test cases

* fix: pass through isLHS on object property and assignment expression

* fix: record parenthesized identifier error for LHS

* remove duplicated skipped tests

* fix: do not record errors on ancestry arrow head

* Update packages/babel-parser/src/util/expression-scope.js

Co-authored-by: Brian Ng <bng412@gmail.com>

Co-authored-by: Brian Ng <bng412@gmail.com>
2020-11-10 14:42:37 -05:00
Sosuke Suzuki
ad8a4d62fd
Fix syntax error for getter and setter with ts and estree plugin (#12333) 2020-11-09 08:36:39 +01:00
Huáng Jùnliàng
766df9c369
fix: support string assertion key in assert entries (#12281)
* fix: support string assertion key in assert entries

* Update packages/babel-parser/src/parser/statement.js

Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>

Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>
2020-10-29 15:10:20 -04:00
Sosuke Suzuki
963537d5f5
[ts] Make ImportDeclaration always have importKind (#12170) 2020-10-29 20:07:10 +01:00
Huáng Jùnliàng
b7754d3c82
fix: disallow import assertionts in export without from (#12264) 2020-10-28 07:07:20 +01:00
Huáng Jùnliàng
a8c66f4680
Handle exprAllowed before ObjectLike is parsed (#12267)
* fix: disallow expression after `}` is consumed in parseObjectLike

* refactor: avoid accessing this.prodParam in context update
2020-10-27 20:25:50 -04:00
Huáng Jùnliàng
5b48f40a08
Polish parser errors (#12258)
* polish: update AwaitNotInAsyncFunction message

* polish: update YieldInParameter error message

* Apply suggestions from code review

Co-authored-by: Brian Ng <bng412@gmail.com>

* update test fixtures

Co-authored-by: Brian Ng <bng412@gmail.com>
2020-10-26 20:55:04 -04:00
Huáng Jùnliàng
2782a549e9
Refactor yield await classification (#12230)
* fix: incomplete ParamKind declaration

* refactor: add expression scope handler

* test: update test262 allowlist

* chore: cleanup

* fix: push expression scope for function body

* fix: push new expression scope for initializer and static block

* test: add more test cases

* fix flow error

* refactor: remove unecessary expression scope

* fix: parameter initializer error should not cross expression scope boundary

* chore: cleanup outdated comments

* fix: do not record async arrow error on ParameterDeclaration

* Update packages/babel-parser/src/util/expression-scope.js

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* polish: clear ancestry declaration error on validate

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-10-26 11:42:02 -04:00
Sosuke Suzuki
faaebfe91f
Support Import Assertions for re-export statement (#12249) 2020-10-26 15:18:45 +01:00
Sosuke Suzuki
f5bd9f2013
Allows the interface to be used as an Identifier for flow plugin (#12254) 2020-10-26 08:50:57 -05:00
Brian Ng
c00bb14f79
[ts] Error on invalid type casts in JSX (#12221) 2020-10-23 08:09:35 -05:00
Brian Ng
d51aa6d761
[ts] Allow optional binding pattern parameters within types/interfaces (#12227) 2020-10-21 08:16:43 -05:00
Sosuke Suzuki
f1bc314c79
Fix parsing of imports with module string name in flow plugin (#12224) 2020-10-20 23:46:12 +02:00
Mongkii
7870465b62
[ts] Add parser test: destructuring-with-annotation-newline (#12203) 2020-10-16 16:45:11 +02:00
Brian Ng
47250ffa65
[ts] Disallow invalid type annotations in ExpressionStatements (#12185)
* Fix regression with invalid type annotations in ExpressionStatements
2020-10-16 10:20:53 +02:00
Nicolò Ribaudo
4fe8c3acc5
Revert "Fix: check if param is assignable when parsing arrow return type annotation" (#12198)
This reverts commit 84987a00e632e65bdafdf7f70df46ded7fb083c8.
2020-10-16 08:16:37 +02:00
Nicolò Ribaudo
84987a00e6
Reland "Fix: check if param is assignable when parsing arrow return type annotation" (#12183)
* Reland "Fix: check if param is assignable when parsing arrow return type annotation"

This reverts commit 91a7a64b4b0c30ab1fdfbb12f77522afa2285ec4.

* Mark `RestElement` as assignable
2020-10-15 11:32:37 -04:00
Nicolò Ribaudo
91a7a64b4b
Revert "Fix: check if param is assignable when parsing arrow return type annotation" (#12173)
This reverts commit 136e6301cbfa9448cfb20396f82f93f0d3e10c12.
2020-10-14 21:42:05 +02:00
Sven Sauleau
af8e0facc1
Parse import-assertions (#12139)
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-10-14 21:18:16 +02:00
iamfotx
59d97d9bca
[parser] Better error message for missing number exponent (#12072)
* fix(babel-parser) better error message for missing number exponent after 'e'

* fix(babel-parser) requested changes

* msg

Co-authored-by: Brian Ng <bng412@gmail.com>
2020-10-14 21:17:38 +02:00
Huáng Jùnliàng
3ccca88178 Parse class static block (#12079)
Co-authored-by: Brian Ng <bng412@gmail.com>
2020-10-14 21:16:24 +02:00
Brian Ng
6830c90ac9
Support TypeScript mapped type 'as' clauses (#12129) 2020-10-14 20:16:22 +02:00
Nicolò Ribaudo
3fd963fdc8
[ts] Add support for template interpolations in types (#12131)
Co-authored-by: Brian Ng <bng412@gmail.com>
2020-10-14 20:15:42 +02:00