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/plugin-transform-typescript outputs warnings on export of global-scope identifiers #14826

Closed
1 task
marcusdarmstrong opened this issue Aug 3, 2022 · 1 comment 路 Fixed by #14827
Labels
i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@marcusdarmstrong
Copy link

馃捇

  • Would you like to work on a fix?

How are you using Babel?

@babel/cli

Input code

export default undefined;

Configuration file name

babel.config.json

Configuration

{
  "presets": ["@babel/preset-typescript"]
}

Current and expected behavior

Upon running babel with this input and configuration, a warning is emitted:

% ./node_modules/@babel/cli/bin/babel.js ./test.ts
The exported identifier "undefined" is not declared in Babel's scope tracker
as a JavaScript value binding, and "@babel/plugin-transform-typescript"
never encountered it as a TypeScript type declaration.
It will be treated as a JavaScript value.

This problem is likely caused by another plugin injecting
"undefined" without registering it in the scope tracker. If you are the author
 of that plugin, please use "scope.registerDeclaration(declarationPath)".

Given that this is a perfectly valid snippet and not due to a misconfigured upstream plugin, this warning seems inappropriate and no output should be produced.

Environment

System:
OS: macOS 11.6
Binaries:
Node: 16.10.0 - ~/.nvm/versions/node/v16.10.0/bin/node
npm: 7.24.0 - ~/.nvm/versions/node/v16.10.0/bin/npm
npmPackages:
@babel/cli: 7.18.10 => 7.18.10
@babel/preset-typescript: 7.18.6 => 7.18.6

Possible solution

I suspect the issue is that the Typescript transform only checks the scope for it's own bindings, rather than hasBinding, but obviously I'm not particularly familiar with this code.

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @marcusdarmstrong! 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.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Nov 4, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants