interface Foo {
hello(): string;
}
export default Foo;
Suppose I want to rename it to Bar
. Then I must do this:
export {Foo as Bar}; // notice there is no `default`
How do I rename and use default
at the same time?
For default exports the name does not matter. When importing the client code can specify whatever name they want for the import
import BarOrWhatever from './Bar'
The ability to rename exports is there when you want to re-export non-default exports.
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