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

TSX Wrong Emit Handler Return Type #4288

Closed
kadiryazici opened this issue Aug 10, 2021 · 4 comments · Fixed by #4290
Closed

TSX Wrong Emit Handler Return Type #4288

kadiryazici opened this issue Aug 10, 2021 · 4 comments · Fixed by #4290

Comments

@kadiryazici
Copy link
Contributor

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

image

@kadiryazici kadiryazici changed the title TSX Wrong Emits Return Type TSX Wrong Emit Handler Return Type Aug 10, 2021
@kadiryazici
Copy link
Contributor Author

kadiryazici commented Aug 10, 2021

@webfansplz I edited type code with your pull request and nothing changed. The problem is here I think.
image

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

@webfansplz
Copy link
Member

webfansplz commented Aug 10, 2021

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

@kadiryazici
Copy link
Contributor Author

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

@webfansplz
Copy link
Member

@kadiryazici You are right, I have mentioned PR to fix this

@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants