Open
Description
Since Uint8Array and its friends are not part of the ECMASCRIPT3 spec, I assumed that they would be shimmed for compatibility when using --language_out=ECMASCRIPT3
. E.g., something like this:
var a = new Uint8Array([1, 2]);
=>
var a = window.Uint8Array ? new Uint8Array([1, 2]) : [1, 2];
And likewise, although IE 10+ supports some Uint8Array methods, it doesn't support all of them, like slice:
a.slice ? a.slice() : Array.prototype.slice.call(a);
Using ECMASCRIPT3 as the language_out, no transformation is performed. E.g. running this:
java -jar compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --new_type_inf --warning_level VERBOSE --language_in ECMASCRIPT_NEXT --language_out ECMASCRIPT3 \
--output_wrapper ";(function() {%output%}());" --js test.js --js_output_file=test.min.js --module_resolution NODE
on this:
var a = new Uint8Array([1, 2]);
console.log(a[0]);
console.log(a.slice(1));
produces this:
;(function() {var a=new Uint8Array([1,2]);console.log(a[0]);console.log(a.slice(1));}());
Since typed arrays are part of the language definition, shouldn't ECMASCRIPT3 shim them? Also, is there any other configuration I should be changing?
(Also, as always, thanks for all your work on Closure Compiler - it's made JS development much better for me.)