Goal: Upgrade antd from 4.19.0 to 4.20.0

Showing antd and typescript version

Preparation: Initially, I upgraded directly from 4.19.0 to 4.19.1 then to 4.19.2 and got to first error as shown below. I followed the incremental upgrade, i.e. upgrade package version wise.

We can check the current version of antd with command npm ls antd. It shows the current version as 4.19.0.

  • Install antd version 4.19.2
npm install --save antd@4.19.2

Check to see if it works fine or not with NODE_ENV=development npm run dev

I faced my first issue that needed me to upgrade TypeScript version. Upgrade Typescript Version

Failed to compile

Fixed above errors by upgrading typescript version from 3.8.3 to latest version, which is 4.6.3 while writing this post.

  • Upgrade TypeScript
npm install --save typescript@latest

After TypeScript version was upgraded, the first issue was fixed. Then, I tried running npm run dev again and got another issue “Object is of type ‘unknown'”. This issue occurred because I had upgraded TypeScript from 3.8.3 to 4.0.0, and in 4.0.0 error type was changed from any to unknown in catch block by default details are here

error type unknown

Failed npm run dev

To resolve it, open tsconfig.json and enter "useUnknownInCatchVariables": false, in compilerOptions section.

Now, running npm run dev worked fine without errors.

  • Upgrade antd to 4.20.0
npm install --save antd@4.20.0 

The installation went fine and I could also run npm run dev without issue. Finally, we are at antd@4.20.0

References

  • https://stackoverflow.com/a/69445095
  • https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html#unknown-on-catch-clause-bindings