From dfa423f5422c57c06cc4fadd07e74781d3b677af Mon Sep 17 00:00:00 2001 From: Colin Alworth Date: Fri, 19 Jul 2024 16:29:13 -0500 Subject: [PATCH 1/2] 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 fab8d3ace2d..41b0e0f1f6d 100644 --- a/externs/es6.js +++ b/externs/es6.js @@ -406,7 +406,8 @@ ArrayBuffer.isView = function(arg) {}; /** - * @constructor + * @interface + * @see https://webidl.spec.whatwg.org/#ArrayBufferView */ function ArrayBufferView() {} @@ -447,12 +448,13 @@ var BufferSource; /** - * @constructor + * @interface * @implements {IArrayLike} * @implements {Iterable} - * @extends {ArrayBufferView} + * @implements {ArrayBufferView} + * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-typedarray-objects */ -function TypedArray() {}; +function TypedArray() {} /** @const {number} */ TypedArray.prototype.BYTES_PER_ELEMENT; @@ -730,7 +732,7 @@ TypedArray.prototype[Symbol.iterator] = function() {}; * @param {number=} opt_byteOffset * @param {number=} opt_length * @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 @@ -776,7 +778,7 @@ Int8Array.of = function(var_args) {}; * @param {number=} opt_byteOffset * @param {number=} opt_length * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -812,7 +814,7 @@ Uint8Array.of = function(var_args) {}; * @param {number=} opt_byteOffset * @param {number=} opt_length * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -857,7 +859,7 @@ var CanvasPixelArray; * @param {number=} opt_byteOffset * @param {number=} opt_length * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -893,7 +895,7 @@ Int16Array.of = function(var_args) {}; * @param {number=} opt_byteOffset * @param {number=} opt_length * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -929,7 +931,7 @@ Uint16Array.of = function(var_args) {}; * @param {number=} opt_byteOffset * @param {number=} opt_length * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -965,7 +967,7 @@ Int32Array.of = function(var_args) {}; * @param {number=} opt_byteOffset * @param {number=} opt_length * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -1001,7 +1003,7 @@ Uint32Array.of = function(var_args) {}; * @param {number=} opt_byteOffset * @param {number=} opt_length * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -1037,7 +1039,7 @@ Float32Array.of = function(var_args) {}; * @param {number=} opt_byteOffset * @param {number=} opt_length * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -1073,7 +1075,7 @@ Float64Array.of = function(var_args) {}; * @param {number=} byteOffset * @param {number=} bufferLength * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -1109,7 +1111,7 @@ BigInt64Array.of = function(var_args) {}; * @param {number=} byteOffset * @param {number=} bufferLength * @constructor - * @extends {TypedArray} + * @implements {TypedArray} * @throws {Error} * @modifies {arguments} */ @@ -1140,7 +1142,7 @@ BigUint64Array.of = function(var_args) {}; * @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 e4f1e02ebd1b12d8d484613d3fcfef2700a9097b Mon Sep 17 00:00:00 2001 From: Colin Alworth Date: Thu, 25 Jul 2024 14:42:55 -0500 Subject: [PATCH 2/2] 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 41b0e0f1f6d..4057a8cf219 100644 --- a/externs/es6.js +++ b/externs/es6.js @@ -449,9 +449,9 @@ var BufferSource; /** * @interface - * @implements {IArrayLike} - * @implements {Iterable} - * @implements {ArrayBufferView} + * @extends {IArrayLike} + * @extends {Iterable} + * @extends {ArrayBufferView} * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-typedarray-objects */ function TypedArray() {}