TSX Wrong Emit Handler Return Type
Version
3.2.1
Reproduction link
https://jsfiddle.net/986ukynp/
Steps to reproduce
Event handler should return void not validation value of emit.
What is expected?
No type error
What is actually happening?
Type error is happening
@webfansplz I edited type code with your pull request and nothing changed. The problem is here I think.
I don't have a good knowledge about typing types but if I change it to this, I don't get any type error in component file but in type file.
Hi @kadiryazici,Maybe you just forgot to return it when you invoked it
import { defineComponent } from 'vue';
const Component = defineComponent({
emits: {
something: (value: string) => true
}
});
const OtherComponent = defineComponent({
render() {
return (
<Component
onSomething={() => {
console.log('yeah');
return true // return true
}}
/>
);
}
});
export default OtherComponent
@webfansplz it is not the return type of emit, it is just validator. I return true from validator because I don't need validaton. Vscode type checking is enough for me.
Emit handler should return any or void always.