2 * Copyright 2014 The Closure Compiler Authors
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @fileoverview Definitions for ECMAScript 6.
19 * @see http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts
20 * @see https://www.khronos.org/registry/typedarray/specs/latest/
24 // TODO(johnlenz): symbol should be a primitive type.
29 * @param {string} description
32 function Symbol(description) {}
34 /** @const {symbol} */
42 function Iterable() {}
44 // TODO(johnlenz): remove this when the compiler understands "symbol" natively
46 * @return {Iterator.<VALUE>}
47 * @suppress {externsValidation}
49 Iterable.prototype[Symbol.iterator] = function() {};
53 // TODO(johnlenz): Iterator should be a templated record type.
57 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol
59 function Iterator() {}
62 * @param {VALUE=} value
63 * @return {{value:VALUE, done:boolean}}
65 Iterator.prototype.next;
70 * @see http://people.mozilla.org/~jorendorff/es6-draft.html#sec-generator-objects
71 * @implements {Iterator<VALUE>}
74 var Generator = function() {};
77 * @param {?=} opt_value
78 * @return {{value:VALUE, done:boolean}}
81 Generator.prototype.next = function(opt_value) {};
84 * @param {VALUE} value
85 * @return {{value:VALUE, done:boolean}}
87 Generator.prototype.return = function(value) {};
90 * @param {?} exception
91 * @return {{value:VALUE, done:boolean}}
93 Generator.prototype.throw = function(exception) {};
96 // TODO(johnlenz): Array should be Iterable.
101 * @param {number} value
105 Math.log10 = function(value) {};
108 * @param {number} value
112 Math.log2 = function(value) {};
115 * @param {number} value
119 Math.log1p = function(value) {};
122 * @param {number} value
126 Math.expm1 = function(value) {};
129 * @param {number} value
133 Math.cosh = function(value) {};
136 * @param {number} value
140 Math.sinh = function(value) {};
143 * @param {number} value
147 Math.tanh = function(value) {};
150 * @param {number} value
154 Math.acosh = function(value) {};
157 * @param {number} value
161 Math.asinh = function(value) {};
164 * @param {number} value
168 Math.atanh = function(value) {};
171 * @param {number} value
175 Math.trunc = function(value) {};
178 * @param {number} value
182 Math.sign = function(value) {};
185 * @param {number} value
189 Math.cbrt = function(value) {};
192 * @param {number} value1
193 * @param {...number} var_args
196 * @see http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.hypot
198 Math.hypot = function(value1, var_args) {};
205 * @see http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.is
211 * Returns a language-sensitive string representation of this number.
212 * @param {(string|!Array<string>)=} opt_locales
213 * @param {Object=} opt_options
216 * @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString
217 * @see http://www.ecma-international.org/ecma-402/1.0/#sec-13.2.1
220 Number.prototype.toLocaleString = function(opt_locales, opt_options) {};
224 * @see http://dev.w3.org/html5/postmsg/
227 function Transferable() {}
230 * @param {number} length The length in bytes
235 * @implements {Transferable}
237 function ArrayBuffer(length) {}
239 /** @type {number} */
240 ArrayBuffer.prototype.byteLength;
243 * @param {number} begin
244 * @param {number=} opt_end
245 * @return {!ArrayBuffer}
248 ArrayBuffer.prototype.slice = function(begin, opt_end) {};
255 function ArrayBufferView() {}
257 /** @type {!ArrayBuffer} */
258 ArrayBufferView.prototype.buffer;
260 /** @type {number} */
261 ArrayBufferView.prototype.byteOffset;
263 /** @type {number} */
264 ArrayBufferView.prototype.byteLength;
268 * @param {number|ArrayBufferView|Array.<number>|ArrayBuffer} length or array
270 * @param {number=} opt_byteOffset
271 * @param {number=} opt_length
272 * @extends {ArrayBufferView}
276 * @modifies {arguments} If the user passes a backing array, then indexed
277 * accesses will modify the backing array. JSCompiler does not model
278 * this well. In other words, if you have:
280 * var x = new ArrayBuffer(1);
281 * var y = new Int8Array(x);
284 * JSCompiler will not recognize that the last assignment modifies x.
285 * We workaround this by marking all these arrays as @modifies {arguments},
286 * to introduce the possibility that x aliases y.
288 function Int8Array(length, opt_byteOffset, opt_length) {}
290 /** @type {number} */
291 Int8Array.BYTES_PER_ELEMENT;
293 /** @type {number} */
294 Int8Array.prototype.BYTES_PER_ELEMENT;
296 /** @type {number} */
297 Int8Array.prototype.length;
300 * @param {ArrayBufferView|Array.<number>} array
301 * @param {number=} opt_offset
303 Int8Array.prototype.set = function(array, opt_offset) {};
306 * @param {number} begin
307 * @param {number=} opt_end
308 * @return {!Int8Array}
311 Int8Array.prototype.subarray = function(begin, opt_end) {};
315 * @param {number|ArrayBufferView|Array.<number>|ArrayBuffer} length or array
317 * @param {number=} opt_byteOffset
318 * @param {number=} opt_length
319 * @extends {ArrayBufferView}
323 * @modifies {arguments}
325 function Uint8Array(length, opt_byteOffset, opt_length) {}
327 /** @type {number} */
328 Uint8Array.BYTES_PER_ELEMENT;
330 /** @type {number} */
331 Uint8Array.prototype.BYTES_PER_ELEMENT;
333 /** @type {number} */
334 Uint8Array.prototype.length;
337 * @param {ArrayBufferView|Array.<number>} array
338 * @param {number=} opt_offset
340 Uint8Array.prototype.set = function(array, opt_offset) {};
343 * @param {number} begin
344 * @param {number=} opt_end
345 * @return {!Uint8Array}
348 Uint8Array.prototype.subarray = function(begin, opt_end) {};
352 * @param {number|ArrayBufferView|Array.<number>|ArrayBuffer} length or array
354 * @param {number=} opt_byteOffset
355 * @param {number=} opt_length
356 * @extends {ArrayBufferView}
360 * @modifies {arguments}
362 function Uint8ClampedArray(length, opt_byteOffset, opt_length) {}
364 /** @type {number} */
365 Uint8ClampedArray.BYTES_PER_ELEMENT;
367 /** @type {number} */
368 Uint8ClampedArray.prototype.BYTES_PER_ELEMENT;
370 /** @type {number} */
371 Uint8ClampedArray.prototype.length;
374 * @param {ArrayBufferView|Array.<number>} array
375 * @param {number=} opt_offset
377 Uint8ClampedArray.prototype.set = function(array, opt_offset) {};
380 * @param {number} begin
381 * @param {number=} opt_end
382 * @return {!Uint8ClampedArray}
385 Uint8ClampedArray.prototype.subarray = function(begin, opt_end) {};
389 * @typedef {Uint8ClampedArray}
390 * @deprecated CanvasPixelArray has been replaced by Uint8ClampedArray
391 * in the latest spec.
392 * @see http://www.w3.org/TR/2dcontext/#imagedata
394 var CanvasPixelArray;
398 * @param {number|ArrayBufferView|Array.<number>|ArrayBuffer} length or array
400 * @param {number=} opt_byteOffset
401 * @param {number=} opt_length
402 * @extends {ArrayBufferView}
406 * @modifies {arguments}
408 function Int16Array(length, opt_byteOffset, opt_length) {}
410 /** @type {number} */
411 Int16Array.BYTES_PER_ELEMENT;
413 /** @type {number} */
414 Int16Array.prototype.BYTES_PER_ELEMENT;
416 /** @type {number} */
417 Int16Array.prototype.length;
420 * @param {ArrayBufferView|Array.<number>} array
421 * @param {number=} opt_offset
423 Int16Array.prototype.set = function(array, opt_offset) {};
426 * @param {number} begin
427 * @param {number=} opt_end
428 * @return {!Int16Array}
431 Int16Array.prototype.subarray = function(begin, opt_end) {};
435 * @param {number|ArrayBufferView|Array.<number>|ArrayBuffer} length or array
437 * @param {number=} opt_byteOffset
438 * @param {number=} opt_length
439 * @extends {ArrayBufferView}
443 * @modifies {arguments}
445 function Uint16Array(length, opt_byteOffset, opt_length) {}
447 /** @type {number} */
448 Uint16Array.BYTES_PER_ELEMENT;
450 /** @type {number} */
451 Uint16Array.prototype.BYTES_PER_ELEMENT;
453 /** @type {number} */
454 Uint16Array.prototype.length;
457 * @param {ArrayBufferView|Array.<number>} array
458 * @param {number=} opt_offset
460 Uint16Array.prototype.set = function(array, opt_offset) {};
463 * @param {number} begin
464 * @param {number=} opt_end
465 * @return {!Uint16Array}
468 Uint16Array.prototype.subarray = function(begin, opt_end) {};
472 * @param {number|ArrayBufferView|Array.<number>|ArrayBuffer} length or array
474 * @param {number=} opt_byteOffset
475 * @param {number=} opt_length
476 * @extends {ArrayBufferView}
480 * @modifies {arguments}
482 function Int32Array(length, opt_byteOffset, opt_length) {}
484 /** @type {number} */
485 Int32Array.BYTES_PER_ELEMENT;
487 /** @type {number} */
488 Int32Array.prototype.BYTES_PER_ELEMENT;
490 /** @type {number} */
491 Int32Array.prototype.length;
494 * @param {ArrayBufferView|Array.<number>} array
495 * @param {number=} opt_offset
497 Int32Array.prototype.set = function(array, opt_offset) {};
500 * @param {number} begin
501 * @param {number=} opt_end
502 * @return {!Int32Array}
505 Int32Array.prototype.subarray = function(begin, opt_end) {};
509 * @param {number|ArrayBufferView|Array.<number>|ArrayBuffer} length or array
511 * @param {number=} opt_byteOffset
512 * @param {number=} opt_length
513 * @extends {ArrayBufferView}
517 * @modifies {arguments}
519 function Uint32Array(length, opt_byteOffset, opt_length) {}
521 /** @type {number} */
522 Uint32Array.BYTES_PER_ELEMENT;
524 /** @type {number} */
525 Uint32Array.prototype.BYTES_PER_ELEMENT;
527 /** @type {number} */
528 Uint32Array.prototype.length;
531 * @param {ArrayBufferView|Array.<number>} array
532 * @param {number=} opt_offset
534 Uint32Array.prototype.set = function(array, opt_offset) {};
537 * @param {number} begin
538 * @param {number=} opt_end
539 * @return {!Uint32Array}
542 Uint32Array.prototype.subarray = function(begin, opt_end) {};
546 * @param {number|ArrayBufferView|Array.<number>|ArrayBuffer} length or array
548 * @param {number=} opt_byteOffset
549 * @param {number=} opt_length
550 * @extends {ArrayBufferView}
554 * @modifies {arguments}
556 function Float32Array(length, opt_byteOffset, opt_length) {}
558 /** @type {number} */
559 Float32Array.BYTES_PER_ELEMENT;
561 /** @type {number} */
562 Float32Array.prototype.BYTES_PER_ELEMENT;
564 /** @type {number} */
565 Float32Array.prototype.length;
568 * @param {ArrayBufferView|Array.<number>} array
569 * @param {number=} opt_offset
571 Float32Array.prototype.set = function(array, opt_offset) {};
574 * @param {number} begin
575 * @param {number=} opt_end
576 * @return {!Float32Array}
579 Float32Array.prototype.subarray = function(begin, opt_end) {};
583 * @param {number|ArrayBufferView|Array.<number>|ArrayBuffer} length or array
585 * @param {number=} opt_byteOffset
586 * @param {number=} opt_length
587 * @extends {ArrayBufferView}
591 * @modifies {arguments}
593 function Float64Array(length, opt_byteOffset, opt_length) {}
595 /** @type {number} */
596 Float64Array.BYTES_PER_ELEMENT;
598 /** @type {number} */
599 Float64Array.prototype.BYTES_PER_ELEMENT;
601 /** @type {number} */
602 Float64Array.prototype.length;
605 * @param {ArrayBufferView|Array.<number>} array
606 * @param {number=} opt_offset
608 Float64Array.prototype.set = function(array, opt_offset) {};
611 * @param {number} begin
612 * @param {number=} opt_end
613 * @return {!Float64Array}
616 Float64Array.prototype.subarray = function(begin, opt_end) {};
620 * @param {ArrayBuffer} buffer
621 * @param {number=} opt_byteOffset
622 * @param {number=} opt_byteLength
623 * @extends {ArrayBufferView}
628 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays/DataView
630 function DataView(buffer, opt_byteOffset, opt_byteLength) {}
633 * @param {number} byteOffset
638 DataView.prototype.getInt8 = function(byteOffset) {};
641 * @param {number} byteOffset
646 DataView.prototype.getUint8 = function(byteOffset) {};
649 * @param {number} byteOffset
650 * @param {boolean=} opt_littleEndian
655 DataView.prototype.getInt16 = function(byteOffset, opt_littleEndian) {};
658 * @param {number} byteOffset
659 * @param {boolean=} opt_littleEndian
664 DataView.prototype.getUint16 = function(byteOffset, opt_littleEndian) {};
667 * @param {number} byteOffset
668 * @param {boolean=} opt_littleEndian
673 DataView.prototype.getInt32 = function(byteOffset, opt_littleEndian) {};
676 * @param {number} byteOffset
677 * @param {boolean=} opt_littleEndian
682 DataView.prototype.getUint32 = function(byteOffset, opt_littleEndian) {};
685 * @param {number} byteOffset
686 * @param {boolean=} opt_littleEndian
691 DataView.prototype.getFloat32 = function(byteOffset, opt_littleEndian) {};
694 * @param {number} byteOffset
695 * @param {boolean=} opt_littleEndian
700 DataView.prototype.getFloat64 = function(byteOffset, opt_littleEndian) {};
703 * @param {number} byteOffset
704 * @param {number} value
707 DataView.prototype.setInt8 = function(byteOffset, value) {};
710 * @param {number} byteOffset
711 * @param {number} value
714 DataView.prototype.setUint8 = function(byteOffset, value) {};
717 * @param {number} byteOffset
718 * @param {number} value
719 * @param {boolean=} opt_littleEndian
722 DataView.prototype.setInt16 = function(byteOffset, value, opt_littleEndian) {};
725 * @param {number} byteOffset
726 * @param {number} value
727 * @param {boolean=} opt_littleEndian
730 DataView.prototype.setUint16 = function(byteOffset, value, opt_littleEndian) {};
733 * @param {number} byteOffset
734 * @param {number} value
735 * @param {boolean=} opt_littleEndian
738 DataView.prototype.setInt32 = function(byteOffset, value, opt_littleEndian) {};
741 * @param {number} byteOffset
742 * @param {number} value
743 * @param {boolean=} opt_littleEndian
746 DataView.prototype.setUint32 = function(byteOffset, value, opt_littleEndian) {};
749 * @param {number} byteOffset
750 * @param {number} value
751 * @param {boolean=} opt_littleEndian
754 DataView.prototype.setFloat32 = function(
755 byteOffset, value, opt_littleEndian) {};
758 * @param {number} byteOffset
759 * @param {number} value
760 * @param {boolean=} opt_littleEndian
763 DataView.prototype.setFloat64 = function(
764 byteOffset, value, opt_littleEndian) {};
768 * @see https://github.com/promises-aplus/promises-spec
769 * @typedef {{then: !Function}}
775 * This is not an official DOM interface. It is used to add generic typing
776 * and respective type inference where available.
777 * {@see goog.Thenable} inherits from this making all promises
782 var IThenable = function() {};
786 * @param {?(function(TYPE):
787 * (RESULT|IThenable.<RESULT>|Thenable))=} opt_onFulfilled
788 * @param {?(function(*): *)=} opt_onRejected
789 * @return {!IThenable.<RESULT>}
792 IThenable.prototype.then = function(opt_onFulfilled, opt_onRejected) {};
796 * @see https://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects
798 * function((TYPE|IThenable.<TYPE>|Thenable|null)=),
799 * function(*=))} resolver
801 * @implements {IThenable.<TYPE>}
804 var Promise = function(resolver) {};
808 * @param {(TYPE|IThenable.<TYPE>)=} opt_value
809 * @return {!Promise.<TYPE>}
812 Promise.resolve = function(opt_value) {};
816 * @param {*=} opt_error
817 * @return {!Promise.<?>}
819 Promise.reject = function(opt_error) {};
824 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
825 * @param {!Array<T|!Promise<T>>} iterable
826 * @return {!Promise<!Array<T>>}
828 Promise.all = function(iterable) {};
833 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
834 * @param {!Array.<T>} iterable
835 * @return {!Promise.<T>}
837 Promise.race = function(iterable) {};
841 * @param {?(function(TYPE):
842 * (RESULT|IThenable.<RESULT>|Thenable))=} opt_onFulfilled
843 * @param {?(function(*): *)=} opt_onRejected
844 * @return {!Promise.<RESULT>}
848 Promise.prototype.then = function(opt_onFulfilled, opt_onRejected) {};
852 * @param {function(*): RESULT} onRejected
853 * @return {!Promise.<RESULT>}
856 Promise.prototype.catch = function(onRejected) {};