Creating a Typescript union, while also having runtime access to the values

· Jamie Tanna · Oct. 28, 2026, 12:37 p.m.
Summary
This blog post by Jamie Tanna discusses a useful approach for creating TypeScript unions while maintaining runtime access to their values. The example focuses on a union of Git-hosting platforms (github, gitlab, forgejo) and demonstrates how to define them in a way that allows both type safety and runtime reference, using the 'as const' assertion.
AUTHOR