{"id":24419017,"url":"https://github.com/badbatch/cts-types","last_synced_at":"2025-09-12T23:40:58.828Z","repository":{"id":211804527,"uuid":"728985867","full_name":"badbatch/cts-types","owner":"badbatch","description":"A command line script for generating d.cts files from d.ts files.","archived":false,"fork":false,"pushed_at":"2025-06-21T15:55:38.000Z","size":475,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-25T23:54:46.809Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/badbatch.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-08T06:20:51.000Z","updated_at":"2025-06-21T15:55:41.000Z","dependencies_parsed_at":"2024-01-13T04:01:48.154Z","dependency_job_id":"5f527c1c-6a56-4879-b8b5-71305380d460","html_url":"https://github.com/badbatch/cts-types","commit_stats":null,"previous_names":["badbatch/cts-types"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/badbatch/cts-types","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbatch%2Fcts-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbatch%2Fcts-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbatch%2Fcts-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbatch%2Fcts-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/badbatch","download_url":"https://codeload.github.com/badbatch/cts-types/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbatch%2Fcts-types/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274894072,"owners_count":25369483,"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","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-01-20T09:16:48.610Z","updated_at":"2025-09-12T23:40:58.804Z","avatar_url":"https://github.com/badbatch.png","language":"TypeScript","readme":"# cts-types\n\nA command line script for generating d.cts files from d.ts files.\n\n[![npm version](https://badge.fury.io/js/cts-types.svg)](https://badge.fury.io/js/cts-types)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\nSupporting esmodules and commonjs in the same Typescript library that is itself an esmodule is not straight forward. At the time of creating this library, Typescript's new module resolution strategies requires esmodule libraries that support commonjs to provide a set of types suffixed with `d.cts` instead of `d.ts`.\n\nWithout `d.cts` files, Typescript assumes the library only supports esmodules and throws an error when you try to `require()` the commonjs version of the library. For more information about this, read the Github issue about [NodeNext duel package resolution](https://github.com/microsoft/TypeScript/issues/50466).\n\n`cts-types` streamlines the process of generating `d.cts` files. Just install it as a dev dependency and run the `cts-types build` command in your pipeline after generating the `d.ts` files. The script will not just copy and rename files, it will also update references to `.d.cts` and `.d.cts.map` in the content of a file.\n\n## Install package\n\n```sh\n# terminal\nnpm add cts-types --save-dev\n```\n\n## Usage\n\n```jsonc\n// package.json\n{\n  ...\n  \"types\": \"./dist/types/cjs/index.d.cts\",\n  \"exports\": {\n    \"types\": {\n      \"import\": \"./dist/types/esm/index.d.ts\",\n      \"require\": \"./dist/types/cjs/index.d.cts\"\n    },\n    ...\n  },\n  ...\n  \"scripts\": {\n    ...\n    \"compile:types\": \"tsc --project ./tsconfig.build.json \u0026\u0026 cts-types build dist/types/esm dist/types/cjs\",\n    ...\n  }\n  ...\n}\n```\n\n```jsonc\n// tsconfig.build.json\n{\n  ...\n  \"compilerOptions\": {\n    ...\n    \"outDir\": \"dist/types/esm\"\n    ...\n  },\n  ...\n}\n```\n\n## API\n\n```sh\nctsTypes build \u003cinput\u003e \u003coutput\u003e\n\nBuild .d.cts type files from .d.ts files to provide types for both esm and cjs outputs.\n\nPositionals:\n  input   The directory where the .d.ts files are located, relative to the\n          project root                                       [string] [required]\n  output  The directory where the .d.cts files should be output, relative to the\n          project root                                       [string] [required]\n\nOptions:\n  --version  Show version number                                       [boolean]\n  --help     Show help                                                 [boolean]\n  --verbose  Whether to output verbose logs                            [boolean]\n```\n\n### A note on `output`\n\nThe output should be in the same folder as or a sibling folder of the input in order for the source maps to work correctly. The source maps include a path to the source file and that path is based on the location of the input file. This library does not currently support updating the relative path of source files in the `.map` files.\n\nTo get around this limitation, either do not provide an `output` path (and the output will be written to the `input` path) or have the `output` path leaf directory be a sibling of the `input` path leaf directory, i.e. `input` of `dist/types/esm` and `output` of `dist/types/cjs`.\n\n## Changelog\n\nCheck out the [features, fixes and more](CHANGELOG.md) that go into each major, minor and patch version.\n\n## License\n\ncts-types is [MIT Licensed](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadbatch%2Fcts-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadbatch%2Fcts-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadbatch%2Fcts-types/lists"}