title: in Typescript, try...catch error object shows "Object is of type 'unknown'.ts(2571)"
body: <pre class="lang-js prettyprint-override"><code>router.get('/cells', async (req, res) =&gt; {
      try {
        const result = await fs.readFile(fullPath, { encoding: 'utf-8' });
        res.send(JSON.parse(result));
      } catch (err) {
        if (err.code === 'ENOENT') { // Object is of type 'unknown'.ts(2571) (local var) err: unknown
          await fs.writeFile(fullPath, '[]', 'utf-8');
          res.send([]);
        } else {
          throw err;
        }
      }
  </code></pre>
  <p><code>err.code</code> make this ts error : <code>Object is of type 'unknown'.ts(2571)</code></p>
  <p>I definitely know that <code>err.code</code> exists, so I want to know how to define the type(or interface) of <code>err</code>?</p>
  <p>(tsc version info : My global typescript version is <strong>v4.3.5</strong> and the above code belongs to my project which has typescript <strong>v4.1.2</strong>)</p>
  <p>--- Edit ---</p>
  <p>I finally know why this error happens to me.
  I thought I used tsc version under 4.3.x, but it turns out I used v4.4.x.</p>
  <p>In vscode, <code>cmd + shift + P</code> and search for Select Typescript version
  and I actually used v4.4.3, (I mistakenly thought on version because I only check tsc version from terminal)</p>
  <p><a href="https://i.stack.imgur.com/d7ea7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/d7ea7.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/cSU66.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cSU66.png" alt="enter image description here" /></a></p>
  <p>Thanks for sharing <a href="https://www.youtube.com/watch?v=JyBvFey7pVc" rel="noreferrer">Youtube video</a>,</p>