Skip to content

Commit 3fd8a57

Browse files
committed
use project relative preference for declaration emit
Fixes #39117
1 parent a477076 commit 3fd8a57

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5679,7 +5679,7 @@ namespace ts {
56795679
specifierCompilerOptions,
56805680
contextFile,
56815681
moduleResolverHost,
5682-
{ importModuleSpecifierPreference: isBundle ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle ? "minimal" : undefined },
5682+
{ importModuleSpecifierPreference: isBundle ? "non-relative" : "project-relative", importModuleSpecifierEnding: isBundle ? "minimal" : undefined },
56835683
));
56845684
links.specifierCache ??= new Map();
56855685
links.specifierCache.set(contextFile.path, specifier);

src/compiler/moduleSpecifiers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ namespace ts.moduleSpecifiers {
206206
}
207207

208208
if (relativePreference === RelativePreference.ExternalNonRelative) {
209-
const projectDirectory = host.getCurrentDirectory();
209+
const projectDirectory = compilerOptions.configFilePath ?
210+
toPath(getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) :
211+
info.getCanonicalFileName(host.getCurrentDirectory());
210212
const modulePath = toPath(moduleFileName, projectDirectory, getCanonicalFileName);
211213
const sourceIsInternal = startsWith(sourceDirectory, projectDirectory);
212214
const targetIsInternal = startsWith(modulePath, projectDirectory);

0 commit comments

Comments
 (0)