You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
remove function wrappers for member type declarations
To declare the types of class members, we want to emit e.g.
/** @type {Foo} */
MyClass.prototype.foo;
We cannot declare these in the class constructor because sometimes
we don't have a constructor and it's difficult to create our own
(we'd need to match the superclass in that case).
We sometimes cannot declare these at the top level because it's possible
there's a supertype that throws on get, which means the code cannot be
loaded as written without compiling it first. (We know this actually
can happen because we tried it.)
In the past we declared these in a helper method or bare function,
but it turns out declarations in those are ignored by Closure in
unpredictable circumstances.
So our final approach is:
- for interfaces, declare them at the top level
- for classes, wrap them in an 'if (false)' block.
To do so we must suppress the 'useless code' compiler check, because
putting code in an 'if (false)' is pretty suspicious looking otherwise.
0 commit comments