mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 23:08:20 -06:00
Minimal fix for auto-importing node_modules in node12/nodenext (#46148)
This commit is contained in:
parent
d613748932
commit
96f259ddcc
@ -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);
|
||||
|
||||
11
tests/cases/fourslash/autoImport_node12_node_modules1.ts
Normal file
11
tests/cases/fourslash/autoImport_node12_node_modules1.ts
Normal file
@ -0,0 +1,11 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @module: node12
|
||||
|
||||
// @Filename: /node_modules/undici/index.d.ts
|
||||
//// export function request(): any;
|
||||
|
||||
// @Filename: /index.mts
|
||||
//// request/**/
|
||||
|
||||
verify.importFixModuleSpecifiers("", ["undici"]);
|
||||
Loading…
x
Reference in New Issue
Block a user