Detective Typescript Save

Get the dependencies of a TypeScript module

Project README

detective-typescript

CI npm version npm downloads

Get the dependencies of TypeScript module

npm install detective-typescript typescript

Usage

const fs = require('fs');
const detective = require('detective-typescript');

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

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

Options

  • skipTypeImports (default: false) Skips imports that only imports types
  • mixedImports: (default: false) Include CJS imports in dependency list
  • skipAsyncImports: (default: false) Whether or not to omit async imports (import('foo'))
  • jsx: (default: false) Enable parsing of JSX
  • onFile: A callback that will be called before the file is processed. Intended for use with dependency-tree. Passed an object argument with properties options (echoing any options passed in, e.g., by precinct), src (source code for file as string), ast (parsed AST object for the file source), and walker (a Walker instance from node-source-walk configured for TypeScript to which you can pass the ast or src).
  • onAfterFile: Similar to onFile, but the callback is also passed an object property dependencies, a string array with the extracted dependencies.

License

MIT

Open Source Agenda is not affiliated with "Detective Typescript" Project. README Source: dependents/detective-typescript
Stars
53
Open Issues
3
Last Commit
3 weeks ago

Open Source Agenda Badge

Open Source Agenda Rating