fix(parser): properly handle optional markers in generator class methods#17312
fix(parser): properly handle optional markers in generator class methods#17312nicolo-ribaudo merged 4 commits intobabel:mainfrom magic-akari:fix/issue-17310
Conversation
magic-akari
commented
May 15, 2025
| Q | A |
|---|---|
| Fixed Issues? | Fixes #17310 |
| Patch: Bug Fix? | |
| Major: Breaking Change? | |
| Minor: New Feature? | |
| Tests Added + Pass? | Yes |
| Documentation PR Link | |
| Any Dependency Changes? | |
| License | MIT |
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/59338 |
| "SyntaxError: Class methods cannot have the 'readonly' modifier. (6:2)", | ||
| "SyntaxError: Class methods cannot have the 'declare' modifier. (7:2)" |
There was a problem hiding this comment.
TS1024: 'readonly' modifier can only appear on a property declaration or index signature.
TS1031: 'declare' modifier cannot appear on class elements of this kind.
| @@ -0,0 +1,9 @@ | |||
| class A { | |||
| *[a?.b]?() { }; | |||
There was a problem hiding this comment.
Should we report a recoverable error in cases like this, similarly to how report it for readonly and declare?
There was a problem hiding this comment.
Actually, this is valid TypeScript syntax.
Do you mean readonly *[a?.b]?() { }; ?
There was a problem hiding this comment.
Oh I meant with just ?, I didn't realize it's actually valid syntax.
| readonly *[e?.e]?() { } | ||
| declare *[f?.f]?() { } | ||
| protected *[g?.g]?() { } | ||
| } |
There was a problem hiding this comment.
Thank you. Can you split this test into two? one for the valid cases and the other for invalid ones.