gristlabs / ts-interface-builder

Compile TypeScript interfaces into a description that allows runtime validation
Apache License 2.0
132 stars 28 forks source link

feat: Add support for callback signatures #11

Open diosney opened 5 years ago

diosney commented 5 years ago

Something like:


export interface IHookOnCancel {
  (): void | Promise<void | null>;
}
dsagal commented 5 years ago

Could you include an example of where it would be useful? In particular, it would help decide how to support such signatures, or if we only need to be able to skip them.

diosney commented 5 years ago

All the issues I recently created are useful to me righth now on a single feat I need, namely client configuration validation, I mean, validate the configuration that my library users enter.

After some though and testing, I came to realization that maybe using these libraries is not the way to go in my case, but using something like JSON Schema or some other schema validator.

Thanks

dsagal commented 5 years ago

Perhaps you are right. But that's why I am asking. Call signatures don't make sense for a data descriptor of the kind that you might consider using JSON Schema validator for.

diosney commented 5 years ago

@dsagal You're right, JSON Schema doesn't have callback signatures, I said it only to say something as an example, which I have to check now how can I overcome that or to find another way to fully validate client configuration entries.