我们再写ts代码的时候经常会遇到这样的问题,说不存在这个类型我们该如何解决呢?

1.在定义接口的时候使用[索引签名]的形式

interface Person {name: stringage?: number[propName: string]: any
}

这样就可以拥有一个包含所有string类型的接口

2.使用extends属性

interface Size {size: number
}function track <T extends Size>(arg: T) : T {return arg
}

3.使用ts内置的方法,Record

const user1: Record<string, string> = {name: 'xjc'
}

看一下使用索引签名这里应该怎么写

const user2: { [key: string]: string } = {name: 'xjc'
}

TS报错Error: xxx doesn‘t exist on type ‘xxx’相关推荐

  1. readxl包导入excel报错Error: `path` does not exist解决方法

    readxl包导入excel报错Error: `path` does not exist解决方法 方法1:File - import dataset - from excel 方法2:检查语法错误 正 ...

  2. darknet编译报错 error: ‘__fatBinC_Wrapper_t’ does not name a type

    git clone darknet项目,进行make -j8编译,发现报错error: '__fatBinC_Wrapper_t' does not name a type. 发生这种错误的原因在于c ...

  3. 编译PX4时,报错error ‘i‘ does not name a type __ULong i[2];解决方法

    编译PX4时,报错error: 'i' does not name a type __ULong i[2];解决方法 在编译PX4的时候,会遇到报错: /usr/include/newlib/math ...

  4. 03-postgresql报错ERROR: operator does not exist: numeric = character varyin

    现在要把数据库换成postgresql,但在转换过程中发现postgresql对传入的参数类型匹配相当严格. 如select * from user where a= #b# 假设a类型为numeri ...

  5. IDEA 启动项目报错 Error running 'XXXApplication': No jdk for module 'XXX'

    今天在运行项目的时候,突然发现之前一直好好的项目突然启动不了了,报错: Error running 'XXXApplication': No jdk for module 'XXX' 按理说jdk都是 ...

  6. 报错ERROR:Skipping MapperFactoryBean with name 'xxxMapper' and 'xxx.xxx.xxx.mapper.xxxxxMapper'

    报错信息:Skipping MapperFactoryBean with name 'xxxMapper' and 'xxx.xxx.xxx.mapper.xxxxxMapper' nterface. ...

  7. 解决C/C++报错error: cannot pass objects of non-trivially-copyable type ‘std::string’问题

    目录 1.问题描述 2.原因分析 3.解决方法 1.问题描述 运行程序时,编译报错: error: cannot pass objects of non-trivially-copyable type ...

  8. ROS报错Error:cannot launch node of type [map_server/map_server]

    报错: ERROR: cannot launch node of type [map_server/map_server]: Cannot locate node of type [map_serve ...

  9. springboot 工程启动报错之Consider defining a bean of type ‘XXX’ in your configuration.

    一.前言: 使用springboot自动注入的方式搭建好了工程,结果启动的时候报错了!!!,错误如下图: Description:Field userEntityMapper in com.xxx.x ...

  10. Angular使用ng build打包报错 Property 'setControl' does not exist on type 'AbstractControl'.解决方法

    在项目打包出现setControl报错解决方法: 对于用setControl设置多层级表单的值的用法,会出现这个报错: 以下是正确的写法: get services(): FormArray {ret ...

最新文章

  1. 为什么 ConcurrentHashMap 的读操作不需要加锁?
  2. “头移植模型”论文称换头术可行 业内疑两大问题未解
  3. 一起谈.NET技术,asp.net控件开发基础(20)
  4. 00075_BigInteger
  5. 从delphi到C++Builder
  6. tomcat 系统访问日志配置
  7. TensorFlow前向传播
  8. 当你和天猫精灵对话时,它在想什么?阿里智能对话技术深度解读
  9. USACO-Section2.2 Party Lamps
  10. Java 算法 友好数
  11. css3-background clip 和background origin
  12. 关于-最佳的业务连续性容灾架构设计
  13. 简述计算机的四代发展阶段 以及电子器件,2014计算机作业1答案
  14. Git XP 安装图解
  15. EMC/EMI 测试顺利通过
  16. 即时通讯 视频会议开源技术选择
  17. 阿里巴巴余军:钉钉宜搭低代码实践之路
  18. 饭店点餐系统之数据库表结构
  19. 英:程序员 外企 英语常用语 (整理)
  20. Abbkine ExKine 胞浆蛋白提取试剂盒

热门文章

  1. k8s重启导致node没有成功连接:The connection to the server localhost:8080 was refused - did you specify the righ
  2. 计算机二级c语言答题怎么保存,计算机二级考试C语言答题注意事项
  3. KOLO是如何赋能NFT音乐行业?
  4. 【伊利丹】Hadoop-2.5.0-CDH5.2.0/Hive与Hbase整合实验
  5. 运维体系框架标准化模型简介
  6. VMware安装Centos7系统
  7. 创建学生、课程、老师、学生成绩表
  8. Windows 7 中文版命令行如何修改字符编码为UTF-8?
  9. 摆脱外包进大厂,苦逼翻身把歌唱,20K、30K、40K!咬牙硬吃下这份儿数据结构与算法手册
  10. sudo spctl --master-disable