Altinn / Altinn/app-frontend-react

Type-checking: Warn about rendering `Label` for components without `TRBLabel` (or `LabeledComponentProps`)

Open
#2,315 0 comments 0 reactions 0 assignees View on GitHub
quality/debt
Dominant language
TypeScript
Stars
21
Forks
33
Avg merge
6d 23h
Merged PRs (30d)
3

Description

See discussion behind this issue here: https://github.com/Altinn/app-frontend-react/pull/2244#discussion_r1719694789

Basically, earlier when GenericComponent rendered the label, the correct text resource bindings and `LabeledComponentProps` were added automatically to components when you configured them with automatic label rendering. These would now have to be added manually to components, and we'll have to remember to configure those options for components that are supposed to render labels.

This is brittle, so to prevent us from forgetting we should have a mechanism (preferably directly in types, so typescript warns us) when we try to render a `Label` for a component/node not configured with `TRBLabel`. Also, if the component category is `Form`, `LabeledComponentProps` should also be configured.

Contributor guide

Open the contributing guide

Research direction

Read the linked pull request discussion and inspect GenericComponent, Label, TRBLabel, and LabeledComponentProps. Define the type-checking behavior so TypeScript warns when Label is rendered without TRBLabel, and when a Form component lacks LabeledComponentProps; done means these invalid configurations are caught by the type system.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
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.