codecharta
codecharta copied to clipboard
Improve type guarding
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 ofsquarifiedNode
- 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.