dsherret / ts-morph

TypeScript Compiler API wrapper for static analysis and programmatic code changes.
https://ts-morph.com
MIT License
4.71k stars 191 forks source link

Support for Angular language service #892

Open cwilson opened 3 years ago

cwilson commented 3 years ago

Is your feature request related to a problem? Please describe.

I'm tying to find references to nodes that may come from Angular templates. WebStorm is able to resolve these references; I'm assuming it's using Angular's language service: https://angular.io/guide/language-service.

Describe the solution you'd like

A way to configure ts-morph (possibly through compiler options) to use Angular language service. I'm hoping there already is a way that I'm missing!

Describe alternatives you've considered

I've tried specifying the language service as a compiler plugin in tsconfig.json, and through the compiler options passed to ts-morph.

    "plugins": [
      {"name": "@angular/language-service"}
    ]

Other alternative is to consume the language service directly if support from ts-morph is not realistic.

jpike88 commented 7 months ago

@dsherret I figured out how to find unused class properties, but just hit a wall when trying to see if it could find references in angular templates (which it cannot).

Is it possible without much effort to hook up to angular language service from ts-morph to access that information?

jpike88 commented 7 months ago

After some more reading, it seems the problem may require ts-morph to use ngtsc instead of its own built in tsc library to plug into that api instead. Does this sound about right?

https://github.com/angular/angular/tree/main/packages/compiler-cli/src/ngtsc