Yeonju Hwang
0671afcf87
[ts] support optional chain call with generic ( #13513 )
...
* support optional chain call with generic
* Add testcase handling new line
* allow only call if optional chain type parameter
* use exact error message
* add transform-typescript optional-chain call test
* use exact error message
* apply feedbacks
* Fix lint error
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-08-04 17:29:44 +02:00
Federico Ciardi
c35637e247
feat(ts): raise error for abstract property with initializer ( #13523 )
...
* feat: raise error for abstract property with initializer
* Improve tests
* Address review
* JLHwung review
* Update packages/babel-parser/src/plugins/typescript/index.js
* update test fixtures
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
2021-08-03 23:50:27 +02:00
Oleksandr T
b3ab4769d0
fix(ts): raise error for export default interface {} ( #13622 )
2021-08-02 18:16:01 +02:00
Huáng Jùnliàng
d3a7cd5e8d
Replace generic __clone call by specific methods ( #13611 )
...
* update benchmark babel parser version
* perf: replace generic __clone by specific methods
baseline 256 length-1 named export: 4_704 ops/sec ±1.59% (0.213ms)
baseline 512 length-1 named export: 2_426 ops/sec ±0.52% (0.412ms)
baseline 1024 length-1 named export: 1_118 ops/sec ±1.23% (0.895ms)
baseline 2048 length-1 named export: 556 ops/sec ±0.77% (1.799ms)
current 256 length-1 named export: 7_073 ops/sec ±33.67% (0.141ms)
current 512 length-1 named export: 4_441 ops/sec ±0.79% (0.225ms)
current 1024 length-1 named export: 2_142 ops/sec ±1.09% (0.467ms)
current 2048 length-1 named export: 943 ops/sec ±2.12% (1.06ms)
* breaking: remove Node#__clone in Babel 8
* test: use t.cloneNode
2021-07-30 22:19:35 +02:00
Nicolò Ribaudo
4a56387330
ts: Check if param is assignable when parsing arrow return type ( #13581 )
2021-07-26 17:58:10 +02:00
Huáng Jùnliàng
79d3276f61
Overhaul comment attachment ( #13521 )
...
* refactor: inline pushComment
* chore: add benchmark cases
* perf: overhaul comment attachment
* cleanup
* update test fixtures
They are all bugfixes.
* fix: merge HTMLComment parsing to skipSpace
* perf: remove unattachedCommentStack
baseline 128 nested leading comments: 11_034 ops/sec ±50.64% (0.091ms)
baseline 256 nested leading comments: 6_037 ops/sec ±11.46% (0.166ms)
baseline 512 nested leading comments: 3_077 ops/sec ±2.31% (0.325ms)
baseline 1024 nested leading comments: 1_374 ops/sec ±3.22% (0.728ms)
current 128 nested leading comments: 11_027 ops/sec ±37.41% (0.091ms)
current 256 nested leading comments: 6_736 ops/sec ±1.39% (0.148ms)
current 512 nested leading comments: 3_306 ops/sec ±0.69% (0.302ms)
current 1024 nested leading comments: 1_579 ops/sec ±2.09% (0.633ms)
baseline 128 nested trailing comments: 10_073 ops/sec ±42.95% (0.099ms)
baseline 256 nested trailing comments: 6_294 ops/sec ±2.19% (0.159ms)
baseline 512 nested trailing comments: 3_041 ops/sec ±0.8% (0.329ms)
baseline 1024 nested trailing comments: 1_530 ops/sec ±1.18% (0.654ms)
current 128 nested trailing comments: 11_461 ops/sec ±44.89% (0.087ms)
current 256 nested trailing comments: 7_212 ops/sec ±1.6% (0.139ms)
current 512 nested trailing comments: 3_403 ops/sec ±1% (0.294ms)
current 1024 nested trailing comments: 1_539 ops/sec ±1.49% (0.65ms)
* fix: do not expose CommentWhitespace type
* add comments on CommentWhitespace
* add test case for #11576
* fix: mark containerNode be the innermost node containing commentWS
* fix: adjust trailing comma comments for Record/Tuple/OptionalCall
* fix: drain comment stacks in parseExpression
* docs: update comments
* add a new benchmark
* chore: containerNode => containingNode
* add more benchmark cases
* fix: avoid finishNodeAt in stmtToDirective
* finalize comment right after containerNode is set
* add testcase about directive
* fix: finish SequenceExpression at current pos and adjust later
* chore: rename test cases
* add new test case on switch statement
* fix: adjust comments after trailing comma of function params
* add comment attachment design doc
* misc fix
* fix: reset previous trailing comments when parsing async method/accessor
* chore: add more comment testcases
* fix flow errors
* fix: handle comments when parsing async arrow
* fix: handle comments when "static" is a class modifier
* fix flow errors
* fix: handle comments when parsing async function/do
* refactor: simplify resetPreviousNodeTrailingComments
* update test fixtures
2021-07-07 11:51:40 -04:00
Federico Ciardi
9bad558d13
[babel 8] Use an identifier for TSTypeParameter.name ( #12829 )
2021-07-02 10:44:49 +02:00
Huáng Jùnliàng
5145c98a73
Simplify token context ( #13450 )
...
* refactor: unify tc.brace and tc.templateQuasi
* refactor: remove unused context check
* perf: reduce arrayPrototype call and hoist variables
2021-06-21 10:51:00 -04:00
Tony Gorez
101249f3aa
refactor(parser): remove refNeedsArrowPos ( #13419 )
...
* fix(parser:expression): remove refNeedsArrowPos in parseExprListItem
* feat: use refExpressionErrors to catch optional parameters
* feat: delete useless refNeedArrowPos
* fix: forgotten deletion
* fix: lint and factorize
* fix: delete useless comment
* fix: review corrections
* fix: review corrections pt2
* fix: review correction pt2
* fix: nit correction
* fix: update types
* Update packages/babel-parser/src/parser/util.js
* fix: add invariant comment in flow and ts file
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-06-19 10:40:52 +02:00
Sosuke Suzuki
0eb2853732
[ts] Support override modifiers for parameter properties ( #13428 )
2021-06-10 22:29:38 +02:00
Huáng Jùnliàng
b1fe831e4a
fix: disallow JSX tag after non-null assertion ( #13449 )
2021-06-10 15:07:47 -04:00
Huáng Jùnliàng
b9c1884a58
Reduce exprAllowed usage ( #13431 )
2021-06-09 16:36:09 +02:00
Huáng Jùnliàng
b281fe352c
Use set in parser scope ( #13408 )
...
* chore: rename benchmark
* perf: back parser scope names storage by set
* chore: add benchmark
2021-06-01 10:35:19 -04:00
Huáng Jùnliàng
acf2a10899
Faster tokenizer lookahead ( #13341 )
...
* refactor: simplify token context structure
* add benchmark
* perf: return a sub-state on tokenizer lookahead
* Update packages/babel-parser/src/tokenizer/index.js
Co-authored-by: Brian Ng <bng412@gmail.com>
* Update packages/babel-parser/src/tokenizer/index.js
Co-authored-by: Brian Ng <bng412@gmail.com>
* remove irrelevant comment
* fix: guard curPosition with isLookahead
* add test cases
Co-authored-by: Brian Ng <bng412@gmail.com>
2021-05-25 21:12:38 -04:00
Sosuke Suzuki
d6a5f6190d
[ts] Default typeAnnotation of TSTypePredicate to null ( #13354 )
2021-05-23 20:12:42 +02:00
Huáng Jùnliàng
461ba2531a
refactor: add parse*Literal parser routines ( #13333 )
...
* refactor: simplify parseLiteral interface
* refactor: extract specific methods on parsing literals
* fix: avoid StringLiteral type comparison
* add test cases
* fix: remove redundant node
* Update packages/babel-parser/src/plugins/flow/index.js
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
* update test fixtures
* fix: refine parseLiteral typings
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
2021-05-19 16:00:24 -04:00
Sosuke Suzuki
b2d9156cc6
Update to Prettier 2.3 ( #13288 )
2021-05-10 15:34:13 +02:00
Sosuke Suzuki
1d54419ec4
Parse attributes of import expression with estree plugin ( #13284 )
...
* Parse attributes of import expression with estree plugin
* Add tests
* Update packages/babel-parser/src/types.js
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
2021-05-07 16:37:20 -04:00
Huáng Jùnliàng
a8fea4037d
Faster identifier tokenizing ( #13262 )
...
* add benchmark
* perf: faster identifier tokenizing
- Mover iterator identifier parsing to the Flow plugin
- If the character is an identifier start, pass it to readWord1
2021-05-06 18:47:19 -04:00
Huáng Jùnliàng
a387973821
Refactor private name tokenizing ( #13256 )
...
* add benchmark
* refactor: create tt.privateName token for private names
* add backward compat privateName = hash + name to Babel 7
* perf: get private name SV from token value
* chore: tweak benchmark file
* chore: update test fixtures
* convert tt.privateName to PrivateIdentifier
* perf: avoid most isPrivateName call
* Update packages/babel-parser/src/parser/expression.js
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
* perf: use inlinable codePointAtPos
* make prettier happy
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2021-05-06 09:46:09 -04:00
Sosuke Suzuki
ef87648f3f
Parse static blocks with typescript plugin ( #13243 )
...
* Support static blocks with typescript
* Add tests
* Reuse isStatic var
* Disallow parsing static blocks with modifiers
* Add tests
* Raise recoverable errors
* Address review
* Add tests for static static {}
2021-05-03 16:17:08 -04:00
Sosuke Suzuki
7f5b212322
babel-parser: Add new typescript plugin option dts: boolean ( #13113 )
2021-04-28 18:24:18 +02:00
Nicolò Ribaudo
22b0eb038f
[ts] Enforce order for the override modifier ( #13209 )
...
* [ts] Enforce order for the `override` modifier
* generator
* Add more checks
* Update TS tests
2021-04-28 18:21:31 +02:00
George Zahariev
8433cd0c05
Support parsing Flow's Optional Indexed Access Types ( #13224 )
2021-04-28 18:21:31 +02:00
Sosuke Suzuki
b116865077
Use this.isThisParam in typescript parser ( #13163 )
2021-04-28 18:21:31 +02:00
Sosuke Suzuki
7484b51e56
Support TS 4.3 get/set type members ( #13089 )
...
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-04-28 18:21:31 +02:00
Sosuke Suzuki
2521c666f7
Add internal ESLint rule for consistent parser error messages ( #13130 )
2021-04-28 18:21:31 +02:00
Pig Fang
bf14a106ad
Support TS 4.3 override syntax in class ( #13097 )
...
* support TS 4.3 `override` syntax in class
* fix types
* fix types
* tweak error message
* update TypeScript commit
* split tests
* add more tests
* update allowlist
* disallow `override` with `declare`
* disallow `override` in non-sub class
* update TypeScript allowlist
* rename error message key
* add more tests
2021-04-28 18:21:31 +02:00
Sosuke Suzuki
f8aa32f767
Support parsing Flow's Indexed Access Types ( #13053 )
2021-04-28 18:21:31 +02:00
Pig Fang
eac0259ce2
Support TS 4.3 static index signature in classes ( #13096 )
2021-04-28 18:21:31 +02:00
Sosuke Suzuki
0ee98139a6
Introduce parser error codes ( #13033 )
2021-04-28 18:21:31 +02:00
Huáng Jùnliàng
10f4d08efb
refactor: avoid parsing logic on locations ( #13200 )
2021-04-25 09:15:48 -04:00
Federico Ciardi
368bf893fa
[ts] raise SyntaxError for declare before getter/setter ( #13143 )
...
* fix: raise `SyntaxError` for `declare` before getter/setter
* fix: allow `declare` when class property name is `get` or `set`
2021-04-17 23:00:24 +02:00
Federico Ciardi
42e630e8a2
Allow trailing comma after rest parameter in TSDeclareFunction ( #13101 )
...
* fix(ts): allow trailing comma after rest parameter in `TSDeclareFunction`
* Apply code review changes
Co-Authored-By: Nicolò Ribaudo <7000710+nicolo-ribaudo@users.noreply.github.com>
2021-04-06 18:36:17 +02:00
Federico Ciardi
7fe3ebf4db
fix: raise SyntaxError for unparenthesized assert and assign ( #13099 )
...
* fix: raise `SyntaxError` for unparenthesized assert and assign
* chore
2021-04-06 16:07:13 +02:00
Federico Ciardi
4f727139ec
fix(ts): Allow parenthesized "assert and assign" ( #12933 )
...
Co-authored-by: Nicolò Ribaudo <7000710+nicolo-ribaudo@users.noreply.github.com>
2021-03-22 17:00:03 +01:00
Sosuke Suzuki
beb7cf8b24
Sort error keys with ESLint ( #13020 )
2021-03-18 21:01:57 +01:00
Huáng Jùnliàng
0988c471e9
Parse type imports in TSImportEqualsDeclaration ( #12962 )
2021-03-14 23:34:49 +01:00
Sosuke Suzuki
b416847b61
(ts) Raise syntax error for abstract methods with a body ( #12687 )
...
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-03-02 11:57:58 +01:00
Sosuke Suzuki
b62fc3d44f
babel-parser(flow): Set this property to null for FunctionTypeAnnotation without parens ( #12930 )
...
* Add null property to FunctionTypeAnnotation without parens
* Update tests
* Update tests
2021-03-01 09:15:43 -05:00
Nicolò Ribaudo
c30039029a
Don't enable class features by default in estree ( #12867 )
...
* Don't enable class features by default in `estree`
* Flow
* Reduce breakage
2021-02-23 11:30:01 +01:00
Huáng Jùnliàng
03d7911be6
Implement class features in estree ( #12370 )
...
Co-authored-by: Kai Cataldo <kai@kaicataldo.com>
2021-02-21 20:12:12 +01:00
Sosuke Suzuki
e4588bed22
Support TypeScript 4.2 abstract constructor signatures ( #12628 )
...
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-02-21 20:07:55 +01:00
George Zahariev
5b99b8f221
Flow Enums with unknown members support ( #12193 )
...
* Flow Enums with unknown members parsing
* Updates after rebase
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-02-21 18:42:23 +01:00
Daniel Sainati
16e9f1c8e5
Support Flow this parameter annotations ( #12234 )
2021-02-21 17:44:27 +01:00
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