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
Nicolò Ribaudo
9f40d6fcd0
[ts] Add support for the "intrinsic" keyword ( #12147 )
2020-10-14 20:15:17 +02:00
Huáng Jùnliàng
136e6301cb
Check if param is assignable when parsing arrow return type ( #11992 )
2020-10-14 20:09:48 +02:00
Huáng Jùnliàng
21d7ee2610
String import/export specifier ( #12091 )
...
* feat: parse moduleExportName
* feat: add validators
* Support string specifier name in commonjs transform
* Support string specifier name in export-ns-from
* test: add loose testcases
* test: add testcases for amd and umd
* feat: support systemjs
* test: update fixtures fixed in #12110
* add plugin name typings
* test: rename test layout
* feat: implement under moduleStringNames flag
* chore: add plugin syntax module string names
* feat: support ModuleExportName as ModuleExportName
* test: update test fixtures
* fix flow errors
* docs: update AST spec
* feat: support { "some imports" as "some exports" }
* feat: support { "some imports" as "some exports" } in systemjs
* test: add test on `import { "foo" }`
* Address review comments
* add moduleStringNames to missing plugin helpers
* Apply suggestions from code review
* update test fixtures
* Update packages/babel-parser/src/parser/error-message.js
* update test fixtures
Co-Authored-By: Kai Cataldo <kai@kaicataldo.com>
Co-authored-by: Brian Ng <bng412@gmail.com>
2020-10-14 20:01:37 +02:00
Sosuke Suzuki
a5bed04f55
Make asserts property boolean, not undefined ( #12167 )
2020-10-13 23:56:08 +02:00
Brian Ng
13a1cfd396
Move check for TSTypeCastExpression to catch another case ( #12161 )
2020-10-11 13:03:57 +02:00
Sosuke Suzuki
45f0cc2ed9
Recover from error for missing initializer in const declaration ( #12120 )
2020-09-29 18:40:51 +02:00
Sosuke Suzuki
39a12674b4
Improve syntax error for class fields in ambient context ( #12108 )
...
* Improve error messages for ambient context class fields
* Modify switching state.isDeclareContext for class fields with declare
2020-09-26 15:52:12 -04:00
Sosuke Suzuki
434b65bc2a
[ts] Throw a syntax error for index signature with declare ( #12111 )
2020-09-26 18:06:13 +02:00
Sosuke Suzuki
0d32e3fc36
Add missing tests for TypeScript syntax errors ( #12103 )
...
* Add missing tests for index signatures with modifiers
* Add missing test for import type
2020-09-24 14:38:11 -04:00