Compiler API: respect typeRoots in resolveModuleName #44270
Labels
Fix Available
A PR has been opened for this issue
Needs Investigation
This issue needs a team member to investigate its status.
Suggestion
π Search Terms
List of keywords you searched for before creating this issue: I've tried
resolveModuleName
,typeRoot
,api
and their combinations.β Viability Checklist
β Suggestion
At the Compiler API Wiki, You can see that
resolveModuleNames
suggested implementation treats node modules packages typings and custom typings differently (here).This means anyone that uses the
ts.resolveModuleName
API has to implement the fallback and search onmoduleSearchLocations
(which I assume, we'll get those by reading thetsconfig
and scanning for thetypeRoot
.I am not sure whether this is a bug or not, but I would assume
ts.resolveModuleName
would respect thetypeRoots
given in the passed compiler options. What do you think? Is there a reason it doesn't behave this way?NOTE: I've not just relied on the example, I've tested it myself.
π» Use Cases
Any tool that uses the compiler API will need this, for example, I'm writing an ESLint plugin that makes sure every dependency either comes with type declarations or it has the corresponding
@types
package installed next to it. (It's here)Thanks!
The text was updated successfully, but these errors were encountered: