是否有可能为 redux-saga 提供强大的 TypeScript 类型?

Is it possible to have strong TypeScript typings for redux-saga?

我希望我的 Redux sagas 有强类型。例如:

// Selector
const getCount = (state: AppState) => state.count;

function* mySaga() {
    // I would like `count` to be typed as `AppState['count']`
    const count = yield select(getCount);
}

但是,我不确定这是否可行,因为 TypeScript 仅限于单个 TNext 值。它无法知道在给定迭代中 TNextredux-saga 将提供什么。是吗?

TS Playground

我调查了另一个类似的 Whosebug 问题,不幸的是现在 TypeScript 对使用生成器作为协程的库没有很好的支持。

参见:Redux-saga Module augumentation for select effect