question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Name overload term/type module re-export as namespace

See original GitHub issue

Suggestion

🔍 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

CleanShot 2022-10-08 at 08 39 55@2x

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:open
  • Created a year ago
  • Reactions:5
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
cruhlcommented, Oct 25, 2022

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.

3reactions
MartinJohnscommented, Oct 8, 2022
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found