Upgrading TypeScript to v4

· 1 min read · 159 Words · -Views -Comments

I upgraded our project to TypeScript 4.0 to use newer TS/JS features like logical assignment operators. Here are the details.

Remember: TypeScript is about types—upgrading shouldn’t change runtime behavior.

Package Updates

{
  "typescript": "4.0.3",
  "@typescript-eslint/eslint-plugin": "^4.5.0",
  "@typescript-eslint/eslint-plugin-tslint": "^4.5.0",
  "@typescript-eslint/parser": "^4.5.0"
}
  • Upgrade related @typescript-eslint packages because ESLint relies on the TS parser.
  • Update other vendor types as needed when errors appear.

Issues Encountered

  1. Parsing error: Cannot read property 'map' of undefined — fixed by upgrading the @typescript-eslint packages above.

  2. Property 'canCostRelief' does not exist on type 'never' — TypeScript narrowed an intersection to never because selected had conflicting types (boolean vs string). Align the types.

  3. This expression is not callablequoteLines was typed as A | B, but the helper expected A. Narrow it (quoteLines as A[]) or adjust the function signature.

Final Thoughts

Version upgrades can be bumpy, but they improve type safety and unlock language features. Treat issues as learning opportunities and don’t postpone upgrades indefinitely.

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover