Reputation: 4593
I am trying to include function signature inside a type.
type validatorAction = {
validatorFN: function method(str, bool, ...nums) {
},
errorKey: string,
errorMessage: string
}
Tried multiple variations but none of them work and the documentation are horrible.
Upvotes: 0
Views: 31
Reputation: 37918
You shouldn't include function implementation in type declaration but specify its (function's) type:
type validatorAction = {
validatorFN: (string, boolean, ...number[]) => boolean,
errorKey: string,
errorMessage: string
}
And here's version with parameter names:
validatorFN: (str: string, bool: boolean, ...nums: number[]) => void
Upvotes: 2