deno_lint icon indicating copy to clipboard operation
deno_lint copied to clipboard

Lint for Implicitly Exported Types in Declare Namespace

Open sno2 opened this issue 1 year ago • 0 comments

Hello, as https://github.com/denoland/deno/issues/14976 has shown, it can be hard to realize TypeScript's default behavior of exporting all types in a declare namespace block. It might be beneficial to add an optional lint (something like no_implicit_declare_namespace_export) onto type and interface members that are implicitly exported. This should be able to help stop further costly bugs from happening in Deno and elsewhere.

Example code:

declare namespace ResourceHandler {
  type FormatResource<T extends string> = `resource-${T}`;
}

Output:

Type 'FormatResource' is implicitly exported from the 'ResourceHandler' namespace. Try adding an 'export {};' to the top of the namespace to disable this behavior.

And the suggestion could be integrated into editors. Thanks

sno2 avatar Jul 04 '22 05:07 sno2