redux-toolkit
redux-toolkit copied to clipboard
isFulfilled() in typescript wouldn't accept spread arguments
const someSlice = createSlice({
/* ... */
extraReducers: builder => {
builder.addMatcher(
isFulfilled(...someAsyncThunkArray), // <-- A spread argument must either have a tuple type or be passed to a rest parameter.ts(2556)
someReducer
);
}
});
Is this intended behavior? Inline document says the param (asyncThunks) is optional. New to typescript, but it looks like the type definition defined asyncThunks as a tuple?
export declare function isFulfilled<AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]>(...asyncThunks: >AsyncThunks): (action: any) => action is FulfilledActionFromAsyncThunk<AsyncThunks[number]>;
I tried isFulfilled(someAsyncThunkArray[0], ...someAsyncThunkArray.slice(1)) which at least doesn't yell at me, but not sure if it's the correct way to do it. (someAsyncThunkArray has at least 2 items in my case)
Any suggestions?
@reduxjs/toolkit v1.6.1 typescript v4.4.3
Looks like the same issue as #2209
Merged, will be out in 1.9.2 shortly.