Community
Participate
Working Groups
var n = "hi"; var a = [1, 3]; switch(n) { case 1: // case 2: // case 'hi': // case 'bye': // case "hi": // case 60 * 60: // case Math.PI: // case n + 1: // case a[0]: // } Put that switch statement on a JavaScript page. You'll see a much of errors, for example: Description Resource Path Location Type Type mismatch: cannot convert from Number to String script1.js /JSProject line 9 JavaScript Problem To my knowledge, all of the expressions in that case are valid.
I donot think the authors of JSDT know Javascript Language. I suggest let us close the javascript validation. But eclipse jee 3.7.1 canot close JS validation.I close the Preference of javascript validation and make the level be Ignore ,but eclipse Problems still reports the problems (errors and warnings) of Javascript type . Guys , you all can import a js file ,like JQuery-1.x.min.js , so that you can find too many errors.
I think problem is on another place. Look at 2 tests: 1. var n = 1.5; switch (n) { case 1/2: alert(1); break; case 1/3: alert(2); break; } No errors now, but here: 2. var n = 1; switch (n) { case 1/2: alert(1); break; case 1/3: alert(2); break; } And you will get duplicate case error :/ In JavaScript switch/case statement , case expression is never casted to switch expresssion type. As always sorry for my english ;)