<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>node on Abdellah Codes</title>
    <link>https://abdellahcodes.xyz/tags/node/</link>
    <description>Recent content in node on Abdellah Codes</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Sun, 20 Mar 2022 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://abdellahcodes.xyz/tags/node/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Use Typescript generics for a type safe `setTimeout` and `setInterval`</title>
      <link>https://abdellahcodes.xyz/posts/use-typescript-generics-for-a-type-safe-settimeout-and-setinterval/</link>
      <pubDate>Sun, 20 Mar 2022 00:00:00 +0000</pubDate>
      <guid>https://abdellahcodes.xyz/posts/use-typescript-generics-for-a-type-safe-settimeout-and-setinterval/</guid>
      <description>TLDR; Here&amp;rsquo;s the code:
type Handler = ((...args: any[]) =&amp;gt; any) | string; function safeSetTimeout&amp;lt;F extends Handler&amp;gt;( handler: F, timeout?: number, ...args: F extends string ? any[] : Parameters&amp;lt;F extends string ? never : F&amp;gt; ) { return setTimeout(handler, timeout, ...args); } If you understand everything in the following snippet, you don&amp;rsquo;t have much to gain from this post. But you might want check out the practical snippet at the end of this post.</description>
    </item>
  </channel>
</rss>
