microsoft / microsoft/TypeScript
export import in declare module
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Suggestion
🔍 Search Terms
declare module enum export import
✅ Viability Checklist
My suggestion meets these guidelines:
- [v] This wouldn't be a breaking change in existing TypeScript/JavaScript code
- [v] This wouldn't change the runtime behavior of existing JavaScript code
- [v] This could be implemented without emitting different JS based on the types of the expressions
- [v] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- [v] This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
Allow export import for types and values in declare module
📃 Motivating Example
declare module './back_module' {
/** @deprecated for backward compatible */
export import EnumType = import('./front_module').EnumType; // Suggestion feature
}
(back_module as any).RawTypeId = front_module.RawTypeId;
// ...
import { EnumType } from './back_module';
type foobar = EnumType.Value; // it's impossible with just `type =` and `let =`
type foobar2 = OnlyForEnumType<EnumType>; // it's impossible if enum is new
💻 Use Cases
I moved EnumType to a different module but I wish to keep it backward compatible.
and back_module cannot import front_module for my situation.
So I want to declare it on the other module which combines them.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the motivating example and the existing handling of declare module, import types, and export assignments. Determine how TypeScript would represent export import for both types and values without changing emitted JavaScript; done means the back_module declaration supports the shown EnumType usage while preserving backward compatibility.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100