TS parser small fixes#17888
Conversation
9996668 to
bae6d4f
Compare
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/61253 |
|
commit: |
|
/cc @fisker The following Prettier test is failing due to this PR Pending prettier test updates. |
Thanks. We can |
| // the parameters rather than the class method key. | ||
| this.raise( | ||
| TSErrors.DeclareFunctionHasImplementation, | ||
| this.state.lastTokEndLoc!, |
There was a problem hiding this comment.
This might point to a space after ), this.state.startLoc would be better?
packages\babel-parser\test\fixtures\typescript\declare\module-function
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
Looks good, just a minor comment about naming.
| "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.", | ||
| TypeModifierIsUsedInTypeImports: | ||
| "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.", | ||
| UnexpectedDeclaration: (type: "interface" | "type") => |
There was a problem hiding this comment.
I would prefer a name that makes it clearer that this is for TS thing, like UnexpectedTypeDeclaration (most of other TS errors have an error code that makes it clear they are about types/modifiers)
In this PR we cleaned up a few tsc parse test errors. The parser now rejects a few new productions which is also rejected by the tsc.
The typescript parser tests now also recognizes errors in the format of
TestName(OptionKey=value).errors.txt, such asregExpWithOpenBracketInCharClass(target=esnext).errors.txt. Therefore, we have one more invalid case in the allowlist. This is currently expected because we don't parse regex in the Babel parser.