Typescript: Given better error messages for iterated entities when not using --downlevelIteration

Created on 23 May 2017  ·  3Comments  ·  Source: microsoft/TypeScript



TypeScript Version: 2.3.3

Code

String.fromCharCode(...new Uint8Array(0));

Expected behavior:
I would expect there is no compile error.

Actual behavior:
image
image

I have to write this code:

String.fromCharCode(...Array.from(new Uint8Array(0)));
Bug Error Messages Moderate help wanted

Most helpful comment

In cases where the value is iterable (i.e. has a Symbol.iterator), we should issue this error message

Type '{0}' can only be iterated through when using the '--downlevelIteration' flag.

All 3 comments

use --downlevelIteration.

e.g.:

tsc --downlevelIteration --lib es5,es2015.iterable a.ts

In cases where the value is iterable (i.e. has a Symbol.iterator), we should issue this error message

Type '{0}' can only be iterated through when using the '--downlevelIteration' flag.

For people who come here from search, for me, using "target": "es6" fixed this. Before I didn't have any target configuration in tsconfig.json. This is with TypeScript 2.8.1.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wmaurer picture wmaurer  ·  3Comments

fwanicka picture fwanicka  ·  3Comments

bgrieder picture bgrieder  ·  3Comments

weswigham picture weswigham  ·  3Comments

DanielRosenwasser picture DanielRosenwasser  ·  3Comments