ts-morph icon indicating copy to clipboard operation
ts-morph copied to clipboard

Support for Angular language service

Open cwilson opened this issue 5 years ago • 2 comments

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.

cwilson avatar Dec 03 '20 20:12 cwilson

@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 avatar Nov 08 '23 05:11 jpike88

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

jpike88 avatar Nov 08 '23 06:11 jpike88