{"id":13834677,"url":"https://github.com/cprecioso/ts-trim-declarations","last_synced_at":"2025-03-24T23:35:29.868Z","repository":{"id":57381248,"uuid":"310130858","full_name":"cprecioso/ts-trim-declarations","owner":"cprecioso","description":null,"archived":false,"fork":false,"pushed_at":"2020-11-05T10:39:38.000Z","size":667,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-13T09:51:22.328Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cprecioso.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-04T22:21:15.000Z","updated_at":"2020-11-05T10:39:40.000Z","dependencies_parsed_at":"2022-09-26T16:41:19.428Z","dependency_job_id":null,"html_url":"https://github.com/cprecioso/ts-trim-declarations","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cprecioso%2Fts-trim-declarations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cprecioso%2Fts-trim-declarations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cprecioso%2Fts-trim-declarations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cprecioso%2Fts-trim-declarations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cprecioso","download_url":"https://codeload.github.com/cprecioso/ts-trim-declarations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245372220,"owners_count":20604488,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T14:00:50.868Z","updated_at":"2025-03-24T23:35:29.849Z","avatar_url":"https://github.com/cprecioso.png","language":"TypeScript","funding_links":[],"categories":["Transformers"],"sub_categories":["General transformers"],"readme":"# ts-trim-declarations\n\nCustom transformer for [TypeScript](https://www.typescriptlang.org/) that\nremoves type declarations with `/** @internal */` JSDoc comments (or whatever\nother tags you specify!). Inspired by\n[`@microsoft/api-extractor`](https://api-extractor.com/).\n\nCustom transformers can't be (yet) used with plain typescript, you're encouraged\nto use [`ttypescript`](https://github.com/cevek/ttypescript), or plugins to your\nbuild tool of choice, especially\n[`@wessberg/rollup-plugin-ts`](https://github.com/wessberg/rollup-plugin-ts).\nFor other build tools, refer to their documentation on how to use TypeScript\nCustom Transformers.\n\n## Effect\n\nIt will remove the declarions tagged with the specified JSDoc comments\n(`/** @internal */` by default) from the `.d.ts` file output, so they will\n**not** be documented. Users of your library trying to use these methods,\nproperties, exports, etc. will get a typechecking error, and automated\ndocumentation generators like\n[`@microsoft/api-documenter`](https://github.com/microsoft/rushstack/tree/master/apps/api-documenter)\nwill not export their typings.\n\nFor example, this `source.ts`:\n\n```patch\n class MyClass {\n+  /** @internal */\n   protected _foo() {\n     return \"very internal string\"\n   }\n\n   bar() {\n     const publicString = this._foo().toUpperCase()\n     // Now it's ready for public usage!\n     return publicString\n   }\n }\n```\n\nwill output the following `source.d.ts`:\n\n```patch\n declare class MyClass {\n-  protected _foo(): string\n   bar(): string\n }\n```\n\n## Installation\n\n```sh\n$ yarn add --dev ts-trim-declarations\n```\n\nor\n\n```sh\n$ npm install --save-dev ts-trim-declarations\n```\n\nthen add the Custom Transformer to your build tool's configuration\n\n### `ttypescript`\n\nAdd this field to your `tsconfig.json` (only works from Node.js 12.7 onwards):\n\n```patch\n {\n   // ..\n   \"compilerOptions\": {\n     \"plugins\": [\n        // ...\n+       { \"transform\": \"ts-trim-declarations/raw\", \"type\": \"raw\" }\n     ]\n   }\n }\n```\n\n### `rollup` and `@wessberg/rollup-plugin-ts`\n\nAdd this plugin to the object exported from `rollup.config.js`:\n\n```patch\n// ...\n import ts from \"@wessberg/rollup-plugin-ts\"\n+import tsTrimDeclarations from \"ts-trim-declarations\"\n\n export default {\n   // ...\n   plugins: [\n     // ...\n     ts({\n       // ...\n       transpiler: \"typescript\",\n       transformers: [\n         // ...\n+        tsTrimDeclarations(),\n       ],\n     }),\n   ],\n }\n```\n\n### TypeScript API\n\nCheck out this\n[TypeScript's issue](https://github.com/Microsoft/TypeScript/pull/13940) to\nlearn about their API.\n\n### Other build tools\n\nPlease refer to your build tool's documentation for information on hwo to use\nTypeScript Custom Transformers\n\n## Options\n\nImporting `ts-trim-declarations` will give you a function you can call with an\narray of JSDoc tags to remove. The default is `[\"internal\"]`-\n\n```js\nimport tsTrimDeclarations from \"ts-trim-declarations\"\n// ...\ntsTrimDeclarations(isBeta ? [\"internal\"] : [\"internal\", \"beta\"])\n// Will remove all declarations with `/** @internal */, but will only remove\n// the `/** @beta */` declarations when `isBeta === true`.\n```\n\nThe `ts-trim-declarations/raw` import will forgo the function call and give you\na straight Custom Transformer that removes only `/** @internal */` tags.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcprecioso%2Fts-trim-declarations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcprecioso%2Fts-trim-declarations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcprecioso%2Fts-trim-declarations/lists"}