Typescript definitions
poupryc opened this issue · 6 comments
Hello,
Is it planned to add TypeScript definitions to this module? I think it would be appreciated by the developers. I unfortunately do not have enough experience writing good definitions of my own.
Anyway, good work with avvio ^^
It is not planned at the moment.
We aren't typescript users, but we are open to accept a pr with type definitions! :)
Feel free to send a PR!
Okay, I'll try, but if anyone else ever wants to contribute, feel free!
After several searches, I came to the conclusion that Avvio was not typable with Typescript:
the reason is that Avvio uses several different signatures for certain functions, like after
, which is written with typescript like this:
type done = () => void
after(callback: (err: Error, done: avvio.done) => void): this
after(callback: (err: Error, context: server<T>, done: avvio.done) => void): this
AFAIK, typescript cannot handle this case because a consistency is required at the type level :/
If anyone had a solution, it could be extremely useful. I don't see any other way
@HelloEdit I think this has been modelled in https://github.com/fastify/fastify/blob/master/fastify.d.ts#L310-L316