GithubHelp home page GithubHelp logo

detective-typescript's Introduction

Dependents

Gitter Package Control

Navigate front-end codebases in Sublime Text 2/3

For updates, follow @getDependents.

Currently supports JavaScript (AMD, CommonJS, and ES6) and CSS Preprocessor (Sass and Stylus) codebases.

  1. Installation
  2. Usage and Settings Details
  3. Bindings
  4. Reporting an Issue
  5. Contributing to Dependents

Installation

You can install Dependents via Package Control.

Don't see it? Try reinstalling Package Control. Alternatively, add the repository and install it:

  1. Package Control -> Add Repository
  2. Enter https://github.com/dependents/Dependents
  3. Package Control -> Install Package
  4. Choose Dependents

Nodejs Dependency

You must have Node.js installed on your system. Anything v0.10 and above is fine.

  • Note: The Node.js windows installer will add the install directory to the PATH variable but you must reboot to reload it.
NVM Users

NVM will install Nodejs outside of the standard binary location. If you encounter an error where your Node executable cannot be found, please override the node_path in User settings:

  • Preferences -> Package Settings -> Dependents -> Settings - User
{
  "node_path": "path/to/the/node/install/directory"
}
  • This will allow Dependents to find the Node binary for every codebase

Bindings

To more swiftly and conveniently trigger the package's commands both key and mouse bindings are provided.

Key bindings

By default, the following key bindings have been supplied:

OSX:

  • Jump to dependency: Command + Option + Right arrow
  • Find Dependents: Command + Option + Up arrow
  • Copy path to clipboard: Command + Shift + C

Windows and Linux:

  • Jump to dependency: Ctrl + Shift + Down arrow
  • Find Dependents: Ctrl + Shift + Up arrow

Mouse bindings

By default, the following key bindings have been supplied:

OSX:

  • Jump to dependency: Command + Option + Click on the dependency item
  • Find Dependents: Command + Shift + Click anywhere in document

Windows and Linux:

  • Jump to dependency: Ctrl + Alt + Click on the dependency item
  • Find Dependents: Ctrl + Shift + Click anywhere in document

Reporting an issue

You can get console logs via View -> Show Console.

Paste those logs into the body of your issue.

Feel free to chat with me on Gitter if you need help or ping me @mrjoelkemp.

License

(Creative Commons Attribution NoDerivs (CC-ND)](https://tldrlegal.com/license/creative-commons-attribution-noderivs-(cc-nd))

The no derivatives creative commons license is straightforward; you can take a work released under this license and re-distribute it but you can’t change it.

detective-typescript's People

Contributors

andersdjohnson avatar codemonkey800 avatar dependabot[bot] avatar eelco avatar fatso83 avatar grncdr avatar joscha avatar mk0x9 avatar mrjoelkemp avatar nbeliard avatar pahen avatar petehunt avatar realityking avatar samfrances avatar timm-gs avatar waivital avatar xhmikosr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

detective-typescript's Issues

Add support for es6 import specifier details

Currently, given an import such as import { Foo, Bar } from './utilities', the returned dependencies will only give ['utilities'], and no other details about what specifically was imported.

For example, the previous import in the page.ts file:

// Directory Structure
├── page.ts
└── utilities
    ├── index.ts
    ├── foo.ts
    ├── bar.ts
    └── baz.ts

// utilities/index.ts
export * from './foo'
export * from './bar'
export * from './baz'

These details would be incredibly useful in other places such as dependency-tree so that the specific imports could be traced.

Currently when getting the dependencies for page.ts it would be utilities/index.ts, and utilities/index.ts would depend on foo, bar, and baz. This gives the appearance that page.ts depends on foo, bar, and baz, even though it only imports Foo and Bar.

I would be happy to PR this improvement to this package if this is an acceptable addition. When implementing it, I would add an opt-in config option to retrieve the extra import declaration data, and then pass it to the onAfterFile callback for use in other locations.

Publish in NPM registry

Hi there,

the README.md suggests running

npm install detective-typescript

Unfortunately there is no such package in the npmjs.com registry.

Could you please publish it or redirect me to the correct package?

Thanks!

wonderful with ts files but breaks w/ tsx files

thank you for this excellent tool :)

I've been using this with a typescript application and today I added a tsx file and found that detective-typescript throws an error which looks like this,

{ index: 727,
  lineNumber: 48,
  column: 14,
  message: '\'>\' expected.' }

what is the best way to resolve this? will you publish this module to npm?

Support ESM typescript modules

If your tsconfig.json has "module": "ES2020" or later (e.g you are outputting ESM and not CJS), TypeScript doesn't rewrite import './foo' to import './foo.js' in the transpiled output - instead you have to use import './foo.js' in your .ts file.

This module then breaks because it (quite reasonably) detects './foo.js' as a dependency which of course doesn't exist.

I've hacked round it by replacing the file extension here and here but it doesn't take into account if ./foo.js does actually exist and that's what you meant to import. I don't know the AST well enough to make that change, but a simple fs.existsSync should be enough?

Another workaround is to run the dep checker over the transpiled output instead of the ts source, but then you lose any import type declarations, so it's not ideal.

Refs: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#type-in-package-json-and-new-extensions

Fails to recognize import expressions

In some situations the detective fails to recognize ImportExpression (import('...')) that imports a tsx file. In that case the imports that are inside the file that got imported by that expression are not recognised.

Repository to reproduce the issue:
https://github.com/leanazulyoro/test_depscheck

  1. npm install

  2. npm run deps:check
    It will fail with Fail! Modules in package.json not used in code: lodash even when lodash is imported in TestFile2.ts

  3. change the extension of TestFile.tsx to TestFile.ts and it works fine. So the issue might be in the @fatso83/detective-tsx package, that uses the typescript-detective's tsx version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.