Upgrade to 1.4.0 typescript report error
Ttou opened this issue · comments
Ttou commented
https://codesandbox.io/s/composition-1-4-0-f56jt?file=/src/App.tsx
Type '{ on: { click: () => void; }; }' is not assignable to type 'IntrinsicAttributes & Readonly<Partial<{}> & Omit<{} & {} & { [x: string & `on${string}`]: ((...args: any[]) => any) | undefined; }, never>>'.
Type '{ on: { click: () => void; }; }' is not assignable to type 'Readonly<Partial<{}> & Omit<{} & {} & { [x: string & `on${string}`]: ((...args: any[]) => any) | undefined; }, never>>'.
Property 'on' is incompatible with index signature.
Type '{ click: () => void; }' is not assignable to type '(...args: any[]) => any'.
Type '{ click: () => void; }' provides no match for the signature '(...args: any[]): any'.ts(2322)
ZHAO Jin-Xiang commented
Use <HelloWorld onClick={this.handleClick}/>
instead.
Ttou commented
like vant ActionSheet
component, it has click-overlay
event listener, maybe need fix type:
import { defineComponent } from '@vue/composition-api'
import { ActionSheet } from 'vant'
export default defineComponent({
setup() {
function handleClick() {
alert('Click Overlay')
}
return {
handleClick
}
},
render() {
return (
<div>
<ActionSheet
// can't work
onClickOverlay={this.handleClick}
// can work
on-click-overlay={this.handleClick}
on={{
// can work
'click-overlay': this.handleClick
}}
/>
</div>
)
}
})