We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yarn dev:all
[...rack-example] ERROR in ./apps/react-trrack-example/src/app/store/trrack.ts:46:7 [...rack-example] TS2345: Argument of type '(add: number) => { type: string; payload: number; meta: { hasSideEffects: boolean; }; }' is not assignable to parameter of type 'TrrackActionFunction<"increment-counter", string, any, number> | StateChangeFunction<number, number>'. [...rack-example] Type '(add: number) => { type: string; payload: number; meta: { hasSideEffects: boolean; }; }' is not assignable to type 'TrrackActionFunction<"increment-counter", string, any, number>'. [...rack-example] Property 'undo' is missing in type '{ type: string; payload: number; meta: { hasSideEffects: boolean; }; }' but required in type '{ do?: { payload: number; type: "increment-counter"; } | undefined; undo: { payload: any; type: string; }; }'. [...rack-example] 44 | const incrementCounter = reg.register( [...rack-example] 45 | 'increment-counter', [...rack-example] > 46 | (add: number) => { [...rack-example] | ^^^^^^^^^^^^^^^^^^ [...rack-example] 47 | setCounter((c) => c + add); [...rack-example] 48 | return { [...rack-example] 49 | type: 'decrement-counter', [...rack-example] [...rack-example] ERROR in ./apps/react-trrack-example/src/app/store/trrack.ts:60:7 [...rack-example] TS2345: Argument of type '(sub: number) => { type: string; payload: number; meta: { hasSideEffects: boolean; }; }' is not assignable to parameter of type 'StateChangeFunction<number, number> | TrrackActionFunction<"decrement-counter", string, any, number>'. [...rack-example] Type '(sub: number) => { type: string; payload: number; meta: { hasSideEffects: boolean; }; }' is not assignable to type 'StateChangeFunction<number, number>'. [...rack-example] Type '{ type: string; payload: number; meta: { hasSideEffects: boolean; }; }' is not assignable to type 'number'. [...rack-example] 58 | const decrementCounter = reg.register( [...rack-example] 59 | 'decrement-counter', [...rack-example] > 60 | (sub: number) => { [...rack-example] | ^^^^^^^^^^^^^^^^^^ [...rack-example] 61 | setCounter((c) => c - sub); [...rack-example] 62 | return { [...rack-example] 63 | type: 'increment-counter', [...rack-example] [...rack-example] Found 2 errors in 339 ms.
The action functions for incrementCounter and decrementCounter are probably not up-to-date with the most recent typings.
incrementCounter
decrementCounter
The examples should compile without errors.
The text was updated successfully, but these errors were encountered:
Changing the functions to the undo property resolves the compile errors:
undo
const incrementCounter = reg.register( 'increment-counter', (add: number) => { setCounter((c) => c + add); return { undo: { type: 'decrement-counter', payload: add, }, }; } ); const decrementCounter = reg.register( 'decrement-counter', (sub: number) => { setCounter((c) => c - sub); return { undo: { type: 'increment-counter', payload: sub, }, }; } );
However, now I see runtime errors when I click the increment/decrement button.
TypeError Cannot read properties of undefined (reading 'map') Call Stack App main.js:78:61 renderWithHooks vendor.js:37547:18 updateFunctionComponent vendor.js:40825:20 beginWork vendor.js:42838:16 HTMLUnknownElement.callCallback vendor.js:25406:14 Object.invokeGuardedCallbackDev vendor.js:25455:16 invokeGuardedCallback vendor.js:25519:31 beginWork$1 vendor.js:48688:7 performUnitOfWork vendor.js:47794:12 workLoopSync vendor.js:47703:5
Initial state:
After clicking the counter button:
It looks like the tasks property is removed from the initial state with the counter methods. How does a valid counter action function look like?
Sorry, something went wrong.
No branches or pull requests
Steps to reproduce
yarn dev:all
Observed behavior
The action functions for
incrementCounter
anddecrementCounter
are probably not up-to-date with the most recent typings.Expected behavior
The examples should compile without errors.
The text was updated successfully, but these errors were encountered: