如何正确输入传奇
How to properly type sagas
我正在尝试输入 sagas。我正在使用流类型定义:
https://github.com/flowtype/flow-typed/blob/master/definitions/npm/redux-saga_v0.13.x/flow_v0.36.x-v0.37.x/redux-saga_v0.13.x.js
export function* fetchUsers(): Generator<IOEffect, void, any> {
const users = yield call(UserApi.list)
yield put(fetchUserSucc(users))
}
但是流一直在抱怨:
Identifier IOEffect
Could not resolve name
我做错了什么?
您需要像这样从 libdef 导入 IOEffect:
import type { IOEffect } from 'redux-saga/effects';
试试这个:
import { type Saga } from 'redux-saga';
export function* fetchUsers(): Saga<void> {
some logic...
}
它适合我
我正在尝试输入 sagas。我正在使用流类型定义: https://github.com/flowtype/flow-typed/blob/master/definitions/npm/redux-saga_v0.13.x/flow_v0.36.x-v0.37.x/redux-saga_v0.13.x.js
export function* fetchUsers(): Generator<IOEffect, void, any> {
const users = yield call(UserApi.list)
yield put(fetchUserSucc(users))
}
但是流一直在抱怨:
Identifier
IOEffect
Could not resolve name
我做错了什么?
您需要像这样从 libdef 导入 IOEffect:
import type { IOEffect } from 'redux-saga/effects';
试试这个:
import { type Saga } from 'redux-saga';
export function* fetchUsers(): Saga<void> {
some logic...
}
它适合我