TypeScript Reference ยท tsconfig: Type Checking Options
TypeScript stripInternal option
Reference for stripInternal: how the @internal JSDoc tag removes declarations from generated .d.ts files, what it does not hide and its pitfalls.
stripInternal removes any declaration annotated with the @internal JSDoc tag from the .d.ts files that tsc generates. The code still exists in the emitted JavaScript and is still usable inside your package. Only the published type information hides it, so consumers get compile errors if they try to use it.
It is meant for library authors who need helpers to be shared between their own files but not to appear in the public API. The option only has an effect when declaration output is on (declaration or composite).
export class Cache { /** @internal */ _evictAll(): void {} get(key: string): string | undefined { return undefined; } }
Try it
The option changes generated .d.ts files, which this runner does not show. These examples show the runtime side and a rough model of the output.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Syntax
{ "compilerOptions": { "declaration": true, "stripInternal": true } }
| Part | Description |
|---|---|
| Type | boolean. Default: false. |
| Command line | tsc --declaration --stripInternal |
| Trigger | A JSDoc comment containing @internal directly before a declaration (class member, function, interface, type alias, variable, property signature). |
Usage notes
- It is a declaration-emit feature. The JavaScript output still contains the code, so it is not a security boundary or a way to make something private at runtime.
- Types that mention an
@internaldeclaration in their public signature break: the compiler does not warn, and the generated.d.tsrefers to a name that no longer exists. Keep internal types out of public signatures. - Tools such as API Extractor offer richer release tags (
@public,@beta) if you need more than a single level. - With project references, a stripped declaration is hidden from the other projects too, so shared internals between sibling packages must not use the tag.
- The tag is not recognised in
.jsfiles unless declaration emit is configured for JavaScript. - Prefer real language features first:
private,#privateand not exporting a name at all are checked by the compiler and need no option.