- Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Search Terms
module namespace declaration rexporting
Suggestion
When trying to export types in an index.ts
, currently one must redefine those types in the barrel.
e.g.
Consumer
import { myModule } from 'my-module' function foo(bar: myModule.MyClass) { }
MyModule
Currently developers must export their variables and export their types too, but types must be redeclared.
// my-module/index.ts import * as myClass from './my-class'; export const myModule = { ...myClass } export declare namespace myModule { export type MyClass<T> = myClass.MyClass<T> }
Suggestion
Would be nice if developers could just embed the type in the namespace
// my-module/index.ts import * as myClass from './my-class'; export const myModule = { ...myClass } export declare namespace myModule { export types from './my-class' }
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, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript