Skip to content

Commit 4fe7e41

Browse files
TypeScript Bota-tarasyuk
TypeScript Bot
andauthored
🤖 Pick PR #59670 (fix(59649): ts Move to a new file d...) into release-5.6 (#59725)
Co-authored-by: Oleksandr T. <[email protected]>
1 parent 1a03e53 commit 4fe7e41

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

‎src/compiler/moduleSpecifiers.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ export function getLocalModuleSpecifierBetweenFileNames(
435435
targetFileName: string,
436436
compilerOptions: CompilerOptions,
437437
host: ModuleSpecifierResolutionHost,
438+
preferences: UserPreferences,
438439
options: ModuleSpecifierOptions = {},
439440
): string {
440441
const info = getInfo(importingFile.fileName, host);
@@ -445,7 +446,7 @@ export function getLocalModuleSpecifierBetweenFileNames(
445446
compilerOptions,
446447
host,
447448
importMode,
448-
getModuleSpecifierPreferences({}, host, compilerOptions, importingFile),
449+
getModuleSpecifierPreferences(preferences, host, compilerOptions, importingFile),
449450
);
450451
}
451452

‎src/services/codefixes/importFixes.ts

+1
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ function createImportAdderWorker(sourceFile: SourceFile | FutureSourceFile, prog
336336
exportingFileName,
337337
compilerOptions,
338338
createModuleSpecifierResolutionHost(program, host),
339+
preferences,
339340
);
340341
const importKind = getImportKind(futureExportingSourceFile, exportKind, program);
341342
const addAsTypeOnly = getAddAsTypeOnly(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @Filename: /tsconfig.json
4+
//// {
5+
//// "compilerOptions": {
6+
//// "moduleResolution": "Bundler",
7+
//// "baseUrl": "."
8+
//// "paths": {
9+
//// "@foo/*": ["src/*"]
10+
//// }
11+
//// }
12+
//// }
13+
14+
// @Filename: /src/a.ts
15+
////export function a() {
16+
//// b();
17+
////}
18+
////[|export function b() {
19+
////}|]
20+
21+
verify.moveToNewFile({
22+
newFileContents: {
23+
"/src/a.ts":
24+
`import { b } from "@foo/b";
25+
26+
export function a() {
27+
b();
28+
}
29+
`,
30+
"/src/b.ts":
31+
`export function b() {
32+
}
33+
`,
34+
},
35+
preferences: {
36+
importModuleSpecifierPreference: "non-relative",
37+
}
38+
});

0 commit comments

Comments
 (0)