Provide a way to alias namespaces
See original GitHub issueTypeScript should have a way to embed (type) namespaces. In the following case, assigned (embeded) namespace NS.A should have a C type.
TypeScript Version: master
Code
namespace NS_A {
export class C {
}
}
namespace NS {
export var A = NS_A;
export type A = NS_A;
}
var C = NS.A.C;
type C = NS.A.C;
Expected behavior:
$ node built/local/tsc.js --lib es6 -m commonjs --noEmit index.ts
Actual behavior:
$ node built/local/tsc.js --lib es6 -m commonjs --noEmit index.ts
index.ts(7,19): error TS2304: Cannot find name 'NS_A'.
index.ts(10,13): error TS2305: Module 'NS' has no exported member 'A'.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:25
- Comments:17 (11 by maintainers)
Top Results From Across the Web
Namespace aliases - cppreference.com
Namespace aliases allow the programmer to define an alternate name for a namespace. They are commonly used as a convenient shortcut for long...
Read more >In C++, what is a "namespace alias"? - Stack Overflow
A namespace alias is a convenient way of referring to a long namespace name by a different, shorter name. As an example, say...
Read more >How to use :: Namespace Alias Qualifier in C# - GeeksforGeeks
Namespace Alias Qualifier(::) makes the use of alias name in place of longer namespace and it provides a way to avoid ambiguous definitions ......
Read more >Creating an alias for a nested namespace (C++ only) - IBM
Namespace definitions hold declarations. Since a namespace definition is a declaration itself, namespace definitions can be nested. An alias can also be applied ......
Read more >One of C++ most underrated features: Namespace aliases
In case you didn't know (which is likely): A namespace alias is just that - an alias for a namespace. Just like a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve been thinking about this as well. We have
var
/const
to alias a value, andtype
to alias a type, but no equivalent for namespace. We could even considerfor establishing namespace aliases.
stumbled upon this issue, it looks like this feature is supported now see doc here https://www.typescriptlang.org/docs/handbook/namespaces.html#aliases @falsandtru if that answer your question you might want to close this issue