Name overload term/type module re-export as namespace
See original GitHub issueSuggestion
🔍 Search Terms
I wasn’t sure what terms to be searching for this.
✅ Viability Checklist
My suggestion meets these guidelines:
- This wouldn’t be a breaking change in existing TypeScript/JavaScript code
- This wouldn’t change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn’t a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript’s Design Goals.
⭐ Suggestion
Currently this is possible:
export type A = 1
export namespace A {
export const foo = 2
}
import { A } from './a.js'
console.log(A.foo)
const A: A = 2 // type errror
However this is not possible:
export type A = 1
export * as A from './something/else/somewhere/else.js'
📃 Motivating Example
I want to be able to reuse a name for a type and namespace for more streamlined downstream usage.
💻 Use Cases
All the same use-cases there already are today for namespace
name overloading between terms/types.
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:13 (1 by maintainers)
Top Results From Across the Web
How to re-export the child namespace in TypeScript?
I see two options here: Explicitly export the nested namespace; Extract the nested namespace. Option 1. When working with namespaces, ...
Read more >Documentation - Namespaces - TypeScript
This post outlines the various ways to organize your code using namespaces (previously “internal modules”) in TypeScript. As we alluded in our note...
Read more >Modules and Namespaces — Idris 0.9.18 documentation
The module A will export the name a , as well as any public or abstract names in module C , but will...
Read more >Overview of modules in C++ - Microsoft Learn
A module interface exports the module name and all the namespaces, types, functions, and so on that make up the public interface of...
Read more >Modules and Namespaces — Idris 1.3.3 documentation
Each module includes an optional module declaration giving the name of the module, ... Additionally, a module can re-export a module it has...
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 have been trying to get something like this working for literal years now.
It would dramatically help write better functional/Rust-module-style code.
I believe this to be a duplicate of https://github.com/microsoft/TypeScript/issues/48764#issuecomment-1102818406.