带有嵌套别名的Typescript export *

时间:2017-04-04 22:02:29

标签: typescript

基本上,我想做类似的事情:

export * as services.* from "./services";

解决方法是:

import * as _services from "./services";
export const services = _services;

有更好的方法吗?

1 个答案:

答案 0 :(得分:1)

现在有办法处理通配符导出而不是模块加载器。基本上,您将在services文件夹中有一个索引文件,该文件单独导出服务:

export * from './services.service1';
export * from './services.service2';
export * from './services.service3';

然后您可以从索引导入所有内容:

import { * } from './services';
BTW:这不是最佳做法,鼓励不要使用。

请看here