const dispatch = useDispatch();   // 这里const dispatch: Dispatch<AnyAction>useEffect(() => {dispatch(getProductDetail(touristRouteId));}, []) 

getProductDetail的类型是 AsyncThunk<void, string, {}>,但是const dispatch: Dispatch<AnyAction>。

export const getProductDetail=createAsyncThunk("productDetail/getProductDetail",async (touristRouteId:string, thunkAPI) => {const fetchData = async () => {thunkAPI.dispatch(productDetailSlice.actions.fetchStart());try {const { data } = await axios.get(`http://123.56.149.216:8080/api/touristRoutes/${touristRouteId}`);thunkAPI.dispatch(productDetailSlice.actions.fetchSuccess(data));} catch (error) {thunkAPI.dispatch(productDetailSlice.actions.fetchFail(error.message));}};fetchData();}
)

两种解决办法:

一是定义getProductDetail是any类型

export const getProductDetail:any=createAsyncThunk("productDetail/getProductDetail",async (touristRouteId:string, thunkAPI) => {const fetchData = async () => {thunkAPI.dispatch(productDetailSlice.actions.fetchStart());try {const { data } = await axios.get(`http://123.56.149.216:8080/api/touristRoutes/${touristRouteId}`);thunkAPI.dispatch(productDetailSlice.actions.fetchSuccess(data));} catch (error) {thunkAPI.dispatch(productDetailSlice.actions.fetchFail(error.message));}};fetchData();}
)

二是用getDefaultMiddleware().concat而不是[...getDefaultMiddleware(),...]

const store = configureStore ({reducer:rootReducer,// 不要用展开运算符这种写法 middleware: (getDefaultMiddleware) => [...getDefaultMiddleware(), actionLog, changeLanguage],middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(actionLog,changeLanguage), devTools:true
});

【bug记录】 Argument of type ‘AsyncThunkAction<void, string, {}>‘ is not assignable to parameter of type相关推荐

  1. TypeScript语法错误:Argument of type ‘string‘ is not assignable to parameter of type ‘Element‘. 解决方法

    问题描述 DOM插入元素节点报错. TypeScript语法错误: TS2345: Argument of type 'string' is not assignable to parameter o ...

  2. Argument of type ‘string‘ is not assignable to parameter of type ‘never‘.

    在react中遇到了一个这样的问题Argument of type 'string' is not assignable to parameter of type 'never'. 更改之前: 更改之 ...

  3. Argument of type ‘‘ is not assignable to parameter of type ‘never‘.

    最近在写ts代码,记录下开发中遇到的代码规范问题 Argument of type 'any' is not assignable to parameter of type 'never'. // 问 ...

  4. typeScript踩坑记录 T2345 Argument of type is not assignable to parameter of type never

    最近在对接谷歌的localhomeSDK,详情看这里https://aijishu.com/a/1060000000011433,[后续对接完成会写一篇踩坑的血泪史==]应用他们的sdk需要的语言可用 ...

  5. 当使用pinia遇见Argument of type ‘any‘ is not assignable to parameter of type ‘never‘解决方法

    state return的数据改为. goodsArray:[] as any[] 通过 as 进行类型断言欺骗ts类型约束

  6. vue3 router.push 传参路由跳转错误提示 Argument type {xxx} is not assignable to parameter type RouteLocationRaw

    文章目录 问题描述 解决方法 问题描述 传参时,router.push中布尔值变量会给出一个错误提示 setup(){const router = useRouter();/** 查看已办任务的流程记 ...

  7. Failed to convert value of type 'java.lang.String' to required type 'java.util.Date

    异常原因:Controller层获取JSP页面请求参数是String类型,而在Controller层接收时使用Date类型,属于方法参数类型不匹配异常 警告: Failed to bind reque ...

  8. 解决 No converter found capable of converting from type [java.lang.String] to type ... 的问题

    目录 问题 分析问题 解决问题 问题 今天在项目启动类SuperJsonManagerApplication中,加上这行代码@MapperScan("com.**.mapper") ...

  9. springboot启动报错Parameter 0 of method a in com.* required a bean of type 'java.lang.String' that could

    springboot服务启动报错,报错信息如下 *************************** APPLICATION FAILED TO START ******************** ...

最新文章

  1. 什么是数据结构,为什么我们需要数据结构?
  2. xp装linux一键安装教程图解,XP下硬盘安装CentOS 6.0图解教程
  3. python后端将svc文件数据读入数据库具体实现
  4. javascript设置和获取cookie的方法
  5. 使用Roslyn将代码编译成单独的网络模块并将它们组装成动态库
  6. 大数据之-Hadoop之HDFS_HDFS的优缺点---大数据之hadoop工作笔记0049
  7. 自定义iOS UIPickerView
  8. LINUX编译Android FFmpeg:fatal error: errno.h: No such file or directory
  9. SpringBoot生成条形码
  10. 如何成为一名优秀的测试/开发程序员?专注谋定而后动......
  11. 台式计算机锁屏快捷键,台式机锁屏快捷键是什么
  12. 复合高斯求积matlab代码,谁有复何求积公式和高斯求积公式在matlab中实现的代码...
  13. 戴尔3080计算机重装系统步骤,戴尔OptiPlex 3080MT台式机重装系统BIOS设置教程
  14. 改变linux字体的大小,如何更改字体并调整其大小?
  15. Allegro PCB Design GXL (legacy) - 铺网格铜
  16. 具体应如何办理股票开户?
  17. (原创)梅子与锤子的一生(光阴故事)
  18. python用循环结构求平均值_有python的输出问题;循环总数和平均值
  19. springmvc(尚硅谷版)
  20. 哈希冲突和一致性哈希

热门文章

  1. Zynq实现分布式Fir滤波器
  2. 集群服务器上的jupyter配置
  3. stm32f105vct6例程_STM32F105VCT6_USB_TEST
  4. STM32F105替换为AT32F403A注意事项
  5. 2017开发语言排行(本人是搞C#+javascript的)
  6. 亚马逊echo中国使用_我需要Amazon Echo才能使用Alexa吗?
  7. 几种颜色单位设置(颜色设置)
  8. 如何更改Code::Blocks背景颜色(懒人版)
  9. Oracle 查询临时表空间
  10. 翻译《Pro SQL Server Internals,2nd edition》的CHAPTER 3 Statistics的Introduction to SQL Server Statistics等