我可以:
import * as foo from './foo'
但似乎不能出口同样的产品:
export * as foo from './foo'
这似乎也不管用…:
import * as fooImport from './foo';
export const foo = fooImport;
有什么 idea 吗?
---更新---
你想要实现什么?
基本上,我正在为我的应用程序实现一个ngrx/store
后端.我想这样组织我的代码:
app/core/
index.ts
viewer/
index.ts
viewer-actions.ts
viewer-reducer.ts
view-data/
index.ts
view-data-actions.ts
view-data-reducer.ts
我想用我的index.ts
个文件来链接每个子集的所有导出(通用范例).
然而,我想保留一些东西.我的xxx-reducer.ts
个和xxx-actions.ts
个文件中的每个文件都有相同名称的导出(reducer
、ActionTypes
、Actions
,…)所以正常的链接会导致名称冲突.我想做的是让xxx-actions
和xxx-reducer
的所有出口都变成re-exported和xxx
.这将使我能够:
import { viewer, viewerData } from './core';
...
private viewer: Observable<viewer.Viewer>;
private viewData: Observable<viewData.ViewData>;
ngOnInit() {
this.viewer = this.store.let(viewer.getViewer());
this.viewData = this.store.let(viewData.getViewData());
}
而不是更冗长的:
import * as viewer from './core/viewer';
import * as viewerData from './core/viewer-data';
...
这就是要点...