Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ways to do an alias of an exported type inside a namespace #40771

Open
paztis opened this issue Sep 25, 2020 · 2 comments
Open

No ways to do an alias of an exported type inside a namespace #40771

paztis opened this issue Sep 25, 2020 · 2 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Milestone

Comments

@paztis
Copy link

paztis commented Sep 25, 2020

TypeScript Version: 3.9.7

Search Terms:
export type alias namespace

Code
With import type, in case of long namespaces encapsulation, there's no way to do an alias of the namespaces.
We are forced to alias the final types / interfaces

file types.ts

type A = {}
type B = {}
type C = {}

export type {
    A,
    B,
    C
};

file namespace1.ts

import type * as namespace1 from 'types';

export type {namespace1}

file namespace2.ts

import type * as namespace2 from 'namespace1';

export type {namespace2}

file finalUsage.ts

import type {namespace2} from 'namespace2';

type A = namespace2.namespace1.A; // this is working
namespace aliasNamespaces2 {
   export import namespace1 = namespace2.namespace1; // fails with message 'An import alias cannot reference a declaration that was imported using 'import type'. '
}

Expected behavior:
we need a way to make a shortcut of namespaces2.namespace1

Actual behavior:
Cannot do it: we are forced to aliasthe final types namespaces2.namespace1.A

Playground Link:

Related Issues:

@andrewbranch andrewbranch added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript labels Sep 25, 2020
@andrewbranch andrewbranch added this to the Backlog milestone Sep 25, 2020
@paztis paztis changed the title No was to do an alias of an exported type inside a namespace No ways to do an alias of an exported type inside a namespace Sep 28, 2020
@harrysolovay
Copy link

I've also run into this limitation. Frustrating that one cannot re-export within a namespace.

@cruhl
Copy link

cruhl commented Dec 8, 2020

Relevant: #39865

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants