i have folowing code: (without compilation everything work fine)
var audio = new Audio("audio.ogg");
goog.events.listen(audio, 'timeupdate', function(e){
ERROR
actual parameter 1 of goog.events.listen does not match formal parameter
>> found : Audio
>> required: (EventTarget|goog.events.Listenable|null)
>> goog.events.listen(this.audio.singing, 'timeupdate', function(e){
my Extern
/**
* @param {string=} src
* @constructor
*/
var Audio = function(src) {};
Audio.prototype.play = function() {};
How can i compile with internal event like this? Thank you
You should certainly try augmenting your extern definition:
goog.require('goog.events.EventTarget');
/**
* @param {string=} src
* @constructor
* @extends {EventTarget}
*/
var Audio = function(src) {};
Audio.prototype.play = function() {};
So it turns out that your problem had been addressed in the Closure Compiler codebase and then that fix was reverted. See the changelog here .
The relevant part of that commit I reproduce below:
/**
* @param {string=} src address of the media resource (a URL)
* @constructor
* @extends {HTMLAudioElement}
* @see http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#the-audio-element
*/
var Audio = function(src) {};
Closure compiler provides externs which should be added to externs list
https://github.com/google/closure-compiler/wiki/Externs-For-Common-Libraries
The one with Audio API is called html5 or something like that
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.