Skip to content

Commit

Permalink
chore: fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jul 2, 2024
1 parent 7ace504 commit 707bd17
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 51 deletions.
4 changes: 2 additions & 2 deletions packages/language-server/lib/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function initialize(
createTypeScriptProject(
ts,
tsLocalized,
async ({ configFileName, sys, projectHost, asFileName }) => {
async ({ configFileName, sys, projectHost, uriConverter }) => {
let compilerOptions: ts.CompilerOptions;
let vueCompilerOptions: VueCompilerOptions;
if (configFileName) {
Expand All @@ -41,7 +41,7 @@ export function initialize(
return {
languagePlugins: [createVueLanguagePlugin(
ts,
asFileName,
s => uriConverter.asFileName(s),
() => projectHost.getProjectVersion?.() ?? '',
fileName => {
const fileMap = new FileMap(sys.useCaseSensitiveFileNames ?? false);
Expand Down
4 changes: 2 additions & 2 deletions packages/language-service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function getFullLanguageServicePlugins(ts: typeof import('typescript')):
context.language,
languageService,
context.project.vue.compilerOptions,
context.project.typescript.asUri
s => context.project.typescript?.uriConverter.asUri(s)
);
languageService.getCompletionsAtPosition = proxy.getCompletionsAtPosition;
languageService.getCompletionEntryDetails = proxy.getCompletionEntryDetails;
Expand Down Expand Up @@ -99,7 +99,7 @@ export function getFullLanguageServicePlugins(ts: typeof import('typescript')):
languageService,
languageServiceHost: context.project.typescript.languageServiceHost,
isTsPlugin: false,
getFileId: context.project.typescript.asUri,
getFileId: s => context.project.typescript!.uriConverter.asUri(s),
};
return {
async collectExtractProps(...args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function create(
let ast: ts.SourceFile | undefined;
let sourceCodeOffset = document.offsetAt(selection);

const fileName = context.project.typescript?.asFileName(sourceScript.id)
const fileName = context.project.typescript?.uriConverter.asFileName(sourceScript.id)
?? sourceScript.id.fsPath.replace(/\\/g, '/');

if (sourceScript.generated) {
Expand Down
2 changes: 1 addition & 1 deletion packages/language-service/lib/plugins/vue-document-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function create(
const additionalEdit: vscode.WorkspaceEdit = {};
const code = [...forEachEmbeddedCode(vueVirtualCode)].find(code => code.id === (sfc.scriptSetup ? 'scriptsetup_raw' : 'script_raw'))!;
const lastImportNode = getLastImportNode(ts, script.ast);
const incomingFileName = context.project.typescript?.asFileName(URI.parse(importUri))
const incomingFileName = context.project.typescript?.uriConverter.asFileName(URI.parse(importUri))
?? URI.parse(importUri).fsPath.replace(/\\/g, '/');

let importPath: string | undefined;
Expand Down
6 changes: 4 additions & 2 deletions packages/language-service/tests/utils/createTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ function createTester(rootUri: URI) {
project.typescript = {
configFileName: realTsConfig,
sys: ts.sys,
asFileName: uriToFileName,
asUri: fileNameToUri,
uriConverter: {
asFileName: uriToFileName,
asUri: fileNameToUri,
},
...createLanguageServiceHost(ts, ts.sys, language, fileNameToUri, projectHost),
};
project.vue = {
Expand Down
79 changes: 36 additions & 43 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 707bd17

Please sign in to comment.