mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-17 21:09:09 -05:00
Do not populate exports pattern keys if more than one * exists (#58123)
This commit is contained in:
@@ -2703,7 +2703,7 @@ function loadModuleFromImportsOrExports(extensions: Extensions, state: ModuleRes
|
||||
const target = (lookupTable as { [idx: string]: unknown; })[moduleName];
|
||||
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false, moduleName);
|
||||
}
|
||||
const expandingKeys = sort(filter(getOwnKeys(lookupTable as MapLike<unknown>), k => k.includes("*") || endsWith(k, "/")), comparePatternKeys);
|
||||
const expandingKeys = sort(filter(getOwnKeys(lookupTable as MapLike<unknown>), k => hasOneAsterisk(k) || endsWith(k, "/")), comparePatternKeys);
|
||||
for (const potentialTarget of expandingKeys) {
|
||||
if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
|
||||
const target = (lookupTable as { [idx: string]: unknown; })[potentialTarget];
|
||||
@@ -2731,6 +2731,11 @@ function loadModuleFromImportsOrExports(extensions: Extensions, state: ModuleRes
|
||||
}
|
||||
}
|
||||
|
||||
function hasOneAsterisk(patternKey: string): boolean {
|
||||
const firstStar = patternKey.indexOf("*");
|
||||
return firstStar !== -1 && firstStar === patternKey.lastIndexOf("*");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the self-recursive function specialized to retrieving the targeted import/export element for the given resolution configuration
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user