R
R
Roman Yakimchuk2019-04-14 07:33:53
typescript
Roman Yakimchuk, 2019-04-14 07:33:53

Why is this code valid?

Hello
Code:

let err = new Error();
let data = {};

let iTakeSomethingAndPassItAnErr
    = (x: (err: Error, data: any) => void) => { /* do something */ };

iTakeSomethingAndPassItAnErr(() => null) // Okay
iTakeSomethingAndPassItAnErr((err) => null) // Okay
iTakeSomethingAndPassItAnErr((err, data) => null) // Okay

Why are we declaring that the input function must have two parameters, we have that the first two calls are valid, while there is an incorrect number of call arguments?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question