简体   繁体   中英

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

I stumped on something in Typescript today.

在此处输入图像描述

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM