-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
Type checking on data() properties doesn't work in Vue SFC's #1750
Comments
I cannot reproduce this in https://github.com/octref/veturpack: |
Oh, so now I'm confused. Perhaps my slightly unorthodox project structure is throwing Vetur, but works without problems with TSC and webpack. My structure is something like this:
Webpack
TSC via webpack picks up errors liked the one indicated in my original post, because it correctly detects the type of |
Ok, I found the problem. It seems that tsconfig.json must be in the project root directory loaded by vscode for tsserver to be started. Perhaps this is a bug or perhaps room for improvement; in our use case, we have a laravel project with a served Vue/TS app whose source resides in I see this problem with Vetur but perhaps the issue is with tsserver? |
Since TSC allows tsconfig to be at any level higher in the source tree than files it's compiling, vscode's typescript/vue intel features should follow suit. Something similar seems to have been requested at issue #815. The workaround is that tsconfig.js must be located at vscode's project root (open folder) for vetur/typescript checking and intellisense to work correctly. It appears that improved functionality along these lines has been requested at issue. If current behaviour is satisfactory go ahead and close this issue. Thanks for help. |
I'll track it in #815 then. Glad you figured it out. |
Info
Problem
Given the below code snippet, TSC correctly reports a TS2322 type mismatch on
this.foo
but vscode/vetur ignores this error. Furthermore, hovering overfoo
inmounted()
, vscode reports the type asany
whereas if I hover overfoo()
in data, it correctly reportsboolean
. What's going on here? Vetur is reporting most errors correctly, but type checking seems not to be working in parts of Vue SFC's.Reproducible Case
Paste in the above code into a '.vue' file in a Vue-CLI project. Load the project in vscode and notice lack of type checking with
foo
.The text was updated successfully, but these errors were encountered: