Upgrading TypeScript to v4
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
Parsing error: Cannot read property 'map' of undefined
— fixed by upgrading the @typescript-eslint packages above.Property 'canCostRelief' does not exist on type 'never'
— TypeScript narrowed an intersection tonever
becauseselected
had conflicting types (boolean
vsstring
). Align the types.This expression is not callable
—quoteLines
was typed asA | B
, but the helper expectedA
. 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.