diff --git a/src/services/services.ts b/src/services/services.ts index eaba4779a522e..0155b2fef6f3c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4048,8 +4048,8 @@ namespace ts { if (host.getDirectories) { // Also get all @types typings installed in visible node_modules directories - for (const package of findPackageJsons(scriptPath)) { - const typesDir = combinePaths(getDirectoryPath(package), "node_modules/@types"); + for (const packageJson of findPackageJsons(scriptPath)) { + const typesDir = combinePaths(getDirectoryPath(packageJson), "node_modules/@types"); getCompletionEntriesFromDirectories(host, options, typesDir, span, result); } } @@ -4095,8 +4095,8 @@ namespace ts { if (host.readFile && host.fileExists) { for (const packageJson of findPackageJsons(scriptPath)) { - const package = tryReadingPackageJson(packageJson); - if (!package) { + const contents = tryReadingPackageJson(packageJson); + if (!contents) { return; } @@ -4105,7 +4105,7 @@ namespace ts { // Provide completions for all non @types dependencies for (const key of nodeModulesDependencyKeys) { - addPotentialPackageNames(package[key], foundModuleNames); + addPotentialPackageNames(contents[key], foundModuleNames); } for (const moduleName of foundModuleNames) {