Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I believe you could have a Protocol that requires the property and that the object is Callable.


Ah, that's not really that different than in TypeScript then. There you have to define a callable interface, and can add whatever properties you want

    interface SomethingCallableWithAnExtraProperty {
      // This means you can call it like a function.
      (args: Whatever): SomethingReturned

      // And since it's an interface, you can still do interface-y things
      anotherProperty: string
    }




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: