ui icon indicating copy to clipboard operation
ui copied to clipboard

Type `onClick` is missing when use UButton in tsx

Open shiny opened this issue 2 years ago • 3 comments

Version

@nuxt/ui: v2.8.1 nuxt: v3.7.3

Reproduction Link

https://stackblitz.com/edit/nuxt-ui-c8yl8v?file=app.vue

Steps to reproduce

<template>
  <Button />
</template>

<script setup lang="tsx">
import { UButton } from '#components'
const sayHello = () => {
  console.log('Hello There!')
}
const Button = <UButton onClick={sayHello}>Go</UButton>
</script>

in Visual Studio Code, onClick will cause a TS Error #2322

What is Expected?

Should not produce a typing error.

What is actually happening?

Actually this example works great in runtime, which follows the vue3 documentation https://vuejs.org/guide/extras/render-function.html#v-on —— what i do is just replace button to UButton. The typing error should not appear.

shiny avatar Sep 21 '23 13:09 shiny

I have also encountered this issue. Although it does not affect the runtime, it would be more user-friendly to include various Vue events in the component's type definition, such as onClick and onChage

@benjamincanac @danielroe 🙏🙏🙏

Image

mcpanl avatar Dec 11 '23 04:12 mcpanl

@mcpanl Unlike other UI frameworks, there is no "events" listed at docs https://ui.nuxt.com/components/button

YipingRuan avatar Mar 11 '24 03:03 YipingRuan

same problem

censujiang avatar Jul 19 '24 16:07 censujiang