Skip to content

Commit 4bcd8f2

Browse files
committed
refactor(typescript-plugin): return string in getImportPathForFile
1 parent 11d9dff commit 4bcd8f2

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

packages/language-service/lib/plugins/vue-document-drop.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function create(
5555
const lastImportNode = getLastImportNode(ts, script.ast);
5656
const incomingFileName = URI.parse(importUri).fsPath.replace(/\\/g, '/');
5757

58-
let importPath: string | undefined;
58+
let importPath: string | null | undefined;
5959

6060
const serviceScript = info.script.generated.languagePlugin.typescript?.getServiceScript(info.root);
6161
if (serviceScript) {
@@ -66,13 +66,11 @@ export function create(
6666
serviceScript.code.snapshot,
6767
);
6868
const preferences = await getUserPreferences(context, tsDocument);
69-
importPath = (
70-
await getImportPathForFile(
71-
info.root.fileName,
72-
incomingFileName,
73-
preferences,
74-
) ?? {}
75-
).path;
69+
importPath = await getImportPathForFile(
70+
info.root.fileName,
71+
incomingFileName,
72+
preferences,
73+
);
7674
}
7775

7876
if (!importPath) {

packages/typescript-plugin/lib/requests/getImportPathForFile.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ export function getImportPathForFile(
77
fileName: string,
88
incomingFileName: string,
99
preferences: ts.UserPreferences,
10-
): { path?: string } {
10+
): string | undefined {
1111
const incomingFile = program.getSourceFile(incomingFileName);
1212
const sourceFile = program.getSourceFile(fileName);
1313
if (!program || !sourceFile || !incomingFile) {
14-
return {};
14+
return;
1515
}
1616

1717
const getModuleSpecifiersWithCacheInfo: (
@@ -36,7 +36,5 @@ export function getImportPathForFile(
3636
preferences,
3737
);
3838

39-
return {
40-
path: moduleSpecifiers[0],
41-
};
39+
return moduleSpecifiers[0];
4240
}

0 commit comments

Comments
 (0)