How I upgraded antd from antd@4.19.0 to antd@4.20.0
Goal: Upgrade antd from 4.19.0 to 4.20.0
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
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.
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
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
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
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