Skip to content

Conversation

@weswigham
Copy link
Member

Fixes #49340

getModeForUsageLocation should be the preferred function, however you may need to resort to getModeForResolutionAtIndex in some implementations of resolveModuleNames (though it's potentially unable to handle partial name lists).

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jun 2, 2022
@DanielRosenwasser
Copy link
Member

@iclanton given changes at microsoft/rushstack#3434, you might want to move that out from TypeScriptInternals once this lands.

* @param file File to fetch the resolution mode within
* @param index Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations
*/
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea:

Suggested change
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number) {
export function getModeForResolutionAtIndex(file: SourceFile, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
/** @internal */
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined {

Then you don't have to expose SourceFileImportsList

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed the changes since I think we should get this into 4.7.3.

@DanielRosenwasser
Copy link
Member

@typescript-bot cherry-pick this to release-4.7

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 3, 2022

Heya @DanielRosenwasser, I've started to run the task to cherry-pick this into release-4.7 on this PR at 4e40185. You can monitor the build here.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Jun 3, 2022
Component commits:
5eb6425 Expose import mode calculation functions

1f907ae Make `SourceFileImportsList` internal again.

4e40185 Accepted API baselines.
@typescript-bot
Copy link
Collaborator

Hey @DanielRosenwasser, I've opened #49370 for you.

DanielRosenwasser added a commit that referenced this pull request Jun 3, 2022
…e-4.7 (#49370)

* Cherry-pick PR #49360 into release-4.7

Component commits:
5eb6425 Expose import mode calculation functions

1f907ae Make `SourceFileImportsList` internal again.

4e40185 Accepted API baselines.

* Fix lints.

Co-authored-by: Daniel Rosenwasser <drosen@microsoft.com>
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
@DanielRosenwasser DanielRosenwasser merged commit 3ccbe80 into microsoft:main Jun 3, 2022
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Impossible to implement LanguageServiceHost::resolveModuleNames without using TS internal getModeForResolutionAtIndex

3 participants