Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Typescript support #59

Closed
tamascsaba opened this issue Jan 26, 2017 · 3 comments
Closed

Typescript support #59

tamascsaba opened this issue Jan 26, 2017 · 3 comments

Comments

@tamascsaba
Copy link

I use 'intall-missing' module which has 'dependency-check' dependency, i want to use to typescript files, but this module doesn't support typescript yet.

@blakeembrey
Copy link
Collaborator

I don't think there's much chance of this module supporting TypeScript directly. It would be a huge undertaking because it operates on a JavaScript AST today, and TypeScript has too much API surface to cover for a small module. You could try https://www.npmjs.com/package/depcheck.

For this sort of functionality to work with TypeScript, it's probably better as a new module, where you can load the TypeScript project from the tsconfig.json file and just traverse through the AST and check additional imports. It's actually not too hard once you dig into the TypeScript compiler to support this directly, but since dependency-check would then be a whole different module, I'm going to suggest creating is as a new module or even TSLint rules. It's also possible that this module could adopt a plugin approach so people could hook in their own checkers, but I think any of this functionality will likely be up for a PR.

@voxpelli
Copy link
Collaborator

I agree with the above.

There could probably be some kind of plugin approach that made this module work with ES6/Babel, Typescript, Coffeescript though converting the code in such a way that the AST needed is provided.

I think such an approach would be pretty good to look into though as not only Typescript projects but also react projects with their JSX-files and projects that in other ways are reliant on Babel to work also needs this kind of functionality – and that's getting quite common.

So while such converters would not be provided in this package, I think it makes sense to enable others to plug such converters into this package.

@blakeembrey
Copy link
Collaborator

Closing in reference to #60. Should create a ts-detective module to parse TypeScript files for imports and references. There's a simple parser built into TypeScript for this that I've used before: https://github.com/typings/core/blob/a33db55fd8c1b0813c58776b1c5b9ada0d8170f1/src/lib/compile.ts#L353 (just concat referencedFiles with importedFiles).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants