Skip to content

fix(typescript): shim tryAddingExtensions to evade ts2876#303

Open
Gehbt wants to merge 1 commit intovolarjs:masterfrom
Gehbt:shim-1
Open

fix(typescript): shim tryAddingExtensions to evade ts2876#303
Gehbt wants to merge 1 commit intovolarjs:masterfrom
Gehbt:shim-1

Conversation

@Gehbt
Copy link
Copy Markdown

@Gehbt Gehbt commented Mar 16, 2026

Relate vuejs/language-tools#5957

This PR only change the resolvedModule.resolvedUsingTsExtension to true.

When resolvedModule.resolvedUsingTsExtension is falsy, it will emit ts2876.

// https://github.com/microsoft/TypeScript/blob/main/src/compiler/checker.ts#L4730
function resolveExternalModule(...){
	...
	if (!resolvedModule.resolvedUsingTsExtension && shouldRewrite) {
	 	error(@ts2876);
	}
	...
}

before:

resolve:
tryAddingExtensions -> switch.default -> tryExtension('.d${originalExtension}.ts')
-> return {..., resolvedUsingTsExtension: {someState} && undefined } always falsy

after:

resolve:
tryAddingExtensions -> switch.case extraSupportedExtensions -> tryExtension(extraSupportedExtension, true)
-> return {..., resolvedUsingTsExtension: {someState} && true }

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant