MaibornWolff / MaibornWolff/codecharta

Improve type guarding

Open
#2,460 0 comments 0 reactions 0 assignees View on GitHub
difficulty:low pr-visualization priority:medium tech
Dominant language
TypeScript
Stars
529
Forks
56
Avg merge
7h 17m
Merged PRs (30d)
34

Description

# 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.:
```ts
type SomeType = { children?: number[] }
const instance: SomeType = {}
instance.children.map // this should throw an TypeScript error
```

## Acceptance criteria
- [This access without guard](https://github.com/MaibornWolff/codecharta/pull/2458#discussion_r732457181) 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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with tsconfig.json and the squarifiedNode definition referenced in the acceptance criteria and linked pull request discussion. Enable strictNullChecks and strictPropertyInitialization, then identify and address the resulting type errors incrementally. Done means the requested strict settings are enabled and optional-property access is guarded or made non-optional where appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.