I want to declare some externs for closure compiler but not know how to do it?
(function(window) {
window.myapi = window.myapi || {};
var myapi = window.myapi;
myapi.hello = function() {
window.document.write('Hello');
}
}(window));
I am not sure how to do it for window.myapi, window.myapi.hello?
Externs are valid javascript, but they are just type information. They should not contain definitions (or for functions only empty definitions).
Here's a start: How to Write Closure-compiler Extern Files Part 1
A couple of notes on your specific example:
Here's a corrected example:
In Closure-compiler properties on the
window
(global) object are seen completely differently than global variables. If you need both, you'll have to declare everything twice.