-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[@babel/preset-typescript] Namespace alias (native TS feature) is not supported #12345
Comments
Hey @alker0! 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." |
See https://babeljs.io/docs/en/babel-plugin-transform-typescript#caveats:
|
This input code is in only one file. // some-file.ts
declare module LongNameModule {
export type SomeType = number;
}
import AliasModule = LongNameModule; // this is also in some-file.ts
const some: AliasModule.SomeType = 3;
console.log(some); I tried this command: // some-file.js
const some = 3;
console.log(some); This is just to create module name alias in same file, and it also works when target is It does not seem to be same feature that is I want to use this feature for development of the browser scripts. Can this preset not support this feature? |
This is the official documentation: https://www.typescriptlang.org/docs/handbook/namespaces.html#aliases
The babel documentation @mischnic quoted seems to mention loading modules, but this is not what I mention. I should have called this feature "Namespace alias" rather than "Module alias". |
This is something that we can support. When we wrote those docs, what we wanted to disallow was |
Hi, Is there any news regarding this ? I looked around for a plugin to use as a workaround until Babel support namespace aliases but no luck :( |
I'm struggling with the same problem right now. |
I would like to work on this! |
support `import alias = Namespace`, reject `import alias = require('foo')` fix babel#12345
support `import alias = Namespace`, reject `import alias = require('foo')` fix #12345
Bug Report
import RenamedModule = OriginalModule
is native Typescript's feature for creating module alias but@babel/preset-typescript
does not allow this syntax.Current behavior
@babel/preset-typescript
gives an error.Input Code
Expected behavior
It outputs:
3
.Using
tsc
andts-node
, it is compiled as expected.Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
babel.config.js
Environment
Possible Solution
I have no idea.
The text was updated successfully, but these errors were encountered: