今天我在 Typescript 中遇到了一些问题。
这个类型中的三个点是什么意思?
我根本找不到任何可以解释这一点的东西。
我正在尝试做这样的事情
let all: { readonly [key: string]: (...args: any) => any } = {
form,
metadatas_reducer,
loader_reducer
}
const combinedReducer = combineReducers(all)
这是 TypeScript 扩展运算符: https://howtodoinjava.com/typescript/spread-operator/
它还可以解构传入的数组和字典,因此您可以通过这样做来合并两个字典:
> 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 有时会出于某种原因用椭圆替换类型,可能是为了缩短它们。在这种特定情况下,构建输出如下。
export declare const combinedReducer: import("redux").Reducer<import("redux").CombinedState<{
readonly [x: string]: any;
}>, import("redux").AnyAction>;
这不是价差运算符。