What does the "three dots" in typescript type mean?

Viewed 4985

I stumped on something in Typescript today.

enter image description here

What does the three dots mean in this type ? I can't find anything that explain this at all.

Knowing that it's the type infer returned from function combineReducers of Redux

EDIT: I edited the picture so we can see clearer.

EDIT2: I add the code here, I'm trying to do something like this

let all: { readonly [key: string]: (...args: any) => any } = {
  form,
  metadatas_reducer,
  loader_reducer
}
const combinedReducer = combineReducers(all)

Thank you.

2 Answers

This is the TypeScript spread operator: https://howtodoinjava.com/typescript/spread-operator/

Which can also destructure incoming arrays and dictionaries, so you can merge two dictionaries by doing this:

> a = [1,2,3]
[ 1, 2, 3 ]
> b = [4,5,6]
[ 4, 5, 6 ]
> [a,b]
[ [ 1, 2, 3 ], [ 4, 5, 6 ] ]
> [...a,...b]
[ 1, 2, 3, 4, 5, 6 ]

VSCode will sometimes replace types with an ellipse for some reason, possibly to shorten them. In this specific case, the build output is the following.

export declare const combinedReducer: import("redux").Reducer<import("redux").CombinedState<{
    readonly [x: string]: any;
}>, import("redux").AnyAction>;

This is not the spread operator.

Related