I'm writing typings for a package to contribute to DefinitelyTyped, so the file I'm creating will be resolved in module context. This is simple enough, along the lines of
import { A } from "package-a";
export function B(): void;
However, I'd like to declare a few types and interfaces that are not useful to consumers of the package, but make the declarations easier to read and write:
type ArgType = string | ArrayBuffer | Uint8Array | Readable | ReadableStream;
export function foo(x: ArgType): void;
export function bar(x: ArgType): string;
export function baz(x: ArgType): number;
The problem is, as soon as I declare ArgType
at the top level, it's actually exported from the module along with foo
, bar
, and baz
. This means ArgType
shows up in the language service for auto-complete, etc, which looks messy. It also happens with interfaces and namespaces.
dtslint
has an error for this, strict-export-declare-modifiers
, which is how I first discovered this behavior. As far as I can tell, this isn't a problem when writing an actual TS module (vice a declaration / typings file). Is it not possible to declare something in this file that the consumer won't see?