u/heyitsmattwadein r/typescript • Recommends
On “How do I use as const but also enforce type”
Yep, the problem is your `as const` for `examplesWithType` essentially gets "thrown away" because you are typing the variable keyword directly!
`satisfies` is when you want to keep some type narrow while also validating it against a wider type.
Here is an updated playground with your example, and I also recommend this video for a quick primer on the `satifies` keyword:
- link to this video