Skip to content

Commit

Permalink
Resolve typeReferenceDirective as fileOrDirectory instead of just dir…
Browse files Browse the repository at this point in the history
…ectory

Fixes #37708
Bug 2 part of the issue
  • Loading branch information
sheetalkamat committed Jul 21, 2020
1 parent 85bce61 commit 892f214
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
16 changes: 8 additions & 8 deletions src/compiler/moduleNameResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,15 @@ namespace ts {
trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
}
return firstDefined(typeRoots, typeRoot => {
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
const candidateDirectory = getDirectoryPath(candidate);
const directoryExists = directoryProbablyExists(candidateDirectory, host);
if (!directoryExists && traceEnabled) {
trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory);
}
return resolvedTypeScriptOnly(
loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate,
!directoryExists, moduleResolutionState));
nodeLoadModuleByRelativeName(
Extensions.DtsOnly,
combinePaths(typeRoot, typeReferenceDirectiveName),
/*onlyRecordFailures*/ false,
moduleResolutionState,
/*considerPackageJson*/ true
)
);
});
}
else {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
=== /a.ts ===
a;
No type information for this code.
No type information for this code.
>a : Symbol(a, Decl(phaser.d.ts, 0, 13))

=== /node_modules/phaser/types/phaser.d.ts ===
declare const a: number;
>a : Symbol(a, Decl(phaser.d.ts, 0, 13))

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[
"======== Resolving type reference directive 'phaser', containing file '/__inferred type names__.ts', root directory '/node_modules/phaser/types'. ========",
"Resolving with primary search path '/node_modules/phaser/types'.",
"Looking up in 'node_modules' folder, initial location '/'.",
"Loading module as file / folder, candidate module location '/node_modules/phaser/types/phaser', target file type 'DtsOnly'.",
"File '/node_modules/phaser/types/phaser.d.ts' exist - use it as a name resolution result.",
"File '/node_modules/phaser/package.json' does not exist.",
"File '/node_modules/phaser.d.ts' does not exist.",
"File '/node_modules/phaser/index.d.ts' does not exist.",
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"======== Type reference directive 'phaser' was not resolved. ========"
"Resolving real path for '/node_modules/phaser/types/phaser.d.ts', result '/node_modules/phaser/types/phaser.d.ts'.",
"======== Type reference directive 'phaser' was successfully resolved to '/node_modules/phaser/types/phaser.d.ts', primary: true. ========"
]
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
=== /a.ts ===
a;
>a : any
>a : number

=== /node_modules/phaser/types/phaser.d.ts ===
declare const a: number;
>a : number

0 comments on commit 892f214

Please sign in to comment.