Today I am using import aliasing to change the name of an import in React:
import { Something as SomethingElse } from 'somewhere';
However, after switching this file over to TypeScript, the same thing doesn't seem possible. Only after removing the alias am I able to use the import:
import Something from 'somewhere';
Is it possible to use an import alias in TypeScript?
That's a default export, so you could just name it whatever you want:
import SomethingElse from 'somewhere';
These default exports are written like:
export default ...
and you can check out some other explanations here.
You may also be interested in the options allowSyntheticDefaultImports and esModuleInterop if you can't get it to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With