I am trying to do this:
const focusReaction: Reaction = {
trigger: { type: 'ON_CLICK' },
actions: [
// Set the current focusFlag to true
{
type: 'SET_VARIABLE' as const, // Explicitly setting the type to 'SET_VARIABLE'
variableId: focusFlag.id,
variableValue: {
resolvedType: 'BOOLEAN',
type: 'BOOLEAN',
value: true,
},
},
// Set all other focusFlags to false
...variableObjects
.filter((vo) => vo.focusFlag.id !== focusFlag.id)
.map((vo) => ({
type: 'SET_VARIABLE' as const, // Explicitly setting the type to 'SET_VARIABLE'
variableId: vo.focusFlag.id,
variableValue: {
resolvedType: 'BOOLEAN',
type: 'BOOLEAN',
value: false,
},
})),
],
};
But it just doesn’t work, it complains about types
etc but it seems like another issue.
Here’s the error:
code.ts:125:21 - error TS2322: Type '{ type: "SET_VARIABLE"; variableId: string; variableValue: { resolvedType: string; type: string; value: boolean; }; }' is not assignable to type 'Action'.
Type '{ type: "SET_VARIABLE"; variableId: string; variableValue: { resolvedType: string; type: string; value: boolean; }; }' is not assignable to type '{ readonly type: "SET_VARIABLE"; readonly variableId: string | null; readonly variableValue?: VariableData | undefined; }'.
The types of 'variableValue.type' are incompatible between these types.
Type 'string' is not assignable to type 'VariableDataType | undefined'.
125 ...variableObjects
~~~~~~~~~~~~~~~~~~
126 .filter((vo) => vo.focusFlag.id !== focusFlag.id)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
134 },
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135 })),
~~~~~~~~~~~~~~~~~~~~~~~~~~~
2:41:22 PM] Found 1 error. Watching for file changes.