Currently, I'm utilizing Immutable.js alongside TypeScript for the development of a Redux application.
In essence, the structure of my State object is as follows:
const defaultState = {
booleanValue: true,
numberValue: 0,
}
const StateRecord = Immutable.Record(defaultState)
class StateClass extends StateRecord {
booleanValue: boolean
numberValue: number
}
const STATE = new StateClass()
(Using this configuration allows for compile-time type checking to catch errors like STATE.booleanValue === 'hi'
)
I'm wondering if there's a way to implement compile-time type checking for the set
method, such as in the expression STATE.set('booleanValue', 'hi')
. (I'd like to receive a warning from the compiler stating that
'booleanValue' cannot be set to 'hi'
.)
Alternatively, is there a different setup that would allow Immutable.js and TypeScript to seamlessly work together for both getting and setting operations?