-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
for-loop: Type 'number' is not assignable to type 'never'. #10721
Comments
You need to type annotate You could write:
|
or: var b: number[] = [];
/* or */
var b = <number[]> []; |
Thanks, I missed that type annotation. Nevertheless, I find that error message confusing. I only get it if b[c] = d.charCodeAt(c)
|
While So here: var b = []; // What is supposed to be in this array? So never[]
var c = [ 'foo' ]; // I can guess, so string[]
var d = [ 'foo', 1 ]; // I can guess so (string | number)[] |
It is because an empty array is of type never, which any cannot fit in. On Tue, Sep 6, 2016, 8:35 PM Michael Maier notifications@github.com wrote:
|
TypeScript Version: 2.0.2
Code
Expected behavior:
No error.
Actual behavior:
The text was updated successfully, but these errors were encountered: