Reputation: 7438
I'm trying to re-export everything in a namespace from a new module. I've tried the following, which works to a degree:
// index.ts
import * as foo from 'foo';
function myFunction() {}
// Re-export everything in 'foo' along with myFunction
const thing = {
...foo,
myFunction,
}
export = thing;
This results in a type declaration as follows:
import * as foo from 'foo';
declare function myFunction();
declare const thing: {
Foo: typeof foo.Foo;
Bar: typeof foo.Bar;
myFunction: typeof myFunction;
};
export = thing;
But when I try to consume the types from the generated d.ts
file, I get an error:
'Foo' refers to a value, but used as a type
I suppose this is because Foo
and Bar
as declared as members of an object. Is there a way to achieve this re-export of existing types in a new module?
Upvotes: 0
Views: 1013
Reputation: 25790
Have you tried this?
export * from 'foo';
export function myFunction() {}
Upvotes: 2