language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Native DOM event type checking error since upgrading to 1.0.3

Open ymy0622 opened this issue 4 years ago • 43 comments

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

[email protected] [email protected] vitejs/[email protected] [email protected] [email protected]

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

ymy0622 avatar Oct 11 '22 08:10 ymy0622

Same issue here

jbaubree avatar Oct 11 '22 08:10 jbaubree

I got a similar error like this: image image

vsdeeper avatar Oct 11 '22 09:10 vsdeeper

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

bjornharrtell avatar Oct 11 '22 09:10 bjornharrtell

Same thing but when using vue-tsc from the console

Screenshot 2022-10-11 at 11 06 22

IagoLast avatar Oct 11 '22 09:10 IagoLast

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

Wow, it works. Thank you very much.

ymy0622 avatar Oct 11 '22 09:10 ymy0622

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.

vsdeeper avatar Oct 11 '22 09:10 vsdeeper

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

jbaubree avatar Oct 11 '22 09:10 jbaubree

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

bjornharrtell avatar Oct 11 '22 09:10 bjornharrtell

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

njtyair avatar Oct 11 '22 11:10 njtyair

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

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

lesonky avatar Oct 11 '22 11:10 lesonky

@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 😭

IagoLast avatar Oct 11 '22 12:10 IagoLast

@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.

jbaubree avatar Oct 11 '22 12:10 jbaubree

@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!

widetrace avatar Oct 11 '22 12:10 widetrace

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.

fy5220 avatar Oct 11 '22 13:10 fy5220

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).

Georgitto avatar Oct 11 '22 15:10 Georgitto

18.8.0 didn't work for me but 18.7.14 did.

steveaffleck avatar Oct 11 '22 18:10 steveaffleck

Works with @types/[email protected] also.

cuebit avatar Oct 11 '22 18:10 cuebit

Please track https://github.com/vuejs/core/pull/6855

johnsoncodehk avatar Oct 11 '22 21:10 johnsoncodehk

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.

johnsoncodehk avatar Oct 11 '22 22:10 johnsoncodehk

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?

vis97c avatar Oct 11 '22 23:10 vis97c