Alias a Result Type
A common pattern is a result that can be OK or an error. Aliasing each variant and the union keeps function signatures tight and readable. Narrow by the discriminant to decide which fields are available.
- Create two object aliases with a shared literal property.
- Create a union alias combining them.
- Return formatted strings consistently.
Your Task
- Define aliases:
- type Ok = { ok: true; value: string }
- type Fail = { ok: false; error: string }
- Define type Result = Ok | Fail.
- Implement summarize(r: Result): string:
- "OK: <value>" when ok: true
- "ERROR: <error>" when ok: false.