Add using namespace
statement
#53095
Labels
Out of Scope
This idea sits outside of the TypeScript language design constraints
Suggestion
An idea for TypeScript
Suggestion
π Search Terms
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Add a statement similar to
using namespace NS;
in C++, that allows to append members of an object/namespace/module to the global scope or function scope during compile time.π Motivating Example
Using namespace in global scope
TypeScript:
Compiled JavaScript:
Using namespace in function scope
TypeScript:
Compiled JavaScript:
Using namespace not allowed
Extending another module
π» Use Cases
Currently, I have to use
ModuleName.memberName
statement to access a member declared inside a module. This doesn't have many effects when you only have a few references, but I have far more than the acceptable amount just in one file. It makes your function lines longer, affects the readability of the code, and wastes a lot of time on just on typing out the module name.The text was updated successfully, but these errors were encountered: