Typescript - Import Namespace Into Another Namespace

Viewed 3683

I'm wondering if it's possible to export a namespace from one typescript .d.ts file and then import that namespace into another .d.ts file where it gets used inside of a namespace.

Example:

namespace_export.d.ts

export namespace Foo {
    interface foo {
        prop1: string;
    }
}

types.d.ts

import { Foo } from './namespace_export'

export namespace Types {
    Foo // <-- This doesn't work but is what I would like
    interface Bar {
        prop2: string
    }
}

testfile.ts

import { Types } from './types'

function testTypes(type: Types.Foo.foo) {
    console.log(type);
}
1 Answers
Related