detective-typescript
Get the dependencies of a TypeScript module
Last updated 5 months ago by xhmikosr .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install detective-typescript 
SYNC missed versions from official npm registry.

detective-typescript

CI npm version npm downloads

Get the dependencies of TypeScript module

npm install detective-typescript typescript

Usage

ESM

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

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 and precinct.
onAfterFile Function - Like onFile, but also receives dependencies (string array of extracted dependencies).

License

MIT

Current Tags

  • 15.0.1                                ...           latest (5 months ago)

43 Versions

  • 15.0.1                                ...           5 months ago
  • 15.0.0                                ...           6 months ago
  • 14.1.2                                ...           7 months ago
  • 14.1.1                                ...           7 months ago
  • 14.1.0                                ...           7 months ago
  • 14.0.0                                ...           2 years ago
  • 13.0.1                                ...           2 years ago
  • 13.0.0                                ...           3 years ago
  • 12.0.0                                ...           3 years ago
  • 11.2.0                                ...           3 years ago
  • 11.1.0                                ...           4 years ago
  • 11.0.2                                ...           4 years ago
  • 11.0.1                                ...           4 years ago
  • 11.0.0                                ...           4 years ago
  • 10.0.0                                ...           4 years ago
  • 9.1.1                                ...           4 years ago
  • 9.1.0                                ...           4 years ago
  • 9.0.0                                ...           5 years ago
  • 8.0.1                                ...           5 years ago
  • 8.0.0                                ...           5 years ago
  • 7.0.2                                ...           5 years ago
  • 7.0.1                                ...           5 years ago
  • 7.0.0                                ...           6 years ago
  • 6.0.0                                ...           6 years ago
  • 5.8.0                                ...           7 years ago
  • 5.7.0                                ...           7 years ago
  • 5.6.1                                ...           7 years ago
  • 5.6.0                                ...           7 years ago
  • 5.5.0                                ...           7 years ago
  • 5.4.0                                ...           7 years ago
  • 5.3.0                                ...           8 years ago
  • 5.2.0                                ...           8 years ago
  • 5.1.1                                ...           8 years ago
  • 5.1.0                                ...           8 years ago
  • 5.0.0                                ...           8 years ago
  • 4.1.2                                ...           8 years ago
  • 4.1.1                                ...           8 years ago
  • 4.1.0                                ...           8 years ago
  • 4.0.0                                ...           8 years ago
  • 3.0.0                                ...           8 years ago
  • 2.0.0                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Downloads
Total 141
Today 0
This Week 1
This Month 91
Last Day 1
Last Week 42
Last Month 4
Dev Dependencies (4)

© 2010 - cnpmjs.org x YWFE | Home | YWFE