title: Type 'string' is not assignable to type 'never' and Type 'unknown' is not assignable to type 'never' error in react typescript
body: <p>I have a function in React Typescript</p>
  <pre><code>const filter = (data: any) =&gt; {
      if (Array.isArray(data)) {
        const temp = data.reduce((r, v) =&gt; {
          v = filter(v);
          if (v !== &quot;&quot;) r.push(v);
          return r;
        }, []);
        return temp.length ? temp : &quot;&quot;;
      }
      if (data &amp;&amp; typeof data === &quot;object&quot;) {
        const temp = Object.entries(data).reduce((r, [k, v]) =&gt; {
          v = filter(v);
          if (v !== &quot;&quot;) r.push([k, v]);
          return r;
        }, []);
        return temp.length ? Object.fromEntries(temp) : &quot;&quot;;
      }
      return data;
    };
  </code></pre>
  <p>but here in line <code>if (v !== &quot;&quot;) r.push([k, v]);</code> I am getting error <code>Type 'string' is not assignable to type 'never'.ts(2322)</code> and <code>Type 'unknown' is not assignable to type 'never'.ts(2322)</code> in <code>k</code> and <code>v</code> respectively, but I am not getting any solution to fix these issues. I am new with Typescript.</p>