Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do re-export with overrides?

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

I would like to avoid picking out all named exports just to re-export them;

import { a, b, c, d, e, ..... } from 'some-library'
export { a, b, c, d, e, .... }
export * from './myOverrides'
like image 989
unional Avatar asked Dec 22 '16 23:12

unional


2 Answers

From Guy Sensei:

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

I need to:

import { theFunction } from './myOverrides'

export * from 'some-library'
export { theFunction }

This works because local exports take priority.

like image 125
unional Avatar answered Oct 28 '22 19:10

unional


I found this to work quite nicely:

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

export default { ...packageA, ...packageB };
like image 30
Kangzeroo Avatar answered Oct 28 '22 18:10

Kangzeroo