weixin_39969298
weixin_39969298
2020-12-07 01:28

typescript cannot infer type

Questions

Typescript cannot infer correctly the type, am I wrong somewhere?

Screenshot from 2019-03-30 13-00-47

该提问来源于开源项目:ktsn/vuex-class

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39737240 weixin_39737240 5月前

    This fixed it for me: https://github.com/ktsn/vuex-class/issues/33#issuecomment-433074018

    Try .Mutation(UPDATE_ACL_FILTER) updateAclFilter!: () => void;

    点赞 评论 复制链接分享
  • weixin_39969298 weixin_39969298 5月前

    Thanks! It works like a charm!

    点赞 评论 复制链接分享
  • weixin_39634438 weixin_39634438 5月前

    Why can't we use TypeScript implicit typing? We have access to the Actions and its typing. Is there a way to make it work?

    点赞 评论 复制链接分享
  • weixin_39540704 weixin_39540704 5月前

    Because of decorators not being able to set the type of what it's decorating.... Composition API gives you the ability to infer types.

    点赞 评论 复制链接分享

相关推荐