fix(59649): ts Move to a new file doesn't respect importModuleSpecifier setting (#59670)
This commit is contained in:
Родитель
d1e25f25c2
Коммит
3abe069fd2
|
@ -435,6 +435,7 @@ export function getLocalModuleSpecifierBetweenFileNames(
|
|||
targetFileName: string,
|
||||
compilerOptions: CompilerOptions,
|
||||
host: ModuleSpecifierResolutionHost,
|
||||
preferences: UserPreferences,
|
||||
options: ModuleSpecifierOptions = {},
|
||||
): string {
|
||||
const info = getInfo(importingFile.fileName, host);
|
||||
|
@ -445,7 +446,7 @@ export function getLocalModuleSpecifierBetweenFileNames(
|
|||
compilerOptions,
|
||||
host,
|
||||
importMode,
|
||||
getModuleSpecifierPreferences({}, host, compilerOptions, importingFile),
|
||||
getModuleSpecifierPreferences(preferences, host, compilerOptions, importingFile),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -335,6 +335,7 @@ function createImportAdderWorker(sourceFile: SourceFile | FutureSourceFile, prog
|
|||
exportingFileName,
|
||||
compilerOptions,
|
||||
createModuleSpecifierResolutionHost(program, host),
|
||||
preferences,
|
||||
);
|
||||
const importKind = getImportKind(futureExportingSourceFile, exportKind, program);
|
||||
const addAsTypeOnly = getAddAsTypeOnly(
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
});
|
Загрузка…
Ссылка в новой задаче