如何使用替换进行重新导出?

时间:2016-12-22 23:24:30

标签: javascript typescript ecmascript-6

export * form 'some-library'
export * from './myOverrides'
// error: [ts] Module 'some-module' has already
// exported a member named 'someFunc'.
// Consider explicitly re-exporting to resolve the ambiguity.

import * as SomeLib from 'some-library'
import * as MyOverrides from './myOverrides'

export { ...SomeLib, ...MyOverrides } // syntax error

const Overridden = { ...someLib, ...MyOverrides } // works
export { ...Overridden } // syntax error

我想避免选择所有已命名的导出只是为了重新导出它们;

import { a, b, c, d, e, ..... } from 'some-library'
export { a, b, c, d, e, .... }
export * from './myOverrides'

2 个答案:

答案 0 :(得分:5)

来自Guy Sensei:

https://github.com/systemjs/systemjs/issues/1031#issuecomment-171262430

我需要:

header("path/to/your/page");

这是有效的,因为本地出口优先。

答案 1 :(得分:1)

我发现这很好用:

import * as packageA from "packageA";
import * as packageB from "packageB";

export default { ...packageA, ...packageB };