Skip to content

resolveModuleNames doesn't get host & options #31056

Closed

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:

TypeStrong/fork-ts-checker-webpack-plugin#258 (comment)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

APIRelates to the public API for TypeScriptEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Fix AvailableA PR has been opened for this issueHelp WantedYou can do thisSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions