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

Native DOM event type checking error since upgrading to 1.0.3 #1985

Closed
ymy0622 opened this issue Oct 11, 2022 · 43 comments
Closed

Native DOM event type checking error since upgrading to 1.0.3 #1985

ymy0622 opened this issue Oct 11, 2022 · 43 comments
Labels

Comments

@ymy0622
Copy link

ymy0622 commented Oct 11, 2022

Native DOM event type checking error. (click, contextmenu, etc.)

vue@3.2.40
vite@3.1.7
vitejs/plugin-vue@3.1.2
vue-tsc@1.0.3
volar@1.0.3

I have deleted and installed yarn.lock + node_modules.

<template>
  <div @click="test"></div>
</template>

<script setup lang="ts">
  const test = () => {}
</script>

Type '() => void' is not assignable to type 'MouseEvent'.ts(2322)
__VLS_types.ts(107, 56): The expected type comes from property 'click' which is declared here on type 'EventObject<undefined, "click", {}, MouseEvent | undefined>'
image

@jbaubree
Copy link

Same issue here

@vsdeeper
Copy link

I got a similar error like this:
image
image

@bjornharrtell
Copy link

For me it works after pinning @types/node to 18.8.0 (+removing lockfile and reinstall deps).

@IagoLast
Copy link

Same thing but when using vue-tsc from the console

Screenshot 2022-10-11 at 11 06 22

@ymy0622
Copy link
Author

ymy0622 commented Oct 11, 2022

For me it works after pinning @types/node to 18.8.0 (+removing lockfile and reinstall deps).

Wow, it works.
Thank you very much.

@vsdeeper
Copy link

For me it works after pinning @types/node to 18.8.0 (+removing lockfile and reinstall deps).

Wow, it works. Thank you very much.

Also works for me.

@ymy0622 ymy0622 closed this as completed Oct 11, 2022
@jbaubree
Copy link

@ymy0622 are you sure this is a real solution and not a workaround before fix ?

@bjornharrtell
Copy link

@ymy0622 I think you should leave this open. It's not really a desired workaround to pin @types/node.

@ymy0622 ymy0622 reopened this Oct 11, 2022
@njtyair
Copy link

njtyair commented Oct 11, 2022

同样的报错信息
__VLS_types.ts(107, 56): 所需类型来自属性 "click",在此处的 "EventObject<undefined, "click", {}, MouseEvent | undefined>" 类型上声明该属性

@lesonky
Copy link

lesonky commented Oct 11, 2022

1.0.3 继续报错,导致 vscode 里面报错,我的build 命令还用了
vue-tsc --noEmit && vite build --config ./config/vite.config.prod.ts

导致无法打包,只能把 vue-tsc 去掉

@IagoLast
Copy link

@bjornharrtell I'm trying to do the @types/node hotfix but still doesn't work...

Any idea of how volar / vue-tsc infer DOM typings? or how the __VLS_types.ts file is generated?

I'm stuck because of this 😭

@jbaubree
Copy link

jbaubree commented Oct 11, 2022

@IagoLast make sure to put "@types/node": "18.8.0" and not "@types/node": "^18.8.0".
Edit: remove node_modules folder and lock file before install again.

@widetrace
Copy link

@IagoLast make sure to put "@types/node": "18.8.0" and not "@types/node": "^18.8.0". Edit: remove node_modules folder and lock file before install again.

thanks!

@fy5220
Copy link

fy5220 commented Oct 11, 2022

I did that and still does not work 🤔

when u done this , reopen the vscode

@IagoLast make sure to put "@types/node": "18.8.0" and not "@types/node": "^18.8.0". Edit: remove node_modules folder and lock file before install again.

@Georgitto
Copy link

Still getting the same problem after changing the version of @types/node to 18.8.0 and reinstalling all dependencies (deleting node_modules folder and yarn.lock).

@steveaffleck
Copy link

18.8.0 didn't work for me but 18.7.14 did.

@cuebit
Copy link
Member

cuebit commented Oct 11, 2022

Works with @types/node@18.8.3 also.

@johnsoncodehk
Copy link
Member

Please track vuejs/core#6855

@johnsoncodehk
Copy link
Member

johnsoncodehk commented Oct 11, 2022

We can't fix this problem in language server, but we will have a doctor message to remind user downgrade @types/node to 18.8.0 or update to next vue release.

@vis97c
Copy link

vis97c commented Oct 11, 2022

We can't fix this problem in language server, but we will have a doctor message to remind user downgrade @types/node to 18.8.0 or update to next vue release.

Does it mean that it cannot be solved from vue-tsc?

@acidjazz
Copy link

why is this issue closed but not yet fixed?

@MaoXuKun
Copy link

我遇到了同样的问题,解决方案是切换 VSCode 的 TS 使用工作区版本。
操作方法为 Ctrl + Shift + P,输入 selectTypeScriptVersion,然后选择 Use Workspace Version。
image
image

@warmthsea
Copy link

image
What should I do?

Michaelbr-Dev pushed a commit to Michaelbr-Dev/P7-frontend that referenced this issue Oct 14, 2022
This commit fixes the bug where volar throws an error
(see vuejs/language-tools#1985)
@Adam-Ponting
Copy link

For me it works after pinning @types/node to 18.8.0 (+removing lockfile and reinstall deps).

This worked for me, though I did have to add @types/node to my devDependencies in package.json.
image

@azat-io
Copy link

azat-io commented Oct 14, 2022

image

I have the same problem.

But I'm not using @types/node directly. Here is my tsconfig.json:

{
  "compilerOptions": {
    "forceConsistentCasingInFileNames": true,
    "types": ["@vuepress/client/types"],
    "importsNotUsedAsValues": "error",
    "moduleResolution": "nodenext",
    "preserveValueImports": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "module": "esnext",
    "target": "es2020",
    "jsx": "preserve",
    "allowJs": true,
    "strict": true,
    "baseUrl": ".",
    "noEmit": true,
    "paths": {
      "~/components/*": ["./components/*"],
      "~/typings/*": ["./typings/*"],
      "~/assets/*": ["./assets/*"],
      "~/pages/*": ["./pages/*"],
      "~/icons/*": ["./icons/*"]
    }
  },
  "include": ["**/*.ts", "**/*.vue"],
  "exclude": ["node_modules"]
}

@vis97c
Copy link

vis97c commented Oct 14, 2022

image

I have the same problem.

But I'm not using @types/node directly. Here is my tsconfig.json:

{
  "compilerOptions": {
    "forceConsistentCasingInFileNames": true,
    "types": ["@vuepress/client/types"],
    "importsNotUsedAsValues": "error",
    "moduleResolution": "nodenext",
    "preserveValueImports": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "module": "esnext",
    "target": "es2020",
    "jsx": "preserve",
    "allowJs": true,
    "strict": true,
    "baseUrl": ".",
    "noEmit": true,
    "paths": {
      "~/components/*": ["./components/*"],
      "~/typings/*": ["./typings/*"],
      "~/assets/*": ["./assets/*"],
      "~/pages/*": ["./pages/*"],
      "~/icons/*": ["./icons/*"]
    }
  },
  "include": ["**/*.ts", "**/*.vue"],
  "exclude": ["node_modules"]
}

It doesn't matter that you don't use it directly. Dependencies can install dependecies. Alternatively if you are using yarn use resolutions instead.

E: As stated by @yah-yuan updating vue should fix the issue.

@tzhang-dev
Copy link

seems vue@3.2.41 has been released and fixed this problem. I upgraded vue and @types/node to the latest, and the error no longer exists.

@cuebit
Copy link
Member

cuebit commented Oct 14, 2022

seems vue@3.2.41 has been released and fixed this problem. I upgraded vue and @types/node to the latest, and the error no longer exists.

Sadly this doesn't seem to be the case for many. v3.2.40...v3.2.41 shows no indication of any fix for this and the actual fix (vuejs/core#6855) is yet to be merged and released.

@loneil
Copy link

loneil commented Oct 14, 2022

seems vue@3.2.41 has been released and fixed this problem. I upgraded vue and @types/node to the latest, and the error no longer exists.

Are you sure about that? Vue 3.2.41 hasn't fixed this issue. Is it possible your types/node in your lock is still pinned to 18.8.0 and you didn't really update it? I'm trying starting from scratch and as of right now with the latest everything, you still need that 18.8.0 pin

@johnsoncodehk
Copy link
Member

Please wait for 3.2.42 and pin @types/node to 18.8.0 for now. :)

@johnsoncodehk
Copy link
Member

Please also track DefinitelyTyped/DefinitelyTyped#62729 (Fix for next @types/node version)

Amour1688 pushed a commit to vuejs/babel-plugin-jsx that referenced this issue Oct 15, 2022
* chore(deps): update all non-major dependencies

* chore: remove the lockfile and reinstall to update trnasitive deps

The outdated `@types/babel__traverse` package is causing type errors

* fix: fix htmlTags type error

* fix: pin @types/node to 18.8.0 to work around vuejs/language-tools#1985

* fix: pin @vue/test-utils temporarily to avoid snapshot differences

* test: update snapshot

As far as I see, all the snapshot differences are merely the newlines
after `import` statements

* test: add `attachTo: document.body` to make click event take effect

See vuejs/test-utils#1470 (comment)

* fix: fix mjs processing for webpack 4

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Haoqun Jiang <haoqunjiang@gmail.com>
Effect-Wei added a commit to Effect-Wei/Takina-Frontend that referenced this issue Oct 16, 2022
GefeiSHEN added a commit to GefeiSHEN/frontend-exercise that referenced this issue Oct 17, 2022
Milesq added a commit to Milesq/ministry-sheet that referenced this issue Oct 18, 2022
u-sho added a commit to jphacks/B_2221 that referenced this issue Oct 18, 2022
Milesq added a commit to Milesq/ministry-sheet that referenced this issue Oct 18, 2022
yamarico pushed a commit to jphacks/B_2221 that referenced this issue Oct 18, 2022
* 🎉 Init Vue app

* 🔧 typescript-eslint の設定を強めにかけて型安全性を高める

* 🎨 prettier でフォーマットする

* 🩹 fix vuejs/language-tools#1985

* 🧑‍💻 eslint/prettier を cache で高速化
@johnsoncodehk
Copy link
Member

johnsoncodehk commented Oct 19, 2022

@types/node fixed this problem in 18.11.1, 18.11.2 and later version by DefinitelyTyped/DefinitelyTyped#62782, please upgrade to fix.

But Volar 1.0.8 will still have doctor warns for 18.11.1, 18.11.2 because we can't hot update the version judge, please just ignore the warning or you can disable doctor (not recommend) by add "volar.doctor.statusBarItem": false VSCode setting.

@rodrigocfd
Copy link

@johnsoncodehk Shouldn't Volar have a new version disabling the doctor warning now?

@johnsoncodehk johnsoncodehk unpinned this issue Oct 23, 2022
leomp12 added a commit to ecomplus/cloud-commerce that referenced this issue Nov 1, 2022
codegod2222 added a commit to codegod2222/babel-plugin-jsx that referenced this issue Jan 12, 2023
* chore(deps): update all non-major dependencies

* chore: remove the lockfile and reinstall to update trnasitive deps

The outdated `@types/babel__traverse` package is causing type errors

* fix: fix htmlTags type error

* fix: pin @types/node to 18.8.0 to work around vuejs/language-tools#1985

* fix: pin @vue/test-utils temporarily to avoid snapshot differences

* test: update snapshot

As far as I see, all the snapshot differences are merely the newlines
after `import` statements

* test: add `attachTo: document.body` to make click event take effect

See vuejs/test-utils#1470 (comment)

* fix: fix mjs processing for webpack 4

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Haoqun Jiang <haoqunjiang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests