interface Foo {
hello(): string;
}
export default Foo;
假设我想将其重命名为
Bar
.然后我必须这样做:export {Foo as Bar}; // notice there is no `default`
如何重命名和使用
default
同时?
最佳答案
对于默认导出,名称无关紧要。导入时客户端代码可以指定任何他们想要导入的名称
import BarOrWhatever from './Bar'
当您想要重新导出非默认导出时,可以重命名导出。
关于TypeScript 导出和重命名默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54514212/