-
Notifications
You must be signed in to change notification settings - Fork 13.4k
resolveModuleNames doesn't get host & options #31056
Copy link
Copy link
Closed
Labels
Domain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Fix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Metadata
Metadata
Assignees
Labels
Domain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Fix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
TypeScript Version: master
Search Terms: resolveModuleNames resolveTypeReferenceDirectives
Actual behavior:
The
resolveModuleNameshook (and its sisterresolveTypeReferenceDirectives) don't get direct access to theoptionsandresolutionHostvalue. 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
createWatchProgramand we don't get to access them.We theoretically could retrieve them from
watchProgram.getProgram().getCompilerOptions(), except that it requires to have thewatchProgramobject to begin with ... which doesn't happen untilcreateWatchProgramreturns, by which point TS will already have tried and failed the initial compilation.Expected behavior:
The
optionsparameter (and arguably theresolutionHostas well) should be passed as parameter to the customresolveModuleNamesandresolveTypeReferenceDirectivefunctions. This would allow to callts.resolveModuleNamewithout relying on indirect sources.Related Issues:
TypeStrong/fork-ts-checker-webpack-plugin#258 (comment)