Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
TypeScript
/
Branded types
Why should addUsd(a, b) call the UsdCents constructor on a + b?
from Branded types
TypeScript 6
advanced
1 min
Why should addUsd(a, b) call the UsdCents constructor on a + b?
Addition returns number and may violate range or safe-integer invariants.
Branded numbers cannot be arithmetic operands.
The constructor adds a runtime symbol property used by addition.
TypeScript automatically converts the result to another currency.
Check
Ask AI about this kata
Report an error
previous kata
Given a correctly constructed UserId brand over number, which assignment is safe without …
Quiz
next kata
What does this program print?
Predict the output
A new version is available
Reload