![](/img/trans.png)
[英]What does the | (pipe) mean at the start of a type in TypeScript
[英]What does the "three dots" in typescript type mean?
我今天在 Typescript 中遇到了一些問題。
這種類型中的三個點是什么意思? 我根本找不到任何可以解釋這一點的東西。
知道是 Redux 的 combineReducers 函數返回的類型推斷
編輯:我編輯了圖片,這樣我們可以看得更清楚。
EDIT2:我在這里添加代碼,我正在嘗試做這樣的事情
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>;
這不是擴展運算符。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.