codecharta icon indicating copy to clipboard operation
codecharta copied to clipboard

Improve type guarding

Open shaman-apprentice opened this issue 3 years ago • 0 comments

Feature request / Refactoring / Developer experience

As developer I want the TypeScript definitions to be as strict as possible, to have best possible support and to reduce unnecessary if else blocks.

Description

When an optional property is further accessed, it has to be done guarded or TypeScript will thrown an error. E.g.:

type SomeType = { children?: number[] }
const instance: SomeType = {}
instance.children.map // this should throw an TypeScript error

Acceptance criteria

  • This access without guard throws an error, or children isn't an optional property anymore of squarifiedNode
  • In tsconfig.json we set "strictNullChecks": true
  • In tsconfig.json we set "strictPropertyInitialization": true

Open questions

  • Needed effort for setting all the strict properties to true is unclear. In case of too much effort, we should adress this step by step.

shaman-apprentice avatar Oct 20 '21 15:10 shaman-apprentice