Skip to content

Commit

Permalink
🤖 Pick PR #59670 (fix(59649): ts Move to a new file d...) into releas…
Browse files Browse the repository at this point in the history
…e-5.6 (#59725)

Co-authored-by: Oleksandr T. <oleksandr.tarasiuk@outlook.com>
  • Loading branch information
TypeScript Bot and a-tarasyuk committed Aug 27, 2024
1 parent 1a03e53 commit 4fe7e41
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/compiler/moduleSpecifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ export function getLocalModuleSpecifierBetweenFileNames(
targetFileName: string,
compilerOptions: CompilerOptions,
host: ModuleSpecifierResolutionHost,
preferences: UserPreferences,
options: ModuleSpecifierOptions = {},
): string {
const info = getInfo(importingFile.fileName, host);
Expand All @@ -445,7 +446,7 @@ export function getLocalModuleSpecifierBetweenFileNames(
compilerOptions,
host,
importMode,
getModuleSpecifierPreferences({}, host, compilerOptions, importingFile),
getModuleSpecifierPreferences(preferences, host, compilerOptions, importingFile),
);
}

Expand Down
1 change: 1 addition & 0 deletions src/services/codefixes/importFixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ function createImportAdderWorker(sourceFile: SourceFile | FutureSourceFile, prog
exportingFileName,
compilerOptions,
createModuleSpecifierResolutionHost(program, host),
preferences,
);
const importKind = getImportKind(futureExportingSourceFile, exportKind, program);
const addAsTypeOnly = getAddAsTypeOnly(
Expand Down
38 changes: 38 additions & 0 deletions tests/cases/fourslash/moveToNewFile_nonRelativePaths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/// <reference path="fourslash.ts" />

// @Filename: /tsconfig.json
//// {
//// "compilerOptions": {
//// "moduleResolution": "Bundler",
//// "baseUrl": "."
//// "paths": {
//// "@foo/*": ["src/*"]
//// }
//// }
//// }

// @Filename: /src/a.ts
////export function a() {
//// b();
////}
////[|export function b() {
////}|]

verify.moveToNewFile({
newFileContents: {
"/src/a.ts":
`import { b } from "@foo/b";
export function a() {
b();
}
`,
"/src/b.ts":
`export function b() {
}
`,
},
preferences: {
importModuleSpecifierPreference: "non-relative",
}
});

0 comments on commit 4fe7e41

Please sign in to comment.