51 Commits
Author SHA1 Message Date
Huáng JùnliàngandGitHub a9d0b8fac8 fix(parser): disallow declare module M {} (#18120)
* fix(parser): disallow `declare module M {}`

* update dts

* test: remove invalid test case
2026-07-08 08:13:48 -04:00
Huáng JùnliàngandGitHub f8270721e3 fix(parser): forbid let x! and let x! = (#18100)
* fix(parser): forbid `let x!` and `let x! =`

* test: expand test cases to other variable kinds

* refactor: address review comment

* fix(parser): forbid `x!` and `x! =` as class properties

* update test cases

* remove failing prettier tests

* add new test case
2026-07-06 10:57:51 -04:00
Huáng JùnliàngandGitHub a48fcce83f fix(parser): ts parser small fixes (#17954)
* fix(parser): skip scope for global namespace

* fix(parser): register binding for TSNamespaceExportDeclaration

* test: check TS2451 error

* add TS2480 to error codes

* fix(parser): disallow reserved word in namespace

* fix(parser): forbid import/export in ts namespace

* test(parser): enable TS2567 error

* test(parser): enable TS17019 error
2026-04-28 10:41:19 -04:00
Huáng JùnliàngandGitHub 7e46cd6aa4 test(third-party): parse js defined by // @filename (#17922) 2026-04-17 12:16:53 +02:00
Huáng JùnliàngandGitHub e8449996f8 TS parser small fixes (#17888)
* fix: disallow TSParameterProperty within TSDeclareMethod

* fix(parser): disallow parameter initializer in declare method

* fix(parser): disallow class method implementation in ambient context

* fix(parser): disallow type/interface within single statement context

* test: support (target=es6).errors.txt format in ts references

* test: add more supported parser error codes

* fix: throw implementation error from the start of block statement

* fix: throw DeclareFunctionHasImplementation unconditionally

* Apply suggestion from @JLHwung

* remove conflict prettier test

* address review comments

* rename UnexpectedDeclaration
2026-03-25 11:42:05 -04:00
Huáng JùnliàngandGitHub ec3c42c70d Disallow super call after new (#17871)
* fix(parser): disallow super() after new

* fix(generator): update new callee parenthese rules

* fix: disallow super/import after bind operator

* update typescript parser test allowlist

* fix(types): disallow import/super/v8Intrinsic as callee of new expression

* chore: fix lint error

* add new test cases

* update test cases
2026-03-18 11:10:55 -04:00
d1c07c2e9f Drop support for TS module <identifier> (#17659)
Co-authored-by: Huáng Jùnliàng <[email protected]>
2026-01-09 18:23:43 +01:00
Nicolò Ribaudo 3a912d1a39 Remove Babel 7 from the codebase (#17618) 2025-12-05 12:33:52 +01:00
Huáng JùnliàngandGitHub fc260ec74b Improve @babel/core typings (#17471) 2025-08-21 20:08:50 -04:00
Huáng JùnliàngandGitHub fa73edea15 Enable type checking for scripts and babel-worker.cjs (#17454) 2025-07-29 18:26:27 -04:00
Huáng JùnliàngandGitHub 254525d565 Enforce node protocol import (#17207)
* enable prefer-node-protocol rule

* prefer node protocol import

* fix broken scripts

* fix e2e-old-babel error

* strip node: protocol for old node versions

* update Makefile.mjs
2025-03-31 10:49:22 -04:00
Huáng JùnliàngandGitHub 9f01a9b203 fix(typescript): disallow TSInstantiationExpression in LHS (#17154)
* add some supported error codes

* update typescript commit

* fix(typescript): disallow TSInstantiationExpression in LHS

This commit essentially reverts https://github.com/babel/babel/pull/16476

* update error codes handling and allowlist

* remove invalid test
2025-02-27 13:25:02 -05:00
liuxingbaoyuandGitHub e20a12d698 chore: Update TS 5.7 (#17053) 2025-01-09 17:36:20 +01:00
Nicolò RibaudoandGitHub f894edde64 Add eslint-plugin-regexp (#16680) 2024-07-29 17:42:43 +02:00
Nicolò RibaudoandGitHub 85008a5af3 Use prettier 3.1 (#16098) 2023-11-13 16:49:06 +01:00
Nicolò RibaudoandGitHub bfad58df2e Use Prettier v3.0.0-alpha.12 (#15617) 2023-06-02 15:22:53 +02:00
Nicolò RibaudoandGitHub f363d22618 Implement decorators as presented at 2023-01 TC39 meeting (#15405) 2023-02-18 16:50:41 +01:00
Nicolò RibaudoandGitHub 6128012904 [ts] Fix restrictions for optional parameters (#15414)
Fixes https://github.com/babel/babel/issues/15396
2023-02-09 18:28:33 +01:00
4c508d03bf fix: Support local exports in TS declare modules (#14941)
Co-authored-by: Huáng Jùnliàng <[email protected]>
Co-authored-by: Nicolò Ribaudo <[email protected]>
2022-09-19 14:48:33 +02:00
a6612d18c1 fix: allow ts redeclaration with import = and var (#14940)
Co-authored-by: Nicolò Ribaudo <[email protected]>
2022-09-19 10:35:23 +02:00
liuxingbaoyuandGitHub 526e004e42 chore: fix parser-test allowlist (#14925) 2022-09-13 22:12:53 +09:00
98d0ee5d11 [ts] allow redeclaring a var/type with the same name as import (#14900)
Co-authored-by: Nicolò Ribaudo <[email protected]>
2022-09-13 11:33:37 +09:00
liuxingbaoyuandGitHub 336cd34ecd chore: Improve external parser tests (#14911)
* improve runner

* update allowlist

* review
2022-09-07 10:40:32 +02:00
fa685dfe7d [ts] Add support for instantiation expressions (#14457)
Co-authored-by: Brad Zacher <[email protected]>
2022-05-17 23:44:23 +02:00
Nicolò RibaudoandGitHub c71c3c849c Allow keywords in TS qualified types (#14362) 2022-03-16 23:02:41 +01:00
89497780d5 Type-safe ParseErrors (#14320)
* Flow ParseError version.

Reviewed by @tolmasky.

* Begin updating everything.

Reviewed by @tolmasky.

* Convert more.

Reviewed by @tolmasky.

* Add more.

Reviewed by @tolmasky.

* Fix.

Reviewed by @tolmasky.

* Just switch everything to exact types.

Reviewed by @tolmasky.

* Style fixes.

Reviewed by @tolmasky.

* Fix remaining style issues and remove unecessary dry-error-messages.

Reviewed by @tolmasky.

* Don't use enums and address more issues.

Reviewed by @tolmasky.

* More fixes.

Reviewed by @tolmasky.

* Workaround for import situation.

Reviewed by @tolmasky.

* Fix a bunch of errors messages.

Reviewed by @tolmasky.

* Fix some flow stuff.

Reviewed by @tolmasky.

* Add a way to specify code.

Reviewed by @tolmasky.

* Fix lint errors.

Reviewed by @tolmasky.

* Fix Flow errors.

Reviewed by @tolmasky.

Another Flow things.

Reviewed by @tolmasky.

Fix Flow error.

Reviewed by @tolmasky.

Fix flow errors.

Reviewed by @tolmasky.

Fix flow error.

Reviewed by @tolmasky.

* See if this gets the name right.

Reviewed by @tolmasky.

* Add comments to raise and raiseOverwrite.

Reviewed by @tolmasky.

* Remove forward declaration.

Reviewed by @tolmasky.

* Change option to be kind.

Reviewed by @tolmasky.

* Fix for ambient context not being respected in variable declarations.

Reviewed by @tolmasky.

* Make IllegalBreakContinue based on type.

Reviewed by @tolmasky.

* Begin moving checkLVal to type-based system instead of contextDescription-based system, and fix let error in the process as well.

Reviewed by @tolmasky.

* Switch to isValidLVal.

Reviewed by @tolmasky.

* Don't use checkLVal for class names.

Reviewed by @tolmasky.

* Fix some Flow errors.

Reviewed by @tolmasky.

* Temporary fix for Flow error.

Reviewed by @tolmasky.

* Remove unused stuff.

Reviewed by @tolmasky.

* Try this.

Reviewed by @tolmasky.

* Don't use Object.fromEntries.

Reviewed by @tolmasky.

* Fix linter error.

Reviewed by @tolmasky.

* Fix for SyntaxError.

Reviewed by @tolmasky.

* Add TS1039 Initializers are not allowed in ambient contexts. to error-codes.js.

Reviewed by @tolmasky.

* Add TS1155 'const' declarations must be initialized.

Reviewed by @tolmasky.

* Allow consts with literals.

Reviewed by @tolmasky.

* Add enum support.

Reviewed by @tolmasky.

* Add filename to test runner to correctly identify .d.ts files.

Reviewed by @tolmasky.

* Only ignore reserved words in ambient contexts. Parse interface in parseStatementContent. Fix enums.

Reviewed by @tolmasky.

* Fix simple parameter error.

Reviewed by @tolmasky.

* Type references should allow reserved words (I believe we were just getting away with the fact that we turned reserved words off before).

Reviewed by @tolmasky.

* Allow import and export in TypeScript regardless of module or script.

Reviewed by @tolmasky.

* Fix declare enum and interface and reorganize the code a bit.

Reviewed by @tolmasky.

* Fix for keywords in export as.

Reviewed by @tolmasky.

* Fix reserved words in import types.

Reviewed by @tolmasky.

* Rename files.

Reviewed by @tolmasky.

* Add 1

* Remove files form allowlist that no longer need to be there.

Reviewed by @tolmasky.

* Parse as separate files and switch to only using error codes.

Reviewed by @tolmasky.

* Fix reading files with different encodings.

Reviewed by @tolmasky.

* Fix outside tests.

Reviewed by @tolmasky.

* Change test to pass since typescript should allow import.

Reviewed by @tolmasky.

* Update tests that should fail.

Reviewed by @tolmasky.

* Add tests for complex let assignments.

Reviewed by @tolmasky.

* Choose a better name for these.

Reviewed by @tolmasky.

* Add tests for a number of left-hand side expressions.

Reviewed by @tolmasky.

* Change name to kind.

Reviewed by @tolmasky.

* Choose better parameter names for these errors.

Reviewed by @tolmasky.

* Use error credentials and error details.

Reviewed by @tolmasky.

* Fix some names and add comments.

Reviewed by @tolmasky.

* Get rid of unused option.

Reviewed by @tolmasky.

* Better names.

Reviewed by @tolmasky.

* Split out pipeline errors and choose better names.

Reviewed by @tolmasky.

* Clean up LVal stuff.

reviewed by @tolmasky.

* Use "unambiguous" to determine whether to parse typescript tests as module or script, and stop always allowing imports in Typescript.

Reviewed by @tolmasky.

* Revert test to previous state.

Reviewed by @tolmasky.

* Better name for this.

Reviewed by @tolmasky.

* Add these back in.

Reviewed by @tolmasky.

* Add these.

Reviewed by @tolmasky.

* Fix flow errors and use toNodeDescription in more places.

Reviewed by @tolmasky.

* Rename LHSParent to LValAncestor.

Reviewed by @tolmasky.

* Add ParseError.clone and change symbol name to DefaultMessage from NoMessage.

Reviewed by @tolmasky.

* Change name to identifierName in a bunch of places.

Reviewed by @tolmasky.

* Fix for using type.

Reviewed by @tolmasky.

* Better names.

Reviewed by @tolmasky.

* Clean up API and add comments.

Reviewed by @tolmasky.

* Change name.

Reviewed by @tolmasky.

* Better names.

Reviewed by @tolmasky.

* Minor comment fix.

Reviewed by @tolmasky.

* Remove no longer used method.

Reviewed by @tolmasky.

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

Co-authored-by: Nicolò Ribaudo <[email protected]>

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

Co-authored-by: Nicolò Ribaudo <[email protected]>

* Minor grammar changes to comments.

Reviewed by @tolmasky.

* Use trim instead of slice(0, -1).

Reviewed by @tolmasky.

* Add a comment to explain the tagged template stuff.

Reviewed by @tolmasky.

* Use maxArgumentCount.

Reviewed by @tolmasky.

* Don't allow UpdateExpression without prefix.

Reviewed by @tolmasky.

* Add tds test for no-initializer.

Reviewed by @tolmasky.

* Make this test test ASI and not const initializers.

Reviewed by @tolmasky.

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

Co-authored-by: Nicolò Ribaudo <[email protected]>

* Change template string to normal string and remove default.

Reviewed by @tolmasky.

* Get rid of ParseError class and use SyntaxErrors instead.

Reviewed by @tolmasky.

* Update packages/babel-parser/src/parse-error.js

Co-authored-by: Huáng Jùnliàng <[email protected]>

* Remove this comment since we don't need this argument anymore.

Reviewed by @tolmasky.

* Use this in toMessage and restore clone method.

Reviewed by @tolmasky.

* Make sure pos and missingPlugin are enumerable.

Reviewed by @tolmasky.

* Make typescript tests faster by checking the bom manually.

Reviewed by @tolmasky.

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

Co-authored-by: Nicolò Ribaudo <[email protected]>

* Update packages/babel-parser/src/plugins/estree.js

Co-authored-by: Nicolò Ribaudo <[email protected]>

* Update packages/babel-parser/src/plugins/typescript/index.js

Co-authored-by: Nicolò Ribaudo <[email protected]>

* Update packages/babel-parser/src/plugins/typescript/index.js

Co-authored-by: Nicolò Ribaudo <[email protected]>

* Clarify const enum initialization comment.

Reviewed by @tolmasky.

* Fix Flow being angry because __proto__: null makes it think that the return type can be null.

Reviewed by @tolmasky.

* Don't automatically set DTS on the typescript plugin based on filename.

Reviewed by @tolmasky.

* Fix duplicated export error.

Reviewed by @tolmasky.

Co-authored-by: Nicolò Ribaudo <[email protected]>
Co-authored-by: Huáng Jùnliàng <[email protected]>
2022-03-08 09:36:40 -05:00
Huáng JùnliàngandGitHub e32b58d25d Reinterpret << when parsing TS type arguments (#14145)
* refactor: split bitShift to bitShiftL and bitShiftR

* fix: reinterpret bitShiftL to lt when parsing type arguments

* test: update typescript allowlist

* add Babel 8 test cases

* test: simplify testcase

* add more testcases
2022-01-23 23:47:06 -05:00
Sosuke SuzukiandGitHub bb11b0f5af test: Add importAssertions to TS tests and update TS tests (#14127) 2022-01-10 15:38:01 +01:00
861826a90c chore(deps): update third-party parser tests to 64a1628 (#13816)
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Huáng Jùnliàng <[email protected]>
Co-authored-by: Nicolò Ribaudo <[email protected]>
2021-10-08 00:13:02 +02:00
Sosuke SuzukiandGitHub 467b34f6b0 Update parser plugins for ts tests (#13808) 2021-10-03 19:51:34 +09:00
Nicolò RibaudoandGitHub c99a0a8a36 Enable top-level await parsing by default (#13387) 2021-08-04 00:00:04 +02:00
Nicolò Ribaudo 255ff14c84 [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
Huáng JùnliàngandNicolò Ribaudo fce5ad0489 Parse class fields and private methods by default (#13175)
* feat: materialize class features

* chore: move testcases to es2022

* chore: update test fixtures

* chore: remove classPr\w+ from options.json

* chore: remove empty options.json

* update flow test allowlist

* update typescript allowlist
2021-04-28 18:21:31 +02:00
Sosuke SuzukiandNicolò Ribaudo eeb0165c20 Support TS 4.3 get/set type members (#13089)
Co-authored-by: Nicolò Ribaudo <[email protected]>
2021-04-28 18:21:31 +02:00
Pig FangandNicolò Ribaudo 275f6d994b Support TS 4.3 static index signature in classes (#13096) 2021-04-28 18:21:31 +02:00
83dc04c654 Use native ESM for dev scripts (#12296)
Co-authored-by: Nicolò Ribaudo <[email protected]>
2021-01-30 18:36:21 +01:00
Sosuke SuzukiandGitHub d931539e21 (ts) Throw for abstract methods in a non-abstract class (#12686) 2021-01-27 18:56:55 +01:00
ZenandGitHub 23c7b03663 @babel/preset-typescript: fix tsx assigment issue (#12599) 2021-01-10 09:21:39 -06:00
Sosuke SuzukiandGitHub 769e6ffb1b [ts] Allow modifiers as names of methods with type parameters (#12356) 2020-11-18 15:29:02 +01:00
Huáng JùnliàngandGitHub 690ef74041 refactor: reorder checkLVal parameters (#12346)
* refactor: reorder checkLVal parameters

* update allow list

* Apply suggestions from code review
2020-11-17 09:07:32 -05:00
Brian NgandGitHub 9cb0999e43 [ts] Allow optional binding pattern parameters within types/interfaces (#12227) 2020-10-21 08:16:43 -05:00
c510e5a669 [ts] Add support for template interpolations in types (#12131)
Co-authored-by: Brian Ng <[email protected]>
2020-10-14 20:15:42 +02:00
Sosuke SuzukiandGitHub 330478c461 Throw a syntax error for empty type parameter/argument (#12088) 2020-09-22 08:26:30 -05:00
Sosuke SuzukiandGitHub 86d57320b4 fix: throw for constructors with type parameters (#12065)
* Throw a syntax error for a constructor with type parameters

* Modify to match error location with TypeScript

* Update typescript parser tests

Update allowlist.txt
2020-09-17 13:03:33 -04:00
Brian NgandHuáng Jùnliàng 5052c92c1e Allow unknown/any in TS catch clause param (#11755) 2020-07-29 16:51:48 -04:00
Huáng JùnliàngandGitHub 77125d1ed9 replace whitelist by allowlist in parser-tests (#11727) 2020-06-17 15:32:46 -04:00
Huáng JùnliàngandGitHub 2bd3efd667 fix: allow bigInt in method name and TSLiteralType (#11547)
* refactor: add isLiteralPropertyName to parser utils

* address review comments [skip-ci]

* refactor: keyword is valid identifierName

* fix: allow bigint in TSLiteralType

* update typescript test whitelist
2020-05-14 18:40:52 -04:00
Huáng JùnliàngandNicolò Ribaudo b6ebaa4f45 Reduce false negative cases of typescript parser tests (#10979)
* tests: read baesline errors for typescript parsing error

* chore: add error codes

* chore: tune the regex
2020-01-10 22:11:10 +01:00
Nicolò RibaudoandHuáng Jùnliàng 702b8bdbe0 Update Test262, Flow and TS parser tests (#10976)
* Update Test262, Flow and TS parser tests

* Updates
2020-01-10 09:50:11 -05:00
Huáng JùnliàngandGitHub 5779e72d55 LiteralPropertyName should allow BigIntLiteral (#10955)
* fix: property name should allow BigIntLiteral

* test: add non decimal test case

* add bigintIndex to whitelist
2020-01-07 10:23:50 -05:00