Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Given better error messages for iterated entities when not using --downlevelIteration #16022

Closed
wangzishi opened this issue May 23, 2017 · 4 comments · Fixed by #40070
Closed
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this
Milestone

Comments

@wangzishi
Copy link

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)));
@mhegazy
Copy link
Contributor

mhegazy commented May 23, 2017

use --downlevelIteration.

e.g.:

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

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label May 23, 2017
@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Good First Issue Well scoped, documented and has the green light Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". and removed Question An issue which isn't directly actionable in code Good First Issue Well scoped, documented and has the green light labels May 23, 2017
@DanielRosenwasser
Copy link
Member

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.

@mhegazy mhegazy added this to the Community milestone May 23, 2017
@DanielRosenwasser DanielRosenwasser changed the title Type 'Uint8Array' is not an array type. Given better error messages for iterated entities when not using --downlevelIteration May 30, 2017
@TomasHubelbauer
Copy link

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.

@felixhaeberle
Copy link

Changing "ES5" to "ES2015" fixed it for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this
Projects
None yet
6 participants