Skip to content

Commit 96f259d

Browse files
authored
Minimal fix for auto-importing node_modules in node12/nodenext (#46148)
1 parent d613748 commit 96f259d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/compiler/moduleSpecifiers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ namespace ts.moduleSpecifiers {
619619
const nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
620620
const packageName = getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
621621
// For classic resolution, only allow importing from node_modules/@types, not other node_modules
622-
return getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName;
622+
return getEmitModuleResolutionKind(options) === ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName;
623623

624624
function tryDirectoryWithPackageJson(packageRootIndex: number) {
625625
const packageRootPath = path.substring(0, packageRootIndex);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @module: node12
4+
5+
// @Filename: /node_modules/undici/index.d.ts
6+
//// export function request(): any;
7+
8+
// @Filename: /index.mts
9+
//// request/**/
10+
11+
verify.importFixModuleSpecifiers("", ["undici"]);

0 commit comments

Comments
 (0)