|
|
|
|
|
by oinksoft
5001 days ago
|
|
Actually that's not quite accurate. The Closure Compiler doesn't need you to tell it that `thing` is a myType, it knows that, asuming myType is defined in your compiled code, or you provide an extern specifying what myType means. And I might be wrong about that last bit even; the compiler may always know that `new Foo` returns a {Foo} regardless of context ... I would have to check the compiler source to be certain. Also, I think that the first example is more likely to be written as follows (in the case where type data cannot be inferred): /**
* Description of the variable.
*
* @type {my.UnionType}
*/
var foo = { ... };
Whatever "..." may be. It's common to document the meaning of variables where explicit typing like this is important, just like in well-documented Java and PHP code. |
|