TS выдает странную ошибку:
Ошибка: (125, 18) TS2569: Тип 'строка' не является типом массива или типом строки. Используйте параметр компилятора '--downlevelIteration', чтобы разрешить итерацию итераторов.
Почему строка не является строкой?
Я хочу посмотреть, как TS собирается скомпилировать оператор распространения для строки.
Мой код в консоли браузера. Строка разбита на символы:
> s = 'abcdef';
> r = [...s];
< (6) ["a", "b", "c", "d", "e", "f"]
Мой код в ТС:
const s: string = 'abcdef';
const res = [...s]; // <= Error: Type 'string' is not an array type or a string type
console.log(res);
Почему?
Версия TS:
"dependencies": {
"typescript": "^3.5.3"
}
UPD:
@ VtoCorleone
Скриншот
![enter image description here](https://i.stack.imgur.com/BIcrl.png)
UPD:
Мой tsconfig.json
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"downlevelIteration": false,
"allowJs": true,
"skipLibCheck": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"alwaysStrict": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": false,
"noEmit": false,
"sourceMap": true,
"baseUrl": "./",
"jsx": "preserve"
},
"compileOnSave": true,
"files": [
"sample.ts"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}