Blog

Browse by tags

All Posts

Kevin Dam's profile picture
Kevin Dam
Feb. 12, 20234 min read
TypeScript logo

As const satisfies Type

Since TypeScript does not have immutability by default, I tend to use the `as const` operator liberally. Put another way, I default to using `as const` until it conflicts with my intentions for whatever program I am writing. I also benefit from TypeScript having more information to provide developer experience niceties like editor hinting and auto-complete. However, `as const` only provides type narrowing. It does not provide type-safety on its own. We can restore type-safety by embracing intermediate variables at the cost of noise and loss of developer ergonomics. With the release of the `satisfies` operator, we no longer have to make this tradeoff.