Skip to content

Commit 5b8bc88

Browse files
committed
Use module resolution, rather than absolute path
1 parent 90d1335 commit 5b8bc88

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/jsTyping/jsTyping.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,19 @@ namespace ts.JsTyping {
292292
}
293293
const ownTypes = packageJson.types || packageJson.typings;
294294
if (ownTypes) {
295-
const absolutePath = getNormalizedAbsolutePath(ownTypes, getDirectoryPath(normalizedFileName));
296-
if (host.fileExists(absolutePath)) {
295+
let typesPath: string | undefined;
296+
try {
297+
const result = resolveModuleName(ownTypes, getDirectoryPath(normalizedFileName), { moduleResolution: ModuleResolutionKind.NodeJs }, host);
298+
typesPath = result.resolvedModule && result.resolvedModule.resolvedFileName;
299+
}
300+
catch (e) {
301+
}
302+
if (typesPath) {
297303
if (log) log(` Package '${packageJson.name}' provides its own types.`);
298-
inferredTypings.set(packageJson.name, absolutePath);
304+
inferredTypings.set(packageJson.name, typesPath);
299305
}
300306
else {
301-
if (log) log(` Package '${packageJson.name}' provides its own types but they are missing.`);
307+
if (log) log(` Package '${packageJson.name}' provides its own types but they could not be resolved.`);
302308
}
303309
}
304310
else {

0 commit comments

Comments
 (0)