{"library":"npm-dts","title":"NPM DTS Single File Generator","description":"npm-dts is a utility designed to consolidate all TypeScript declaration files (.d.ts) generated for an NPM package into a single index.d.ts file. This enables library developers to distribute bundled JavaScript code while providing comprehensive type definitions, ensuring full type-checking and IDE intellisense for consumers without exposing the original TypeScript source. The current stable version is 1.3.13. While a specific release cadence isn't published, the incremental versioning suggests regular, feature-driven updates. Its primary differentiator is simplifying the distribution of type definitions for compiled libraries, acting as a post-processing step for `tsc` output to create a unified declaration bundle, making library consumption straightforward for TypeScript users. It operates primarily via a command-line interface, requiring `typescript` to be installed in the consuming project's `node_modules`.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install npm-dts"],"cli":{"name":"npm-dts","version":null}},"imports":["import { generate } from 'npm-dts';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// package.json (inside your library project)\n{\n  \"name\": \"my-library\",\n  \"version\": \"1.0.0\",\n  \"main\": \"dist/index.js\",\n  \"types\": \"dist/index.d.ts\", // Point to the generated declaration file\n  \"devDependencies\": {\n    \"typescript\": \"^5.0.0\", // Required peer dependency for npm-dts\n    \"npm-dts\": \"^1.3.0\"\n  },\n  \"scripts\": {\n    \"build:ts\": \"tsc\", // Standard TypeScript compilation\n    \"build:dts\": \"npm-dts generate --output dist/index.d.ts\", // Generate bundled d.ts\n    \"build\": \"npm run build:ts && npm run build:dts\"\n  },\n  \"files\": [\n    \"dist\"\n  ]\n}\n\n// src/index.ts (example source file)\nexport function greet(name: string): string {\n  return `Hello, ${name}!`\n}\n\nexport interface User {\n  id: number;\n  name: string;\n}\n\nexport class Greeter {\n  constructor(private message: string) {}\n  sayHello(): string {\n    return this.message;\n  }\n}\n\n// To run this after project setup:\n// 1. npm install\n// 2. npm run build\n// This will compile TS to JS, then bundle all .d.ts files into a single dist/index.d.ts.","lang":"typescript","description":"Demonstrates how to integrate `npm-dts` into a `package.json` script to generate a single `index.d.ts` file after TypeScript compilation for a library project.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}