Advanced
TypeScript
Q83 / 100
What is a "branded type" (or nominal typing emulation) pattern used for?
Correct! Well done.
Incorrect.
The correct answer is B) To simulate nominal typing by adding a unique phantom property so structurally identical types are not interchangeable
B
Correct Answer
To simulate nominal typing by adding a unique phantom property so structurally identical types are not interchangeable
Explanation
Branded types add an unused "tag" property (e.g. "& { __brand: 'UserId' }") so that otherwise structurally identical types like UserId and number are not assignable to each other.
Progress
83/100