-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Description
TypeScript Version: master
Search Terms: resolveModuleNames resolveTypeReferenceDirectives
Actual behavior:
The resolveModuleNames hook (and its sister resolveTypeReferenceDirectives) don't get direct access to the options and resolutionHost value. It's left to the user to populate them (as shown in the documentation).
While it worked ok until now since the options are known before injecting the hook, it now causes issues with the Watch API. In this situation, the options are extracted by the internals of createWatchProgram and we don't get to access them.
We theoretically could retrieve them from watchProgram.getProgram().getCompilerOptions(), except that it requires to have the watchProgram object to begin with ... which doesn't happen until createWatchProgram returns, by which point TS will already have tried and failed the initial compilation.
Expected behavior:
The options parameter (and arguably the resolutionHost as well) should be passed as parameter to the custom resolveModuleNames and resolveTypeReferenceDirective functions. This would allow to call ts.resolveModuleName without relying on indirect sources.
Related Issues: