Minimal fix for auto-importing node_modules in node12/nodenext (#46148)

This commit is contained in:
Andrew Branch
2021-09-30 13:42:06 -07:00
committed by GitHub
parent d613748932
commit 96f259ddcc
2 changed files with 12 additions and 1 deletions

View File

@@ -619,7 +619,7 @@ namespace ts.moduleSpecifiers {
const nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
const packageName = getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
// For classic resolution, only allow importing from node_modules/@types, not other node_modules
return getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName;
return getEmitModuleResolutionKind(options) === ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName;
function tryDirectoryWithPackageJson(packageRootIndex: number) {
const packageRootPath = path.substring(0, packageRootIndex);