Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Eclipse is complaining about my JavaScript code:

enter image description here

As fas as I can tell, the code is working fine. What do I have to change to get rid of the warning?

like image 254
BetaRide Avatar asked Apr 25 '12 06:04

BetaRide


1 Answers

The semantic validator (despite it's failings, like this one) actually has a lot of uses. For instance, it can tell you when you've got a variable that's not being used anywhere (eg. because you have a typo in the variable's name).

If you don't want to see that error message, but you still want to keep semantic validation on, you can use this hack:

var textArray = 0 || [ ...

it's a little ugly, and your non-Eclipse-using co-workers may not like it, but at least it gives you a way to ditch the warning and still have the benefits of the validator.

A similar hack (if you don't like the first one, or if you're a big Douglas Crockford fan) that will also work is:

var textArray;
textArray = [ ...
like image 196
machineghost Avatar answered Oct 05 '22 15:10

machineghost