javascript - Immutable.js Record.set type checking with TypeScript -
i'm using immutable.js typescript build redux app.
essentially, state looks like
const defaultstate = { booleanvalue: true, numbervalue: 0, } const staterecord = immutable.record(defaultstate) class stateclass extends staterecord { booleanvalue: boolean numbervalue: number } const state = new stateclass()
(this setup enables compile-time type checking expressions state.booleanvalue === 'hi'
)
is there way enable compile-time type checking set
, such state.set('booleanvalue', 'hi')
? (i want warning compiler saying 'booleanvalue' cannot set 'hi'
.)
or, there alternative setup make immutable.js , typescript work both when getting , setting?
is there alternative setup make immutable.js , typescript work both when getting , setting
not without wrapping staterecord
in helper functions (basically throwing more code @ needs duplicated , kept in sync). in short nope.
Comments
Post a Comment