Typings
Units
// a ListUnit whose value type would be string[]
const namesList = new ListUnit<string>();
namesList.push('Mr. Anderson'); // works
namesList.dispatch(['Trinity', 'Morpheus']) // works
namesList.push(737); // linting error, invalid value
namesList.dispatch([737]) // linting error, invalid value// a DictUnit whose value type would be {[key in 'a' | 'b' | 'c']: number}
const someDict = new DictUnit<{[key in 'a' | 'b' | 'c']: number}>();
someDict.set('a', 1993) // works
someDict.dispatch({a: 1, b: 2, c: 3}) // works
someDict.set('b', 'not a number') // linting error, invalid value
someDict.set('d', 1993) // linting error, invalid key
someDict.dispatch({a: 1, b: 2}) // linting error, property 'c' is missingSystems
Action
Last updated
Was this helpful?