-
-
Notifications
You must be signed in to change notification settings - Fork 596
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
"Cannot find name" and other problems with TypeScript-SFC #1388
Comments
@ktsn This is the output of
|
That's strange because the errors looks only happens on template interpolation service. Could you try to produce it in available source code for us so that we can work on it? (e.g. extract culprit file, make the source code minimal to open etc.) |
@ktsn I hope this description will help you track down the error. Same issue here. The way how I was able to make such error.
|
@msamsel's description is exactly what happened to me. I tried deleting and recreating the file but still have the same error. I've now switched to |
Just encountered this issue as well, same situation as @msamsel Steps taken to address:
|
Yeah + 1 for @msamsel's description. Same for me. Renaming the file is fine - try to name it back, get smacked in the face with a wall of red (even though everything looks legit). |
@yoyo930021 do you think, provided description is sufficient to make a bug report from it? |
It's ok. I will try to study it. |
They seem to still be displayed for me... must be my linter |
This comment has been minimized.
This comment has been minimized.
Ran into the same issue that @msamsel described as well, seems like it might be an issue with vs code and not Vetur. I tried to run Debugging the extension it looks like Then pressed Ctrl+P and started typing the name of the file to ensure that all references to the old improperly cased file were gone. Somehow the file was still there so I ended up pressing the 'X' to the right of the result to manually remove it from my recently opened files. Closed VS Code, deleted the file, re-opened vscode, created a new file with the same name but correct casing, and copied in the contents of the old file. |
@d18n Thanks. This solution works for me. |
Not sure if this is related or not, but it feels related. In a vue 2 project I am making some updates to I noticed that vetur will sometimes not find the correct method when I use '@' instead of 'v-on:'. It appears to be one character off on the name. Here is an example: Now to make things even odder if you move it the line the tag starts on the issue goes away: This seems a bit more specific then the original post, but I wasn't sure if it might be related or not. After a bit more work on this project we noticed that this does not happen when the handler is passed by name. For example: @click="onClick" does not seem to trigger the issue at all. |
@rahicks26 #1319, it's fixed but not released yet. |
Hi, my package.json is below:
If I disable vetur js validation no problem is reported but I don't know if that can produce any collateral issue. |
The same problem bothers me, I disable vetur js validation, but I think this is not a good solution. |
Same issue happening on Vetur 0.31.3 |
Can anyone provide repro operating system? |
I already know the cause of the problem. |
Hello, I was able to solve this problem by clearing vs cache in the following paths : It was a desperate action. May not be the correct thing to do but other given solutions did not work for me. |
Windows 10 Pro 19042.746 |
I tried deleting just the cache from appdata as recommended above, also tried clearing history in vscode itself and it still didn't work. Once I deleted the cache for all extensions and workspaces it seemed to finally clean up. |
I want to add that this worked for me once. Second time I did this to fix the issue:
|
I encountered this issue this morning so hopefully this helps someone. The easy way
The hard way (and a deeper look into what's going on under the hood)
The encoded JSON inside the value looks something like this where
Internally, VSCode still holds a reference to the incorrectly named file, and correcting those references seems to resolve the issue. |
I am able to reliably workaround this issue by keeping the 'typescript' version under '4.5.x' in dev dependencies.
then run yarn\npm install, restart vs-code and the issue goes away. |
In case anyone has the same issue I was having, I kept trying to do this export default {
data() {},
methods: {}
// etc...
} When I think I should've been doing this... import { defineComponent } from "vue";
export default defineComponent({
data() {},
methods: {},
// etc...
}) |
In my case, my editor showed me an error with "already include file name ....",and this method works a lot ,thanks! |
@chris56974 I think you have just a syntax error and you should type |
@msamsel thanks for the catch. I'm not sure why I wrote a syntax error in my example 😂. I've revised it to better reflect the point I intended to make, which is that "typescript users should use defineComponent for typescript to properly infer types inside the component" - vue3 TS docs. I think I was getting an error at the time and switching to defineComponent fixed the error I was getting. It was a while ago though and I don't remember haha. My apologies for anyone who found my original example confusing. |
I'm facing the same issue with the Volar extension |
If you still have the errors:
tsconfig.json working
tsconfig.json working
FINALLY --> 6. Again: Do Step 3 |
Info
Problem
Vetur underlines everything and gives errors like
Cannot find name
all the time.Reproducible Case
At the moment I'm not sure how to make a reproducible case. The project is closed source and I'm not the author of most of the code. I mostly hope, that someone has seen this behaviour before.
The text was updated successfully, but these errors were encountered: