Skip to content

[Bug]: Missing registerDeclaration in plugin-transform-typescript #15486

@amoeller

Description

@amoeller

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

import foo = bar

Configuration file name

No response

Configuration

No response

Current and expected behavior

plugin-transform-typescript fails to register the declaration at

        path.replaceWith(
          t.variableDeclaration("var", [
            t.variableDeclarator(
              path.node.id,
              entityNameToExpr(path.node.moduleReference),
            ),
          ]),
        );

in packages/babel-plugin-transform-typescript/src/index.ts.

Environment

@babel/plugin-transform-typescript: 7.20.13

Possible solution

Insert

path.scope.registerDeclaration(path);

after this line:

Additional context

No response

Metadata

Metadata

Assignees

Labels

area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions