Defining TypeScript callback type

后端 未结 8 1142
情话喂你
情话喂你 2020-12-12 11:53

I\'ve got the following class in TypeScript:

class CallbackTest
{
    public myCallback;

    public doWork(): void
    {
        //doing some work...
               


        
8条回答
  •  借酒劲吻你
    2020-12-12 11:57

    If you want a generic function you can use the following. Although it doesn't seem to be documented anywhere.

    class CallbackTest {
      myCallback: Function;
    }   
    

提交回复
热议问题