当前位置:网站首页>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
keyandvaluetype , Used to display the type of object key and the type of value
Usage method , Define the objectaThe key isstringtype , The value isstring | numberThe type of Union
const a: Record<string, string | number> = {
'name': ' puddle jumper ',
'age': 18
}
边栏推荐
- The solution to turn the newly created XML file into a common file in idea
- Ensure production safety! Guangzhou requires hazardous chemical enterprises to "not produce in an unsafe way, and keep constant communication"
- Markdown编辑器使用基本语法
- [零基础学IoT Pwn] 复现Netgear WNAP320 RCE
- APK签名原理
- [14. Interval sum (discretization)]
- [stage life summary] I gave up the postgraduate entrance examination and participated in the work. I have successfully graduated and just received my graduation certificate yesterday
- Day-02 database
- Opencv Learning Notes 6 -- image feature [harris+sift]+ feature matching
- Error-tf.function-decorated function tried to create variables on non-first call
猜你喜欢

Minimum spanning tree and bipartite graph in graph theory (acwing template)
![Opencv Learning Notes 6 -- image feature [harris+sift]+ feature matching](/img/50/5c8adacea78e470c255070c8621ddd.png)
Opencv Learning Notes 6 -- image feature [harris+sift]+ feature matching

对于编程思想和能力有重大提升的书有哪些?

Junda technology indoor air environment monitoring terminal PM2.5, temperature and humidity TVOC and other multi parameter monitoring

一波三折,终于找到src漏洞挖掘的方法了【建议收藏】

opencv学习笔记四--银行卡号识别

Problem note - Oracle 11g uninstall
![[零基础学IoT Pwn] 复现Netgear WNAP320 RCE](/img/f7/d683df1d4b1b032164a529d3d94615.png)
[零基础学IoT Pwn] 复现Netgear WNAP320 RCE
![After twists and turns, I finally found the method of SRC vulnerability mining [recommended collection]](/img/ac/ab6053e6ea449beedf434d4cf07dbb.png)
After twists and turns, I finally found the method of SRC vulnerability mining [recommended collection]

【14. 区间和(离散化)】
随机推荐
[stage life summary] I gave up the postgraduate entrance examination and participated in the work. I have successfully graduated and just received my graduation certificate yesterday
Cannot link redis when redis is enabled
[leetcode 324] 摆动排序 II 思维+排序
基于价值量化的需求优先级排序方法
Flink 系例 之 TableAPI & SQL 与 MYSQL 分组统计
Solid smart contract development - easy to get started
Error-tf.function-decorated function tried to create variables on non-first call
Task. Run(), Task. Factory. Analysis of behavior inconsistency between startnew() and new task()
TypeScript:const
Word2vec yyds dry goods inventory
Official announcement: Apache Doris graduated successfully and became the top project of ASF!
22-06-26周总结
Minimum spanning tree and bipartite graph in graph theory (acwing template)
Flink 系例 之 TableAPI & SQL 与 Kafka 消息获取
Redis安装及Ubuntu 14.04下搭建ssdb主从环境
TypeScript: let
榨汁机UL982测试项目有哪些
[leetcode] 16. The sum of the nearest three numbers
DirectX repair tool v4.1 public beta! [easy to understand]
数字化转型:数据可视化赋能销售管理