Imagine this scenario: I define
const foo = { myKey: 'myValue' } as const
Now, when I ask for typeof foo
, I get { readonly myKey: 'myValue' }
If I have a type
MyType = Record<string, string>
, and I want to create a modifier (let's call it Modify) that functions like this...
type ModifiedMyType = Modify<MyType>
const foo: ModifiedMyType = { myKey: 'myValue' }
In this instance, I haven't explicitly declared it as const like before. However, I want typeof foo
to still be { readonly myKey: 'myValue' }