I'm converting coffeescripts to typescript and have trouble with one simple delay type function.
The coffeescript:
ise.utils.delay = (->
timer = 0
(callback, ms) ->
clearTimeout timer
timer = setTimeout(callback, ms)
)()
The produced javascript:
ise.utils.delay = (function() {
var timer;
timer = 0;
return function(callback, ms) {
clearTimeout(timer);
return timer = setTimeout(callback, ms);
};
})();
When I enter the produced js into a typescript file I get a compile error.
I can't figure out what is wrong.
If the above code is all the code you have, then you are missing var ise = { utils: { delay: {}}}
I think what you are actually looking for is modules in TypeScript like below
module ise.utils {
var timer = 0;
export function delay(callback, ms) {
clearTimeout(timer);
return timer = setTimeout(callback, ms)
};
}
I ended up using this:
module ise { export module utils { var timer = 0; export function delay(callback, ms) { clearTimeout(timer); return timer = setTimeout(callback, ms) };
... Thanks...
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.