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

Unable to get working #1

Open
goldingdamien opened this issue Nov 25, 2019 · 6 comments
Open

Unable to get working #1

goldingdamien opened this issue Nov 25, 2019 · 6 comments

Comments

@goldingdamien
Copy link

I have a project that is open in VS code that has the Vetur extension working with interpolation is showing errors in various templates.
I am executing vue-type-check with "vtc --workspace ./" in the command line but nothing is being returned. It is the same if I include --srcDir ./path/to/nested/component.
Please provide some further information and/or a test example that should work.

Regards

@Yuyz0112
Copy link
Owner

could you provide a sample component to reproduce this?

@goldingdamien
Copy link
Author

It's a private code base so can't share, but the issues are very standard which would be easy to recreate.

Examples:
v-slide-item with binded :key="obj.property" where property doesn't exist on this.obj or this.obj is of type object.

Could you add an example to this project which outputs errors? Any basic component with basic typescript errors in the template would be enough.

Regards

@Yuyz0112
Copy link
Owner

@goldingdamien
Copy link
Author

I tried executing but couldn't get the test to pass.
I'm assuming the following should be done, is this correct?

  1. tsc
  2. node./tests/component.spec.js

Regards.

@Yuyz0112
Copy link
Owner

yes

@warappa
Copy link

warappa commented Jul 3, 2020

I'm on Windows and after debugging I found, that it has to do how the paths are constructed.

In walk if the path is a .vue file, then the path is always prefixed with file:// (note 2 slashes).

In a custom copy I changed it to file:/// and it works (at least with absolute paths).

Here's the code:

function walk(dir) {
        fs.readdirSync(dir).forEach(p => {
            const joinedP = path.join(dir, p);
            const stats = fs.statSync(joinedP);
            if (stats.isDirectory()) {
                walk(joinedP);
            }
            else if (path.extname(p) === ".vue") {
                var newPath = `file://${joinedP}`.replace(/\\/g, "/");
                if (process.platform == "win32") {
                    if (joinedP.length>1 && joinedP[1] == ':') {
                        newPath = `file:///${joinedP}`.replace(/\\/g, "/");
                    } else {
                        newPath = `file:///${process.cwd()}/${joinedP}`.replace(/\\/g, "/");
                    }
                }
                docs.push(vscode_languageserver_1.TextDocument.create(newPath.toLowerCase(), "vue", 0, fs.readFileSync(joinedP, "utf8")));
            }
        });
    }

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

No branches or pull requests

3 participants