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/parser doesn't throw a recoverable error for infer that is outside of conditional types #14511

Open
1 task
sosukesuzuki opened this issue May 1, 2022 · 1 comment

Comments

@sosukesuzuki
Copy link
Member

馃捇

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

type X = infer U;

Configuration file name

No response

Configuration

const code = "type X = infer U";

require("@babel/parser").parse(code, { plugins: ["typescript"] });

Current and expected behavior

Current:

No error.

Expected:

'infer' declarations are only permitted in the 'extends' clause of a conditional type. error is thrown.

Environment

System:
    OS: macOS 10.15.7
  Binaries:
    Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
    Yarn: 3.1.1 - ~/.nvm/versions/node/v16.13.2/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
  Monorepos:
    Yarn Workspaces: 3.1.1
  npmPackages:
    @babel/cli: ^7.17.0 => 7.17.0 
    @babel/core: ^7.17.0 => 7.17.8 
    @babel/eslint-config-internal: workspace:^ => 7.16.1 
    @babel/eslint-parser: workspace:^ => 7.17.0 
    @babel/eslint-plugin-development: workspace:^ => 7.17.7 
    @babel/eslint-plugin-development-internal: workspace:^ => 7.17.7 
    @babel/plugin-proposal-dynamic-import: ^7.16.7 => 7.16.7 
    @babel/plugin-proposal-export-namespace-from: ^7.16.7 => 7.16.7 
    @babel/plugin-proposal-object-rest-spread: ^7.16.7 => 7.16.7 
    @babel/plugin-transform-modules-commonjs: ^7.16.8 => 7.16.8 
    @babel/plugin-transform-runtime: ^7.17.0 => 7.17.0 
    @babel/preset-env: ^7.16.11 => 7.16.11 
    @babel/preset-flow: ^7.16.7 => 7.16.7 
    @babel/preset-typescript: ^7.16.7 => 7.16.7 
    @babel/runtime: ^7.17.0 => 7.17.0 
    babel-plugin-transform-charcodes: ^0.2.0 => 0.2.0 
    eslint: ^8.9.0 => 8.9.0 
    jest: ^27.4.0 => 27.4.0

Possible solution

No response

Additional context

#14476 (comment)

@cap-mfm
Copy link

cap-mfm commented Jan 12, 2024

+1, same issue here

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