-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[Bug]: TypeScript import alias can cause import to be incorrectly removed #14912
Copy link
Copy link
Closed
Closed
Copy link
Labels
area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
💻
- Would you like to work on a fix?
How are you using Babel?
@babel/cli
Input code
import * as babel from '@babel/core';
import {MyNamespace} from 'myimport';
import b = babel;
import x = MyNamespace.x;Configuration file name
No response
Configuration
module.exports = {
plugins: [
"@babel/plugin-transform-typescript"
]
};Current and expected behavior
Both imports should be retained, however the second import is incorrectly removed.
Output:
import * as babel from '@babel/core';
var b = babel;
var x = MyNamespace.x;expected output:
import * as babel from '@babel/core';
import {MyNamespace} from 'myimport'
var b = babel;
var x = MyNamespace.x;The code is incorrect and fails at runtime with MyNamespace being undefined.
The unit test test case for the import alias feature tests the first style of import but not the second.
Environment
- @babel/core: 7.19.0
- @babel/cli: 7.18.10
- @babel/plugin-transform-typescript: 7.19.0
Possible solution
retain the import in the generated code.
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue