abdellah hariti
Abdellah H.

Abdellah H.

Use Typescript generics for a type safe `setTimeout` and `setInterval`

Mar 23, 20225 min read

TLDR; Here's the code: type Handler = ((...args: any[]) => any) | string; function safeSetTimeout<F extends Handler>( handler: F, timeout?:...

Use Typescript generics for a type safe `setTimeout` and `setInterval`
Promises: run any promise with a timeout
Promises: async/await vs .then(), how we got here and why I use both