Skip to content

Exporting imported types as a namespace #20273

Closed
@ORESoftware

Description

@ORESoftware

This question is a bit tricky and I fear I won't get an answer on StackOverflow:

the question is here:
https://stackoverflow.com/questions/47500855/exporting-imports-as-a-namespace-with-typescript

Essentially I want to group together various types from other files into one namespace X. So the types are not declared in namespace X, but they are later grouped into namespace X after the fact. Hopefully that makes sense.

A simple scenario would look like:

import {p} from 'q';
import {foo} from 'bar';
import {zim} from 'zoom';

export namespace X {
    export p;             //  this syntax is not real, don't know what the right 
    export foo;           //  syntax is in actuality
    export zim;
}

we can sort of do this with a const:

export const X = {
  p,
  foo,
  zim
}

but the problem is, for interfaces, I get the error:

only refers to a type, but is being used as a value here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions