Registry / serialization / dets
library0.17.0jsnpmunverified

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.

npm install dets
INSTALL
IMPORT
SIG · DETS
D
dets
serializationjavascriptv0.17.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

processFiles
import { processFiles } from 'dets';
const { processFiles } = require('dets');
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.
DetsOptions
import { DetsOptions } from 'dets';
Type definition for configuring the behavior of `processFiles` and other programmatic functions. Essential for type-safe API calls.
run
import { run } from 'dets';
import run from 'dets';
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.

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.

import { processFiles } from 'dets'; import * as fs from 'fs'; import * as path from 'path'; const projectRoot = path.resolve('./'); const tempDir = path.join(projectRoot, 'temp_dets_example'); fs.mkdirSync(tempDir, { recursive: true }); // Create some dummy TypeScript files fs.writeFileSync(path.join(tempDir, 'types.ts'), ` export interface User { id: string; name: string; /** @ignore */ secret: string; } `); fs.writeFileSync(path.join(tempDir, 'index.ts'), ` import { User } from './types'; export function getUserName(user: User): string { return user.name; } export const APP_VERSION = '1.0.0'; `); async function bundleDeclarations() { try { const output = await processFiles({ entry: [path.join(tempDir, 'index.ts')], files: [path.join(tempDir, '**/*.ts')], name: 'my-library', noIgnore: false, // Enable @ignore comments out: path.join(tempDir, 'my-library.d.ts') }); console.log('Generated Declaration File:'); console.log(output); console.log(` Check the output file at ${path.join(tempDir, 'my-library.d.ts')}`); } catch (error) { console.error('Error bundling declarations:', error); } finally { // Clean up temporary files fs.rmSync(tempDir, { recursive: true, force: true }); console.log('Cleaned up temporary directory.'); } } bundleDeclarations();
dets --version
Debug
Known issues
breakingStarting with version `0.17.0`, Node.js 16 is no longer supported. The minimum required Node.js version is `18.17` or later.
fix
Upgrade your Node.js environment to version 18.17 or higher.
affects: >=0.17.0
gotchadets 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.
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.
affects: >=0.1.0
gotchaThe `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.
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`.
affects: >=0.1.0
gotchaWhen 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.
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`.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'dets'
The 'dets' package is not installed or not resolvable in the current environment.
fix
Install 'dets' locally using `npm install --save-dev dets` or globally with `npm install -g dets` if using the CLI globally.
TypeError: 'identifier' is not a valid Node.js version. dets requires Node.js >= 18.17.
Your current Node.js version is older than the minimum requirement (18.17) for dets v0.17.0+.
fix
Upgrade your Node.js environment to version 18.17 or newer using `nvm` or your preferred Node.js version manager.
Error: Peer dependency 'typescript' is not installed or its version is incompatible.
The required peer dependency 'typescript' (version 4.x or 5.x) is missing or an incompatible version is installed.
fix
Install 'typescript@^4.0.0 || ^5.0.0' in your project. E.g., `npm install typescript@latest --save-dev`.
Bundling result is an empty string or incomplete declaration file.
Input entry files or file globs are incorrect, leading `dets` to process no or only a subset of the intended source files.
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.
Upgrade
Version history
0.17.0latest on npm
Audit
Dependencies
typescriptrequiredPeer dependency required for TypeScript compilation and declaration processing.
Agent activity
31 hits · last 30 days
node
24
OpenAI (training)
1
Resources
dets — npm install dets · libregistry