源码

const timer:number = setTimeout(()=>{},1)

报错

typescript error TS2322: Type ‘Timeout’ is not assignable to type ‘number’.

原因

项目包含依赖@types/node
setTimeout使用NodeJs定义的接口而非window.setTimeout

解决

方法一

const timer:NodeJS.Timer = setTimeout()

方法二

const timer:number = window.setTimeout()

typescript error TS2322: Type ‘Timeout‘ is not assignable to type ‘number‘.相关推荐

  1. TS2322 Type ‘void‘ is not assignable to type ‘MouseEventHandlerHTMLElement

    问题:TS2322 Type 'void' is not assignable to type 'MouseEventHandlerHTMLElement 实例: 都是在类似这种"----- ...

  2. Type ‘string | null‘ is not assignable to type ‘string‘. Type ‘null‘ is not assignable to type ‘

    报错如下: Type 'string | null' is not assignable to type 'string'. Type 'null' is not assignable to type ...

  3. vue3+ts Type ‘xxx[]‘ is not assignable to type ‘never[]‘

    原因是:ts默认初始化空数组为 never[] 类型,跟你赋值的数据类型不匹配 修改为:arr_data: [] as any[],即可 vue3 keep-alive+vuex配合使用(简单易用)

  4. Type ‘string[]‘ is not assignable to type ‘never[]‘.

    最近使用ts碰到的问题 触发情况:返回的数据会显示proxy,类型为obj,不管返回的数据是什么类型,也会是这样, 然后在编辑器上会报红,有这个提示 上图是打印出来的数据和类型 上面提示的意思就是:类 ...

  5. error TS2322: Type ‘WritableComputedRef<string>‘ is not assignable to type ‘string‘ 解决方法

    前言 在 Vue3 + TypeScript + pinia 项目中,使用 get() set() 定义计算属性时,出现 '不能将类型"WritableComputedRef<stri ...

  6. error TS2322: Type {} is not assignable to type ‘IntrinsicAttributes IntrinsicClassAttributes

    具体build报错 src/components/columnSelectorC/index.tsx(159,7): error TS2322: Type '{ useDragHandle: true ...

  7. 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 ...

  8. 数据库 1205 Error 'Lock wait timeout exceeded; try restarting transaction' on query

    收到报警,mysql的从数据库在同步的过程出现问题,已停止同步. mysql> show slave status\G *************************** 1. row ** ...

  9. Error: TS Error: Subsequent variable declarations must have the same type. Variable ‘beforeEach‘ mus

    Error: TS Error: Subsequent variable declarations must have the same type. Variable 'beforeEach' mus ...

最新文章

  1. 【Boost】noncopyable:不可拷贝
  2. 如何在NLP领域干成第一件事
  3. python常用类库_Python常用库
  4. 洛谷 - P2770 航空路线问题(最大费用最大流+路径打印)
  5. oracle用户和mysql用户_oracle数据库解锁和锁定用户命令
  6. 【我的物联网成长记11】8招带你玩转规则引擎
  7. Android Studio for Experts(Android Dev Summit2015)
  8. python语言-python语言的有何特点?
  9. idea中常用快捷键
  10. php中js中文传值乱码,php解析JSON中文乱码问题的解决方法
  11. php seekdir,readdir()
  12. 【HTML】极简个人主页设计
  13. 图书馆管理系统 Java
  14. linux两块硬盘主从,电脑双硬盘双系统启动的顺序调整及设置方法
  15. 若依源码分析(14)——数据监控
  16. HTML表格制作的例子
  17. 优化代码中的“坏味道”
  18. Android API 29 百度步行导航语音tts集成
  19. LINK : fatal error LNK1168: cannot open Debug/xxx.exe for writing
  20. MySQL 不等于null或空格

热门文章

  1. html中css的注释怎么写,css注释怎么写?
  2. ispring sdk 8.7 Crack ispring sdk 9.7
  3. C++面试知识-计算机网络
  4. 计算机崩溃用英语怎么说,“崩溃”英语怎么说
  5. Ubnt路由器使用WinSCP登录后直接就是root权限可操作任何文件
  6. 关于大数据测试,你一定要试试python的fake库
  7. 使用Python+OpenCV+DVG-Utils实现人群计数与目标跟踪
  8. 视频搬运助手:srt字幕配音/剪映、必剪字幕提取翻译/视频降重/爆文标题/热点榜单
  9. ECCV2020双料冠军团队,带你7日攻克目标检测
  10. 思维导图Xmind安装