Typescript provides a mechanism to not include internal code in a declaration file. It can be useful for building a public library.
We can use the stripInternal: true
property in our tsconfig.json file. This will enable typescript compiler to check the /** @internal */
JS DOC comment.
main.ts
Add the /** @internal */
JS DOC comment .
By default typescript compiler will ignore this comment but we can enable it in tsconfig.json file.
/** @internal */
function init() {
console.log('Hello!!')
}
In tsconfig.json
{
"compilerOptions": {
"outDir": "./dist",
"declaration": true,
"stripInternal": true
}
}
Compile and check your declaration main.d.ts
(in this case it will have the same name as main.ts file) file to not include the init function declaration.
Top comments (0)