当前位置:网站首页>Use compiler option '--downleveliteration' to allow iteration of iterations
Use compiler option '--downleveliteration' to allow iteration of iterations
2022-06-11 11:41:00 【Michael18811380328】
Use compiler option '--downlevelIteration' to allow iterating of iterators Error reporting solution
Recently used in a project TS Unit test , The interface reports an error as follows :

Error reporting analysis
The specific error information is as follows :Set<number> Not array or string type , Cannot use extended operator .
error TS2569: Type 'Set<number>' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.
let newArr:number[] = [...new Set(nums)].sort((a, b) => a - b);After Baidu , Other netizens reported similar mistakes ,Map perhaps Set You cannot use the extension operator directly
TS2569: Type 'Map' is not an array type or a string type. Use compiler. option '- downlevellteration' to allow iterating of iterators.
Solution 1
Follow official tips , Set up '--downlevelIteration' yes true, Allow to use “ ES5” or “ ES3” When it's a goal , stay “ for-of”, spread 、 Support for iteratible items in Deconstruction .
hold tsconfig.json Just modify the configuration file
{
"compilerOptions": {
/* Basic Options */
"downlevelIteration": true,
/* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
}Solution 2
To configure dom.iterable and downlevelIteration It can run normally
tsconfig.json
{
/* When the goal is ES5 or ES3 Provide information about for-of、 Complete support for iterators in extension operators and deconstruction assignment */
"downlevelIteration": true,
"lib": [
"dom",
"es5",
"es6",
"es7",
"dom.iterable"
]
}Set up target=es6 When , It can be executed normally . reason :
Be careful : If not specified --lib, The default library list will be injected . The default library for injection is : ► For --target ES5: DOM,ES5,ScriptHost ► For --target ES6: DOM,ES6,DOM.Iterable,ScriptHost
Reference link
边栏推荐
- Dominating set, independent set, covering set
- 木瓜移动CFO刘凡 释放数字时代女性创新力量
- Create a folder in the WordPress Library
- 中文输入法输入事件composition的使用
- The no category parents plug-in helps you remove the category prefix from the category link
- Modify WordPress management account name plug-in: admin rename extended
- Set the default receiving address [project mall]
- Liufan, CFO of papaya mobile, unleashes women's innovative power in the digital age
- Typeerror: argument of type "Int 'is not Iterable
- typescript 编译选项和配置文件
猜你喜欢

The tutor transferred me 800 yuan and asked me to simulate a circuit (power supply design)

Use compiler option ‘--downlevelIteration‘ to allow iterating of iterators 报错解决

MSF CS OpenSSL traffic encryption

Node connects to MySQL database and writes fuzzy query interface

Node连接MySql数据库写模糊查询接口

ELK - Hearthbeat实现服务监控

导师转我800块,让我仿真一个电路(电源设计)

MYCAT sub database and sub table

中文输入法输入事件composition的使用
![Définir l'adresse de réception par défaut [Centre commercial du projet]](/img/eb/2864b124b66d01849315a367948ed4.png)
Définir l'adresse de réception par défaut [Centre commercial du projet]
随机推荐
How does Sister Feng change to ice?
WordPress用户名修改插件:Username Changer
Method of converting VOC format data set to Yolo format data set
SpingBoot+Quartrz生产环境的应用支持分布式、自定义corn、反射执行多任务
WP super cache static cache plug-in concise tutorial
It will be too late if you don't brush the questions. The most complete bat interview questions
Use yolov5 to train your own data set and get started quickly
Where is it safer to open an account for soda ash futures? How much capital is needed to trade soda ash futures at present?
Count the top k strings with the most occurrences
2022 | framework for Android interview -- Analysis of the core principles of binder, handler, WMS and AMS!
MYCAT sub database and sub table
[file upload vulnerability 05] server suffix detection and bypass experiment (based on upload-labs-3 shooting range)
Use yolov3 to train yourself to make datasets and get started quickly
ELK - Hearthbeat实现服务监控
Use pydub to modify the bit rate of the wav file, and an error is reported: c:\programdata\anaconda3\lib\site packages\pydub\utils py:170: RuntimeWarning:
AcWing 1944. Record keeping (hash, STL)
JEST 单元测试说明 config.json
UCI-HAR数据集的处理
js合并两个对象(面试题)
P2580 "so he started the wrong roll call"