Let's say I have a set of values that I don't want to be editable, like this:
// I don't want this to be editable.
const listenedKeys = new Set(['w', 'a', 's', 'd'])
// This should be fine.
const hasA = listenedKeys.has('a')
// I want this to give an error.
listenedKeys.add('r')
Can I "freeze" this set in TypeScript? How?
I've tried using the Readonly utility type, but that doesn't prevent me from modifying the set:
const listenedKeys: Readonly<Set<string>> = new Set(['w', 'a', 's', 'd'])
// No error here
listenedKeys.add('r')