Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue file can't find the file ts file references by script src attribute #991

Closed
3 tasks done
fuxuejun opened this issue Nov 27, 2018 · 0 comments
Closed
3 tasks done

Comments

@fuxuejun
Copy link

fuxuejun commented Nov 27, 2018

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • Platform: Windows 10 18282 x64
  • Vetur version:0.14.2
  • VS Code version:1.29.1

Problem

File Not Found.
vue file can't find the file ts file references by script src attribute.

1

tsconfig.json

{
    "compilerOptions": {
        "sourceMap": true,
        "strict": true,
        "module": "esnext",
        "moduleResolution": "node",
        "target": "es5",
        "allowSyntheticDefaultImports": true,
        "isolatedModules": false,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "noImplicitAny": false,
        "noImplicitReturns": false,
        "importHelpers": true,
        "listFiles": true,
        "removeComments": true,
        "noImplicitThis": true,
        "suppressImplicitAnyIndexErrors": true,
        "strictPropertyInitialization": false,
        "allowJs": true,
        "checkJs": true,
        "lib": ["dom", "esnext", "dom.iterable", "scripthost"],
        "pretty": true,
        "types": ["node"],
        "typeRoots": ["node_modules/@types"],
        "plugins": [
            {
                "name": "typescript-tslint-plugin"
            }
        ],
        "baseUrl": ".",
        "paths": {
            "./*": [
                "src/*"
            ],
            "@/*": [
                "src/*"
            ]
        }
    },
    "include": ["src/**/*.ts", "src/**/*.vue"],
    "exclude": ["node_modules"]
}

fix code

modify vls.js file line 189 from:

                const docUri = vscode_uri_1.default.parse(doc.uri);                
                return docUri
                    .with({
                    path: path.resolve(docUri.path, ref)
                })
                    .toString();

to:

                const docUri = vscode_uri_1.default.parse(doc.uri);
                const lastPosition = docUri.path.toString().lastIndexOf("/");
                const rawPath = docUri.path.slice(1, lastPosition);
                
                return docUri
                    .with({
                    path: path.resolve(rawPath, ref)
                })
                    .toString();

can reslove this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants