Why does Eclipse sometimes warn about array arrays in JavaScript?

In Eclipse, the following line of JavaScript

var a1 = [[1, 2], [3, 4]]; 

generates warnings:

 Type mismatch: cannot convert from Number[] to any Type mismatch: cannot convert from Number[] to any 

a

 var a2 = [['w', 'x'], ['y', 'z']]; 

generates:

 Type mismatch: cannot convert from String[] to any Type mismatch: cannot convert from String[] to any 

and

 var a3 = [[1, 2], ['y', 'z']]; 

generates:

 Type mismatch: cannot convert from Number[] to any Type mismatch: cannot convert from String[] to any 

However, these lines are fine:

 var a4 = [[1, 'x'], [3, 'y']]; var a5 = [[1, 2]]; var a6 = [['x', 'y']]; 

It seems that the problem is with arrays of arrays when the subarrays contain the same primitive type. However, I don't understand why, and the code seems to be working fine. Can someone explain what bothers Eclipse?

+6
source share
2 answers

Sounds like a mistake. In Javascript, there is essentially no such thing as type mismatch.

I would jeopardize that the parser that does this was based on the Java parser, and this is a bit like the original parser is scanning.

+6
source

Javascript validators in eclipse can filter them in settings.

0
source

Source: https://habr.com/ru/post/900591/


All Articles