0

I would like to have a namespace be the hub of classes for a strategy in my system. The reason it has to be a namespace is that was the best way to do dynamic class generation, as the window object method proved fruitless.

I would like to re-export this file

// Bar.ts export class Bar { public log() {console.log('I'm in Bar);} } 

from the following namespace as such

//Foo.ts export namespace Foo { export Bar from './bar.ts' // <- how do I do this? } 

1 Answer 1

1

You can re-export something you imported outside of the namespace:

import * as BarFile from "./Bar"; export namespace Foo { export import Bar = BarFile.Bar; } 

There may be a better way to export it without the import * as BarFile, but I still use it this way.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a ton! A quick follow up question, what is the syntax export import Bar = BarFile.Bar ? Is there a document page you can quickly recommend to book up on that?
Honestly, I don't know how I know that, I think I searched around when I faced this issue and then I have this code example on my project for some years now. I think this is an extrapolation from the import syntax import _ = require('lodash'); applied to namespace's export <statement>.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.