{"id":13066,"library":"dets","title":"dets: TypeScript Declaration Bundler","description":"dets is a utility for bundling TypeScript declaration files (`.d.ts`) into a single output file. Its primary use case is to create isolated declaration files that do not depend on external declaration packages or to selectively export a public API. Currently at version `0.17.0`, the project appears to have a regular, albeit minor, release cadence with frequent bug fixes and dependency updates, indicating active maintenance. Key differentiators include its ability to ignore, remove, or preserve specific properties and inheritance clauses within declarations using special JSDoc-like comments (`@ignore`, `@dets_preserve`, `@dets_removeprop`, `@dets_removeclause`), offering fine-grained control over the generated declaration file content. It supports both CLI and programmatic usage in Node.js environments.","status":"active","version":"0.17.0","language":"javascript","source_language":"en","source_url":"https://github.com/FlorianRappl/dets","tags":["javascript","typescript","declaration","bundler","tds","file","generate","types"],"install":[{"cmd":"npm install dets","lang":"bash","label":"npm"},{"cmd":"yarn add dets","lang":"bash","label":"yarn"},{"cmd":"pnpm add dets","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for TypeScript compilation and declaration processing.","package":"typescript","optional":false}],"imports":[{"note":"This is the core programmatic function for bundling multiple TypeScript files into a single declaration file. dets primarily uses ESM internally, so direct CommonJS `require` might lead to issues without proper transpilation.","wrong":"const { processFiles } = require('dets');","symbol":"processFiles","correct":"import { processFiles } from 'dets';"},{"note":"Type definition for configuring the behavior of `processFiles` and other programmatic functions. Essential for type-safe API calls.","symbol":"DetsOptions","correct":"import { DetsOptions } from 'dets';"},{"note":"This function is the direct entry point for the CLI. While available programmatically, it's generally not recommended for embedding within applications as it handles command-line argument parsing and process exit.","wrong":"import run from 'dets';","symbol":"run","correct":"import { run } from 'dets';"}],"quickstart":{"code":"import { processFiles } from 'dets';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nconst projectRoot = path.resolve('./');\nconst tempDir = path.join(projectRoot, 'temp_dets_example');\nfs.mkdirSync(tempDir, { recursive: true });\n\n// Create some dummy TypeScript files\nfs.writeFileSync(path.join(tempDir, 'types.ts'), `\nexport interface User {\n  id: string;\n  name: string;\n  /** @ignore */\n  secret: string;\n}\n`);\n\nfs.writeFileSync(path.join(tempDir, 'index.ts'), `\nimport { User } from './types';\nexport function getUserName(user: User): string {\n  return user.name;\n}\nexport const APP_VERSION = '1.0.0';\n`);\n\nasync function bundleDeclarations() {\n  try {\n    const output = await processFiles({\n      entry: [path.join(tempDir, 'index.ts')],\n      files: [path.join(tempDir, '**/*.ts')],\n      name: 'my-library',\n      noIgnore: false, // Enable @ignore comments\n      out: path.join(tempDir, 'my-library.d.ts')\n    });\n\n    console.log('Generated Declaration File:');\n    console.log(output);\n    console.log(`\nCheck the output file at ${path.join(tempDir, 'my-library.d.ts')}`);\n\n  } catch (error) {\n    console.error('Error bundling declarations:', error);\n  } finally {\n    // Clean up temporary files\n    fs.rmSync(tempDir, { recursive: true, force: true });\n    console.log('Cleaned up temporary directory.');\n  }\n}\n\nbundleDeclarations();\n","lang":"typescript","description":"This quickstart demonstrates programmatic bundling of TypeScript declaration files using `processFiles`. It creates a temporary project structure, defines interfaces and functions, and then uses `dets` to generate a single `.d.ts` file, respecting `@ignore` comments."},"warnings":[{"fix":"Upgrade your Node.js environment to version 18.17 or higher.","message":"Starting with version `0.17.0`, Node.js 16 is no longer supported. The minimum required Node.js version is `18.17` or later.","severity":"breaking","affected_versions":">=0.17.0"},{"fix":"Review the documentation for special comments and ensure they are applied correctly. Use the `--no-ignore` CLI flag or `noIgnore` programmatic option if you wish to disable processing of `@ignore` tags.","message":"dets relies on specific JSDoc-like comments (`@ignore`, `@dets_preserve`, `@dets_removeprop`, `@dets_removeclause`) to modify the output declaration file. Forgetting or misusing these comments can lead to unexpected declaration content.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure `typescript@^4.0.0 || ^5.0.0` is installed in your project. You might need to update your `package.json` and run `npm install`.","message":"The `typescript` package is a peer dependency, requiring version `4.x` or `5.x`. Installing an incompatible version or failing to install it can lead to runtime errors.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Double-check your `entry` and `files` paths/globs. Use a tool like `glob` or `ls` with your pattern to verify it matches the intended files before running `dets`.","message":"When specifying input files, especially with glob patterns, ensure they correctly resolve to your source TypeScript files. Incorrect paths or globs can result in empty or incomplete declaration files.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Install 'dets' locally using `npm install --save-dev dets` or globally with `npm install -g dets` if using the CLI globally.","cause":"The 'dets' package is not installed or not resolvable in the current environment.","error":"Error: Cannot find module 'dets'"},{"fix":"Upgrade your Node.js environment to version 18.17 or newer using `nvm` or your preferred Node.js version manager.","cause":"Your current Node.js version is older than the minimum requirement (18.17) for dets v0.17.0+.","error":"TypeError: 'identifier' is not a valid Node.js version. dets requires Node.js >= 18.17."},{"fix":"Install 'typescript@^4.0.0 || ^5.0.0' in your project. E.g., `npm install typescript@latest --save-dev`.","cause":"The required peer dependency 'typescript' (version 4.x or 5.x) is missing or an incompatible version is installed.","error":"Error: Peer dependency 'typescript' is not installed or its version is incompatible."},{"fix":"Verify that the `entry` and `files` options (CLI flags `--entry`, `--files` or programmatic options) correctly point to your TypeScript source files. Ensure glob patterns are expanded as expected.","cause":"Input entry files or file globs are incorrect, leading `dets` to process no or only a subset of the intended source files.","error":"Bundling result is an empty string or incomplete declaration file."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"dets"}