I have the following working code :
var routes = [];
Eclipse validator for javascript prints the following warning :
Type mismatch: cannot convert from any[] to any
What is wrong with my empty array ?
Edit : the warning disappeared later. Apparently Eclipse was wrong and the question needs to be closed. Sorry about that.
Your JavaScript is valid, the problem is with JSDT plugin for Eclipse. In the latest version they introduced a type verification which is problematic in many situations – not only for empty arrays (like in your case). Another typical case may look like this:
a = b || c;The plugin will complain when b and c are of different types (which is absolutely valid code for JavaScript). There is several bugs already reported to JSDT developers about this problem, but the issues are not fixed yet.
Unfortunately currently it is not possible to switch off the type verification using JSDT configuration screen in Eclipse. I switched it off directly from the JSDT source code. To do this, please follow these steps:
org.eclipse.wst.jsdt.debug.coreproject with Eclipse. Make sure you have Eclipse SDK installed. It might also be required to adjust some dependencies in theplugin.xmlfile.computeSeveritymethod ofProblemReporterclass.case IProblem.TypeMismatch: return ProblemSeverities.Warning;withcase IProblem.TypeMismatch: return ProblemSeverities.Ignore;org.eclipse.wst.jsdt.core<version>.jar– make a safe copy of it, then open the jar file and replace theProblemReporter.classfile with the one you compiled in the step 5 (the file is inbinfolder of your project).Important! Make sure you’ve downloaded the same version of JSDT that you are using in Eclipse. Eventually instead of replacing a single file you can replace the entire plugin.
If you don’t want to download and compile the plugin by yourself you can try with my fixed version. I’ve placed it on my FunctionSack webpage. I am using Eclipse 3.7 (Indigo) with JSDT 1.3.0, so make sure you have similar configuration if you want to use my file.