You are right in all you say. While Eclipse is mostly used by
Java developers I can understand that the developers of the web tools packages try to make JavaScript feel a bit more like Java and I personally like that.
What the web tools try to do is infer the actual type of variables and function return values. This allows the code completion to only show the matching items. I have a big JavaScript application and I can tell you that this is really helpful and also more responsive than other approaches that just list everything. And while you
can assign different data to a variable it will usually lead to confusion when someone else looks at the code. If you want to optimize the runtime performance it is also advisable to enable the JavaScript engines to make some assumptions like "x always contains an integer number".
Now to your code... I don't understand what you are trying to do there. But I found that the web tools are somewhat allergic to "{}". So I switched that out for "new Object()". I really hope the automatic type inference becomes better in the next releases though.
I have a case where a member of my class is initialized with null, but is otherwise of object type 'Button'. When I try to assign a 'Button' object to this member Eclipse tells me that Button cannot be converted to __result1. If on the other hand I initialize the member with "new Button()" no warning is produced.
If you want, you can make the code completion more precise by adding some JSDoc. It works great for function parameters that are objects. When you write "@param {Button} btn the button" Eclipse can use that information to 'follow' that object. It will know the type of other variables that you assign it to as in "this.btn = btn" and can infer the return type of methods called on it: "window = btn.getParent()". Since btn is a "Button" and has a method "getParent" that returns a "Window" it knows that "window" is of that type now.