-4

I need to clone an already existing javascript code into Typescript. The javascript is :

object.getsomething( function(err, result) {
    // async
});

How can I type the parameter function(err,result) ?

I tried retrieve(func: function(err:string, result:string) : any){}

but the my intellisense says "err" and "result" name can't be found. And I can't find any documentation about the "function" type.

1

1 Answer 1

6

You can use the "fat arrow" notation as follows:

retrieve(func: (err: string, result: string) => any) { ... }
Sign up to request clarification or add additional context in comments.

1 Comment

upvoting this correct answer, although the question is probably a duplicate.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.