当前位置:网站首页>TS reports an error don't use 'object' as a type The `object` type is currently hard to use
TS reports an error don't use 'object' as a type The `object` type is currently hard to use
2022-07-01 15:01:00 【A small train, besides】
TS Report errors Don’t use object
as a type. The object
type is currently hard to use
Source of problem
function func<T extends object, S extends object>() {
}
When using generic inheritance object
Attribute , typescript
Will prompt questions
Don't use `object` as a type. The `object` type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)).
Consider using `Record<string, unknown>` instead, as it allows you to more easily inspect and use the keys @typescript-eslint/ban-types
The source of the problem can be found in the prompt issue
Link to https://github.com/microsoft/TypeScript/issues/21732
In fact, the solution can also be viewed typescript
A hint of , adopt Record<string, unknown>
Replace object
function func<T extends Record<string, unknown>, S extends Record<string, unknown>>() {
}
expand -Record link
Record
yes typescript
Built in advanced types
- The main purpose is to define the
key
andvalue
type , Used to display the type of object key and the type of value
Usage method , Define the objecta
The key isstring
type , The value isstring | number
The type of Union
const a: Record<string, string | number> = {
'name': ' puddle jumper ',
'age': 18
}
边栏推荐
- 定了!2022海南二级造价工程师考试时间确定!报名通道已开启!
- Filter &(登录拦截)
- leetcode:329. Longest increasing path in matrix
- 基于价值量化的需求优先级排序方法
- Redis installation and setting up SSDB master-slave environment under Ubuntu 14.04
- ArrayList 扩容详解,扩容原理[通俗易懂]
- QT capture interface is displayed as picture or label
- After twists and turns, I finally found the method of SRC vulnerability mining [recommended collection]
- It's settled! 2022 Hainan secondary cost engineer examination time is determined! The registration channel has been opened!
- Redis安装及Ubuntu 14.04下搭建ssdb主从环境
猜你喜欢
JVM performance tuning and practical basic theory part II
Minimum spanning tree and bipartite graph in graph theory (acwing template)
一波三折,终于找到src漏洞挖掘的方法了【建议收藏】
Filter &(登录拦截)
Basic operations of SQL database
[getting started with Django] 13 page Association MySQL "multi" field table (check)
leetcode:329. 矩阵中的最长递增路径
官宣:Apache Doris 顺利毕业,成为 ASF 顶级项目!
如何实现时钟信号分频?
leetcode:329. Longest increasing path in matrix
随机推荐
Build your own website (14)
Filter &(登录拦截)
opencv学习笔记四--银行卡号识别
The first technology podcast month will be broadcast soon
【天线】【3】CST一些快捷键
opencv学习笔记六--图像拼接
APK签名原理
Use the npoi package of net core 6 C to read excel Pictures in xlsx cells and stored to the specified server
Redis installation and setting up SSDB master-slave environment under Ubuntu 14.04
leetcode:329. Longest increasing path in matrix
Solidty智能合约开发-简易入门
JVM performance tuning and practical basic theory part II
Opencv learning note 4 -- bank card number recognition
Markdown编辑器使用基本语法
基于价值量化的需求优先级排序方法
idea中新建的XML文件变成普通文件的解决方法.
Digital transformation: data visualization enables sales management
The first word of JVM -- detailed introduction to JVM and analysis of runtime data area
C#学习笔记(5)类和继承
C learning notes (5) class and inheritance