Skip to content

Commit 362aeab

Browse files
committed
use project relative preference for declaration emit
Fixes #39117
1 parent e69d317 commit 362aeab

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5513,7 +5513,7 @@ namespace ts {
55135513
specifierCompilerOptions,
55145514
contextFile,
55155515
moduleResolverHost,
5516-
{ importModuleSpecifierPreference: isBundle ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle ? "minimal" : undefined },
5516+
{ importModuleSpecifierPreference: isBundle ? "non-relative" : "project-relative", importModuleSpecifierEnding: isBundle ? "minimal" : undefined },
55175517
));
55185518
links.specifierCache ??= new Map();
55195519
links.specifierCache.set(contextFile.path, specifier);

src/compiler/moduleSpecifiers.ts

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

193193
if (relativePreference === RelativePreference.ExternalNonRelative) {
194-
const projectDirectory = host.getCurrentDirectory();
194+
const projectDirectory = compilerOptions.configFilePath ?
195+
toPath(getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) :
196+
info.getCanonicalFileName(host.getCurrentDirectory());
195197
const modulePath = toPath(moduleFileName, projectDirectory, getCanonicalFileName);
196198
const sourceIsInternal = startsWith(sourceDirectory, projectDirectory);
197199
const targetIsInternal = startsWith(modulePath, projectDirectory);

tests/baselines/reference/tsbuild/declarationEmit/initial-build/when-declaration-file-used-inferred-type-from-referenced-project.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ exports.__esModule = true;
109109
}
110110

111111
//// [/src/packages/pkg2/lib/src/index.d.ts]
112-
export declare function fn4(): import("../../pkg1/src").IThing;
112+
export declare function fn4(): import("@fluentui/pkg1/src").IThing;
113113

114114

115115
//// [/src/packages/pkg2/lib/src/index.js]
@@ -139,7 +139,7 @@ exports.fn4 = fn4;
139139
},
140140
"../src/index.ts": {
141141
"version": "8515046367-import { IThings } from '@fluentui/pkg1';\nexport function fn4() {\n const a: IThings = { thing1: { a: 'b' } };\n return a.thing1;\n}",
142-
"signature": "-10018297277-export declare function fn4(): import(\"../../pkg1/src\").IThing;\r\n",
142+
"signature": "-4446422616-export declare function fn4(): import(\"@fluentui/pkg1/src\").IThing;\r\n",
143143
"affectsGlobalScope": false
144144
}
145145
},

0 commit comments

Comments
 (0)