-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
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-loader (webpack)
Input code
export namespace A {}
export namespace B {
interface C {}
}Configuration file name
.babelrc
Configuration
{
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
],
[
"@babel/preset-typescript",
{
"allowNamespaces": true
}
]
]
}Current and expected behavior
Current behavior:
Babel produces consts and empty functions for these namespaces.
Expected behavior:
Babel should ignore them the same way as TypeScript compiler does.
This is useful when you have a React component and a namespace with the same name containing the Props interface inside. This allows you to import { ComponentName } from './ComponentName' without additional import for Props type by accessing it with ComponentName.Props. Such namespace exists in types scope only and should not affect the resulting code. There is no sense and use of such function produced from these empty namespaces, it's just garbage.
Environment
- Babel version: 7.19.1
- Node version: 16
Possible solution
No response
Additional context
No response
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