Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Babel TypeScript syntax throws with error recovery enabled where offical does not #16371

Open
1 task
msteen opened this issue Mar 20, 2024 · 1 comment
Open
1 task

Comments

@msteen
Copy link

msteen commented Mar 20, 2024

馃捇

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

parse("foo.", { errorRecovery: true })

Configuration file name

No response

Configuration

No response

Current and expected behavior

Currently getting SyntaxError.

Expected the parser to allow empty identifiers in error recovery mode, like TypeScript's parser does:
https://ts-ast-viewer.com/#code/GYexDog

Similar to the other syntax errors as listed in the release notes about error recovery:
https://babeljs.io/blog/2019/11/05/7.7.0#parser-error-recovery-10363

This is crucial to get auto completion to work as expected.

Environment

  • System:
    • OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
  • Binaries:
    • Node: 20.8.1 - ~/.nvm/versions/node/v20.8.1/bin/node
    • npm: 10.1.0 - ~/.nvm/versions/node/v20.8.1/bin/npm
    • pnpm: 8.12.1 - ~/.nvm/versions/node/v20.8.1/bin/pnpm
    • bun: 1.0.21 - ~/.nvm/versions/node/v20.8.1/bin/bun
  • npmPackages:
    • @babel/core: ^7.23.3 => 7.23.3
    • @babel/parser: ^7.24.1 => 7.24.1
    • @babel/plugin-proposal-async-do-expressions: ^7.23.3 => 7.23.3
    • @babel/plugin-proposal-do-expressions: ^7.23.3 => 7.23.3
    • @babel/plugin-proposal-throw-expressions: ^7.23.3 => 7.23.3
    • @babel/plugin-syntax-typescript: ^7.23.3 => 7.23.3
    • @babel/preset-env: ^7.23.6 => 7.23.6
    • @babel/preset-react: ^7.23.3 => 7.23.3
    • @babel/preset-typescript: ^7.23.3 => 7.23.3
    • babel-plugin-module-resolver: ^5.0.0 => 5.0.0

Possible solution

No response

Additional context

I have a dialect of TypeScript that compiles to TypeScript to get language features supported like types and auto completion and I use Babel to do this compilation. So even if TypeScript can deal with foo. just fine, if Babel does not, my language features fail too work.

@babel-bot
Copy link
Collaborator

Hey @msteen! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants