resolveModuleNames doesn't get host
& options
#31056
Labels
API
Relates to the public API for TypeScript
Effort: Moderate
Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".
Fix Available
A PR has been opened for this issue
Help Wanted
You can do this
Suggestion
An idea for TypeScript
Milestone
TypeScript Version: master
Search Terms: resolveModuleNames resolveTypeReferenceDirectives
Actual behavior:
The
resolveModuleNames
hook (and its sisterresolveTypeReferenceDirectives
) don't get direct access to theoptions
andresolutionHost
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 thewatchProgram
object to begin with ... which doesn't happen untilcreateWatchProgram
returns, by which point TS will already have tried and failed the initial compilation.Expected behavior:
The
options
parameter (and arguably theresolutionHost
as well) should be passed as parameter to the customresolveModuleNames
andresolveTypeReferenceDirective
functions. This would allow to callts.resolveModuleName
without relying on indirect sources.Related Issues:
TypeStrong/fork-ts-checker-webpack-plugin#258 (comment)
The text was updated successfully, but these errors were encountered: