Skip to content

Commit

Permalink
fix: cannot resolve external vue file path
Browse files Browse the repository at this point in the history
close #1445
  • Loading branch information
johnsoncodehk committed Jun 13, 2022
1 parent 4a084c1 commit 908fccf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/vue-typescript/src/lsContext.ts
Expand Up @@ -28,18 +28,18 @@ export function createLanguageServiceContext(
// .vue.js -> .vue
// .vue.ts -> .vue
// .vue.d.ts (never)
const fileNameTrim = fileName.substring(0, fileName.lastIndexOf('.'));
const vueFileName = fileName.substring(0, fileName.lastIndexOf('.'));

if (fileNameTrim.endsWith('.vue') || fileNameTrim.endsWith('.md') || fileNameTrim.endsWith('.html')) {
const vueFile = documentRegistry.get(fileNameTrim);
if (vueFileName.endsWith('.vue') || vueFileName.endsWith('.md') || vueFileName.endsWith('.html')) {
const vueFile = documentRegistry.get(vueFileName);
if (!vueFile) {
const fileExists = !!host.fileExists?.(fileNameTrim);
const fileExists = !!host.fileExists?.(vueFileName);
if (fileExists) {
// create virtual files
const scriptSnapshot = host.getScriptSnapshot(fileName);
const scriptSnapshot = host.getScriptSnapshot(vueFileName);
if (scriptSnapshot) {
documentRegistry.set(fileName, createSourceFile(
fileName,
documentRegistry.set(vueFileName, createSourceFile(
vueFileName,
scriptSnapshot.getText(0, scriptSnapshot.getLength()),
compilerOptions,
vueCompilerOptions,
Expand Down

0 comments on commit 908fccf

Please sign in to comment.