TS throws strange error:
Error:(125, 18) TS2569: Type 'string' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.
How comes a string is not a string?
I want to see how TS is going to compile spread operator for a string.
My code in browser console. A string is broken up into characters:
> s = 'abcdef';
> r = [...s];
< (6) ["a", "b", "c", "d", "e", "f"]
My code in TS:
const s: string = 'abcdef';
const res = [...s]; // <= Error: Type 'string' is not an array type or a string type
console.log(res);
Why?
TS version:
"dependencies": {
"typescript": "^3.5.3"
}
UPD:
UPD:
My 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"
]
}

"downlevelIteration": trueto yourtsconfig?trueandfalse. TS doesn't blow whentrueas expected. But why is it complaining a string is not a string?3.5.1and got no warnings or errors."target": "es5",. I've updated the question with mytsconfig.json