From 4149aad83a346e44b2753c5038b7f9ba58c4595a Mon Sep 17 00:00:00 2001 From: Colin Alworth Date: Fri, 19 Jul 2024 16:29:13 -0500 Subject: [PATCH 1/4] Define ArrayBufferView and TypedArray as interfaces rather than classes Technically, the former appears to be a typedef and the latter might be a template for classes? But neither exists as a named function/constructor. Earlier versions of the spec do indicate that both were at one point interfaces though. --- externs/es6.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/externs/es6.js b/externs/es6.js index 85f778f4c64..d44e79c28f6 100644 --- a/externs/es6.js +++ b/externs/es6.js @@ -406,8 +406,9 @@ ArrayBuffer.isView = function(arg) {}; /** - * @constructor + * @interface * @template TArrayBuffer (unused) + * @see https://webidl.spec.whatwg.org/#ArrayBufferView */ function ArrayBufferView() {} @@ -453,13 +454,14 @@ var AllowSharedBufferSource; /** - * @constructor + * @interface * @implements {IArrayLike} * @implements {Iterable} - * @extends {ArrayBufferView} + * @implements {ArrayBufferView} * @template TArrayBuffer (unused) + * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-typedarray-objects */ -function TypedArray() {}; +function TypedArray() {} /** @const {number} */ TypedArray.prototype.BYTES_PER_ELEMENT; @@ -771,7 +773,7 @@ TypedArray.prototype[Symbol.iterator] = function() {}; * @param {number=} opt_length * @template TArrayBuffer (unused) * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} If the user passes a backing array, then indexed * accesses will modify the backing array. JSCompiler does not model @@ -818,7 +820,7 @@ Int8Array.of = function(var_args) {}; * @param {number=} opt_length * @template TArrayBuffer (unused) * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -855,7 +857,7 @@ Uint8Array.of = function(var_args) {}; * @param {number=} opt_length * @template TArrayBuffer (unused) * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -901,7 +903,7 @@ var CanvasPixelArray; * @param {number=} opt_length * @template TArrayBuffer (unused) * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -938,7 +940,7 @@ Int16Array.of = function(var_args) {}; * @param {number=} opt_length * @template TArrayBuffer (unused) * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -975,7 +977,7 @@ Uint16Array.of = function(var_args) {}; * @param {number=} opt_length * @template TArrayBuffer (unused) * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -1012,7 +1014,7 @@ Int32Array.of = function(var_args) {}; * @param {number=} opt_length * @template TArrayBuffer (unused) * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -1082,7 +1084,7 @@ Float16Array.of = function(var_args) {}; * @param {number=} opt_length * @template TArrayBuffer (unused) * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -1119,7 +1121,7 @@ Float32Array.of = function(var_args) {}; * @param {number=} opt_length * @template TArrayBuffer (unused) * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -1156,7 +1158,7 @@ Float64Array.of = function(var_args) {}; * @param {number=} bufferLength * @template TArrayBuffer (unused) * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -1226,7 +1228,7 @@ BigInt64Array.prototype.with = function(index, value) {}; * @param {number=} bufferLength * @template TArrayBuffer (unused) * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -1291,7 +1293,7 @@ BigUint64Array.prototype.with = function(index, value) {}; * @param {number=} opt_byteOffset * @param {number=} opt_byteLength * @constructor - * @extends {ArrayBufferView} + * @implements {ArrayBufferView} * @throws {Error} * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays/DataView */ From 2fee2308eb4a27d20efc3d8edc42791e4c930b28 Mon Sep 17 00:00:00 2001 From: Colin Alworth Date: Thu, 25 Jul 2024 14:42:55 -0500 Subject: [PATCH 2/4] Interfaces should use @extends for other interfaces --- externs/es6.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/externs/es6.js b/externs/es6.js index d44e79c28f6..718d3ba724e 100644 --- a/externs/es6.js +++ b/externs/es6.js @@ -455,9 +455,9 @@ var AllowSharedBufferSource; /** * @interface - * @implements {IArrayLike} - * @implements {Iterable} - * @implements {ArrayBufferView} + * @extends {IArrayLike} + * @extends {Iterable} + * @extends {ArrayBufferView} * @template TArrayBuffer (unused) * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-typedarray-objects */ From 91829e4db6161216c896049d4dbdb8b598ceee44 Mon Sep 17 00:00:00 2001 From: Colin Alworth Date: Fri, 2 Jan 2026 11:49:16 -0600 Subject: [PATCH 3/4] Add another reference --- externs/es6.js | 1 + 1 file changed, 1 insertion(+) diff --git a/externs/es6.js b/externs/es6.js index 718d3ba724e..a6614aa444f 100644 --- a/externs/es6.js +++ b/externs/es6.js @@ -460,6 +460,7 @@ var AllowSharedBufferSource; * @extends {ArrayBufferView} * @template TArrayBuffer (unused) * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-typedarray-objects + * @see https://tc39.es/ecma262/multipage/ordinary-and-exotic-objects-behaviours.html#typedarray */ function TypedArray() {} From b5b9d5ec0275ed005b33a11a0a0c7c009f59072d Mon Sep 17 00:00:00 2001 From: Colin Alworth Date: Fri, 2 Jan 2026 16:47:41 -0600 Subject: [PATCH 4/4] Add override for new method, handle other extends/implements change --- externs/es6.js | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/externs/es6.js b/externs/es6.js index a6614aa444f..5a3ec1fb504 100644 --- a/externs/es6.js +++ b/externs/es6.js @@ -810,6 +810,9 @@ Int8Array.from = function(source, mapFn, thisArg) {}; */ Int8Array.of = function(var_args) {}; +/** @override */ +Int8Array.prototype[Symbol.iterator] = function() {}; + /** * @param {number|ArrayBufferView|Array|ArrayBuffer|SharedArrayBuffer} @@ -847,6 +850,9 @@ Uint8Array.from = function(source, mapFn, thisArg) {}; */ Uint8Array.of = function(var_args) {}; +/** @override */ +Uint8Array.prototype[Symbol.iterator] = function() {}; + /** * @param {number|ArrayBufferView|Array|ArrayBuffer|SharedArrayBuffer} @@ -884,6 +890,9 @@ Uint8ClampedArray.from = function(source, mapFn, thisArg) {}; */ Uint8ClampedArray.of = function(var_args) {}; +/** @override */ +Uint8ClampedArray.prototype[Symbol.iterator] = function() {}; + /** * @typedef {Uint8ClampedArray} @@ -930,6 +939,9 @@ Int16Array.from = function(source, mapFn, thisArg) {}; */ Int16Array.of = function(var_args) {}; +/** @override */ +Int16Array.prototype[Symbol.iterator] = function() {}; + /** * @param {number|ArrayBufferView|Array|ArrayBuffer|SharedArrayBuffer} @@ -967,6 +979,9 @@ Uint16Array.from = function(source, mapFn, thisArg) {}; */ Uint16Array.of = function(var_args) {}; +/** @override */ +Uint16Array.prototype[Symbol.iterator] = function() {}; + /** * @param {number|ArrayBufferView|Array|ArrayBuffer|SharedArrayBuffer} @@ -1004,6 +1019,9 @@ Int32Array.from = function(source, mapFn, thisArg) {}; */ Int32Array.of = function(var_args) {}; +/** @override */ +Int32Array.prototype[Symbol.iterator] = function() {}; + /** * @param {number|ArrayBufferView|Array|ArrayBuffer|SharedArrayBuffer} @@ -1041,6 +1059,9 @@ Uint32Array.from = function(source, mapFn, thisArg) {}; */ Uint32Array.of = function(var_args) {}; +/** @override */ +Uint32Array.prototype[Symbol.iterator] = function() {}; + /** * @param {number|ArrayBufferView|Array|ArrayBuffer|SharedArrayBuffer} @@ -1048,7 +1069,7 @@ Uint32Array.of = function(var_args) {}; * @param {number=} opt_byteOffset * @param {number=} opt_length * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array @@ -1075,6 +1096,10 @@ Float16Array.from = function(source, mapFn, thisArg) {}; */ Float16Array.of = function(var_args) {}; +/** @override */ +Float16Array.prototype[Symbol.iterator] = function() {}; + + /** * @param {number|ArrayBufferView|Array|ArrayBuffer|SharedArrayBuffer} * length or array or buffer @@ -1111,6 +1136,9 @@ Float32Array.from = function(source, mapFn, thisArg) {}; */ Float32Array.of = function(var_args) {}; +/** @override */ +Float32Array.prototype[Symbol.iterator] = function() {}; + /** * @param {number|ArrayBufferView|Array|ArrayBuffer|SharedArrayBuffer} @@ -1148,6 +1176,9 @@ Float64Array.from = function(source, mapFn, thisArg) {}; */ Float64Array.of = function(var_args) {}; +/** @override */ +Float64Array.prototype[Symbol.iterator] = function() {}; + /** * @param {number|ArrayBufferView|Array|ArrayBuffer|SharedArrayBuffer} @@ -1219,6 +1250,10 @@ BigInt64Array.prototype.toSorted = function(compareFn) {}; */ BigInt64Array.prototype.with = function(index, value) {}; +/** @override */ +BigInt64Array.prototype[Symbol.iterator] = function() {}; + + /** * @param {number|ArrayBufferView|Array|ArrayBuffer|SharedArrayBuffer} * lengthOrArrayOrBuffer @@ -1289,6 +1324,10 @@ BigUint64Array.prototype.toSorted = function(compareFn) {}; */ BigUint64Array.prototype.with = function(index, value) {}; +/** @override */ +BigUint64Array.prototype[Symbol.iterator] = function() {}; + + /** * @param {ArrayBuffer|SharedArrayBuffer} buffer * @param {number=} opt_byteOffset