typescript中使用.then() 提示Property 'then' does not exits on type '{type:string}'
@sorrycc ,您好,我看commit中 "version": "2.6.0-beta.17", 是需要把dva升级到[email protected]么
而且我每次升级到2.6.[email protected] 都会在@connect出现Unable to resolve signature of class decorator when called as an expression

2219 能解决你的问题吗?
我自己按照这个PR里面的方式定义了一下,还是无法实现dispatch(...).then(...),但是可以使用await 读取返回值。如下:
export interface IDispatch<A extends Action = AnyAction> {
<T extends A>(action: T): Promise<any> | T;
}
export interface IProps {
dispatch: IDispatch<AnyAction>;
[key: string]: any;
children?: React.ReactNode;
}
使用:
class Index extends React.Component<IProps>{
click = () => {
const { success, ...rest } = await this.props.dispatch({type: 'global/someAction'});
// some handle ...
}
render(){
return <div onClick={this.click}>test</div>
}
}
不要使用 decorator 的语法,使用 export default connect(mapState, mapDispatch)(YourComponent); TS 对于 decocrator 的限制比较多。
@xc1427 是的,但是dva,2.4.1版本还是可以用的
@Moicen 我也重新定义了一下,也是不可以,我试一下你的方法,谢谢
@sorrycc 2.6.0-beta.19 还是存在这个问题,请问如何处理?

@sorrycc 2.6.0-beta.19 还是存在这个问题,请问如何处理?
强行 as any吧
{type: string} 是从哪出来的。。

dispatch({
type: 'recommend/fetchDataSource',
}).then(() => {
// XXXX
})
{type: string}是从哪出来的。。
dispatch({ type: 'recommend/fetchDataSource', }).then(() => { // XXXX })
{type: string} 是你dispatch里面的参数类型,如果你的参数是action,dispatch返回的就是action就不能使用.then,如果dispatch的参数是effect,返回的是promise,则可以调用then