-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Hello, will it be possible to merge declarations, like that:
module Hello {
export const A = 3;
}
module Hello {
export const B = 4;
}
console.log(Hello.A, Hello.B) // 3, 4
This is how namespaces
works in typescript (previously they called modules). Playground
One huge benefit of namespaces is that they can be merge with functions declarations. Playground
function Hello() {
return 3
}
namespace Hello {
export const meta = 4
}
console.log(Hello(), Hello.meta) // 3, 4
This is a widely used pattern i.e. in react. Playground
export function Component(props: PropsWithChildren) {
return <div>{props.children}</div>
}
export namespace Component {
export function Icon() {
return <i className="icon" />
}
}
Metadata
Metadata
Assignees
Labels
No labels