# detective-typescript

> Get the dependencies of a TypeScript module

Latest version **15.0.1** (published 2026-07-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install detective-typescript
pnpm add detective-typescript
yarn add detective-typescript
bun add detective-typescript
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 15.0.1 |
| Published | 2026-07-02 |
| First published | 2017-08-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=20.19.0 \|\| >=22.12.0 |
| Dependencies | 3 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 65 |
| Author | Patrik Henningsson |
| Maintainers | pahen, mrjoelkemp, xhmikosr |
| Keywords | detective, typescript, dependencies, module, ast, import |

## Links

- npm: https://www.npmjs.com/package/detective-typescript
- Repository: https://github.com/dependents/detective-typescript
- Issues: https://github.com/dependents/detective-typescript/issues
- npm.io page: https://npm.io/package/detective-typescript

## Dependencies (3)

- [ast-module-types](https://npm.io/package/ast-module-types.md) ^7.0.0
- [node-source-walk](https://npm.io/package/node-source-walk.md) ^8.0.0
- [@typescript-eslint/typescript-estree](https://npm.io/package/@typescript-eslint/typescript-estree.md) ^8.62.1

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 15.0.1 (latest) — 2026-07-02
- 15.0.0 — 2026-05-19
- 14.1.2 — 2026-04-22
- 14.1.1 — 2026-04-19
- 14.1.0 — 2026-04-18
- 14.0.0 — 2025-02-06
- 13.0.1 — 2025-02-01
- 13.0.0 — 2024-04-14
- 12.0.0 — 2024-04-09
- 11.2.0 — 2024-04-09
- 11.1.0 — 2023-05-12
- 11.0.2 — 2023-05-12
- 11.0.1 — 2023-05-08
- 11.0.0 — 2023-05-05
- 10.0.0 — 2023-04-17
- … 28 more at https://npm.io/package/detective-typescript/versions

## README

# detective-typescript

[![CI](https://img.shields.io/github/actions/workflow/status/dependents/detective-typescript/ci.yml?branch=main&label=CI&logo=github)](https://github.com/dependents/detective-typescript/actions/workflows/ci.yml?query=branch%3Amain)
[![npm version](https://img.shields.io/npm/v/detective-typescript?logo=npm&logoColor=fff)](https://www.npmjs.com/package/detective-typescript)
[![npm downloads](https://img.shields.io/npm/dm/detective-typescript)](https://www.npmjs.com/package/detective-typescript)

> Get the dependencies of TypeScript module

```sh
npm install detective-typescript typescript
```

## Usage

### ESM

```js
import fs from 'node:fs';
import detective from 'detective-typescript';

const mySourceCode = fs.readFileSync('myfile.ts', 'utf8');

// Pass in a file's content or an AST
const dependencies = detective(mySourceCode);

// For TSX/JSX files
const tsxDependencies = detective.tsx(mySourceCode);
```

### CommonJS

```js
const { default: detective } = require('detective-typescript');
```

## Options

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `skipTypeImports` | `boolean` | `false` | Skip imports that only import types |
| `mixedImports` | `boolean` | `false` | Include CJS `require()` calls in the dependency list |
| `skipAsyncImports` | `boolean` | `false` | Omit dynamic `import('foo')` expressions |
| `jsx` | `boolean` | `false` | Enable parsing of JSX/TSX syntax |
| `onFile` | `Function` | - | Callback invoked before a file is processed. Receives `{ options, src, ast, walker }`. Intended for use with [`dependency-tree`](https://github.com/dependents/node-dependency-tree) and [`precinct`](https://github.com/dependents/node-precinct). |
| `onAfterFile` | `Function` | - | Like `onFile`, but also receives `dependencies` (string array of extracted dependencies). |

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/detective-typescript · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
