0

What is the syntax to define onChange in this interface:

interface myInterface{
   data: Type1
   onChange : ({field: string, value: any}[]) => void
}

It gives me compile error on '=>' (; expected) I want to say onChange receives an array of field-value pair and return type is void. What is the syntax?

1
  • 3
    First you need a name for the parameter: (arr: {...}[]). Then either pick arrow prop or method syntax, not both (onChange(...): void or onChange: (...) => void. Commented Apr 30, 2020 at 19:12

1 Answer 1

2

Your forgot about :

interface myInterface{
  data: Type1
  onChange: (arr: {field: string, value: any}[]) => void
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.