diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..d476904 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Build", + "skipFiles": ["/**"], + "program": "${workspaceFolder}/build/build.ts", + "outFiles": ["${workspaceFolder}/dist/**/*.js"] + } + ] +} diff --git a/build/alias.ts b/build/alias.ts new file mode 100644 index 0000000..f7bbf6a --- /dev/null +++ b/build/alias.ts @@ -0,0 +1,46 @@ +const aliasArray: [string, string[]][] = [ + [ + "TypedNumberArray", + [ + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Uint16Array", + "Int32Array", + "Uint32Array", + "Float32Array", + "Float64Array", + ], + ], + ["TypedBigIntArray", ["BigInt64Array", "BigUint64Array"]], +]; + +export const alias = new Map( + aliasArray.flatMap(([originalType, replacementTypes]) => [ + [ + originalType, + new Map( + replacementTypes.map((replacement) => [ + replacement, + new Map([ + [originalType, replacement], + [`${originalType}Constructor`, `${replacement}Constructor`], + ]), + ]) + ), + ], + [ + `${originalType}Constructor`, + new Map( + replacementTypes.map((replacement) => [ + `${replacement}Constructor`, + new Map([ + [originalType, replacement], + [`${originalType}Constructor`, `${replacement}Constructor`], + ]), + ]) + ), + ], + ]) +); diff --git a/build/logic/generate.ts b/build/logic/generate.ts index 97c1e94..1ae4f72 100644 --- a/build/logic/generate.ts +++ b/build/logic/generate.ts @@ -1,5 +1,6 @@ import path from "path"; import ts from "typescript"; +import { alias } from "../alias"; import { upsert } from "../util/upsert"; import { projectDir } from "./projectDir"; @@ -24,14 +25,10 @@ export function generate( let result = ""; - const replacementTargets = scanBetterFile(libFile); + const replacementTargets = scanBetterFile(printer, libFile); if (replacementTargets.size === 0) { - for (const statement of originalFile.statements) { - result += statement.getFullText(originalFile); - } - result += originalFile.text.slice(originalFile.endOfFileToken.pos); - return result; + return originalFile.text; } const consumedReplacements = new Set(); @@ -132,7 +129,7 @@ export function generate( }, ]; }); - result += printInterface(printer, statement, memberList); + result += printInterface(printer, statement, memberList, originalFile); if (emitOriginalAsComment) { result += "\n"; @@ -188,7 +185,10 @@ type ReplacementTarget = ( /** * Scan better lib file to determine which statements need to be replaced. */ -function scanBetterFile(libFile: string): Map { +function scanBetterFile( + printer: ts.Printer, + libFile: string +): Map { const replacementTargets = new Map(); { const betterLibFile = path.join(betterLibDir, `lib.${libFile}`); @@ -198,43 +198,58 @@ function scanBetterFile(libFile: string): Map { // Scan better file to determine which statements need to be replaced. for (const statement of betterFile.statements) { const name = getStatementDeclName(statement) ?? ""; - if (ts.isInterfaceDeclaration(statement)) { - const members = new Map< - string, - { - member: ts.TypeElement; - text: string; - }[] - >(); - for (const member of statement.members) { - const memberName = member.name?.getText(betterFile) ?? ""; - upsert(members, memberName, (members = []) => { - members.push({ - member, - text: member.getFullText(betterFile), + const aliasesMap = + alias.get(name) ?? new Map([[name, new Map()]]); + for (const [targetName, typeMap] of aliasesMap) { + const transformedStatement = replaceAliases(statement, typeMap); + if (ts.isInterfaceDeclaration(transformedStatement)) { + const members = new Map< + string, + { + member: ts.TypeElement; + text: string; + }[] + >(); + for (const member of transformedStatement.members) { + const memberName = member.name?.getText(betterFile) ?? ""; + upsert(members, memberName, (members = []) => { + const leadingSpacesMatch = /^\s*/.exec( + member.getFullText(betterFile) + ); + const leadingSpaces = + leadingSpacesMatch !== null ? leadingSpacesMatch[0] : ""; + members.push({ + member, + text: + leadingSpaces + + printer.printNode( + ts.EmitHint.Unspecified, + member, + betterFile + ), + }); + return members; }); - return members; - }); - } - - upsert(replacementTargets, name, (targets = []) => { - targets.push({ - type: "interface", - members, - originalStatement: statement, - sourceFile: betterFile, + } + upsert(replacementTargets, targetName, (targets = []) => { + targets.push({ + type: "interface", + members, + originalStatement: transformedStatement, + sourceFile: betterFile, + }); + return targets; }); - return targets; - }); - } else { - upsert(replacementTargets, name, (statements = []) => { - statements.push({ - type: "non-interface", - statement, - sourceFile: betterFile, + } else { + upsert(replacementTargets, targetName, (statements = []) => { + statements.push({ + type: "non-interface", + statement: transformedStatement, + sourceFile: betterFile, + }); + return statements; }); - return statements; - }); + } } } } @@ -308,10 +323,12 @@ function isPartialReplacement( function printInterface( printer: ts.Printer, originalNode: ts.InterfaceDeclaration, - members: readonly { text: string }[] + members: readonly { text: string }[], + originalSourceFile: ts.SourceFile ): string { - const originalSourceFile = originalNode.getSourceFile(); - let result = ""; + let result = originalNode + .getFullText(originalSourceFile) + .slice(0, originalNode.getLeadingTriviaWidth(originalSourceFile)); for (const dec of originalNode.decorators ?? []) { result += printer.printNode( ts.EmitHint.Unspecified, @@ -372,3 +389,29 @@ function commentOut(code: string): string { const result = lines.map((line) => `// ${line}`); return result.join("\n") + "\n"; } + +function replaceAliases( + statement: ts.Statement, + typeMap: Map +): ts.Statement { + if (typeMap.size === 0) return statement; + return ts.transform(statement, [ + (context) => (sourceStatement) => { + const visitor = (node: ts.Node): ts.Node => { + if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName)) { + const replacementType = typeMap.get(node.typeName.text); + if (replacementType === undefined) { + return node; + } + return ts.factory.updateTypeReferenceNode( + node, + ts.factory.createIdentifier(replacementType), + node.typeArguments + ); + } + return ts.visitEachChild(node, visitor, context); + }; + return ts.visitNode(sourceStatement, visitor); + }, + ]).transformed[0]; +} diff --git a/docs/diff.md b/docs/diff.md index 7824599..587f1e7 100644 --- a/docs/diff.md +++ b/docs/diff.md @@ -15,6 +15,7 @@ The following files are improved in better-typescript-lib: - [es2018.asyncgenerator.d.ts](./diff/es2018.asyncgenerator.d.ts.md) - [es2018.asynciterable.d.ts](./diff/es2018.asynciterable.d.ts.md) - [es2019.object.d.ts](./diff/es2019.object.d.ts.md) +- [es2020.bigint.d.ts](./diff/es2020.bigint.d.ts.md) - [es2021.promise.d.ts](./diff/es2021.promise.d.ts.md) - [es2021.string.d.ts](./diff/es2021.string.d.ts.md) - [es2022.object.d.ts](./diff/es2022.object.d.ts.md) diff --git a/docs/diff/es2015.collection.d.ts.md b/docs/diff/es2015.collection.d.ts.md index ffb1d5b..a63c782 100644 --- a/docs/diff/es2015.collection.d.ts.md +++ b/docs/diff/es2015.collection.d.ts.md @@ -5,7 +5,7 @@ Index: es2015.collection.d.ts =================================================================== --- es2015.collection.d.ts +++ es2015.collection.d.ts -@@ -1,28 +1,25 @@ +@@ -1,28 +1,27 @@ interface Map { clear(): void; delete(key: K): boolean; @@ -13,7 +13,7 @@ Index: es2015.collection.d.ts - callbackfn: (value: V, key: K, map: Map) => void, - thisArg?: any + forEach( -+ callbackfn: (this: This, value: V, key: K, map: Map) => void, ++ callbackfn: (this: This, value: V, key: K, map: this) => void, + thisArg?: This ): void; get(key: K): V | undefined; @@ -21,7 +21,7 @@ Index: es2015.collection.d.ts set(key: K, value: V): this; readonly size: number; } -- + interface MapConstructor { - new (): Map; new (entries?: readonly (readonly [K, V])[] | null): Map; @@ -29,24 +29,22 @@ Index: es2015.collection.d.ts + readonly prototype: Map; } declare var Map: MapConstructor; -- + interface ReadonlyMap { - forEach( - callbackfn: (value: V, key: K, map: ReadonlyMap) => void, - thisArg?: any + forEach( -+ callbackfn: (this: This, value: V, key: K, map: ReadonlyMap) => void, ++ callbackfn: (this: This, value: V, key: K, map: this) => void, + thisArg?: This ): void; get(key: K): V | undefined; has(key: K): boolean; readonly size: number; -@@ -33,39 +30,35 @@ - get(key: K): V | undefined; - has(key: K): boolean; +@@ -35,37 +34,37 @@ set(key: K, value: V): this; } -- + interface WeakMapConstructor { - new ( - entries?: readonly [K, V][] | null @@ -57,7 +55,7 @@ Index: es2015.collection.d.ts + readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; -- + interface Set { add(value: T): this; clear(): void; @@ -66,13 +64,13 @@ Index: es2015.collection.d.ts - callbackfn: (value: T, value2: T, set: Set) => void, - thisArg?: any + forEach( -+ callbackfn: (this: This, value: T, value2: T, set: Set) => void, ++ callbackfn: (this: This, value: T, value2: T, set: this) => void, + thisArg?: This ): void; has(value: T): boolean; readonly size: number; } -- + interface SetConstructor { - new (values?: readonly T[] | null): Set; - readonly prototype: Set; @@ -80,13 +78,13 @@ Index: es2015.collection.d.ts + readonly prototype: Set; } declare var Set: SetConstructor; -- + interface ReadonlySet { - forEach( - callbackfn: (value: T, value2: T, set: ReadonlySet) => void, - thisArg?: any + forEach( -+ callbackfn: (this: This, value: T, value2: T, set: ReadonlySet) => void, ++ callbackfn: (this: This, value: T, value2: T, set: this) => void, + thisArg?: This ): void; has(value: T): boolean; diff --git a/docs/diff/es2015.core.d.ts.md b/docs/diff/es2015.core.d.ts.md index 157bedb..f4bec93 100644 --- a/docs/diff/es2015.core.d.ts.md +++ b/docs/diff/es2015.core.d.ts.md @@ -5,15 +5,87 @@ Index: es2015.core.d.ts =================================================================== --- es2015.core.d.ts +++ es2015.core.d.ts -@@ -201,44 +201,42 @@ - * @param x A numeric expression. +@@ -7,15 +7,25 @@ + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. */ - cbrt(x: number): number; +- find( +- predicate: (this: void, value: T, index: number, obj: T[]) => value is S, +- thisArg?: any ++ find( ++ predicate: (this: This, value: T, index: number, obj: this) => value is S, ++ thisArg?: This + ): S | undefined; +- find( +- predicate: (value: T, index: number, obj: T[]) => unknown, +- thisArg?: any ++ ++ /** ++ * Returns the value of the first element in the array where predicate is true, and undefined ++ * otherwise. ++ * @param predicate find calls predicate once for each element of the array, in ascending ++ * order, until it finds one where predicate returns true. If such an element is found, find ++ * immediately returns that element value. Otherwise, find returns undefined. ++ * @param thisArg If provided, it will be used as the this value for each invocation of ++ * predicate. If it is not provided, undefined is used instead. ++ */ ++ find( ++ predicate: (this: This, value: T, index: number, obj: this) => boolean, ++ thisArg?: This + ): T | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and -1 +@@ -25,11 +35,11 @@ + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- findIndex( +- predicate: (value: T, index: number, obj: T[]) => unknown, +- thisArg?: any ++ findIndex( ++ predicate: (this: This, value: T, index: number, obj: this) => boolean, ++ thisArg?: This + ): number; + + /** + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array +@@ -54,23 +64,23 @@ } -- - interface NumberConstructor { + + interface ArrayConstructor { /** - * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 +- * Creates an array from an array-like object. +- * @param arrayLike An array-like object to convert to an array. ++ * Creates an array from an array-like or iterable object. ++ * @param source An array-like or iterable object to convert to an array. + */ +- from(arrayLike: ArrayLike): T[]; ++ from(source: ArrayLike): T[]; + + /** +- * Creates an array from an iterable object. +- * @param arrayLike An array-like object to convert to an array. ++ * Creates an array from an array-like or iterable object. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: ArrayLike, +- mapfn: (v: T, k: number) => U, +- thisArg?: any ++ from( ++ source: ArrayLike, ++ mapfn: (this: This, v: T, k: number) => U, ++ thisArg?: This + ): U[]; + + /** + * Returns a new array from a set of elements. +@@ -209,36 +219,35 @@ * that is representable as a Number value, which is approximately: * 2.2204460492503130808472633361816 x 10‍−‍16. */ @@ -54,13 +126,7 @@ Index: es2015.core.d.ts /** * The value of the largest integer n such that n and n + 1 are both exactly representable as * a Number value. -@@ -267,51 +265,21 @@ - * All other strings are considered decimal. - */ - parseInt(string: string, radix?: number): number; - } -- - interface ObjectConstructor { +@@ -273,45 +282,26 @@ /** * Copy the values of all of the enumerable own properties from one or more source objects to a * target object. Returns the target object. @@ -95,7 +161,17 @@ Index: es2015.core.d.ts - source3: W - ): T & U & V & W; + ...sources: Ts -+ ): First>; ++ ): CheckNonNullable< ++ T, ++ First< ++ UnionToIntersection< ++ | [T] ++ | { ++ [K in keyof Ts]: [Ts[K]]; ++ }[number] ++ > ++ > ++ >; /** - * Copy the values of all of the enumerable own properties from one or more source objects to a @@ -110,7 +186,7 @@ Index: es2015.core.d.ts * @param o Object to retrieve the symbols from. */ getOwnPropertySymbols(o: any): symbol[]; -@@ -326,16 +294,23 @@ +@@ -326,16 +316,23 @@ * Returns true if the values are the same value, false otherwise. * @param value1 The first value. * @param value2 The second value. @@ -136,17 +212,59 @@ Index: es2015.core.d.ts interface ReadonlyArray { /** -@@ -407,9 +382,8 @@ - interface RegExpConstructor { - new (pattern: RegExp | string, flags?: string): RegExp; - (pattern: RegExp | string, flags?: string): RegExp; - } -- - interface String { +@@ -346,20 +343,25 @@ + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- find( +- predicate: ( +- this: void, +- value: T, +- index: number, +- obj: readonly T[] +- ) => value is S, +- thisArg?: any ++ find( ++ predicate: (this: This, value: T, index: number, obj: this) => value is S, ++ thisArg?: This + ): S | undefined; +- find( +- predicate: (value: T, index: number, obj: readonly T[]) => unknown, +- thisArg?: any ++ ++ /** ++ * Returns the value of the first element in the array where predicate is true, and undefined ++ * otherwise. ++ * @param predicate find calls predicate once for each element of the array, in ascending ++ * order, until it finds one where predicate returns true. If such an element is found, find ++ * immediately returns that element value. Otherwise, find returns undefined. ++ * @param thisArg If provided, it will be used as the this value for each invocation of ++ * predicate. If it is not provided, undefined is used instead. ++ */ ++ find( ++ predicate: (this: This, value: T, index: number, obj: this) => boolean, ++ thisArg?: This + ): T | undefined; + /** - * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point - * value of the UTF-16 encoded code point starting at the string element at position pos in -@@ -433,26 +407,17 @@ + * Returns the index of the first element in the array where predicate is true, and -1 +@@ -369,11 +371,11 @@ + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- findIndex( +- predicate: (value: T, index: number, obj: readonly T[]) => unknown, +- thisArg?: any ++ findIndex( ++ predicate: (this: This, value: T, index: number, obj: this) => boolean, ++ thisArg?: This + ): number; + } + + interface RegExp { +@@ -433,26 +435,17 @@ * same as the corresponding elements of this object (converted to a String) starting at * endPosition – length(this). Otherwise returns false. */ diff --git a/docs/diff/es2015.iterable.d.ts.md b/docs/diff/es2015.iterable.d.ts.md index 1663e56..6fdf4fa 100644 --- a/docs/diff/es2015.iterable.d.ts.md +++ b/docs/diff/es2015.iterable.d.ts.md @@ -28,12 +28,42 @@ Index: es2015.iterable.d.ts } interface Array { -@@ -95,12 +94,11 @@ - * Returns an iterable of values in the array +@@ -58,23 +57,23 @@ + } + + interface ArrayConstructor { + /** +- * Creates an array from an iterable object. +- * @param iterable An iterable object to convert to an array. ++ * Creates an array from an array-like or iterable object. ++ * @param source An array-like or iterable object to convert to an array. + */ +- from(iterable: Iterable | ArrayLike): T[]; ++ from(source: Iterable | ArrayLike): T[]; + + /** +- * Creates an array from an iterable object. +- * @param iterable An iterable object to convert to an array. ++ * Creates an array from an array-like or iterable object. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. */ - values(): IterableIterator; +- from( +- iterable: Iterable | ArrayLike, +- mapfn: (v: T, k: number) => U, +- thisArg?: any ++ from( ++ source: Iterable | ArrayLike, ++ mapfn: (this: This, v: T, k: number) => U, ++ thisArg?: This + ): U[]; } -- + + interface ReadonlyArray { +@@ -98,9 +97,9 @@ + } + interface IArguments { /** Iterator */ - [Symbol.iterator](): IterableIterator; @@ -42,27 +72,17 @@ Index: es2015.iterable.d.ts interface Map { /** Returns an iterable of entries in the map. */ -@@ -140,11 +138,9 @@ - * Returns an iterable of values in the map - */ +@@ -142,9 +141,8 @@ values(): IterableIterator; } -- + interface MapConstructor { - new (): Map; new (iterable?: Iterable | null): Map; } interface WeakMap {} -@@ -201,25 +197,24 @@ - new (iterable: Iterable): WeakSet; - } - - interface Promise {} -- - interface PromiseConstructor { - /** - * Creates a Promise that is resolved with an array of results when all of the provided Promises +@@ -209,17 +207,17 @@ * resolve, or rejected when any Promise is rejected. * @param values An iterable of Promises. * @returns A new Promise. @@ -82,5 +102,273 @@ Index: es2015.iterable.d.ts interface String { /** Iterator */ +@@ -243,19 +241,23 @@ + } + + interface Int8ArrayConstructor { + new (elements: Iterable): Int8Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. ++ */ ++ from(source: Iterable | ArrayLike): Int8Array; ++ /** ++ * Creates an array from an array-like or iterable object. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: Iterable, +- mapfn?: (v: number, k: number) => number, +- thisArg?: any ++ from( ++ source: Iterable | ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Int8Array; + } + + interface Uint8Array { +@@ -275,19 +277,23 @@ + } + + interface Uint8ArrayConstructor { + new (elements: Iterable): Uint8Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. ++ */ ++ from(source: Iterable | ArrayLike): Uint8Array; ++ /** ++ * Creates an array from an array-like or iterable object. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: Iterable, +- mapfn?: (v: number, k: number) => number, +- thisArg?: any ++ from( ++ source: Iterable | ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Uint8Array; + } + + interface Uint8ClampedArray { +@@ -309,19 +315,23 @@ + } + + interface Uint8ClampedArrayConstructor { + new (elements: Iterable): Uint8ClampedArray; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. ++ */ ++ from(source: Iterable | ArrayLike): Uint8ClampedArray; ++ /** ++ * Creates an array from an array-like or iterable object. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: Iterable, +- mapfn?: (v: number, k: number) => number, +- thisArg?: any ++ from( ++ source: Iterable | ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Uint8ClampedArray; + } + + interface Int16Array { +@@ -343,19 +353,23 @@ + } + + interface Int16ArrayConstructor { + new (elements: Iterable): Int16Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. ++ */ ++ from(source: Iterable | ArrayLike): Int16Array; ++ /** ++ * Creates an array from an array-like or iterable object. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: Iterable, +- mapfn?: (v: number, k: number) => number, +- thisArg?: any ++ from( ++ source: Iterable | ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Int16Array; + } + + interface Uint16Array { +@@ -375,19 +389,23 @@ + } + + interface Uint16ArrayConstructor { + new (elements: Iterable): Uint16Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. ++ */ ++ from(source: Iterable | ArrayLike): Uint16Array; ++ /** ++ * Creates an array from an array-like or iterable object. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: Iterable, +- mapfn?: (v: number, k: number) => number, +- thisArg?: any ++ from( ++ source: Iterable | ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Uint16Array; + } + + interface Int32Array { +@@ -407,19 +425,23 @@ + } + + interface Int32ArrayConstructor { + new (elements: Iterable): Int32Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. ++ */ ++ from(source: Iterable | ArrayLike): Int32Array; ++ /** ++ * Creates an array from an array-like or iterable object. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: Iterable, +- mapfn?: (v: number, k: number) => number, +- thisArg?: any ++ from( ++ source: Iterable | ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Int32Array; + } + + interface Uint32Array { +@@ -439,19 +461,23 @@ + } + + interface Uint32ArrayConstructor { + new (elements: Iterable): Uint32Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. ++ */ ++ from(source: Iterable | ArrayLike): Uint32Array; ++ /** ++ * Creates an array from an array-like or iterable object. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: Iterable, +- mapfn?: (v: number, k: number) => number, +- thisArg?: any ++ from( ++ source: Iterable | ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Uint32Array; + } + + interface Float32Array { +@@ -471,19 +497,23 @@ + } + + interface Float32ArrayConstructor { + new (elements: Iterable): Float32Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. ++ */ ++ from(source: Iterable | ArrayLike): Float32Array; ++ /** ++ * Creates an array from an array-like or iterable object. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: Iterable, +- mapfn?: (v: number, k: number) => number, +- thisArg?: any ++ from( ++ source: Iterable | ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Float32Array; + } + + interface Float64Array { +@@ -503,17 +533,21 @@ + } + + interface Float64ArrayConstructor { + new (elements: Iterable): Float64Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. ++ */ ++ from(source: Iterable | ArrayLike): Float64Array; ++ /** ++ * Creates an array from an array-like or iterable object. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: Iterable, +- mapfn?: (v: number, k: number) => number, +- thisArg?: any ++ from( ++ source: Iterable | ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Float64Array; + } ``` diff --git a/docs/diff/es2015.symbol.wellknown.d.ts.md b/docs/diff/es2015.symbol.wellknown.d.ts.md index 828033f..3e16efd 100644 --- a/docs/diff/es2015.symbol.wellknown.d.ts.md +++ b/docs/diff/es2015.symbol.wellknown.d.ts.md @@ -5,13 +5,7 @@ Index: es2015.symbol.wellknown.d.ts =================================================================== --- es2015.symbol.wellknown.d.ts +++ es2015.symbol.wellknown.d.ts -@@ -69,23 +69,14 @@ - [Symbol.toPrimitive](hint: string): symbol; - - readonly [Symbol.toStringTag]: string; - } -- - interface Array { +@@ -75,16 +75,10 @@ /** * Returns an object whose properties have the value 'true' * when they will be absent when used in a 'with' statement. @@ -24,21 +18,13 @@ Index: es2015.symbol.wellknown.d.ts - findIndex: boolean; - keys: boolean; - values: boolean; -- }; -+ readonly [Symbol.unscopables]: { [key: PropertyKey]: boolean }; ++ readonly [Symbol.unscopables]: { ++ [key: PropertyKey]: boolean; + }; } interface Date { - /** -@@ -156,17 +147,15 @@ - - interface PromiseConstructor { - readonly [Symbol.species]: PromiseConstructor; - } -- - interface RegExp { - /** - * Matches a string with this regular expression, and returns an array containing the results of +@@ -164,9 +158,8 @@ * that search. * @param string A string to search within. */ @@ -48,7 +34,7 @@ Index: es2015.symbol.wellknown.d.ts * Replaces text in a string, using this regular expression. * @param string A String object or string literal whose contents matching against * this regular expression will be replaced -@@ -182,9 +171,14 @@ +@@ -182,9 +175,14 @@ * @param replacer A function that returns the replacement text. */ [Symbol.replace]( @@ -64,17 +50,7 @@ Index: es2015.symbol.wellknown.d.ts /** * Finds the position beginning first substring match in a regular expression search -@@ -211,9 +205,8 @@ - - interface RegExpConstructor { - readonly [Symbol.species]: RegExpConstructor; - } -- - interface String { - /** - * Matches a string or an object that supports being matched against, and returns an array - * containing the results of that search, or null if no matches are found. -@@ -221,12 +214,11 @@ +@@ -221,12 +219,11 @@ */ match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; @@ -88,7 +64,7 @@ Index: es2015.symbol.wellknown.d.ts */ replace( searchValue: { -@@ -243,12 +235,12 @@ +@@ -243,12 +240,12 @@ replace( searchValue: { [Symbol.replace]( diff --git a/docs/diff/es2017.object.d.ts.md b/docs/diff/es2017.object.d.ts.md index ecfce9d..2101f1f 100644 --- a/docs/diff/es2017.object.d.ts.md +++ b/docs/diff/es2017.object.d.ts.md @@ -5,7 +5,7 @@ Index: es2017.object.d.ts =================================================================== --- es2017.object.d.ts +++ es2017.object.d.ts -@@ -2,27 +2,35 @@ +@@ -2,34 +2,45 @@ /** * Returns an array of values of the enumerable properties of an object * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. @@ -23,7 +23,7 @@ Index: es2017.object.d.ts + * Returns an array of values of the enumerable properties of an object + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ -+ values(o: unknown): unknown[]; ++ values(o: T): CheckNonNullable; /** * Returns an array of key/values of the enumerable properties of an object @@ -42,10 +42,25 @@ Index: es2017.object.d.ts + * Returns an array of key/values of the enumerable properties of an object + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ -+ entries(o: T): [string, unknown][]; ++ entries(o: T): CheckNonNullable; /** * Returns an object containing all own property descriptors of an object * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ +- getOwnPropertyDescriptors( +- o: T +- ): { [P in keyof T]: TypedPropertyDescriptor } & { +- [x: string]: PropertyDescriptor; +- }; ++ getOwnPropertyDescriptors(o: T): CheckNonNullable< ++ T, ++ { ++ [P in keyof T]: TypedPropertyDescriptor; ++ } & { ++ [x: string]: PropertyDescriptor; ++ } ++ >; + } ``` diff --git a/docs/diff/es2019.object.d.ts.md b/docs/diff/es2019.object.d.ts.md index 0644860..a5e628a 100644 --- a/docs/diff/es2019.object.d.ts.md +++ b/docs/diff/es2019.object.d.ts.md @@ -5,10 +5,7 @@ Index: es2019.object.d.ts =================================================================== --- es2019.object.d.ts +++ es2019.object.d.ts -@@ -1,17 +1,9 @@ --/// -- - interface ObjectConstructor { +@@ -4,14 +4,8 @@ /** * Returns an object created by key-value entries for properties and methods * @param entries An iterable object that contains key-value entries for properties and methods. diff --git a/docs/diff/es2020.bigint.d.ts.md b/docs/diff/es2020.bigint.d.ts.md new file mode 100644 index 0000000..abb1384 --- /dev/null +++ b/docs/diff/es2020.bigint.d.ts.md @@ -0,0 +1,593 @@ +# es2020.bigint.d.ts Diffs + +```diff +Index: es2020.bigint.d.ts +=================================================================== +--- es2020.bigint.d.ts ++++ es2020.bigint.d.ts +@@ -259,20 +259,24 @@ + copyWithin(target: number, start: number, end?: number): this; + + /** Yields index, value pairs for every entry in the array. */ + entries(): IterableIterator<[number, bigint]>; +- + /** + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- every( +- predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, +- thisArg?: any ++ every( ++ predicate: ( ++ this: This, ++ value: bigint, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array +@@ -282,21 +286,24 @@ + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: bigint, start?: number, end?: number): this; +- + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- filter( +- predicate: (value: bigint, index: number, array: BigInt64Array) => any, +- thisArg?: any ++ filter( ++ predicate: ( ++ this: This, ++ value: bigint, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): BigInt64Array; +- + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -304,13 +311,17 @@ + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- find( +- predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, +- thisArg?: any ++ find( ++ predicate: ( ++ this: This, ++ value: bigint, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): bigint | undefined; +- + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -318,23 +329,27 @@ + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- findIndex( +- predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, +- thisArg?: any ++ findIndex( ++ predicate: ( ++ this: This, ++ value: bigint, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): number; +- + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- forEach( +- callbackfn: (value: bigint, index: number, array: BigInt64Array) => void, +- thisArg?: any ++ forEach( ++ callbackfn: (this: This, value: bigint, index: number, array: this) => void, ++ thisArg?: This + ): void; + + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. +@@ -370,41 +385,40 @@ + lastIndexOf(searchElement: bigint, fromIndex?: number): number; + + /** The length of the array. */ + readonly length: number; +- + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- map( +- callbackfn: (value: bigint, index: number, array: BigInt64Array) => bigint, +- thisArg?: any ++ map( ++ callbackfn: ( ++ this: This, ++ value: bigint, ++ index: number, ++ array: this ++ ) => bigint, ++ thisArg?: This + ): BigInt64Array; +- + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an argument +- * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( +- previousValue: bigint, ++ previousValue: bigint | U, + currentValue: bigint, + currentIndex: number, +- array: BigInt64Array +- ) => bigint +- ): bigint; +- ++ array: this ++ ) => U ++ ): bigint | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. +@@ -413,37 +427,32 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( + previousValue: U, + currentValue: bigint, + currentIndex: number, +- array: BigInt64Array ++ array: this + ) => U, + initialValue: U + ): U; +- + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an +- * argument instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( +- previousValue: bigint, ++ previousValue: bigint | U, + currentValue: bigint, + currentIndex: number, +- array: BigInt64Array +- ) => bigint +- ): bigint; +- ++ array: this ++ ) => U ++ ): bigint | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. +@@ -452,14 +461,14 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( + previousValue: U, + currentValue: bigint, + currentIndex: number, +- array: BigInt64Array ++ array: this + ) => U, + initialValue: U + ): U; + +@@ -478,20 +487,24 @@ + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): BigInt64Array; +- + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls the + * predicate function for each element in the array until the predicate returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- some( +- predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, +- thisArg?: any ++ some( ++ predicate: ( ++ this: This, ++ value: bigint, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Sorts the array. +@@ -543,20 +556,23 @@ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: bigint[]): BigInt64Array; +- + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. ++ */ ++ from(arrayLike: Iterable | ArrayLike): BigInt64Array; ++ /** ++ * Creates an array from an array-like or iterable object. ++ * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from(arrayLike: ArrayLike): BigInt64Array; +- from( +- arrayLike: ArrayLike, +- mapfn: (v: U, k: number) => bigint, +- thisArg?: any ++ from( ++ arrayLike: Iterable | ArrayLike, ++ mapfn: (this: This, v: T, k: number) => bigint, ++ thisArg?: This + ): BigInt64Array; + } + + declare var BigInt64Array: BigInt64ArrayConstructor; +@@ -590,20 +606,24 @@ + copyWithin(target: number, start: number, end?: number): this; + + /** Yields index, value pairs for every entry in the array. */ + entries(): IterableIterator<[number, bigint]>; +- + /** + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- every( +- predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, +- thisArg?: any ++ every( ++ predicate: ( ++ this: This, ++ value: bigint, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array +@@ -613,21 +633,24 @@ + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: bigint, start?: number, end?: number): this; +- + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- filter( +- predicate: (value: bigint, index: number, array: BigUint64Array) => any, +- thisArg?: any ++ filter( ++ predicate: ( ++ this: This, ++ value: bigint, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): BigUint64Array; +- + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -635,13 +658,17 @@ + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- find( +- predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, +- thisArg?: any ++ find( ++ predicate: ( ++ this: This, ++ value: bigint, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): bigint | undefined; +- + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -649,23 +676,27 @@ + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- findIndex( +- predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, +- thisArg?: any ++ findIndex( ++ predicate: ( ++ this: This, ++ value: bigint, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): number; +- + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- forEach( +- callbackfn: (value: bigint, index: number, array: BigUint64Array) => void, +- thisArg?: any ++ forEach( ++ callbackfn: (this: This, value: bigint, index: number, array: this) => void, ++ thisArg?: This + ): void; + + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. +@@ -701,41 +732,40 @@ + lastIndexOf(searchElement: bigint, fromIndex?: number): number; + + /** The length of the array. */ + readonly length: number; +- + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- map( +- callbackfn: (value: bigint, index: number, array: BigUint64Array) => bigint, +- thisArg?: any ++ map( ++ callbackfn: ( ++ this: This, ++ value: bigint, ++ index: number, ++ array: this ++ ) => bigint, ++ thisArg?: This + ): BigUint64Array; +- + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an argument +- * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( +- previousValue: bigint, ++ previousValue: bigint | U, + currentValue: bigint, + currentIndex: number, +- array: BigUint64Array +- ) => bigint +- ): bigint; +- ++ array: this ++ ) => U ++ ): bigint | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. +@@ -744,37 +774,32 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( + previousValue: U, + currentValue: bigint, + currentIndex: number, +- array: BigUint64Array ++ array: this + ) => U, + initialValue: U + ): U; +- + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an +- * argument instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( +- previousValue: bigint, ++ previousValue: bigint | U, + currentValue: bigint, + currentIndex: number, +- array: BigUint64Array +- ) => bigint +- ): bigint; +- ++ array: this ++ ) => U ++ ): bigint | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. +@@ -783,14 +808,14 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( + previousValue: U, + currentValue: bigint, + currentIndex: number, +- array: BigUint64Array ++ array: this + ) => U, + initialValue: U + ): U; + +@@ -809,20 +834,24 @@ + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): BigUint64Array; +- + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls the + * predicate function for each element in the array until the predicate returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- some( +- predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, +- thisArg?: any ++ some( ++ predicate: ( ++ this: This, ++ value: bigint, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Sorts the array. +@@ -874,20 +903,23 @@ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: bigint[]): BigUint64Array; +- + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. ++ */ ++ from(arrayLike: Iterable | ArrayLike): BigUint64Array; ++ /** ++ * Creates an array from an array-like or iterable object. ++ * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from(arrayLike: ArrayLike): BigUint64Array; +- from( +- arrayLike: ArrayLike, +- mapfn: (v: U, k: number) => bigint, +- thisArg?: any ++ from( ++ arrayLike: Iterable | ArrayLike, ++ mapfn: (this: This, v: T, k: number) => bigint, ++ thisArg?: This + ): BigUint64Array; + } + + declare var BigUint64Array: BigUint64ArrayConstructor; + +``` diff --git a/docs/diff/es2022.object.d.ts.md b/docs/diff/es2022.object.d.ts.md index 7ce05f0..8e3470b 100644 --- a/docs/diff/es2022.object.d.ts.md +++ b/docs/diff/es2022.object.d.ts.md @@ -5,7 +5,7 @@ Index: es2022.object.d.ts =================================================================== --- es2022.object.d.ts +++ es2022.object.d.ts -@@ -3,6 +3,17 @@ +@@ -3,6 +3,19 @@ * Determines whether an object has a property with the specified name. * @param o An object. * @param v A property name. @@ -21,7 +21,9 @@ Index: es2022.object.d.ts + : symbol extends Key + ? {} + : Key extends PropertyKey -+ ? { [key in Key]: unknown } ++ ? { ++ [key in Key]: unknown; ++ } + : {}; } diff --git a/docs/diff/es5.d.ts.md b/docs/diff/es5.d.ts.md index 90635eb..c4643a1 100644 --- a/docs/diff/es5.d.ts.md +++ b/docs/diff/es5.d.ts.md @@ -16,17 +16,7 @@ Index: es5.d.ts /** * Converts a string to an integer. * @param string A string to convert into a number. -@@ -99,9 +99,8 @@ - - interface PropertyDescriptorMap { - [key: PropertyKey]: PropertyDescriptor; - } -- - interface Object { - /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ - constructor: Function; - -@@ -112,14 +111,23 @@ +@@ -112,14 +112,25 @@ toLocaleString(): string; /** Returns the primitive value of the specified object. */ @@ -46,18 +36,17 @@ Index: es5.d.ts + : symbol extends Key + ? {} + : Key extends PropertyKey -+ ? { [key in Key]: unknown } ++ ? { ++ [key in Key]: unknown; ++ } + : {}; /** * Determines whether an object exists in another object's prototype chain. * @param v Another object whose prototype chain is to be checked. -@@ -131,22 +139,21 @@ - * @param v A property name. - */ - propertyIsEnumerable(v: PropertyKey): boolean; +@@ -134,75 +145,145 @@ } -- + interface ObjectConstructor { new (value?: any): Object; - (): any; @@ -73,18 +62,29 @@ Index: es5.d.ts * @param o The object that references the prototype. */ - getPrototypeOf(o: any): any; -+ getPrototypeOf(o: any): unknown; ++ getPrototypeOf(o: T): CheckNonNullable; /** * Gets the own property descriptor of the specified object. * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. -@@ -162,47 +169,101 @@ + * @param o Object that contains the property. + * @param p Name of the property. + */ +- getOwnPropertyDescriptor( +- o: any, ++ getOwnPropertyDescriptor( ++ o: T, + p: PropertyKey +- ): PropertyDescriptor | undefined; ++ ): CheckNonNullable; + + /** * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. * @param o Object that contains the own properties. */ - getOwnPropertyNames(o: any): string[]; -+ getOwnPropertyNames(o: O): O extends undefined | null ? never : string[]; ++ getOwnPropertyNames(o: T): CheckNonNullable; /** * Creates an object that has the specified prototype or that has null prototype. @@ -112,9 +112,13 @@ Index: es5.d.ts + o: O, + properties: P & ThisType + ): { -+ [K in keyof (O & P)]: P[K] extends { value: infer V } ++ [K in keyof (O & P)]: P[K] extends { ++ value: infer V; ++ } + ? V -+ : P[K] extends { get: () => infer V } ++ : P[K] extends { ++ get: () => infer V; ++ } + ? V + : K extends keyof O + ? O[K] @@ -130,9 +134,13 @@ Index: es5.d.ts + o: null, + properties: P & ThisType + ): { -+ [K in keyof P]: P[K] extends { value: infer V } ++ [K in keyof P]: P[K] extends { ++ value: infer V; ++ } + ? V -+ : P[K] extends { get: () => infer V } ++ : P[K] extends { ++ get: () => infer V; ++ } + ? V + : unknown; + }; @@ -159,9 +167,13 @@ Index: es5.d.ts + ): O & + (P extends PropertyKey // required to make P distributive + ? { -+ [K in P]: D extends { value: infer V } ++ [K in P]: D extends { ++ value: infer V; ++ } + ? V -+ : D extends { get: () => infer V } ++ : D extends { ++ get: () => infer V; ++ } + ? V + : unknown; + } @@ -183,9 +195,13 @@ Index: es5.d.ts + o: O, + properties: P & ThisType + ): { -+ [K in keyof (O & P)]: P[K] extends { value: infer V } ++ [K in keyof (O & P)]: P[K] extends { ++ value: infer V; ++ } + ? V -+ : P[K] extends { get: () => infer V } ++ : P[K] extends { ++ get: () => infer V; ++ } + ? V + : K extends keyof O + ? O[K] @@ -195,17 +211,7 @@ Index: es5.d.ts /** * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. * @param o Object on which to lock the attributes. -@@ -326,9 +387,8 @@ - ? T - : T extends (...args: infer A) => infer R - ? (...args: A) => R - : T; -- - interface CallableFunction extends Function { - /** - * Calls the function with the specified object as the this value and the elements of specified array as the arguments. - * @param thisArg The object to be used as the this object. -@@ -350,56 +410,32 @@ +@@ -350,47 +431,19 @@ this: (this: T, ...args: A) => R, thisArg: T, ...args: A @@ -254,25 +260,17 @@ Index: es5.d.ts + ...args: A + ): (...args: B) => R; } -- + interface NewableFunction extends Function { /** - * Calls the function with the specified object as the this value and the elements of specified array as the arguments. - * @param thisArg The object to be used as the this object. -+ */ -+ apply(this: new () => T, thisArg: T): void; -+ -+ /** -+ * Calls the function with the specified object as the this value and the elements of specified array as the arguments. -+ * @param thisArg The object to be used as the this object. - * @param args An array of argument values to be passed to the function. - */ -- apply(this: new () => T, thisArg: T): void; - apply( +@@ -414,51 +467,23 @@ this: new (...args: A) => T, thisArg: T, - args: A -@@ -421,48 +457,19 @@ + ...args: A + ): void; +- + /** + * For a given function, creates a bound function that has the same body as the original function. * The this object of the bound function is associated with the specified object, and has the specified initial parameters. * @param thisArg The object to be used as the this object. * @param args Arguments to bind to the parameters of the function. @@ -314,19 +312,15 @@ Index: es5.d.ts + ...args: A + ): new (...args: B) => R; } -- + interface IArguments { - [index: number]: any; + [index: number]: unknown; length: number; callee: Function; } -- - interface String { - /** Returns a string representation of a string. */ - toString(): string; -@@ -508,24 +515,28 @@ +@@ -508,24 +533,28 @@ * Matches a string with a regular expression, and returns an array containing the results of that search. * @param regexp A variable name or string literal containing the regular expression pattern and flags. */ @@ -359,17 +353,7 @@ Index: es5.d.ts /** * Finds the first substring match in a regular expression search. -@@ -1177,9 +1188,8 @@ - readonly prototype: URIError; - } - - declare var URIError: URIErrorConstructor; -- - interface JSON { - /** - * Converts a JavaScript Object Notation (JSON) string into an object. - * @param text A valid JSON string. -@@ -1187,43 +1197,80 @@ +@@ -1187,32 +1216,74 @@ * If a member contains nested objects, the nested objects are transformed before the parent object is. */ parse( @@ -453,18 +437,7 @@ Index: es5.d.ts /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. - */ - declare var JSON: JSON; -- --///////////////////////////// --/// ECMAScript Array API (specially handled by compiler) --///////////////////////////// -- - interface ReadonlyArray { - /** - * Gets the length of the array. This is a number one higher than the highest element defined in an array. - */ -@@ -1276,11 +1323,16 @@ +@@ -1276,23 +1347,25 @@ * which is coercible to the Boolean value false, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. @@ -472,19 +445,17 @@ Index: es5.d.ts - every( - predicate: (value: T, index: number, array: readonly T[]) => value is S, - thisArg?: any +- ): this is readonly S[]; + every( -+ predicate: ( -+ this: This, -+ value: T, -+ index: number, -+ array: readonly T[] -+ ) => value is S, ++ predicate: (this: This, value: T, index: number, array: this) => value is S, + thisArg?: This - ): this is readonly S[]; ++ ): this is { ++ [K in keyof this]: S; ++ }; /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls -@@ -1288,11 +1340,16 @@ + * the predicate function for each element in the array until the predicate returns a value * which is coercible to the Boolean value false, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. @@ -493,18 +464,13 @@ Index: es5.d.ts - predicate: (value: T, index: number, array: readonly T[]) => unknown, - thisArg?: any + every( -+ predicate: ( -+ this: This, -+ value: T, -+ index: number, -+ array: readonly T[] -+ ) => boolean, ++ predicate: (this: This, value: T, index: number, array: this) => boolean, + thisArg?: This ): boolean; /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls -@@ -1300,47 +1357,67 @@ +@@ -1300,117 +1373,99 @@ * which is coercible to the Boolean value true, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. @@ -513,12 +479,7 @@ Index: es5.d.ts - predicate: (value: T, index: number, array: readonly T[]) => unknown, - thisArg?: any + some( -+ predicate: ( -+ this: This, -+ value: T, -+ index: number, -+ array: readonly T[] -+ ) => boolean, ++ predicate: (this: This, value: T, index: number, array: this) => boolean, + thisArg?: This ): boolean; /** @@ -530,12 +491,7 @@ Index: es5.d.ts - callbackfn: (value: T, index: number, array: readonly T[]) => void, - thisArg?: any + forEach( -+ callbackfn: ( -+ this: This, -+ value: T, -+ index: number, -+ array: readonly T[] -+ ) => void, ++ callbackfn: (this: This, value: T, index: number, array: this) => void, + thisArg?: This ): void; /** @@ -546,10 +502,13 @@ Index: es5.d.ts - map( - callbackfn: (value: T, index: number, array: readonly T[]) => U, - thisArg?: any +- ): U[]; + map( -+ callbackfn: (this: This, value: T, index: number, array: readonly T[]) => U, ++ callbackfn: (this: This, value: T, index: number, array: this) => U, + thisArg?: This - ): U[]; ++ ): { ++ -readonly [K in keyof this]: U; ++ }; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. @@ -559,12 +518,7 @@ Index: es5.d.ts - predicate: (value: T, index: number, array: readonly T[]) => value is S, - thisArg?: any + filter( -+ predicate: ( -+ this: This, -+ value: T, -+ index: number, -+ array: readonly T[] -+ ) => value is S, ++ predicate: (this: This, value: T, index: number, array: this) => value is S, + thisArg?: This ): S[]; /** @@ -576,48 +530,97 @@ Index: es5.d.ts - predicate: (value: T, index: number, array: readonly T[]) => unknown, - thisArg?: any + filter( -+ predicate: ( -+ this: This, -+ value: T, -+ index: number, -+ array: readonly T[] -+ ) => boolean, ++ predicate: (this: This, value: T, index: number, array: this) => boolean, + thisArg?: This ): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. -@@ -1422,9 +1499,8 @@ - readonly [n: number]: T; - join(separator?: string): string; - slice(start?: number, end?: number): T[]; - } -- - interface Array { - /** - * Gets or sets the length of the array. This is a number one higher than the highest index in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ -@@ -1500,17 +1576,17 @@ - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @returns An array containing the elements that were deleted. +- reduce( ++ reduce( + callbackfn: ( +- previousValue: T, ++ previousValue: T | U, + currentValue: T, + currentIndex: number, +- array: readonly T[] +- ) => T +- ): T; +- reduce( +- callbackfn: ( +- previousValue: T, +- currentValue: T, +- currentIndex: number, +- array: readonly T[] +- ) => T, +- initialValue: T +- ): T; ++ array: this ++ ) => U ++ ): T | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ -- splice(start: number, deleteCount?: number): T[]; -+ splice(start: number, deleteCount?: number): this; +- reduce( ++ reduce( + callbackfn: ( + previousValue: U, + currentValue: T, + currentIndex: number, +- array: readonly T[] ++ array: this + ) => U, + initialValue: U + ): U; /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. - * @returns An array containing the elements that were deleted. + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ -- splice(start: number, deleteCount: number, ...items: T[]): T[]; -+ splice(start: number, deleteCount: number, ...items: T[]): this; +- reduceRight( ++ reduceRight( + callbackfn: ( +- previousValue: T, ++ previousValue: T | U, + currentValue: T, + currentIndex: number, +- array: readonly T[] +- ) => T +- ): T; +- reduceRight( +- callbackfn: ( +- previousValue: T, +- currentValue: T, +- currentIndex: number, +- array: readonly T[] +- ) => T, +- initialValue: T +- ): T; ++ array: this ++ ) => U ++ ): T | U; /** - * Inserts new elements at the start of an array, and returns the new length of the array. - * @param items Elements to insert at the start of the array. + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ -@@ -1534,11 +1610,11 @@ +- reduceRight( ++ reduceRight( + callbackfn: ( + previousValue: U, + currentValue: T, + currentIndex: number, +- array: readonly T[] ++ array: this + ) => U, + initialValue: U + ): U; + +@@ -1534,23 +1589,25 @@ * which is coercible to the Boolean value false, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. @@ -625,14 +628,17 @@ Index: es5.d.ts - every( - predicate: (value: T, index: number, array: T[]) => value is S, - thisArg?: any +- ): this is S[]; + every( -+ predicate: (this: This, value: T, index: number, array: T[]) => value is S, ++ predicate: (this: This, value: T, index: number, array: this) => value is S, + thisArg?: This - ): this is S[]; ++ ): this is { ++ [K in keyof this]: S; ++ }; /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls -@@ -1546,11 +1622,11 @@ + * the predicate function for each element in the array until the predicate returns a value * which is coercible to the Boolean value false, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. @@ -641,13 +647,13 @@ Index: es5.d.ts - predicate: (value: T, index: number, array: T[]) => unknown, - thisArg?: any + every( -+ predicate: (this: This, value: T, index: number, array: T[]) => boolean, ++ predicate: (this: This, value: T, index: number, array: this) => boolean, + thisArg?: This ): boolean; /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls -@@ -1558,47 +1634,47 @@ +@@ -1558,133 +1615,113 @@ * which is coercible to the Boolean value true, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. @@ -656,7 +662,7 @@ Index: es5.d.ts - predicate: (value: T, index: number, array: T[]) => unknown, - thisArg?: any + some( -+ predicate: (this: This, value: T, index: number, array: T[]) => boolean, ++ predicate: (this: This, value: T, index: number, array: this) => boolean, + thisArg?: This ): boolean; /** @@ -668,7 +674,7 @@ Index: es5.d.ts - callbackfn: (value: T, index: number, array: T[]) => void, - thisArg?: any + forEach( -+ callbackfn: (this: This, value: T, index: number, array: T[]) => void, ++ callbackfn: (this: This, value: T, index: number, array: this) => void, + thisArg?: This ): void; /** @@ -679,10 +685,13 @@ Index: es5.d.ts - map( - callbackfn: (value: T, index: number, array: T[]) => U, - thisArg?: any +- ): U[]; + map( -+ callbackfn: (this: This, value: T, index: number, array: T[]) => U, ++ callbackfn: (this: This, value: T, index: number, array: this) => U, + thisArg?: This - ): U[]; ++ ): { ++ [K in keyof this]: U; ++ }; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. @@ -692,7 +701,7 @@ Index: es5.d.ts - predicate: (value: T, index: number, array: T[]) => value is S, - thisArg?: any + filter( -+ predicate: (this: This, value: T, index: number, array: T[]) => value is S, ++ predicate: (this: This, value: T, index: number, array: this) => value is S, + thisArg?: This ): S[]; /** @@ -704,18 +713,99 @@ Index: es5.d.ts - predicate: (value: T, index: number, array: T[]) => unknown, - thisArg?: any + filter( -+ predicate: (this: This, value: T, index: number, array: T[]) => boolean, ++ predicate: (this: This, value: T, index: number, array: this) => boolean, + thisArg?: This ): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. -@@ -1673,18 +1749,15 @@ +- * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( +- previousValue: T, ++ previousValue: T | U, + currentValue: T, + currentIndex: number, +- array: T[] +- ) => T +- ): T; +- reduce( +- callbackfn: ( +- previousValue: T, +- currentValue: T, +- currentIndex: number, +- array: T[] +- ) => T, +- initialValue: T +- ): T; ++ array: this ++ ) => U ++ ): T | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( + previousValue: U, + currentValue: T, + currentIndex: number, +- array: T[] ++ array: this + ) => U, + initialValue: U + ): U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( +- previousValue: T, ++ previousValue: T | U, + currentValue: T, + currentIndex: number, +- array: T[] +- ) => T +- ): T; +- reduceRight( +- callbackfn: ( +- previousValue: T, +- currentValue: T, +- currentIndex: number, +- array: T[] +- ) => T, +- initialValue: T +- ): T; ++ array: this ++ ) => U ++ ): T | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( + previousValue: U, + currentValue: T, + currentIndex: number, +- array: T[] ++ array: this + ) => U, + initialValue: U ): U; [n: number]: T; } -- + interface ArrayConstructor { - new (arrayLength?: number): any[]; new (arrayLength: number): T[]; @@ -731,7 +821,7 @@ Index: es5.d.ts declare var Array: ArrayConstructor; -@@ -1716,9 +1789,15 @@ +@@ -1716,9 +1753,15 @@ ) => void; declare type PromiseConstructorLike = new ( @@ -748,29 +838,2762 @@ Index: es5.d.ts ) => void ) => PromiseLike; -@@ -5434,9 +5513,8 @@ - options?: DateTimeFormatOptions - ): string[]; - }; - } +@@ -2123,20 +2166,24 @@ + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; - - interface String { /** - * Determines whether two strings are equivalent in the current or specified locale. - * @param that String to compare to target string -@@ -5491,4 +5569,22 @@ - locales?: string | string[], - options?: Intl.DateTimeFormatOptions - ): string; + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- every( +- predicate: (value: number, index: number, array: Int8Array) => unknown, +- thisArg?: any ++ every( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array +@@ -2146,21 +2193,24 @@ + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): this; +- + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- filter( +- predicate: (value: number, index: number, array: Int8Array) => any, +- thisArg?: any ++ filter( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): Int8Array; +- + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -2168,13 +2218,12 @@ + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- find( +- predicate: (value: number, index: number, obj: Int8Array) => boolean, +- thisArg?: any ++ find( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number | undefined; +- + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -2182,23 +2231,22 @@ + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- findIndex( +- predicate: (value: number, index: number, obj: Int8Array) => boolean, +- thisArg?: any ++ findIndex( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number; +- + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- forEach( +- callbackfn: (value: number, index: number, array: Int8Array) => void, +- thisArg?: any ++ forEach( ++ callbackfn: (this: This, value: number, index: number, array: this) => void, ++ thisArg?: This + ): void; + + /** + * Returns the index of the first occurrence of a value in an array. +@@ -2226,50 +2274,40 @@ + /** + * The length of the array. + */ + readonly length: number; +- + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- map( +- callbackfn: (value: number, index: number, array: Int8Array) => number, +- thisArg?: any ++ map( ++ callbackfn: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => number, ++ thisArg?: This + ): Int8Array; +- + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an argument +- * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Int8Array +- ) => number +- ): number; +- reduce( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Int8Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. +@@ -2278,46 +2316,32 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Int8Array ++ array: this + ) => U, + initialValue: U + ): U; +- + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an +- * argument instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Int8Array +- ) => number +- ): number; +- reduceRight( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Int8Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. +@@ -2326,14 +2350,14 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Int8Array ++ array: this + ) => U, + initialValue: U + ): U; + +@@ -2354,20 +2378,24 @@ + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ + slice(start?: number, end?: number): Int8Array; +- + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- some( +- predicate: (value: number, index: number, array: Int8Array) => unknown, +- thisArg?: any ++ some( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Sorts an array. +@@ -2422,25 +2450,23 @@ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + */ +- from(arrayLike: ArrayLike): Int8Array; +- ++ from(source: ArrayLike): Int8Array; + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: ArrayLike, +- mapfn: (v: T, k: number) => number, +- thisArg?: any ++ from( ++ source: ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Int8Array; } -+// -------------------- -+type First = T extends [any] ? T[0] : unknown; -+ -+type UnionToIntersection = ( -+ T extends any ? (arg: T) => void : never -+) extends (arg: infer F) => void -+ ? F -+ : unknown; + declare var Int8Array: Int8ArrayConstructor; + +@@ -2478,20 +2504,24 @@ + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; +- + /** + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- every( +- predicate: (value: number, index: number, array: Uint8Array) => unknown, +- thisArg?: any ++ every( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array +@@ -2501,21 +2531,24 @@ + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): this; +- + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- filter( +- predicate: (value: number, index: number, array: Uint8Array) => any, +- thisArg?: any ++ filter( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): Uint8Array; +- + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -2523,13 +2556,12 @@ + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- find( +- predicate: (value: number, index: number, obj: Uint8Array) => boolean, +- thisArg?: any ++ find( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number | undefined; +- + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -2537,23 +2569,22 @@ + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- findIndex( +- predicate: (value: number, index: number, obj: Uint8Array) => boolean, +- thisArg?: any ++ findIndex( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number; +- + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- forEach( +- callbackfn: (value: number, index: number, array: Uint8Array) => void, +- thisArg?: any ++ forEach( ++ callbackfn: (this: This, value: number, index: number, array: this) => void, ++ thisArg?: This + ): void; + + /** + * Returns the index of the first occurrence of a value in an array. +@@ -2581,50 +2612,40 @@ + /** + * The length of the array. + */ + readonly length: number; +- + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- map( +- callbackfn: (value: number, index: number, array: Uint8Array) => number, +- thisArg?: any ++ map( ++ callbackfn: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => number, ++ thisArg?: This + ): Uint8Array; +- + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an argument +- * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Uint8Array +- ) => number +- ): number; +- reduce( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Uint8Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. +@@ -2633,46 +2654,32 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Uint8Array ++ array: this + ) => U, + initialValue: U + ): U; +- + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an +- * argument instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Uint8Array +- ) => number +- ): number; +- reduceRight( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Uint8Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. +@@ -2681,14 +2688,14 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Uint8Array ++ array: this + ) => U, + initialValue: U + ): U; + +@@ -2709,20 +2716,24 @@ + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ + slice(start?: number, end?: number): Uint8Array; +- + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- some( +- predicate: (value: number, index: number, array: Uint8Array) => unknown, +- thisArg?: any ++ some( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Sorts an array. +@@ -2778,25 +2789,23 @@ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + */ +- from(arrayLike: ArrayLike): Uint8Array; +- ++ from(source: ArrayLike): Uint8Array; + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: ArrayLike, +- mapfn: (v: T, k: number) => number, +- thisArg?: any ++ from( ++ source: ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Uint8Array; + } + declare var Uint8Array: Uint8ArrayConstructor; + +@@ -2834,24 +2843,24 @@ + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; +- + /** + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- every( ++ every( + predicate: ( ++ this: This, + value: number, + index: number, +- array: Uint8ClampedArray +- ) => unknown, +- thisArg?: any ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array +@@ -2861,21 +2870,24 @@ + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): this; +- + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- filter( +- predicate: (value: number, index: number, array: Uint8ClampedArray) => any, +- thisArg?: any ++ filter( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): Uint8ClampedArray; +- + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -2883,17 +2895,12 @@ + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- find( +- predicate: ( +- value: number, +- index: number, +- obj: Uint8ClampedArray +- ) => boolean, +- thisArg?: any ++ find( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number | undefined; +- + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -2901,31 +2908,22 @@ + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- findIndex( +- predicate: ( +- value: number, +- index: number, +- obj: Uint8ClampedArray +- ) => boolean, +- thisArg?: any ++ findIndex( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number; +- + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- forEach( +- callbackfn: ( +- value: number, +- index: number, +- array: Uint8ClampedArray +- ) => void, +- thisArg?: any ++ forEach( ++ callbackfn: (this: This, value: number, index: number, array: this) => void, ++ thisArg?: This + ): void; + + /** + * Returns the index of the first occurrence of a value in an array. +@@ -2953,54 +2951,40 @@ + /** + * The length of the array. + */ + readonly length: number; +- + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- map( ++ map( + callbackfn: ( ++ this: This, + value: number, + index: number, +- array: Uint8ClampedArray ++ array: this + ) => number, +- thisArg?: any ++ thisArg?: This + ): Uint8ClampedArray; +- + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an argument +- * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Uint8ClampedArray +- ) => number +- ): number; +- reduce( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Uint8ClampedArray +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. +@@ -3009,46 +2993,32 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Uint8ClampedArray ++ array: this + ) => U, + initialValue: U + ): U; +- + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an +- * argument instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Uint8ClampedArray +- ) => number +- ): number; +- reduceRight( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Uint8ClampedArray +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. +@@ -3057,14 +3027,14 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Uint8ClampedArray ++ array: this + ) => U, + initialValue: U + ): U; + +@@ -3085,24 +3055,24 @@ + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ + slice(start?: number, end?: number): Uint8ClampedArray; +- + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- some( ++ some( + predicate: ( ++ this: This, + value: number, + index: number, +- array: Uint8ClampedArray +- ) => unknown, +- thisArg?: any ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Sorts an array. +@@ -3158,25 +3128,23 @@ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + */ +- from(arrayLike: ArrayLike): Uint8ClampedArray; +- ++ from(source: ArrayLike): Uint8ClampedArray; + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: ArrayLike, +- mapfn: (v: T, k: number) => number, +- thisArg?: any ++ from( ++ source: ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Uint8ClampedArray; + } + declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +@@ -3214,20 +3182,24 @@ + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; +- + /** + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- every( +- predicate: (value: number, index: number, array: Int16Array) => unknown, +- thisArg?: any ++ every( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array +@@ -3237,21 +3209,24 @@ + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): this; +- + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- filter( +- predicate: (value: number, index: number, array: Int16Array) => any, +- thisArg?: any ++ filter( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): Int16Array; +- + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -3259,13 +3234,12 @@ + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- find( +- predicate: (value: number, index: number, obj: Int16Array) => boolean, +- thisArg?: any ++ find( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number | undefined; +- + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -3273,23 +3247,22 @@ + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- findIndex( +- predicate: (value: number, index: number, obj: Int16Array) => boolean, +- thisArg?: any ++ findIndex( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number; +- + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- forEach( +- callbackfn: (value: number, index: number, array: Int16Array) => void, +- thisArg?: any ++ forEach( ++ callbackfn: (this: This, value: number, index: number, array: this) => void, ++ thisArg?: This + ): void; + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. +@@ -3316,50 +3289,40 @@ + /** + * The length of the array. + */ + readonly length: number; +- + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- map( +- callbackfn: (value: number, index: number, array: Int16Array) => number, +- thisArg?: any ++ map( ++ callbackfn: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => number, ++ thisArg?: This + ): Int16Array; +- + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an argument +- * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Int16Array +- ) => number +- ): number; +- reduce( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Int16Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. +@@ -3368,46 +3331,32 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Int16Array ++ array: this + ) => U, + initialValue: U + ): U; +- + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an +- * argument instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Int16Array +- ) => number +- ): number; +- reduceRight( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Int16Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. +@@ -3416,14 +3365,14 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Int16Array ++ array: this + ) => U, + initialValue: U + ): U; + +@@ -3444,20 +3393,24 @@ + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ + slice(start?: number, end?: number): Int16Array; +- + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- some( +- predicate: (value: number, index: number, array: Int16Array) => unknown, +- thisArg?: any ++ some( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Sorts an array. +@@ -3513,25 +3466,23 @@ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + */ +- from(arrayLike: ArrayLike): Int16Array; +- ++ from(source: ArrayLike): Int16Array; + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: ArrayLike, +- mapfn: (v: T, k: number) => number, +- thisArg?: any ++ from( ++ source: ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Int16Array; + } + declare var Int16Array: Int16ArrayConstructor; + +@@ -3569,20 +3520,24 @@ + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; +- + /** + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- every( +- predicate: (value: number, index: number, array: Uint16Array) => unknown, +- thisArg?: any ++ every( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array +@@ -3592,21 +3547,24 @@ + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): this; +- + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- filter( +- predicate: (value: number, index: number, array: Uint16Array) => any, +- thisArg?: any ++ filter( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): Uint16Array; +- + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -3614,13 +3572,12 @@ + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- find( +- predicate: (value: number, index: number, obj: Uint16Array) => boolean, +- thisArg?: any ++ find( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number | undefined; +- + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -3628,23 +3585,22 @@ + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- findIndex( +- predicate: (value: number, index: number, obj: Uint16Array) => boolean, +- thisArg?: any ++ findIndex( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number; +- + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- forEach( +- callbackfn: (value: number, index: number, array: Uint16Array) => void, +- thisArg?: any ++ forEach( ++ callbackfn: (this: This, value: number, index: number, array: this) => void, ++ thisArg?: This + ): void; + + /** + * Returns the index of the first occurrence of a value in an array. +@@ -3672,50 +3628,40 @@ + /** + * The length of the array. + */ + readonly length: number; +- + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- map( +- callbackfn: (value: number, index: number, array: Uint16Array) => number, +- thisArg?: any ++ map( ++ callbackfn: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => number, ++ thisArg?: This + ): Uint16Array; +- + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an argument +- * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Uint16Array +- ) => number +- ): number; +- reduce( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Uint16Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. +@@ -3724,46 +3670,32 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Uint16Array ++ array: this + ) => U, + initialValue: U + ): U; +- + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an +- * argument instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Uint16Array +- ) => number +- ): number; +- reduceRight( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Uint16Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. +@@ -3772,14 +3704,14 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Uint16Array ++ array: this + ) => U, + initialValue: U + ): U; + +@@ -3800,20 +3732,24 @@ + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ + slice(start?: number, end?: number): Uint16Array; +- + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- some( +- predicate: (value: number, index: number, array: Uint16Array) => unknown, +- thisArg?: any ++ some( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Sorts an array. +@@ -3869,25 +3805,23 @@ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + */ +- from(arrayLike: ArrayLike): Uint16Array; +- ++ from(source: ArrayLike): Uint16Array; + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: ArrayLike, +- mapfn: (v: T, k: number) => number, +- thisArg?: any ++ from( ++ source: ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Uint16Array; + } + declare var Uint16Array: Uint16ArrayConstructor; + /** +@@ -3924,20 +3858,24 @@ + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; +- + /** + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- every( +- predicate: (value: number, index: number, array: Int32Array) => unknown, +- thisArg?: any ++ every( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array +@@ -3947,21 +3885,24 @@ + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): this; +- + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- filter( +- predicate: (value: number, index: number, array: Int32Array) => any, +- thisArg?: any ++ filter( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): Int32Array; +- + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -3969,13 +3910,12 @@ + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- find( +- predicate: (value: number, index: number, obj: Int32Array) => boolean, +- thisArg?: any ++ find( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number | undefined; +- + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -3983,23 +3923,22 @@ + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- findIndex( +- predicate: (value: number, index: number, obj: Int32Array) => boolean, +- thisArg?: any ++ findIndex( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number; +- + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- forEach( +- callbackfn: (value: number, index: number, array: Int32Array) => void, +- thisArg?: any ++ forEach( ++ callbackfn: (this: This, value: number, index: number, array: this) => void, ++ thisArg?: This + ): void; + + /** + * Returns the index of the first occurrence of a value in an array. +@@ -4027,50 +3966,40 @@ + /** + * The length of the array. + */ + readonly length: number; +- + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- map( +- callbackfn: (value: number, index: number, array: Int32Array) => number, +- thisArg?: any ++ map( ++ callbackfn: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => number, ++ thisArg?: This + ): Int32Array; +- + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an argument +- * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Int32Array +- ) => number +- ): number; +- reduce( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Int32Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. +@@ -4079,46 +4008,32 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Int32Array ++ array: this + ) => U, + initialValue: U + ): U; +- + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an +- * argument instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Int32Array +- ) => number +- ): number; +- reduceRight( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Int32Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. +@@ -4127,14 +4042,14 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Int32Array ++ array: this + ) => U, + initialValue: U + ): U; + +@@ -4155,20 +4070,24 @@ + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ + slice(start?: number, end?: number): Int32Array; +- + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- some( +- predicate: (value: number, index: number, array: Int32Array) => unknown, +- thisArg?: any ++ some( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Sorts an array. +@@ -4224,25 +4143,23 @@ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + */ +- from(arrayLike: ArrayLike): Int32Array; +- ++ from(source: ArrayLike): Int32Array; + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: ArrayLike, +- mapfn: (v: T, k: number) => number, +- thisArg?: any ++ from( ++ source: ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Int32Array; + } + declare var Int32Array: Int32ArrayConstructor; + +@@ -4280,20 +4197,24 @@ + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; +- + /** + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- every( +- predicate: (value: number, index: number, array: Uint32Array) => unknown, +- thisArg?: any ++ every( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array +@@ -4303,21 +4224,24 @@ + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): this; +- + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- filter( +- predicate: (value: number, index: number, array: Uint32Array) => any, +- thisArg?: any ++ filter( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): Uint32Array; +- + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -4325,13 +4249,12 @@ + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- find( +- predicate: (value: number, index: number, obj: Uint32Array) => boolean, +- thisArg?: any ++ find( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number | undefined; +- + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -4339,23 +4262,22 @@ + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- findIndex( +- predicate: (value: number, index: number, obj: Uint32Array) => boolean, +- thisArg?: any ++ findIndex( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number; +- + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- forEach( +- callbackfn: (value: number, index: number, array: Uint32Array) => void, +- thisArg?: any ++ forEach( ++ callbackfn: (this: This, value: number, index: number, array: this) => void, ++ thisArg?: This + ): void; + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. +@@ -4382,50 +4304,40 @@ + /** + * The length of the array. + */ + readonly length: number; +- + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- map( +- callbackfn: (value: number, index: number, array: Uint32Array) => number, +- thisArg?: any ++ map( ++ callbackfn: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => number, ++ thisArg?: This + ): Uint32Array; +- + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an argument +- * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Uint32Array +- ) => number +- ): number; +- reduce( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Uint32Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. +@@ -4434,46 +4346,32 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Uint32Array ++ array: this + ) => U, + initialValue: U + ): U; +- + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an +- * argument instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Uint32Array +- ) => number +- ): number; +- reduceRight( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Uint32Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. +@@ -4482,14 +4380,14 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Uint32Array ++ array: this + ) => U, + initialValue: U + ): U; + +@@ -4510,20 +4408,24 @@ + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ + slice(start?: number, end?: number): Uint32Array; +- + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- some( +- predicate: (value: number, index: number, array: Uint32Array) => unknown, +- thisArg?: any ++ some( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Sorts an array. +@@ -4579,25 +4481,23 @@ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + */ +- from(arrayLike: ArrayLike): Uint32Array; +- ++ from(source: ArrayLike): Uint32Array; + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: ArrayLike, +- mapfn: (v: T, k: number) => number, +- thisArg?: any ++ from( ++ source: ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Uint32Array; + } + declare var Uint32Array: Uint32ArrayConstructor; + +@@ -4635,20 +4535,24 @@ + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; +- + /** + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- every( +- predicate: (value: number, index: number, array: Float32Array) => unknown, +- thisArg?: any ++ every( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array +@@ -4658,21 +4562,24 @@ + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): this; +- + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- filter( +- predicate: (value: number, index: number, array: Float32Array) => any, +- thisArg?: any ++ filter( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): Float32Array; +- + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -4680,13 +4587,12 @@ + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- find( +- predicate: (value: number, index: number, obj: Float32Array) => boolean, +- thisArg?: any ++ find( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number | undefined; +- + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -4694,23 +4600,22 @@ + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- findIndex( +- predicate: (value: number, index: number, obj: Float32Array) => boolean, +- thisArg?: any ++ findIndex( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number; +- + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- forEach( +- callbackfn: (value: number, index: number, array: Float32Array) => void, +- thisArg?: any ++ forEach( ++ callbackfn: (this: This, value: number, index: number, array: this) => void, ++ thisArg?: This + ): void; + + /** + * Returns the index of the first occurrence of a value in an array. +@@ -4738,50 +4643,40 @@ + /** + * The length of the array. + */ + readonly length: number; +- + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- map( +- callbackfn: (value: number, index: number, array: Float32Array) => number, +- thisArg?: any ++ map( ++ callbackfn: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => number, ++ thisArg?: This + ): Float32Array; +- + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an argument +- * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Float32Array +- ) => number +- ): number; +- reduce( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Float32Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. +@@ -4790,46 +4685,32 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Float32Array ++ array: this + ) => U, + initialValue: U + ): U; +- + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an +- * argument instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Float32Array +- ) => number +- ): number; +- reduceRight( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Float32Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. +@@ -4838,14 +4719,14 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Float32Array ++ array: this + ) => U, + initialValue: U + ): U; + +@@ -4866,20 +4747,24 @@ + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ + slice(start?: number, end?: number): Float32Array; +- + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- some( +- predicate: (value: number, index: number, array: Float32Array) => unknown, +- thisArg?: any ++ some( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Sorts an array. +@@ -4935,25 +4820,23 @@ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + */ +- from(arrayLike: ArrayLike): Float32Array; +- ++ from(source: ArrayLike): Float32Array; + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: ArrayLike, +- mapfn: (v: T, k: number) => number, +- thisArg?: any ++ from( ++ source: ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Float32Array; + } + declare var Float32Array: Float32ArrayConstructor; + +@@ -4991,20 +4874,24 @@ + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; +- + /** + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- every( +- predicate: (value: number, index: number, array: Float64Array) => unknown, +- thisArg?: any ++ every( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array +@@ -5014,21 +4901,24 @@ + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): this; +- + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- filter( +- predicate: (value: number, index: number, array: Float64Array) => any, +- thisArg?: any ++ filter( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): Float64Array; +- + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -5036,13 +4926,12 @@ + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- find( +- predicate: (value: number, index: number, obj: Float64Array) => boolean, +- thisArg?: any ++ find( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number | undefined; +- + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending +@@ -5050,23 +4939,22 @@ + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ +- findIndex( +- predicate: (value: number, index: number, obj: Float64Array) => boolean, +- thisArg?: any ++ findIndex( ++ predicate: (this: This, value: number, index: number, obj: this) => boolean, ++ thisArg?: This + ): number; +- + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- forEach( +- callbackfn: (value: number, index: number, array: Float64Array) => void, +- thisArg?: any ++ forEach( ++ callbackfn: (this: This, value: number, index: number, array: this) => void, ++ thisArg?: This + ): void; + + /** + * Returns the index of the first occurrence of a value in an array. +@@ -5094,50 +4982,40 @@ + /** + * The length of the array. + */ + readonly length: number; +- + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ +- map( +- callbackfn: (value: number, index: number, array: Float64Array) => number, +- thisArg?: any ++ map( ++ callbackfn: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => number, ++ thisArg?: This + ): Float64Array; +- + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an argument +- * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Float64Array +- ) => number +- ): number; +- reduce( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Float64Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. +@@ -5146,46 +5024,32 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduce( ++ reduce( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Float64Array ++ array: this + ) => U, + initialValue: U + ): U; +- + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. +- * @param initialValue If initialValue is specified, it is used as the initial value to start +- * the accumulation. The first call to the callbackfn function provides this value as an +- * argument instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( +- previousValue: number, ++ previousValue: number | U, + currentValue: number, + currentIndex: number, +- array: Float64Array +- ) => number +- ): number; +- reduceRight( +- callbackfn: ( +- previousValue: number, +- currentValue: number, +- currentIndex: number, +- array: Float64Array +- ) => number, +- initialValue: number +- ): number; +- ++ array: this ++ ) => U ++ ): number | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. +@@ -5194,14 +5058,14 @@ + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ +- reduceRight( ++ reduceRight( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, +- array: Float64Array ++ array: this + ) => U, + initialValue: U + ): U; + +@@ -5222,20 +5086,24 @@ + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ + slice(start?: number, end?: number): Float64Array; +- + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ +- some( +- predicate: (value: number, index: number, array: Float64Array) => unknown, +- thisArg?: any ++ some( ++ predicate: ( ++ this: This, ++ value: number, ++ index: number, ++ array: this ++ ) => boolean, ++ thisArg?: This + ): boolean; + + /** + * Sorts an array. +@@ -5282,25 +5150,23 @@ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; +- + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + */ +- from(arrayLike: ArrayLike): Float64Array; +- ++ from(source: ArrayLike): Float64Array; + /** + * Creates an array from an array-like or iterable object. +- * @param arrayLike An array-like or iterable object to convert to an array. ++ * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ +- from( +- arrayLike: ArrayLike, +- mapfn: (v: T, k: number) => number, +- thisArg?: any ++ from( ++ source: ArrayLike, ++ mapfn: (this: This, v: T, k: number) => number, ++ thisArg?: This + ): Float64Array; + } + declare var Float64Array: Float64ArrayConstructor; + +@@ -5491,4 +5357,24 @@ + locales?: string | string[], + options?: Intl.DateTimeFormatOptions + ): string; + } ++// -------------------- ++type First = T extends [any] ? T[0] : unknown; ++ ++type UnionToIntersection = ( ++ T extends any ? (arg: T) => void : never ++) extends (arg: infer F) => void ++ ? F ++ : unknown; ++ ++type CheckNonNullable = [T] extends [NonNullable] ? U : never; + +type JSONValue = + | null diff --git a/generated/lib.es2015.collection.d.ts b/generated/lib.es2015.collection.d.ts index 017b597..a656a12 100644 --- a/generated/lib.es2015.collection.d.ts +++ b/generated/lib.es2015.collection.d.ts @@ -2,7 +2,7 @@ interface Map { clear(): void; delete(key: K): boolean; forEach( - callbackfn: (this: This, value: V, key: K, map: Map) => void, + callbackfn: (this: This, value: V, key: K, map: this) => void, thisArg?: This ): void; get(key: K): V | undefined; @@ -21,9 +21,10 @@ interface MapConstructor { // readonly prototype: Map; declare var Map: MapConstructor; + interface ReadonlyMap { forEach( - callbackfn: (this: This, value: V, key: K, map: ReadonlyMap) => void, + callbackfn: (this: This, value: V, key: K, map: this) => void, thisArg?: This ): void; get(key: K): V | undefined; @@ -38,6 +39,7 @@ interface WeakMap { has(key: K): boolean; set(key: K, value: V): this; } + interface WeakMapConstructor { new ( entries?: readonly (readonly [K, V])[] | null @@ -48,12 +50,13 @@ interface WeakMapConstructor { // readonly prototype: WeakMap; declare var WeakMap: WeakMapConstructor; + interface Set { add(value: T): this; clear(): void; delete(value: T): boolean; forEach( - callbackfn: (this: This, value: T, value2: T, set: Set) => void, + callbackfn: (this: This, value: T, value2: T, set: this) => void, thisArg?: This ): void; has(value: T): boolean; @@ -69,9 +72,10 @@ interface SetConstructor { // readonly prototype: Set; declare var Set: SetConstructor; + interface ReadonlySet { forEach( - callbackfn: (this: This, value: T, value2: T, set: ReadonlySet) => void, + callbackfn: (this: This, value: T, value2: T, set: this) => void, thisArg?: This ): void; has(value: T): boolean; diff --git a/generated/lib.es2015.core.d.ts b/generated/lib.es2015.core.d.ts index cec806c..1a7c668 100644 --- a/generated/lib.es2015.core.d.ts +++ b/generated/lib.es2015.core.d.ts @@ -8,13 +8,23 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find( - predicate: (this: void, value: T, index: number, obj: T[]) => value is S, - thisArg?: any + find( + predicate: (this: This, value: T, index: number, obj: this) => value is S, + thisArg?: This ): S | undefined; - find( - predicate: (value: T, index: number, obj: T[]) => unknown, - thisArg?: any + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find( + predicate: (this: This, value: T, index: number, obj: this) => boolean, + thisArg?: This ): T | undefined; /** @@ -26,9 +36,9 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex( - predicate: (value: T, index: number, obj: T[]) => unknown, - thisArg?: any + findIndex( + predicate: (this: This, value: T, index: number, obj: this) => boolean, + thisArg?: This ): number; /** @@ -52,24 +62,45 @@ interface Array { */ copyWithin(target: number, start: number, end?: number): this; } +// /** +// * Returns the value of the first element in the array where predicate is true, and undefined +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, find +// * immediately returns that element value. Otherwise, find returns undefined. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// find(predicate: (this: void, value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined; +// find(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined; +// /** +// * Returns the index of the first element in the array where predicate is true, and -1 +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, +// * findIndex immediately returns that element index. Otherwise, findIndex returns -1. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// findIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number; interface ArrayConstructor { /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. */ - from(arrayLike: ArrayLike): T[]; + from(source: ArrayLike): T[]; /** - * Creates an array from an iterable object. - * @param arrayLike An array-like object to convert to an array. + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: ArrayLike, - mapfn: (v: T, k: number) => U, - thisArg?: any + from( + source: ArrayLike, + mapfn: (this: This, v: T, k: number) => U, + thisArg?: This ): U[]; /** @@ -78,6 +109,18 @@ interface ArrayConstructor { */ of(...items: T[]): T[]; } +// /** +// * Creates an array from an array-like object. +// * @param arrayLike An array-like object to convert to an array. +// */ +// from(arrayLike: ArrayLike): T[]; +// /** +// * Creates an array from an iterable object. +// * @param arrayLike An array-like object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; interface DateConstructor { new (value: number | string | Date): Date; @@ -202,6 +245,7 @@ interface Math { */ cbrt(x: number): number; } + interface NumberConstructor { /** * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 @@ -301,7 +345,17 @@ interface ObjectConstructor { assign( target: T, ...sources: Ts - ): First>; + ): CheckNonNullable< + T, + First< + UnionToIntersection< + | [T] + | { + [K in keyof Ts]: [Ts[K]]; + }[number] + > + > + >; /** * Returns an array of all symbol properties found directly on object o. @@ -390,18 +444,23 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find( - predicate: ( - this: void, - value: T, - index: number, - obj: readonly T[] - ) => value is S, - thisArg?: any + find( + predicate: (this: This, value: T, index: number, obj: this) => value is S, + thisArg?: This ): S | undefined; - find( - predicate: (value: T, index: number, obj: readonly T[]) => unknown, - thisArg?: any + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find( + predicate: (this: This, value: T, index: number, obj: this) => boolean, + thisArg?: This ): T | undefined; /** @@ -413,11 +472,32 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex( - predicate: (value: T, index: number, obj: readonly T[]) => unknown, - thisArg?: any + findIndex( + predicate: (this: This, value: T, index: number, obj: this) => boolean, + thisArg?: This ): number; } +// /** +// * Returns the value of the first element in the array where predicate is true, and undefined +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, find +// * immediately returns that element value. Otherwise, find returns undefined. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// find(predicate: (this: void, value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined; +// find(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined; +// /** +// * Returns the index of the first element in the array where predicate is true, and -1 +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, +// * findIndex immediately returns that element index. Otherwise, findIndex returns -1. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// findIndex(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): number; interface RegExp { /** @@ -451,6 +531,7 @@ interface RegExpConstructor { new (pattern: RegExp | string, flags?: string): RegExp; (pattern: RegExp | string, flags?: string): RegExp; } + interface String { /** * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point diff --git a/generated/lib.es2015.iterable.d.ts b/generated/lib.es2015.iterable.d.ts index b5d62bd..e0f09bc 100644 --- a/generated/lib.es2015.iterable.d.ts +++ b/generated/lib.es2015.iterable.d.ts @@ -67,23 +67,35 @@ interface Array { interface ArrayConstructor { /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. */ - from(iterable: Iterable | ArrayLike): T[]; + from(source: Iterable | ArrayLike): T[]; /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - iterable: Iterable | ArrayLike, - mapfn: (v: T, k: number) => U, - thisArg?: any + from( + source: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => U, + thisArg?: This ): U[]; } +// /** +// * Creates an array from an iterable object. +// * @param iterable An iterable object to convert to an array. +// */ +// from(iterable: Iterable | ArrayLike): T[]; +// /** +// * Creates an array from an iterable object. +// * @param iterable An iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(iterable: Iterable | ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; interface ReadonlyArray { /** Iterator of values in the array. */ @@ -104,6 +116,7 @@ interface ReadonlyArray { */ values(): IterableIterator; } + interface IArguments { /** Iterator */ [Symbol.iterator](): IterableIterator; @@ -150,6 +163,7 @@ interface ReadonlyMap { */ values(): IterableIterator; } + interface MapConstructor { new (iterable?: Iterable | null): Map; } @@ -211,6 +225,7 @@ interface WeakSetConstructor { } interface Promise {} + interface PromiseConstructor { /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -266,19 +281,30 @@ interface Int8Array { interface Int8ArrayConstructor { new (elements: Iterable): Int8Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. + */ + from(source: Iterable | ArrayLike): Int8Array; + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: Iterable, - mapfn?: (v: number, k: number) => number, - thisArg?: any + from( + source: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Int8Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; interface Uint8Array { [Symbol.iterator](): IterableIterator; @@ -298,19 +324,30 @@ interface Uint8Array { interface Uint8ArrayConstructor { new (elements: Iterable): Uint8Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. + */ + from(source: Iterable | ArrayLike): Uint8Array; + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: Iterable, - mapfn?: (v: number, k: number) => number, - thisArg?: any + from( + source: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Uint8Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; interface Uint8ClampedArray { [Symbol.iterator](): IterableIterator; @@ -332,19 +369,30 @@ interface Uint8ClampedArray { interface Uint8ClampedArrayConstructor { new (elements: Iterable): Uint8ClampedArray; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. + */ + from(source: Iterable | ArrayLike): Uint8ClampedArray; + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: Iterable, - mapfn?: (v: number, k: number) => number, - thisArg?: any + from( + source: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Uint8ClampedArray; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; interface Int16Array { [Symbol.iterator](): IterableIterator; @@ -366,19 +414,30 @@ interface Int16Array { interface Int16ArrayConstructor { new (elements: Iterable): Int16Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. + */ + from(source: Iterable | ArrayLike): Int16Array; + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: Iterable, - mapfn?: (v: number, k: number) => number, - thisArg?: any + from( + source: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Int16Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; interface Uint16Array { [Symbol.iterator](): IterableIterator; @@ -398,19 +457,30 @@ interface Uint16Array { interface Uint16ArrayConstructor { new (elements: Iterable): Uint16Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. + */ + from(source: Iterable | ArrayLike): Uint16Array; + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: Iterable, - mapfn?: (v: number, k: number) => number, - thisArg?: any + from( + source: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Uint16Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; interface Int32Array { [Symbol.iterator](): IterableIterator; @@ -430,19 +500,30 @@ interface Int32Array { interface Int32ArrayConstructor { new (elements: Iterable): Int32Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. + */ + from(source: Iterable | ArrayLike): Int32Array; + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: Iterable, - mapfn?: (v: number, k: number) => number, - thisArg?: any + from( + source: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Int32Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; interface Uint32Array { [Symbol.iterator](): IterableIterator; @@ -462,19 +543,30 @@ interface Uint32Array { interface Uint32ArrayConstructor { new (elements: Iterable): Uint32Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. + */ + from(source: Iterable | ArrayLike): Uint32Array; + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: Iterable, - mapfn?: (v: number, k: number) => number, - thisArg?: any + from( + source: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Uint32Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; interface Float32Array { [Symbol.iterator](): IterableIterator; @@ -494,19 +586,30 @@ interface Float32Array { interface Float32ArrayConstructor { new (elements: Iterable): Float32Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. + */ + from(source: Iterable | ArrayLike): Float32Array; + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: Iterable, - mapfn?: (v: number, k: number) => number, - thisArg?: any + from( + source: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Float32Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; interface Float64Array { [Symbol.iterator](): IterableIterator; @@ -526,16 +629,27 @@ interface Float64Array { interface Float64ArrayConstructor { new (elements: Iterable): Float64Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. + */ + from(source: Iterable | ArrayLike): Float64Array; + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: Iterable, - mapfn?: (v: number, k: number) => number, - thisArg?: any + from( + source: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Float64Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; diff --git a/generated/lib.es2015.symbol.wellknown.d.ts b/generated/lib.es2015.symbol.wellknown.d.ts index 3ff9f67..95694ac 100644 --- a/generated/lib.es2015.symbol.wellknown.d.ts +++ b/generated/lib.es2015.symbol.wellknown.d.ts @@ -70,12 +70,15 @@ interface Symbol { readonly [Symbol.toStringTag]: string; } + interface Array { /** * Returns an object whose properties have the value 'true' * when they will be absent when used in a 'with' statement. */ - readonly [Symbol.unscopables]: { [key: PropertyKey]: boolean }; + readonly [Symbol.unscopables]: { + [key: PropertyKey]: boolean; + }; } // /** // * Returns an object whose properties have the value 'true' @@ -161,6 +164,7 @@ interface Promise { interface PromiseConstructor { readonly [Symbol.species]: PromiseConstructor; } + interface RegExp { /** * Matches a string with this regular expression, and returns an array containing the results of @@ -234,6 +238,7 @@ interface RegExp { interface RegExpConstructor { readonly [Symbol.species]: RegExpConstructor; } + interface String { /** * Matches a string or an object that supports being matched against, and returns an array diff --git a/generated/lib.es2017.object.d.ts b/generated/lib.es2017.object.d.ts index 1536cef..7ea448f 100644 --- a/generated/lib.es2017.object.d.ts +++ b/generated/lib.es2017.object.d.ts @@ -13,7 +13,7 @@ interface ObjectConstructor { * Returns an array of values of the enumerable properties of an object * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ - values(o: unknown): unknown[]; + values(o: T): CheckNonNullable; /** * Returns an array of key/values of the enumerable properties of an object @@ -29,17 +29,20 @@ interface ObjectConstructor { * Returns an array of key/values of the enumerable properties of an object * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ - entries(o: T): [string, unknown][]; + entries(o: T): CheckNonNullable; /** * Returns an object containing all own property descriptors of an object * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ - getOwnPropertyDescriptors( - o: T - ): { [P in keyof T]: TypedPropertyDescriptor } & { - [x: string]: PropertyDescriptor; - }; + getOwnPropertyDescriptors(o: T): CheckNonNullable< + T, + { + [P in keyof T]: TypedPropertyDescriptor; + } & { + [x: string]: PropertyDescriptor; + } + >; } // /** // * Returns an array of values of the enumerable properties of an object @@ -61,3 +64,8 @@ interface ObjectConstructor { // * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. // */ // entries(o: {}): [string, any][]; +// /** +// * Returns an object containing all own property descriptors of an object +// * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. +// */ +// getOwnPropertyDescriptors(o: T): {[P in keyof T]: TypedPropertyDescriptor} & { [x: string]: PropertyDescriptor }; diff --git a/generated/lib.es2019.object.d.ts b/generated/lib.es2019.object.d.ts index c907856..4da0897 100644 --- a/generated/lib.es2019.object.d.ts +++ b/generated/lib.es2019.object.d.ts @@ -1,3 +1,5 @@ +/// + interface ObjectConstructor { /** * Returns an object created by key-value entries for properties and methods diff --git a/generated/lib.es2020.bigint.d.ts b/generated/lib.es2020.bigint.d.ts index e2a3155..1c18b69 100644 --- a/generated/lib.es2020.bigint.d.ts +++ b/generated/lib.es2020.bigint.d.ts @@ -260,7 +260,6 @@ interface BigInt64Array { /** Yields index, value pairs for every entry in the array. */ entries(): IterableIterator<[number, bigint]>; - /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -269,9 +268,14 @@ interface BigInt64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every( - predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, - thisArg?: any + every( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -283,7 +287,6 @@ interface BigInt64Array { * length+end. */ fill(value: bigint, start?: number, end?: number): this; - /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls @@ -291,11 +294,15 @@ interface BigInt64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter( - predicate: (value: bigint, index: number, array: BigInt64Array) => any, - thisArg?: any + filter( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This ): BigInt64Array; - /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. @@ -305,11 +312,15 @@ interface BigInt64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find( - predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, - thisArg?: any + find( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This ): bigint | undefined; - /** * Returns the index of the first element in the array where predicate is true, and -1 * otherwise. @@ -319,11 +330,15 @@ interface BigInt64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex( - predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, - thisArg?: any + findIndex( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This ): number; - /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the @@ -331,9 +346,9 @@ interface BigInt64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach( - callbackfn: (value: bigint, index: number, array: BigInt64Array) => void, - thisArg?: any + forEach( + callbackfn: (this: This, value: bigint, index: number, array: this) => void, + thisArg?: This ): void; /** @@ -371,7 +386,6 @@ interface BigInt64Array { /** The length of the array. */ readonly length: number; - /** * Calls a defined callback function on each element of an array, and returns an array that * contains the results. @@ -380,30 +394,30 @@ interface BigInt64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map( - callbackfn: (value: bigint, index: number, array: BigInt64Array) => bigint, - thisArg?: any + map( + callbackfn: ( + this: This, + value: bigint, + index: number, + array: this + ) => bigint, + thisArg?: This ): BigInt64Array; - /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. */ - reduce( + reduce( callbackfn: ( - previousValue: bigint, + previousValue: bigint | U, currentValue: bigint, currentIndex: number, - array: BigInt64Array - ) => bigint - ): bigint; - + array: this + ) => U + ): bigint | U; /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next @@ -414,35 +428,30 @@ interface BigInt64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce( + reduce( callbackfn: ( previousValue: U, currentValue: bigint, currentIndex: number, - array: BigInt64Array + array: this ) => U, initialValue: U ): U; - /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( - previousValue: bigint, + previousValue: bigint | U, currentValue: bigint, currentIndex: number, - array: BigInt64Array - ) => bigint - ): bigint; - + array: this + ) => U + ): bigint | U; /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an @@ -453,12 +462,12 @@ interface BigInt64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( previousValue: U, currentValue: bigint, currentIndex: number, - array: BigInt64Array + array: this ) => U, initialValue: U ): U; @@ -479,7 +488,6 @@ interface BigInt64Array { * @param end The end of the specified portion of the array. */ slice(start?: number, end?: number): BigInt64Array; - /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls the @@ -488,9 +496,14 @@ interface BigInt64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some( - predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, - thisArg?: any + some( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -525,6 +538,113 @@ interface BigInt64Array { [index: number]: bigint; } +// /** +// * Determines whether all the members of an array satisfy the specified test. +// * @param predicate A function that accepts up to three arguments. The every method calls +// * the predicate function for each element in the array until the predicate returns false, +// * or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// every(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; +// /** +// * Returns the elements of an array that meet the condition specified in a callback function. +// * @param predicate A function that accepts up to three arguments. The filter method calls +// * the predicate function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// filter(predicate: (value: bigint, index: number, array: BigInt64Array) => any, thisArg?: any): BigInt64Array; +// /** +// * Returns the value of the first element in the array where predicate is true, and undefined +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, find +// * immediately returns that element value. Otherwise, find returns undefined. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// find(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): bigint | undefined; +// /** +// * Returns the index of the first element in the array where predicate is true, and -1 +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, +// * findIndex immediately returns that element index. Otherwise, findIndex returns -1. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// findIndex(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): number; +// /** +// * Performs the specified action for each element in an array. +// * @param callbackfn A function that accepts up to three arguments. forEach calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// forEach(callbackfn: (value: bigint, index: number, array: BigInt64Array) => void, thisArg?: any): void; +// /** +// * Calls a defined callback function on each element of an array, and returns an array that +// * contains the results. +// * @param callbackfn A function that accepts up to three arguments. The map method calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// map(callbackfn: (value: bigint, index: number, array: BigInt64Array) => bigint, thisArg?: any): BigInt64Array; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an +// * argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; +// /** +// * Determines whether the specified callback function returns true for any element of an array. +// * @param predicate A function that accepts up to three arguments. The some method calls the +// * predicate function for each element in the array until the predicate returns true, or until +// * the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// some(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; interface BigInt64ArrayConstructor { readonly prototype: BigInt64Array; @@ -544,20 +664,31 @@ interface BigInt64ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: bigint[]): BigInt64Array; - + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ + from(arrayLike: Iterable | ArrayLike): BigInt64Array; /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike): BigInt64Array; - from( - arrayLike: ArrayLike, - mapfn: (v: U, k: number) => bigint, - thisArg?: any + from( + arrayLike: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => bigint, + thisArg?: This ): BigInt64Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: ArrayLike): BigInt64Array; +// from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array; declare var BigInt64Array: BigInt64ArrayConstructor; @@ -591,7 +722,6 @@ interface BigUint64Array { /** Yields index, value pairs for every entry in the array. */ entries(): IterableIterator<[number, bigint]>; - /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -600,9 +730,14 @@ interface BigUint64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every( - predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, - thisArg?: any + every( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -614,7 +749,6 @@ interface BigUint64Array { * length+end. */ fill(value: bigint, start?: number, end?: number): this; - /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls @@ -622,11 +756,15 @@ interface BigUint64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter( - predicate: (value: bigint, index: number, array: BigUint64Array) => any, - thisArg?: any + filter( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This ): BigUint64Array; - /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. @@ -636,11 +774,15 @@ interface BigUint64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find( - predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, - thisArg?: any + find( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This ): bigint | undefined; - /** * Returns the index of the first element in the array where predicate is true, and -1 * otherwise. @@ -650,11 +792,15 @@ interface BigUint64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex( - predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, - thisArg?: any + findIndex( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This ): number; - /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the @@ -662,9 +808,9 @@ interface BigUint64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach( - callbackfn: (value: bigint, index: number, array: BigUint64Array) => void, - thisArg?: any + forEach( + callbackfn: (this: This, value: bigint, index: number, array: this) => void, + thisArg?: This ): void; /** @@ -702,7 +848,6 @@ interface BigUint64Array { /** The length of the array. */ readonly length: number; - /** * Calls a defined callback function on each element of an array, and returns an array that * contains the results. @@ -711,30 +856,30 @@ interface BigUint64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map( - callbackfn: (value: bigint, index: number, array: BigUint64Array) => bigint, - thisArg?: any + map( + callbackfn: ( + this: This, + value: bigint, + index: number, + array: this + ) => bigint, + thisArg?: This ): BigUint64Array; - /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. */ - reduce( + reduce( callbackfn: ( - previousValue: bigint, + previousValue: bigint | U, currentValue: bigint, currentIndex: number, - array: BigUint64Array - ) => bigint - ): bigint; - + array: this + ) => U + ): bigint | U; /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next @@ -745,35 +890,30 @@ interface BigUint64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce( + reduce( callbackfn: ( previousValue: U, currentValue: bigint, currentIndex: number, - array: BigUint64Array + array: this ) => U, initialValue: U ): U; - /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( - previousValue: bigint, + previousValue: bigint | U, currentValue: bigint, currentIndex: number, - array: BigUint64Array - ) => bigint - ): bigint; - + array: this + ) => U + ): bigint | U; /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an @@ -784,12 +924,12 @@ interface BigUint64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( previousValue: U, currentValue: bigint, currentIndex: number, - array: BigUint64Array + array: this ) => U, initialValue: U ): U; @@ -810,7 +950,6 @@ interface BigUint64Array { * @param end The end of the specified portion of the array. */ slice(start?: number, end?: number): BigUint64Array; - /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls the @@ -819,9 +958,14 @@ interface BigUint64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some( - predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, - thisArg?: any + some( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -856,6 +1000,113 @@ interface BigUint64Array { [index: number]: bigint; } +// /** +// * Determines whether all the members of an array satisfy the specified test. +// * @param predicate A function that accepts up to three arguments. The every method calls +// * the predicate function for each element in the array until the predicate returns false, +// * or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// every(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; +// /** +// * Returns the elements of an array that meet the condition specified in a callback function. +// * @param predicate A function that accepts up to three arguments. The filter method calls +// * the predicate function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// filter(predicate: (value: bigint, index: number, array: BigUint64Array) => any, thisArg?: any): BigUint64Array; +// /** +// * Returns the value of the first element in the array where predicate is true, and undefined +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, find +// * immediately returns that element value. Otherwise, find returns undefined. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// find(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): bigint | undefined; +// /** +// * Returns the index of the first element in the array where predicate is true, and -1 +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, +// * findIndex immediately returns that element index. Otherwise, findIndex returns -1. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// findIndex(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): number; +// /** +// * Performs the specified action for each element in an array. +// * @param callbackfn A function that accepts up to three arguments. forEach calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// forEach(callbackfn: (value: bigint, index: number, array: BigUint64Array) => void, thisArg?: any): void; +// /** +// * Calls a defined callback function on each element of an array, and returns an array that +// * contains the results. +// * @param callbackfn A function that accepts up to three arguments. The map method calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// map(callbackfn: (value: bigint, index: number, array: BigUint64Array) => bigint, thisArg?: any): BigUint64Array; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an +// * argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; +// /** +// * Determines whether the specified callback function returns true for any element of an array. +// * @param predicate A function that accepts up to three arguments. The some method calls the +// * predicate function for each element in the array until the predicate returns true, or until +// * the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// some(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; interface BigUint64ArrayConstructor { readonly prototype: BigUint64Array; @@ -875,20 +1126,31 @@ interface BigUint64ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: bigint[]): BigUint64Array; - + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ + from(arrayLike: Iterable | ArrayLike): BigUint64Array; /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike): BigUint64Array; - from( - arrayLike: ArrayLike, - mapfn: (v: U, k: number) => bigint, - thisArg?: any + from( + arrayLike: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => bigint, + thisArg?: This ): BigUint64Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: ArrayLike): BigUint64Array; +// from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array; declare var BigUint64Array: BigUint64ArrayConstructor; diff --git a/generated/lib.es2022.object.d.ts b/generated/lib.es2022.object.d.ts index 1198123..28b6c85 100644 --- a/generated/lib.es2022.object.d.ts +++ b/generated/lib.es2022.object.d.ts @@ -14,7 +14,9 @@ interface ObjectConstructor { : symbol extends Key ? {} : Key extends PropertyKey - ? { [key in Key]: unknown } + ? { + [key in Key]: unknown; + } : {}; } // /** diff --git a/generated/lib.es5.d.ts b/generated/lib.es5.d.ts index fdc0756..b92c308 100644 --- a/generated/lib.es5.d.ts +++ b/generated/lib.es5.d.ts @@ -105,6 +105,7 @@ interface PropertyDescriptor { interface PropertyDescriptorMap { [key: PropertyKey]: PropertyDescriptor; } + interface Object { /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ constructor: Function; @@ -130,7 +131,9 @@ interface Object { : symbol extends Key ? {} : Key extends PropertyKey - ? { [key in Key]: unknown } + ? { + [key in Key]: unknown; + } : {}; /** @@ -163,7 +166,7 @@ interface ObjectConstructor { * Returns the prototype of an object. * @param o The object that references the prototype. */ - getPrototypeOf(o: any): unknown; + getPrototypeOf(o: T): CheckNonNullable; /** * Gets the own property descriptor of the specified object. @@ -171,17 +174,17 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor( - o: any, + getOwnPropertyDescriptor( + o: T, p: PropertyKey - ): PropertyDescriptor | undefined; + ): CheckNonNullable; /** * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. * @param o Object that contains the own properties. */ - getOwnPropertyNames(o: O): O extends undefined | null ? never : string[]; + getOwnPropertyNames(o: T): CheckNonNullable; /** * Creates an object that has the specified prototype or that has null prototype. @@ -204,9 +207,13 @@ interface ObjectConstructor { o: O, properties: P & ThisType ): { - [K in keyof (O & P)]: P[K] extends { value: infer V } + [K in keyof (O & P)]: P[K] extends { + value: infer V; + } ? V - : P[K] extends { get: () => infer V } + : P[K] extends { + get: () => infer V; + } ? V : K extends keyof O ? O[K] @@ -222,9 +229,13 @@ interface ObjectConstructor { o: null, properties: P & ThisType ): { - [K in keyof P]: P[K] extends { value: infer V } + [K in keyof P]: P[K] extends { + value: infer V; + } ? V - : P[K] extends { get: () => infer V } + : P[K] extends { + get: () => infer V; + } ? V : unknown; }; @@ -246,9 +257,13 @@ interface ObjectConstructor { ): O & (P extends PropertyKey // required to make P distributive ? { - [K in P]: D extends { value: infer V } + [K in P]: D extends { + value: infer V; + } ? V - : D extends { get: () => infer V } + : D extends { + get: () => infer V; + } ? V : unknown; } @@ -266,9 +281,13 @@ interface ObjectConstructor { o: O, properties: P & ThisType ): { - [K in keyof (O & P)]: P[K] extends { value: infer V } + [K in keyof (O & P)]: P[K] extends { + value: infer V; + } ? V - : P[K] extends { get: () => infer V } + : P[K] extends { + get: () => infer V; + } ? V : K extends keyof O ? O[K] @@ -338,6 +357,13 @@ interface ObjectConstructor { // */ // getPrototypeOf(o: any): any; // /** +// * Gets the own property descriptor of the specified object. +// * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. +// * @param o Object that contains the property. +// * @param p Name of the property. +// */ +// getOwnPropertyDescriptor(o: any, p: PropertyKey): PropertyDescriptor | undefined; +// /** // * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly // * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. // * @param o Object that contains the own properties. @@ -437,6 +463,7 @@ type OmitThisParameter = unknown extends ThisParameterType : T extends (...args: infer A) => infer R ? (...args: A) => R : T; + interface CallableFunction extends Function { /** * Calls the function with the specified object as the this value and the elements of specified array as the arguments. @@ -486,17 +513,12 @@ interface CallableFunction extends Function { // bind(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; interface NewableFunction extends Function { - /** - * Calls the function with the specified object as the this value and the elements of specified array as the arguments. - * @param thisArg The object to be used as the this object. - */ - apply(this: new () => T, thisArg: T): void; - /** * Calls the function with the specified object as the this value and the elements of specified array as the arguments. * @param thisArg The object to be used as the this object. * @param args An array of argument values to be passed to the function. */ + apply(this: new () => T, thisArg: T): void; apply( this: new (...args: A) => T, thisArg: T, @@ -513,7 +535,6 @@ interface NewableFunction extends Function { thisArg: T, ...args: A ): void; - /** * For a given function, creates a bound function that has the same body as the original function. * The this object of the bound function is associated with the specified object, and has the specified initial parameters. @@ -527,19 +548,6 @@ interface NewableFunction extends Function { ): new (...args: B) => R; } // /** -// * Calls the function with the specified object as the this value and the elements of specified array as the arguments. -// * @param thisArg The object to be used as the this object. -// * @param args An array of argument values to be passed to the function. -// */ -// apply(this: new () => T, thisArg: T): void; -// apply(this: new (...args: A) => T, thisArg: T, args: A): void; -// /** -// * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. -// * @param thisArg The object to be used as the this object. -// * @param args Argument values to be passed to the function. -// */ -// call(this: new (...args: A) => T, thisArg: T, ...args: A): void; -// /** // * For a given function, creates a bound function that has the same body as the original function. // * The this object of the bound function is associated with the specified object, and has the specified initial parameters. // * @param thisArg The object to be used as the this object. @@ -1291,6 +1299,7 @@ interface URIErrorConstructor extends ErrorConstructor { } declare var URIError: URIErrorConstructor; + interface JSON { /** * Converts a JavaScript Object Notation (JSON) string into an object. @@ -1393,6 +1402,11 @@ interface JSON { * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. */ declare var JSON: JSON; + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + interface ReadonlyArray { /** * Gets the length of the array. This is a number one higher than the highest element defined in an array. @@ -1448,14 +1462,11 @@ interface ReadonlyArray { * If thisArg is omitted, undefined is used as the this value. */ every( - predicate: ( - this: This, - value: T, - index: number, - array: readonly T[] - ) => value is S, + predicate: (this: This, value: T, index: number, array: this) => value is S, thisArg?: This - ): this is readonly S[]; + ): this is { + [K in keyof this]: S; + }; /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -1465,12 +1476,7 @@ interface ReadonlyArray { * If thisArg is omitted, undefined is used as the this value. */ every( - predicate: ( - this: This, - value: T, - index: number, - array: readonly T[] - ) => boolean, + predicate: (this: This, value: T, index: number, array: this) => boolean, thisArg?: This ): boolean; /** @@ -1482,12 +1488,7 @@ interface ReadonlyArray { * If thisArg is omitted, undefined is used as the this value. */ some( - predicate: ( - this: This, - value: T, - index: number, - array: readonly T[] - ) => boolean, + predicate: (this: This, value: T, index: number, array: this) => boolean, thisArg?: This ): boolean; /** @@ -1496,12 +1497,7 @@ interface ReadonlyArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach( - callbackfn: ( - this: This, - value: T, - index: number, - array: readonly T[] - ) => void, + callbackfn: (this: This, value: T, index: number, array: this) => void, thisArg?: This ): void; /** @@ -1510,21 +1506,18 @@ interface ReadonlyArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ map( - callbackfn: (this: This, value: T, index: number, array: readonly T[]) => U, + callbackfn: (this: This, value: T, index: number, array: this) => U, thisArg?: This - ): U[]; + ): { + -readonly [K in keyof this]: U; + }; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. */ filter( - predicate: ( - this: This, - value: T, - index: number, - array: readonly T[] - ) => value is S, + predicate: (this: This, value: T, index: number, array: this) => value is S, thisArg?: This ): S[]; /** @@ -1533,83 +1526,58 @@ interface ReadonlyArray { * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. */ filter( - predicate: ( - this: This, - value: T, - index: number, - array: readonly T[] - ) => boolean, + predicate: (this: This, value: T, index: number, array: this) => boolean, thisArg?: This ): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduce( - callbackfn: ( - previousValue: T, - currentValue: T, - currentIndex: number, - array: readonly T[] - ) => T - ): T; - reduce( + reduce( callbackfn: ( - previousValue: T, + previousValue: T | U, currentValue: T, currentIndex: number, - array: readonly T[] - ) => T, - initialValue: T - ): T; + array: this + ) => U + ): T | U; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduce( + reduce( callbackfn: ( previousValue: U, currentValue: T, currentIndex: number, - array: readonly T[] + array: this ) => U, initialValue: U ): U; /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduceRight( - callbackfn: ( - previousValue: T, - currentValue: T, - currentIndex: number, - array: readonly T[] - ) => T - ): T; - reduceRight( + reduceRight( callbackfn: ( - previousValue: T, + previousValue: T | U, currentValue: T, currentIndex: number, - array: readonly T[] - ) => T, - initialValue: T - ): T; + array: this + ) => U + ): T | U; /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( previousValue: U, currentValue: T, currentIndex: number, - array: readonly T[] + array: this ) => U, initialValue: U ): U; @@ -1667,6 +1635,32 @@ interface ReadonlyArray { // * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. // */ // filter(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[]; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. +// */ +// reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T; +// reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. +// */ +// reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T; +// reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U; interface ConcatArray { readonly length: number; @@ -1674,6 +1668,7 @@ interface ConcatArray { join(separator?: string): string; slice(start?: number, end?: number): T[]; } + interface Array { /** * Gets or sets the length of the array. This is a number one higher than the highest index in the array. @@ -1751,7 +1746,7 @@ interface Array { * @param deleteCount The number of elements to remove. * @returns An array containing the elements that were deleted. */ - splice(start: number, deleteCount?: number): this; + splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. @@ -1759,7 +1754,7 @@ interface Array { * @param items Elements to insert into the array in place of the deleted elements. * @returns An array containing the elements that were deleted. */ - splice(start: number, deleteCount: number, ...items: T[]): this; + splice(start: number, deleteCount: number, ...items: T[]): T[]; /** * Inserts new elements at the start of an array, and returns the new length of the array. * @param items Elements to insert at the start of the array. @@ -1786,9 +1781,11 @@ interface Array { * If thisArg is omitted, undefined is used as the this value. */ every( - predicate: (this: This, value: T, index: number, array: T[]) => value is S, + predicate: (this: This, value: T, index: number, array: this) => value is S, thisArg?: This - ): this is S[]; + ): this is { + [K in keyof this]: S; + }; /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -1798,7 +1795,7 @@ interface Array { * If thisArg is omitted, undefined is used as the this value. */ every( - predicate: (this: This, value: T, index: number, array: T[]) => boolean, + predicate: (this: This, value: T, index: number, array: this) => boolean, thisArg?: This ): boolean; /** @@ -1810,7 +1807,7 @@ interface Array { * If thisArg is omitted, undefined is used as the this value. */ some( - predicate: (this: This, value: T, index: number, array: T[]) => boolean, + predicate: (this: This, value: T, index: number, array: this) => boolean, thisArg?: This ): boolean; /** @@ -1819,7 +1816,7 @@ interface Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach( - callbackfn: (this: This, value: T, index: number, array: T[]) => void, + callbackfn: (this: This, value: T, index: number, array: this) => void, thisArg?: This ): void; /** @@ -1828,16 +1825,18 @@ interface Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ map( - callbackfn: (this: This, value: T, index: number, array: T[]) => U, + callbackfn: (this: This, value: T, index: number, array: this) => U, thisArg?: This - ): U[]; + ): { + [K in keyof this]: U; + }; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. */ filter( - predicate: (this: This, value: T, index: number, array: T[]) => value is S, + predicate: (this: This, value: T, index: number, array: this) => value is S, thisArg?: This ): S[]; /** @@ -1846,78 +1845,58 @@ interface Array { * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. */ filter( - predicate: (this: This, value: T, index: number, array: T[]) => boolean, + predicate: (this: This, value: T, index: number, array: this) => boolean, thisArg?: This ): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduce( - callbackfn: ( - previousValue: T, - currentValue: T, - currentIndex: number, - array: T[] - ) => T - ): T; - reduce( + reduce( callbackfn: ( - previousValue: T, + previousValue: T | U, currentValue: T, currentIndex: number, - array: T[] - ) => T, - initialValue: T - ): T; + array: this + ) => U + ): T | U; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduce( + reduce( callbackfn: ( previousValue: U, currentValue: T, currentIndex: number, - array: T[] + array: this ) => U, initialValue: U ): U; /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduceRight( - callbackfn: ( - previousValue: T, - currentValue: T, - currentIndex: number, - array: T[] - ) => T - ): T; - reduceRight( + reduceRight( callbackfn: ( - previousValue: T, + previousValue: T | U, currentValue: T, currentIndex: number, - array: T[] - ) => T, - initialValue: T - ): T; + array: this + ) => U + ): T | U; /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( previousValue: U, currentValue: T, currentIndex: number, - array: T[] + array: this ) => U, initialValue: U ): U; @@ -1925,21 +1904,6 @@ interface Array { [n: number]: T; } // /** -// * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. -// * @param start The zero-based location in the array from which to start removing elements. -// * @param deleteCount The number of elements to remove. -// * @returns An array containing the elements that were deleted. -// */ -// splice(start: number, deleteCount?: number): T[]; -// /** -// * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. -// * @param start The zero-based location in the array from which to start removing elements. -// * @param deleteCount The number of elements to remove. -// * @param items Elements to insert into the array in place of the deleted elements. -// * @returns An array containing the elements that were deleted. -// */ -// splice(start: number, deleteCount: number, ...items: T[]): T[]; -// /** // * Determines whether all the members of an array satisfy the specified test. // * @param predicate A function that accepts up to three arguments. The every method calls // * the predicate function for each element in the array until the predicate returns a value @@ -1990,6 +1954,32 @@ interface Array { // * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. // */ // filter(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. +// */ +// reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; +// reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. +// */ +// reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; +// reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; interface ArrayConstructor { new (arrayLength: number): T[]; @@ -2453,7 +2443,6 @@ interface Int8Array { * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): this; - /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -2462,9 +2451,14 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every( - predicate: (value: number, index: number, array: Int8Array) => unknown, - thisArg?: any + every( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -2476,7 +2470,6 @@ interface Int8Array { * length+end. */ fill(value: number, start?: number, end?: number): this; - /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls @@ -2484,11 +2477,15 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter( - predicate: (value: number, index: number, array: Int8Array) => any, - thisArg?: any + filter( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): Int8Array; - /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. @@ -2498,11 +2495,10 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find( - predicate: (value: number, index: number, obj: Int8Array) => boolean, - thisArg?: any + find( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number | undefined; - /** * Returns the index of the first element in the array where predicate is true, and -1 * otherwise. @@ -2512,11 +2508,10 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex( - predicate: (value: number, index: number, obj: Int8Array) => boolean, - thisArg?: any + findIndex( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number; - /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the @@ -2524,9 +2519,9 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach( - callbackfn: (value: number, index: number, array: Int8Array) => void, - thisArg?: any + forEach( + callbackfn: (this: This, value: number, index: number, array: this) => void, + thisArg?: This ): void; /** @@ -2556,7 +2551,6 @@ interface Int8Array { * The length of the array. */ readonly length: number; - /** * Calls a defined callback function on each element of an array, and returns an array that * contains the results. @@ -2565,39 +2559,30 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map( - callbackfn: (value: number, index: number, array: Int8Array) => number, - thisArg?: any + map( + callbackfn: ( + this: This, + value: number, + index: number, + array: this + ) => number, + thisArg?: This ): Int8Array; - /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. */ - reduce( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Int8Array - ) => number - ): number; - reduce( + reduce( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Int8Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next @@ -2608,44 +2593,30 @@ interface Int8Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce( + reduce( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Int8Array + array: this ) => U, initialValue: U ): U; - /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Int8Array - ) => number - ): number; - reduceRight( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Int8Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an @@ -2656,12 +2627,12 @@ interface Int8Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Int8Array + array: this ) => U, initialValue: U ): U; @@ -2684,7 +2655,6 @@ interface Int8Array { * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Int8Array; - /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls @@ -2693,9 +2663,14 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some( - predicate: (value: number, index: number, array: Int8Array) => unknown, - thisArg?: any + some( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -2732,6 +2707,116 @@ interface Int8Array { [index: number]: number; } +// /** +// * Determines whether all the members of an array satisfy the specified test. +// * @param predicate A function that accepts up to three arguments. The every method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value false, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// every(predicate: (value: number, index: number, array: Int8Array) => unknown, thisArg?: any): boolean; +// /** +// * Returns the elements of an array that meet the condition specified in a callback function. +// * @param predicate A function that accepts up to three arguments. The filter method calls +// * the predicate function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// filter(predicate: (value: number, index: number, array: Int8Array) => any, thisArg?: any): Int8Array; +// /** +// * Returns the value of the first element in the array where predicate is true, and undefined +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, find +// * immediately returns that element value. Otherwise, find returns undefined. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// find(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number | undefined; +// /** +// * Returns the index of the first element in the array where predicate is true, and -1 +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, +// * findIndex immediately returns that element index. Otherwise, findIndex returns -1. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// findIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number; +// /** +// * Performs the specified action for each element in an array. +// * @param callbackfn A function that accepts up to three arguments. forEach calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; +// /** +// * Calls a defined callback function on each element of an array, and returns an array that +// * contains the results. +// * @param callbackfn A function that accepts up to three arguments. The map method calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number; +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an +// * argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number; +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; +// /** +// * Determines whether the specified callback function returns true for any element of an array. +// * @param predicate A function that accepts up to three arguments. The some method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value true, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// some(predicate: (value: number, index: number, array: Int8Array) => unknown, thisArg?: any): boolean; + interface Int8ArrayConstructor { readonly prototype: Int8Array; new (length: number): Int8Array; @@ -2752,25 +2837,36 @@ interface Int8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int8Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. */ - from(arrayLike: ArrayLike): Int8Array; - + from(source: ArrayLike): Int8Array; /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: ArrayLike, - mapfn: (v: T, k: number) => number, - thisArg?: any + from( + source: ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Int8Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// */ +// from(arrayLike: ArrayLike): Int8Array; +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; + declare var Int8Array: Int8ArrayConstructor; /** @@ -2808,7 +2904,6 @@ interface Uint8Array { * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): this; - /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -2817,9 +2912,14 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every( - predicate: (value: number, index: number, array: Uint8Array) => unknown, - thisArg?: any + every( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -2831,7 +2931,6 @@ interface Uint8Array { * length+end. */ fill(value: number, start?: number, end?: number): this; - /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls @@ -2839,11 +2938,15 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter( - predicate: (value: number, index: number, array: Uint8Array) => any, - thisArg?: any + filter( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): Uint8Array; - /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. @@ -2853,11 +2956,10 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find( - predicate: (value: number, index: number, obj: Uint8Array) => boolean, - thisArg?: any + find( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number | undefined; - /** * Returns the index of the first element in the array where predicate is true, and -1 * otherwise. @@ -2867,11 +2969,10 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex( - predicate: (value: number, index: number, obj: Uint8Array) => boolean, - thisArg?: any + findIndex( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number; - /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the @@ -2879,9 +2980,9 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach( - callbackfn: (value: number, index: number, array: Uint8Array) => void, - thisArg?: any + forEach( + callbackfn: (this: This, value: number, index: number, array: this) => void, + thisArg?: This ): void; /** @@ -2911,7 +3012,6 @@ interface Uint8Array { * The length of the array. */ readonly length: number; - /** * Calls a defined callback function on each element of an array, and returns an array that * contains the results. @@ -2920,39 +3020,30 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map( - callbackfn: (value: number, index: number, array: Uint8Array) => number, - thisArg?: any + map( + callbackfn: ( + this: This, + value: number, + index: number, + array: this + ) => number, + thisArg?: This ): Uint8Array; - /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. */ - reduce( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Uint8Array - ) => number - ): number; - reduce( + reduce( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Uint8Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next @@ -2963,44 +3054,30 @@ interface Uint8Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce( + reduce( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Uint8Array + array: this ) => U, initialValue: U ): U; - /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. */ - reduceRight( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Uint8Array - ) => number - ): number; - reduceRight( + reduceRight( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Uint8Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an @@ -3011,12 +3088,12 @@ interface Uint8Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Uint8Array + array: this ) => U, initialValue: U ): U; @@ -3039,7 +3116,6 @@ interface Uint8Array { * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Uint8Array; - /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls @@ -3048,14 +3124,19 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some( - predicate: (value: number, index: number, array: Uint8Array) => unknown, - thisArg?: any - ): boolean; - - /** - * Sorts an array. - * @param compareFn Function used to determine the order of the elements. It is expected to return + some( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This + ): boolean; + + /** + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if first argument is less than second argument, zero if they're equal and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts @@ -3087,6 +3168,115 @@ interface Uint8Array { [index: number]: number; } +// /** +// * Determines whether all the members of an array satisfy the specified test. +// * @param predicate A function that accepts up to three arguments. The every method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value false, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// every(predicate: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any): boolean; +// /** +// * Returns the elements of an array that meet the condition specified in a callback function. +// * @param predicate A function that accepts up to three arguments. The filter method calls +// * the predicate function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// filter(predicate: (value: number, index: number, array: Uint8Array) => any, thisArg?: any): Uint8Array; +// /** +// * Returns the value of the first element in the array where predicate is true, and undefined +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, find +// * immediately returns that element value. Otherwise, find returns undefined. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// find(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number | undefined; +// /** +// * Returns the index of the first element in the array where predicate is true, and -1 +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, +// * findIndex immediately returns that element index. Otherwise, findIndex returns -1. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// findIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number; +// /** +// * Performs the specified action for each element in an array. +// * @param callbackfn A function that accepts up to three arguments. forEach calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; +// /** +// * Calls a defined callback function on each element of an array, and returns an array that +// * contains the results. +// * @param callbackfn A function that accepts up to three arguments. The map method calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number; +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an +// * argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number; +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; +// /** +// * Determines whether the specified callback function returns true for any element of an array. +// * @param predicate A function that accepts up to three arguments. The some method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value true, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// some(predicate: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any): boolean; interface Uint8ArrayConstructor { readonly prototype: Uint8Array; @@ -3108,25 +3298,36 @@ interface Uint8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint8Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. */ - from(arrayLike: ArrayLike): Uint8Array; - + from(source: ArrayLike): Uint8Array; /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: ArrayLike, - mapfn: (v: T, k: number) => number, - thisArg?: any + from( + source: ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Uint8Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// */ +// from(arrayLike: ArrayLike): Uint8Array; +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; + declare var Uint8Array: Uint8ArrayConstructor; /** @@ -3164,7 +3365,6 @@ interface Uint8ClampedArray { * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): this; - /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -3173,13 +3373,14 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every( + every( predicate: ( + this: This, value: number, index: number, - array: Uint8ClampedArray - ) => unknown, - thisArg?: any + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -3191,7 +3392,6 @@ interface Uint8ClampedArray { * length+end. */ fill(value: number, start?: number, end?: number): this; - /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls @@ -3199,11 +3399,15 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter( - predicate: (value: number, index: number, array: Uint8ClampedArray) => any, - thisArg?: any + filter( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): Uint8ClampedArray; - /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. @@ -3213,15 +3417,10 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find( - predicate: ( - value: number, - index: number, - obj: Uint8ClampedArray - ) => boolean, - thisArg?: any + find( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number | undefined; - /** * Returns the index of the first element in the array where predicate is true, and -1 * otherwise. @@ -3231,15 +3430,10 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex( - predicate: ( - value: number, - index: number, - obj: Uint8ClampedArray - ) => boolean, - thisArg?: any + findIndex( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number; - /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the @@ -3247,13 +3441,9 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach( - callbackfn: ( - value: number, - index: number, - array: Uint8ClampedArray - ) => void, - thisArg?: any + forEach( + callbackfn: (this: This, value: number, index: number, array: this) => void, + thisArg?: This ): void; /** @@ -3283,7 +3473,6 @@ interface Uint8ClampedArray { * The length of the array. */ readonly length: number; - /** * Calls a defined callback function on each element of an array, and returns an array that * contains the results. @@ -3292,43 +3481,30 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map( + map( callbackfn: ( + this: This, value: number, index: number, - array: Uint8ClampedArray + array: this ) => number, - thisArg?: any + thisArg?: This ): Uint8ClampedArray; - /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. */ - reduce( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Uint8ClampedArray - ) => number - ): number; - reduce( + reduce( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Uint8ClampedArray - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next @@ -3339,44 +3515,30 @@ interface Uint8ClampedArray { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce( + reduce( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Uint8ClampedArray + array: this ) => U, initialValue: U ): U; - /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. */ - reduceRight( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Uint8ClampedArray - ) => number - ): number; - reduceRight( + reduceRight( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Uint8ClampedArray - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an @@ -3387,12 +3549,12 @@ interface Uint8ClampedArray { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Uint8ClampedArray + array: this ) => U, initialValue: U ): U; @@ -3415,7 +3577,6 @@ interface Uint8ClampedArray { * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Uint8ClampedArray; - /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls @@ -3424,13 +3585,14 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some( + some( predicate: ( + this: This, value: number, index: number, - array: Uint8ClampedArray - ) => unknown, - thisArg?: any + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -3467,6 +3629,115 @@ interface Uint8ClampedArray { [index: number]: number; } +// /** +// * Determines whether all the members of an array satisfy the specified test. +// * @param predicate A function that accepts up to three arguments. The every method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value false, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// every(predicate: (value: number, index: number, array: Uint8ClampedArray) => unknown, thisArg?: any): boolean; +// /** +// * Returns the elements of an array that meet the condition specified in a callback function. +// * @param predicate A function that accepts up to three arguments. The filter method calls +// * the predicate function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// filter(predicate: (value: number, index: number, array: Uint8ClampedArray) => any, thisArg?: any): Uint8ClampedArray; +// /** +// * Returns the value of the first element in the array where predicate is true, and undefined +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, find +// * immediately returns that element value. Otherwise, find returns undefined. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// find(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number | undefined; +// /** +// * Returns the index of the first element in the array where predicate is true, and -1 +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, +// * findIndex immediately returns that element index. Otherwise, findIndex returns -1. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// findIndex(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number; +// /** +// * Performs the specified action for each element in an array. +// * @param callbackfn A function that accepts up to three arguments. forEach calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; +// /** +// * Calls a defined callback function on each element of an array, and returns an array that +// * contains the results. +// * @param callbackfn A function that accepts up to three arguments. The map method calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number): number; +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an +// * argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number): number; +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; +// /** +// * Determines whether the specified callback function returns true for any element of an array. +// * @param predicate A function that accepts up to three arguments. The some method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value true, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// some(predicate: (value: number, index: number, array: Uint8ClampedArray) => unknown, thisArg?: any): boolean; interface Uint8ClampedArrayConstructor { readonly prototype: Uint8ClampedArray; @@ -3488,25 +3759,36 @@ interface Uint8ClampedArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint8ClampedArray; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. */ - from(arrayLike: ArrayLike): Uint8ClampedArray; - + from(source: ArrayLike): Uint8ClampedArray; /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: ArrayLike, - mapfn: (v: T, k: number) => number, - thisArg?: any + from( + source: ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Uint8ClampedArray; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// */ +// from(arrayLike: ArrayLike): Uint8ClampedArray; +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; + declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** @@ -3544,7 +3826,6 @@ interface Int16Array { * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): this; - /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -3553,9 +3834,14 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every( - predicate: (value: number, index: number, array: Int16Array) => unknown, - thisArg?: any + every( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -3567,7 +3853,6 @@ interface Int16Array { * length+end. */ fill(value: number, start?: number, end?: number): this; - /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls @@ -3575,11 +3860,15 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter( - predicate: (value: number, index: number, array: Int16Array) => any, - thisArg?: any + filter( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): Int16Array; - /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. @@ -3589,11 +3878,10 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find( - predicate: (value: number, index: number, obj: Int16Array) => boolean, - thisArg?: any + find( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number | undefined; - /** * Returns the index of the first element in the array where predicate is true, and -1 * otherwise. @@ -3603,11 +3891,10 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex( - predicate: (value: number, index: number, obj: Int16Array) => boolean, - thisArg?: any + findIndex( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number; - /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the @@ -3615,9 +3902,9 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach( - callbackfn: (value: number, index: number, array: Int16Array) => void, - thisArg?: any + forEach( + callbackfn: (this: This, value: number, index: number, array: this) => void, + thisArg?: This ): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3646,7 +3933,6 @@ interface Int16Array { * The length of the array. */ readonly length: number; - /** * Calls a defined callback function on each element of an array, and returns an array that * contains the results. @@ -3655,39 +3941,30 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map( - callbackfn: (value: number, index: number, array: Int16Array) => number, - thisArg?: any + map( + callbackfn: ( + this: This, + value: number, + index: number, + array: this + ) => number, + thisArg?: This ): Int16Array; - /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. */ - reduce( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Int16Array - ) => number - ): number; - reduce( + reduce( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Int16Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next @@ -3698,44 +3975,30 @@ interface Int16Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce( + reduce( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Int16Array + array: this ) => U, initialValue: U ): U; - /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. */ - reduceRight( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Int16Array - ) => number - ): number; - reduceRight( + reduceRight( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Int16Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an @@ -3746,12 +4009,12 @@ interface Int16Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Int16Array + array: this ) => U, initialValue: U ): U; @@ -3774,7 +4037,6 @@ interface Int16Array { * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Int16Array; - /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls @@ -3783,9 +4045,14 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some( - predicate: (value: number, index: number, array: Int16Array) => unknown, - thisArg?: any + some( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -3822,6 +4089,115 @@ interface Int16Array { [index: number]: number; } +// /** +// * Determines whether all the members of an array satisfy the specified test. +// * @param predicate A function that accepts up to three arguments. The every method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value false, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// every(predicate: (value: number, index: number, array: Int16Array) => unknown, thisArg?: any): boolean; +// /** +// * Returns the elements of an array that meet the condition specified in a callback function. +// * @param predicate A function that accepts up to three arguments. The filter method calls +// * the predicate function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// filter(predicate: (value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; +// /** +// * Returns the value of the first element in the array where predicate is true, and undefined +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, find +// * immediately returns that element value. Otherwise, find returns undefined. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// find(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number | undefined; +// /** +// * Returns the index of the first element in the array where predicate is true, and -1 +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, +// * findIndex immediately returns that element index. Otherwise, findIndex returns -1. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// findIndex(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number; +// /** +// * Performs the specified action for each element in an array. +// * @param callbackfn A function that accepts up to three arguments. forEach calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; +// /** +// * Calls a defined callback function on each element of an array, and returns an array that +// * contains the results. +// * @param callbackfn A function that accepts up to three arguments. The map method calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number; +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an +// * argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number; +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; +// /** +// * Determines whether the specified callback function returns true for any element of an array. +// * @param predicate A function that accepts up to three arguments. The some method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value true, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// some(predicate: (value: number, index: number, array: Int16Array) => unknown, thisArg?: any): boolean; interface Int16ArrayConstructor { readonly prototype: Int16Array; @@ -3843,25 +4219,36 @@ interface Int16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int16Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. */ - from(arrayLike: ArrayLike): Int16Array; - + from(source: ArrayLike): Int16Array; /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: ArrayLike, - mapfn: (v: T, k: number) => number, - thisArg?: any + from( + source: ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Int16Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// */ +// from(arrayLike: ArrayLike): Int16Array; +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; + declare var Int16Array: Int16ArrayConstructor; /** @@ -3899,7 +4286,6 @@ interface Uint16Array { * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): this; - /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -3908,9 +4294,14 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every( - predicate: (value: number, index: number, array: Uint16Array) => unknown, - thisArg?: any + every( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -3922,7 +4313,6 @@ interface Uint16Array { * length+end. */ fill(value: number, start?: number, end?: number): this; - /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls @@ -3930,11 +4320,15 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter( - predicate: (value: number, index: number, array: Uint16Array) => any, - thisArg?: any + filter( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): Uint16Array; - /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. @@ -3944,11 +4338,10 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find( - predicate: (value: number, index: number, obj: Uint16Array) => boolean, - thisArg?: any + find( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number | undefined; - /** * Returns the index of the first element in the array where predicate is true, and -1 * otherwise. @@ -3958,11 +4351,10 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex( - predicate: (value: number, index: number, obj: Uint16Array) => boolean, - thisArg?: any + findIndex( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number; - /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the @@ -3970,9 +4362,9 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach( - callbackfn: (value: number, index: number, array: Uint16Array) => void, - thisArg?: any + forEach( + callbackfn: (this: This, value: number, index: number, array: this) => void, + thisArg?: This ): void; /** @@ -4002,7 +4394,6 @@ interface Uint16Array { * The length of the array. */ readonly length: number; - /** * Calls a defined callback function on each element of an array, and returns an array that * contains the results. @@ -4011,39 +4402,30 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map( - callbackfn: (value: number, index: number, array: Uint16Array) => number, - thisArg?: any + map( + callbackfn: ( + this: This, + value: number, + index: number, + array: this + ) => number, + thisArg?: This ): Uint16Array; - /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. */ - reduce( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Uint16Array - ) => number - ): number; - reduce( + reduce( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Uint16Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next @@ -4054,44 +4436,30 @@ interface Uint16Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce( + reduce( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Uint16Array + array: this ) => U, initialValue: U ): U; - /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. */ - reduceRight( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Uint16Array - ) => number - ): number; - reduceRight( + reduceRight( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Uint16Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an @@ -4102,12 +4470,12 @@ interface Uint16Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Uint16Array + array: this ) => U, initialValue: U ): U; @@ -4130,7 +4498,6 @@ interface Uint16Array { * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Uint16Array; - /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls @@ -4139,9 +4506,14 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some( - predicate: (value: number, index: number, array: Uint16Array) => unknown, - thisArg?: any + some( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -4178,6 +4550,115 @@ interface Uint16Array { [index: number]: number; } +// /** +// * Determines whether all the members of an array satisfy the specified test. +// * @param predicate A function that accepts up to three arguments. The every method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value false, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// every(predicate: (value: number, index: number, array: Uint16Array) => unknown, thisArg?: any): boolean; +// /** +// * Returns the elements of an array that meet the condition specified in a callback function. +// * @param predicate A function that accepts up to three arguments. The filter method calls +// * the predicate function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// filter(predicate: (value: number, index: number, array: Uint16Array) => any, thisArg?: any): Uint16Array; +// /** +// * Returns the value of the first element in the array where predicate is true, and undefined +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, find +// * immediately returns that element value. Otherwise, find returns undefined. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// find(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number | undefined; +// /** +// * Returns the index of the first element in the array where predicate is true, and -1 +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, +// * findIndex immediately returns that element index. Otherwise, findIndex returns -1. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// findIndex(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number; +// /** +// * Performs the specified action for each element in an array. +// * @param callbackfn A function that accepts up to three arguments. forEach calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; +// /** +// * Calls a defined callback function on each element of an array, and returns an array that +// * contains the results. +// * @param callbackfn A function that accepts up to three arguments. The map method calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number; +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an +// * argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number; +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; +// /** +// * Determines whether the specified callback function returns true for any element of an array. +// * @param predicate A function that accepts up to three arguments. The some method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value true, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// some(predicate: (value: number, index: number, array: Uint16Array) => unknown, thisArg?: any): boolean; interface Uint16ArrayConstructor { readonly prototype: Uint16Array; @@ -4199,25 +4680,36 @@ interface Uint16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint16Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. */ - from(arrayLike: ArrayLike): Uint16Array; - + from(source: ArrayLike): Uint16Array; /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: ArrayLike, - mapfn: (v: T, k: number) => number, - thisArg?: any + from( + source: ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Uint16Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// */ +// from(arrayLike: ArrayLike): Uint16Array; +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; + declare var Uint16Array: Uint16ArrayConstructor; /** * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the @@ -4254,7 +4746,6 @@ interface Int32Array { * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): this; - /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -4263,9 +4754,14 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every( - predicate: (value: number, index: number, array: Int32Array) => unknown, - thisArg?: any + every( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -4277,7 +4773,6 @@ interface Int32Array { * length+end. */ fill(value: number, start?: number, end?: number): this; - /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls @@ -4285,11 +4780,15 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter( - predicate: (value: number, index: number, array: Int32Array) => any, - thisArg?: any + filter( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): Int32Array; - /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. @@ -4299,11 +4798,10 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find( - predicate: (value: number, index: number, obj: Int32Array) => boolean, - thisArg?: any + find( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number | undefined; - /** * Returns the index of the first element in the array where predicate is true, and -1 * otherwise. @@ -4313,11 +4811,10 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex( - predicate: (value: number, index: number, obj: Int32Array) => boolean, - thisArg?: any + findIndex( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number; - /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the @@ -4325,9 +4822,9 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach( - callbackfn: (value: number, index: number, array: Int32Array) => void, - thisArg?: any + forEach( + callbackfn: (this: This, value: number, index: number, array: this) => void, + thisArg?: This ): void; /** @@ -4357,7 +4854,6 @@ interface Int32Array { * The length of the array. */ readonly length: number; - /** * Calls a defined callback function on each element of an array, and returns an array that * contains the results. @@ -4366,39 +4862,30 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map( - callbackfn: (value: number, index: number, array: Int32Array) => number, - thisArg?: any + map( + callbackfn: ( + this: This, + value: number, + index: number, + array: this + ) => number, + thisArg?: This ): Int32Array; - /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. */ - reduce( + reduce( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Int32Array - ) => number - ): number; - reduce( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Int32Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next @@ -4409,44 +4896,30 @@ interface Int32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce( + reduce( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Int32Array + array: this ) => U, initialValue: U ): U; - /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. */ - reduceRight( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Int32Array - ) => number - ): number; - reduceRight( + reduceRight( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Int32Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an @@ -4457,12 +4930,12 @@ interface Int32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Int32Array + array: this ) => U, initialValue: U ): U; @@ -4485,7 +4958,6 @@ interface Int32Array { * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Int32Array; - /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls @@ -4494,9 +4966,14 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some( - predicate: (value: number, index: number, array: Int32Array) => unknown, - thisArg?: any + some( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -4533,6 +5010,115 @@ interface Int32Array { [index: number]: number; } +// /** +// * Determines whether all the members of an array satisfy the specified test. +// * @param predicate A function that accepts up to three arguments. The every method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value false, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// every(predicate: (value: number, index: number, array: Int32Array) => unknown, thisArg?: any): boolean; +// /** +// * Returns the elements of an array that meet the condition specified in a callback function. +// * @param predicate A function that accepts up to three arguments. The filter method calls +// * the predicate function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// filter(predicate: (value: number, index: number, array: Int32Array) => any, thisArg?: any): Int32Array; +// /** +// * Returns the value of the first element in the array where predicate is true, and undefined +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, find +// * immediately returns that element value. Otherwise, find returns undefined. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// find(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number | undefined; +// /** +// * Returns the index of the first element in the array where predicate is true, and -1 +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, +// * findIndex immediately returns that element index. Otherwise, findIndex returns -1. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// findIndex(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number; +// /** +// * Performs the specified action for each element in an array. +// * @param callbackfn A function that accepts up to three arguments. forEach calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; +// /** +// * Calls a defined callback function on each element of an array, and returns an array that +// * contains the results. +// * @param callbackfn A function that accepts up to three arguments. The map method calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number; +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an +// * argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number; +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; +// /** +// * Determines whether the specified callback function returns true for any element of an array. +// * @param predicate A function that accepts up to three arguments. The some method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value true, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// some(predicate: (value: number, index: number, array: Int32Array) => unknown, thisArg?: any): boolean; interface Int32ArrayConstructor { readonly prototype: Int32Array; @@ -4554,25 +5140,36 @@ interface Int32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int32Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. */ - from(arrayLike: ArrayLike): Int32Array; - + from(source: ArrayLike): Int32Array; /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: ArrayLike, - mapfn: (v: T, k: number) => number, - thisArg?: any + from( + source: ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Int32Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// */ +// from(arrayLike: ArrayLike): Int32Array; +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; + declare var Int32Array: Int32ArrayConstructor; /** @@ -4610,7 +5207,6 @@ interface Uint32Array { * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): this; - /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -4619,9 +5215,14 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every( - predicate: (value: number, index: number, array: Uint32Array) => unknown, - thisArg?: any + every( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -4633,7 +5234,6 @@ interface Uint32Array { * length+end. */ fill(value: number, start?: number, end?: number): this; - /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls @@ -4641,11 +5241,15 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter( - predicate: (value: number, index: number, array: Uint32Array) => any, - thisArg?: any + filter( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): Uint32Array; - /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. @@ -4655,11 +5259,10 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find( - predicate: (value: number, index: number, obj: Uint32Array) => boolean, - thisArg?: any + find( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number | undefined; - /** * Returns the index of the first element in the array where predicate is true, and -1 * otherwise. @@ -4669,11 +5272,10 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex( - predicate: (value: number, index: number, obj: Uint32Array) => boolean, - thisArg?: any + findIndex( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number; - /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the @@ -4681,9 +5283,9 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach( - callbackfn: (value: number, index: number, array: Uint32Array) => void, - thisArg?: any + forEach( + callbackfn: (this: This, value: number, index: number, array: this) => void, + thisArg?: This ): void; /** * Returns the index of the first occurrence of a value in an array. @@ -4712,7 +5314,6 @@ interface Uint32Array { * The length of the array. */ readonly length: number; - /** * Calls a defined callback function on each element of an array, and returns an array that * contains the results. @@ -4721,39 +5322,30 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map( - callbackfn: (value: number, index: number, array: Uint32Array) => number, - thisArg?: any + map( + callbackfn: ( + this: This, + value: number, + index: number, + array: this + ) => number, + thisArg?: This ): Uint32Array; - /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. */ - reduce( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Uint32Array - ) => number - ): number; - reduce( + reduce( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Uint32Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next @@ -4764,44 +5356,30 @@ interface Uint32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce( + reduce( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Uint32Array + array: this ) => U, initialValue: U ): U; - /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. */ - reduceRight( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Uint32Array - ) => number - ): number; - reduceRight( + reduceRight( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Uint32Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an @@ -4812,12 +5390,12 @@ interface Uint32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Uint32Array + array: this ) => U, initialValue: U ): U; @@ -4840,7 +5418,6 @@ interface Uint32Array { * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Uint32Array; - /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls @@ -4849,9 +5426,14 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some( - predicate: (value: number, index: number, array: Uint32Array) => unknown, - thisArg?: any + some( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -4888,6 +5470,115 @@ interface Uint32Array { [index: number]: number; } +// /** +// * Determines whether all the members of an array satisfy the specified test. +// * @param predicate A function that accepts up to three arguments. The every method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value false, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// every(predicate: (value: number, index: number, array: Uint32Array) => unknown, thisArg?: any): boolean; +// /** +// * Returns the elements of an array that meet the condition specified in a callback function. +// * @param predicate A function that accepts up to three arguments. The filter method calls +// * the predicate function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// filter(predicate: (value: number, index: number, array: Uint32Array) => any, thisArg?: any): Uint32Array; +// /** +// * Returns the value of the first element in the array where predicate is true, and undefined +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, find +// * immediately returns that element value. Otherwise, find returns undefined. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// find(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number | undefined; +// /** +// * Returns the index of the first element in the array where predicate is true, and -1 +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, +// * findIndex immediately returns that element index. Otherwise, findIndex returns -1. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// findIndex(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number; +// /** +// * Performs the specified action for each element in an array. +// * @param callbackfn A function that accepts up to three arguments. forEach calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; +// /** +// * Calls a defined callback function on each element of an array, and returns an array that +// * contains the results. +// * @param callbackfn A function that accepts up to three arguments. The map method calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number; +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an +// * argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number; +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; +// /** +// * Determines whether the specified callback function returns true for any element of an array. +// * @param predicate A function that accepts up to three arguments. The some method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value true, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// some(predicate: (value: number, index: number, array: Uint32Array) => unknown, thisArg?: any): boolean; interface Uint32ArrayConstructor { readonly prototype: Uint32Array; @@ -4909,25 +5600,36 @@ interface Uint32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint32Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. */ - from(arrayLike: ArrayLike): Uint32Array; - + from(source: ArrayLike): Uint32Array; /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: ArrayLike, - mapfn: (v: T, k: number) => number, - thisArg?: any + from( + source: ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Uint32Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// */ +// from(arrayLike: ArrayLike): Uint32Array; +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; + declare var Uint32Array: Uint32ArrayConstructor; /** @@ -4965,7 +5667,6 @@ interface Float32Array { * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): this; - /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -4974,9 +5675,14 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every( - predicate: (value: number, index: number, array: Float32Array) => unknown, - thisArg?: any + every( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -4988,7 +5694,6 @@ interface Float32Array { * length+end. */ fill(value: number, start?: number, end?: number): this; - /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls @@ -4996,11 +5701,15 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter( - predicate: (value: number, index: number, array: Float32Array) => any, - thisArg?: any + filter( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): Float32Array; - /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. @@ -5010,11 +5719,10 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find( - predicate: (value: number, index: number, obj: Float32Array) => boolean, - thisArg?: any + find( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number | undefined; - /** * Returns the index of the first element in the array where predicate is true, and -1 * otherwise. @@ -5024,11 +5732,10 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex( - predicate: (value: number, index: number, obj: Float32Array) => boolean, - thisArg?: any + findIndex( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number; - /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the @@ -5036,9 +5743,9 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach( - callbackfn: (value: number, index: number, array: Float32Array) => void, - thisArg?: any + forEach( + callbackfn: (this: This, value: number, index: number, array: this) => void, + thisArg?: This ): void; /** @@ -5068,7 +5775,6 @@ interface Float32Array { * The length of the array. */ readonly length: number; - /** * Calls a defined callback function on each element of an array, and returns an array that * contains the results. @@ -5077,39 +5783,30 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map( - callbackfn: (value: number, index: number, array: Float32Array) => number, - thisArg?: any + map( + callbackfn: ( + this: This, + value: number, + index: number, + array: this + ) => number, + thisArg?: This ): Float32Array; - /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. */ - reduce( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Float32Array - ) => number - ): number; - reduce( + reduce( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Float32Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next @@ -5120,44 +5817,30 @@ interface Float32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce( + reduce( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Float32Array + array: this ) => U, initialValue: U ): U; - /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. */ - reduceRight( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Float32Array - ) => number - ): number; - reduceRight( + reduceRight( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Float32Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an @@ -5168,12 +5851,12 @@ interface Float32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Float32Array + array: this ) => U, initialValue: U ): U; @@ -5196,7 +5879,6 @@ interface Float32Array { * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Float32Array; - /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls @@ -5205,9 +5887,14 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some( - predicate: (value: number, index: number, array: Float32Array) => unknown, - thisArg?: any + some( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -5244,6 +5931,115 @@ interface Float32Array { [index: number]: number; } +// /** +// * Determines whether all the members of an array satisfy the specified test. +// * @param predicate A function that accepts up to three arguments. The every method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value false, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// every(predicate: (value: number, index: number, array: Float32Array) => unknown, thisArg?: any): boolean; +// /** +// * Returns the elements of an array that meet the condition specified in a callback function. +// * @param predicate A function that accepts up to three arguments. The filter method calls +// * the predicate function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// filter(predicate: (value: number, index: number, array: Float32Array) => any, thisArg?: any): Float32Array; +// /** +// * Returns the value of the first element in the array where predicate is true, and undefined +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, find +// * immediately returns that element value. Otherwise, find returns undefined. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// find(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number | undefined; +// /** +// * Returns the index of the first element in the array where predicate is true, and -1 +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, +// * findIndex immediately returns that element index. Otherwise, findIndex returns -1. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// findIndex(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number; +// /** +// * Performs the specified action for each element in an array. +// * @param callbackfn A function that accepts up to three arguments. forEach calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; +// /** +// * Calls a defined callback function on each element of an array, and returns an array that +// * contains the results. +// * @param callbackfn A function that accepts up to three arguments. The map method calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number; +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an +// * argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number; +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; +// /** +// * Determines whether the specified callback function returns true for any element of an array. +// * @param predicate A function that accepts up to three arguments. The some method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value true, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// some(predicate: (value: number, index: number, array: Float32Array) => unknown, thisArg?: any): boolean; interface Float32ArrayConstructor { readonly prototype: Float32Array; @@ -5265,25 +6061,36 @@ interface Float32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float32Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. */ - from(arrayLike: ArrayLike): Float32Array; - + from(source: ArrayLike): Float32Array; /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: ArrayLike, - mapfn: (v: T, k: number) => number, - thisArg?: any + from( + source: ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Float32Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// */ +// from(arrayLike: ArrayLike): Float32Array; +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; + declare var Float32Array: Float32ArrayConstructor; /** @@ -5321,7 +6128,6 @@ interface Float64Array { * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): this; - /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -5330,9 +6136,14 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every( - predicate: (value: number, index: number, array: Float64Array) => unknown, - thisArg?: any + every( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -5344,7 +6155,6 @@ interface Float64Array { * length+end. */ fill(value: number, start?: number, end?: number): this; - /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls @@ -5352,11 +6162,15 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter( - predicate: (value: number, index: number, array: Float64Array) => any, - thisArg?: any + filter( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): Float64Array; - /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. @@ -5366,11 +6180,10 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find( - predicate: (value: number, index: number, obj: Float64Array) => boolean, - thisArg?: any + find( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number | undefined; - /** * Returns the index of the first element in the array where predicate is true, and -1 * otherwise. @@ -5380,11 +6193,10 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex( - predicate: (value: number, index: number, obj: Float64Array) => boolean, - thisArg?: any + findIndex( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This ): number; - /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the @@ -5392,9 +6204,9 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach( - callbackfn: (value: number, index: number, array: Float64Array) => void, - thisArg?: any + forEach( + callbackfn: (this: This, value: number, index: number, array: this) => void, + thisArg?: This ): void; /** @@ -5424,7 +6236,6 @@ interface Float64Array { * The length of the array. */ readonly length: number; - /** * Calls a defined callback function on each element of an array, and returns an array that * contains the results. @@ -5433,39 +6244,30 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map( - callbackfn: (value: number, index: number, array: Float64Array) => number, - thisArg?: any + map( + callbackfn: ( + this: This, + value: number, + index: number, + array: this + ) => number, + thisArg?: This ): Float64Array; - /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. */ - reduce( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Float64Array - ) => number - ): number; - reduce( + reduce( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Float64Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next @@ -5476,44 +6278,30 @@ interface Float64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce( + reduce( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Float64Array + array: this ) => U, initialValue: U ): U; - /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. */ - reduceRight( - callbackfn: ( - previousValue: number, - currentValue: number, - currentIndex: number, - array: Float64Array - ) => number - ): number; - reduceRight( + reduceRight( callbackfn: ( - previousValue: number, + previousValue: number | U, currentValue: number, currentIndex: number, - array: Float64Array - ) => number, - initialValue: number - ): number; - + array: this + ) => U + ): number | U; /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an @@ -5524,12 +6312,12 @@ interface Float64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight( + reduceRight( callbackfn: ( previousValue: U, currentValue: number, currentIndex: number, - array: Float64Array + array: this ) => U, initialValue: U ): U; @@ -5552,7 +6340,6 @@ interface Float64Array { * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Float64Array; - /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls @@ -5561,9 +6348,14 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some( - predicate: (value: number, index: number, array: Float64Array) => unknown, - thisArg?: any + some( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This ): boolean; /** @@ -5591,6 +6383,115 @@ interface Float64Array { [index: number]: number; } +// /** +// * Determines whether all the members of an array satisfy the specified test. +// * @param predicate A function that accepts up to three arguments. The every method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value false, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// every(predicate: (value: number, index: number, array: Float64Array) => unknown, thisArg?: any): boolean; +// /** +// * Returns the elements of an array that meet the condition specified in a callback function. +// * @param predicate A function that accepts up to three arguments. The filter method calls +// * the predicate function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// filter(predicate: (value: number, index: number, array: Float64Array) => any, thisArg?: any): Float64Array; +// /** +// * Returns the value of the first element in the array where predicate is true, and undefined +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, find +// * immediately returns that element value. Otherwise, find returns undefined. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// find(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number | undefined; +// /** +// * Returns the index of the first element in the array where predicate is true, and -1 +// * otherwise. +// * @param predicate find calls predicate once for each element of the array, in ascending +// * order, until it finds one where predicate returns true. If such an element is found, +// * findIndex immediately returns that element index. Otherwise, findIndex returns -1. +// * @param thisArg If provided, it will be used as the this value for each invocation of +// * predicate. If it is not provided, undefined is used instead. +// */ +// findIndex(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number; +// /** +// * Performs the specified action for each element in an array. +// * @param callbackfn A function that accepts up to three arguments. forEach calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; +// /** +// * Calls a defined callback function on each element of an array, and returns an array that +// * contains the results. +// * @param callbackfn A function that accepts up to three arguments. The map method calls the +// * callbackfn function one time for each element in the array. +// * @param thisArg An object to which the this keyword can refer in the callbackfn function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number; +// reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array. The return value of +// * the callback function is the accumulated result, and is provided as an argument in the next +// * call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduce method calls the +// * callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an +// * argument instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number; +// reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue: number): number; +// /** +// * Calls the specified callback function for all the elements in an array, in descending order. +// * The return value of the callback function is the accumulated result, and is provided as an +// * argument in the next call to the callback function. +// * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls +// * the callbackfn function one time for each element in the array. +// * @param initialValue If initialValue is specified, it is used as the initial value to start +// * the accumulation. The first call to the callbackfn function provides this value as an argument +// * instead of an array value. +// */ +// reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; +// /** +// * Determines whether the specified callback function returns true for any element of an array. +// * @param predicate A function that accepts up to three arguments. The some method calls +// * the predicate function for each element in the array until the predicate returns a value +// * which is coercible to the Boolean value true, or until the end of the array. +// * @param thisArg An object to which the this keyword can refer in the predicate function. +// * If thisArg is omitted, undefined is used as the this value. +// */ +// some(predicate: (value: number, index: number, array: Float64Array) => unknown, thisArg?: any): boolean; interface Float64ArrayConstructor { readonly prototype: Float64Array; @@ -5612,25 +6513,36 @@ interface Float64ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float64Array; - /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. */ - from(arrayLike: ArrayLike): Float64Array; - + from(source: ArrayLike): Float64Array; /** * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. + * @param source An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from( - arrayLike: ArrayLike, - mapfn: (v: T, k: number) => number, - thisArg?: any + from( + source: ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This ): Float64Array; } +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// */ +// from(arrayLike: ArrayLike): Float64Array; +// /** +// * Creates an array from an array-like or iterable object. +// * @param arrayLike An array-like or iterable object to convert to an array. +// * @param mapfn A mapping function to call on every element of the array. +// * @param thisArg Value of 'this' used to invoke the mapfn. +// */ +// from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; + declare var Float64Array: Float64ArrayConstructor; ///////////////////////////// @@ -5764,6 +6676,7 @@ declare namespace Intl { ): string[]; }; } + interface String { /** * Determines whether two strings are equivalent in the current or specified locale. @@ -5829,6 +6742,8 @@ type UnionToIntersection = ( ? F : unknown; +type CheckNonNullable = [T] extends [NonNullable] ? U : never; + type JSONValue = | null | string diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index 7891008..e409e66 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -1,6 +1,6 @@ interface Map { forEach( - callbackfn: (this: This, value: V, key: K, map: Map) => void, + callbackfn: (this: This, value: V, key: K, map: this) => void, thisArg?: This ): void; } @@ -19,14 +19,14 @@ interface WeakMapConstructor { interface ReadonlyMap { forEach( - callbackfn: (this: This, value: V, key: K, map: ReadonlyMap) => void, + callbackfn: (this: This, value: V, key: K, map: this) => void, thisArg?: This ): void; } interface Set { forEach( - callbackfn: (this: This, value: T, value2: T, set: Set) => void, + callbackfn: (this: This, value: T, value2: T, set: this) => void, thisArg?: This ): void; } @@ -38,7 +38,7 @@ interface SetConstructor { interface ReadonlySet { forEach( - callbackfn: (this: This, value: T, value2: T, set: ReadonlySet) => void, + callbackfn: (this: This, value: T, value2: T, set: this) => void, thisArg?: This ): void; } diff --git a/lib/lib.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index 3ae840c..98855ab 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -1,3 +1,67 @@ +interface Array { + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find( + predicate: (this: This, value: T, index: number, obj: this) => value is S, + thisArg?: This + ): S | undefined; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find( + predicate: (this: This, value: T, index: number, obj: this) => boolean, + thisArg?: This + ): T | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex( + predicate: (this: This, value: T, index: number, obj: this) => boolean, + thisArg?: This + ): number; +} + +interface ArrayConstructor { + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. + */ + from(source: ArrayLike): T[]; + + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from( + source: ArrayLike, + mapfn: (this: This, v: T, k: number) => U, + thisArg?: This + ): U[]; +} + interface NumberConstructor { /** * Returns true if passed value is finite. @@ -38,7 +102,10 @@ interface ObjectConstructor { assign( target: T, ...sources: Ts - ): First>; + ): CheckNonNullable< + T, + First> + >; /** * Returns true if the values are the same value, false otherwise. @@ -62,6 +129,50 @@ interface ObjectConstructor { setPrototypeOf(o: T, proto: null): T; } +interface ReadonlyArray { + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find( + predicate: (this: This, value: T, index: number, obj: this) => value is S, + thisArg?: This + ): S | undefined; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find( + predicate: (this: This, value: T, index: number, obj: this) => boolean, + thisArg?: This + ): T | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex( + predicate: (this: This, value: T, index: number, obj: this) => boolean, + thisArg?: This + ): number; +} + interface String { /** * Returns the String value result of normalizing the string into the normalization form diff --git a/lib/lib.es2015.iterable.d.ts b/lib/lib.es2015.iterable.d.ts index de382cc..fbb06b4 100644 --- a/lib/lib.es2015.iterable.d.ts +++ b/lib/lib.es2015.iterable.d.ts @@ -9,6 +9,26 @@ interface IterableIterator extends Iterator { [Symbol.iterator](): IterableIterator; } +interface ArrayConstructor { + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. + */ + from(source: Iterable | ArrayLike): T[]; + + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from( + source: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => U, + thisArg?: This + ): U[]; +} + interface IArguments { /** Iterator */ [Symbol.iterator](): IterableIterator; @@ -35,3 +55,22 @@ interface PromiseConstructor { interface MapConstructor { new (iterable?: Iterable | null): Map; } + +interface TypedNumberArrayConstructor { + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. + */ + from(source: Iterable | ArrayLike): TypedNumberArray; + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from( + source: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This + ): TypedNumberArray; +} diff --git a/lib/lib.es2017.object.d.ts b/lib/lib.es2017.object.d.ts index 81fbf03..9de9db4 100644 --- a/lib/lib.es2017.object.d.ts +++ b/lib/lib.es2017.object.d.ts @@ -13,7 +13,7 @@ interface ObjectConstructor { * Returns an array of values of the enumerable properties of an object * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ - values(o: unknown): unknown[]; + values(o: T): CheckNonNullable; /** * Returns an array of key/values of the enumerable properties of an object @@ -29,5 +29,16 @@ interface ObjectConstructor { * Returns an array of key/values of the enumerable properties of an object * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ - entries(o: T): [string, unknown][]; + entries(o: T): CheckNonNullable; + + /** + * Returns an object containing all own property descriptors of an object + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + getOwnPropertyDescriptors(o: T): CheckNonNullable< + T, + { [P in keyof T]: TypedPropertyDescriptor } & { + [x: string]: PropertyDescriptor; + } + >; } diff --git a/lib/lib.es2020.bigint.d.ts b/lib/lib.es2020.bigint.d.ts new file mode 100644 index 0000000..bd161ab --- /dev/null +++ b/lib/lib.es2020.bigint.d.ts @@ -0,0 +1,203 @@ +interface TypedBigIntArray { + /** + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ + every( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This + ): boolean; + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This + ): TypedBigIntArray; + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This + ): bigint | undefined; + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This + ): number; + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach( + callbackfn: (this: This, value: bigint, index: number, array: this) => void, + thisArg?: This + ): void; + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map( + callbackfn: ( + this: This, + value: bigint, + index: number, + array: this + ) => bigint, + thisArg?: This + ): TypedBigIntArray; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + */ + reduce( + callbackfn: ( + previousValue: bigint | U, + currentValue: bigint, + currentIndex: number, + array: this + ) => U + ): bigint | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce( + callbackfn: ( + previousValue: U, + currentValue: bigint, + currentIndex: number, + array: this + ) => U, + initialValue: U + ): U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + */ + reduceRight( + callbackfn: ( + previousValue: bigint | U, + currentValue: bigint, + currentIndex: number, + array: this + ) => U + ): bigint | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight( + callbackfn: ( + previousValue: U, + currentValue: bigint, + currentIndex: number, + array: this + ) => U, + initialValue: U + ): U; + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls the + * predicate function for each element in the array until the predicate returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ + some( + predicate: ( + this: This, + value: bigint, + index: number, + array: this + ) => boolean, + thisArg?: This + ): boolean; +} + +interface TypedBigIntArrayConstructor { + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ + from(arrayLike: Iterable | ArrayLike): TypedBigIntArray; + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from( + arrayLike: Iterable | ArrayLike, + mapfn: (this: This, v: T, k: number) => bigint, + thisArg?: This + ): TypedBigIntArray; +} diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index d7d4350..0d9d716 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -6,6 +6,8 @@ type UnionToIntersection = ( ? F : unknown; +type CheckNonNullable = [T] extends [NonNullable] ? U : never; + /** * Evaluates JavaScript code and executes it. * @param x A String value that contains valid JavaScript code. @@ -39,14 +41,25 @@ interface ObjectConstructor { * Returns the prototype of an object. * @param o The object that references the prototype. */ - getPrototypeOf(o: any): unknown; + getPrototypeOf(o: T): CheckNonNullable; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor( + o: T, + p: PropertyKey + ): CheckNonNullable; /** * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. * @param o Object that contains the own properties. */ - getOwnPropertyNames(o: O): O extends undefined | null ? never : string[]; + getOwnPropertyNames(o: T): CheckNonNullable; /** * Creates an object that has the specified prototype or that has null prototype. @@ -156,34 +169,6 @@ interface CallableFunction extends Function { } interface NewableFunction extends Function { - /** - * Calls the function with the specified object as the this value and the elements of specified array as the arguments. - * @param thisArg The object to be used as the this object. - */ - apply(this: new () => T, thisArg: T): void; - - /** - * Calls the function with the specified object as the this value and the elements of specified array as the arguments. - * @param thisArg The object to be used as the this object. - * @param args An array of argument values to be passed to the function. - */ - apply( - this: new (...args: A) => T, - thisArg: T, - args: A - ): void; - - /** - * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. - * @param thisArg The object to be used as the this object. - * @param args Argument values to be passed to the function. - */ - call( - this: new (...args: A) => T, - thisArg: T, - ...args: A - ): void; - /** * For a given function, creates a bound function that has the same body as the original function. * The this object of the bound function is associated with the specified object, and has the specified initial parameters. @@ -322,14 +307,9 @@ interface ReadonlyArray { * If thisArg is omitted, undefined is used as the this value. */ every( - predicate: ( - this: This, - value: T, - index: number, - array: readonly T[] - ) => value is S, + predicate: (this: This, value: T, index: number, array: this) => value is S, thisArg?: This - ): this is readonly S[]; + ): this is { [K in keyof this]: S }; /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -339,12 +319,7 @@ interface ReadonlyArray { * If thisArg is omitted, undefined is used as the this value. */ every( - predicate: ( - this: This, - value: T, - index: number, - array: readonly T[] - ) => boolean, + predicate: (this: This, value: T, index: number, array: this) => boolean, thisArg?: This ): boolean; /** @@ -356,12 +331,7 @@ interface ReadonlyArray { * If thisArg is omitted, undefined is used as the this value. */ some( - predicate: ( - this: This, - value: T, - index: number, - array: readonly T[] - ) => boolean, + predicate: (this: This, value: T, index: number, array: this) => boolean, thisArg?: This ): boolean; /** @@ -370,12 +340,7 @@ interface ReadonlyArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach( - callbackfn: ( - this: This, - value: T, - index: number, - array: readonly T[] - ) => void, + callbackfn: (this: This, value: T, index: number, array: this) => void, thisArg?: This ): void; /** @@ -384,21 +349,16 @@ interface ReadonlyArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ map( - callbackfn: (this: This, value: T, index: number, array: readonly T[]) => U, + callbackfn: (this: This, value: T, index: number, array: this) => U, thisArg?: This - ): U[]; + ): { -readonly [K in keyof this]: U }; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. */ filter( - predicate: ( - this: This, - value: T, - index: number, - array: readonly T[] - ) => value is S, + predicate: (this: This, value: T, index: number, array: this) => value is S, thisArg?: This ): S[]; /** @@ -407,32 +367,64 @@ interface ReadonlyArray { * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. */ filter( - predicate: ( - this: This, - value: T, - index: number, - array: readonly T[] - ) => boolean, + predicate: (this: This, value: T, index: number, array: this) => boolean, thisArg?: This ): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + */ + reduce( + callbackfn: ( + previousValue: T | U, + currentValue: T, + currentIndex: number, + array: this + ) => U + ): T | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce( + callbackfn: ( + previousValue: U, + currentValue: T, + currentIndex: number, + array: this + ) => U, + initialValue: U + ): U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + */ + reduceRight( + callbackfn: ( + previousValue: T | U, + currentValue: T, + currentIndex: number, + array: this + ) => U + ): T | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight( + callbackfn: ( + previousValue: U, + currentValue: T, + currentIndex: number, + array: this + ) => U, + initialValue: U + ): U; } interface Array { - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @returns An array containing the elements that were deleted. - */ - splice(start: number, deleteCount?: number): this; - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. - * @returns An array containing the elements that were deleted. - */ - splice(start: number, deleteCount: number, ...items: T[]): this; /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -442,9 +434,9 @@ interface Array { * If thisArg is omitted, undefined is used as the this value. */ every( - predicate: (this: This, value: T, index: number, array: T[]) => value is S, + predicate: (this: This, value: T, index: number, array: this) => value is S, thisArg?: This - ): this is S[]; + ): this is { [K in keyof this]: S }; /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -454,7 +446,7 @@ interface Array { * If thisArg is omitted, undefined is used as the this value. */ every( - predicate: (this: This, value: T, index: number, array: T[]) => boolean, + predicate: (this: This, value: T, index: number, array: this) => boolean, thisArg?: This ): boolean; /** @@ -466,7 +458,7 @@ interface Array { * If thisArg is omitted, undefined is used as the this value. */ some( - predicate: (this: This, value: T, index: number, array: T[]) => boolean, + predicate: (this: This, value: T, index: number, array: this) => boolean, thisArg?: This ): boolean; /** @@ -475,7 +467,7 @@ interface Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach( - callbackfn: (this: This, value: T, index: number, array: T[]) => void, + callbackfn: (this: This, value: T, index: number, array: this) => void, thisArg?: This ): void; /** @@ -484,16 +476,16 @@ interface Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ map( - callbackfn: (this: This, value: T, index: number, array: T[]) => U, + callbackfn: (this: This, value: T, index: number, array: this) => U, thisArg?: This - ): U[]; + ): { [K in keyof this]: U }; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. */ filter( - predicate: (this: This, value: T, index: number, array: T[]) => value is S, + predicate: (this: This, value: T, index: number, array: this) => value is S, thisArg?: This ): S[]; /** @@ -502,9 +494,61 @@ interface Array { * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. */ filter( - predicate: (this: This, value: T, index: number, array: T[]) => boolean, + predicate: (this: This, value: T, index: number, array: this) => boolean, thisArg?: This ): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + */ + reduce( + callbackfn: ( + previousValue: T | U, + currentValue: T, + currentIndex: number, + array: this + ) => U + ): T | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce( + callbackfn: ( + previousValue: U, + currentValue: T, + currentIndex: number, + array: this + ) => U, + initialValue: U + ): U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + */ + reduceRight( + callbackfn: ( + previousValue: T | U, + currentValue: T, + currentIndex: number, + array: this + ) => U + ): T | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight( + callbackfn: ( + previousValue: U, + currentValue: T, + currentIndex: number, + array: this + ) => U, + initialValue: U + ): U; } interface ArrayConstructor { @@ -528,3 +572,197 @@ declare type PromiseConstructorLike = new ( reject: (reason?: any) => void ) => void ) => PromiseLike; + +interface TypedNumberArray { + /** + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ + every( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This + ): boolean; + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This + ): TypedNumberArray; + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This + ): number | undefined; + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex( + predicate: (this: This, value: number, index: number, obj: this) => boolean, + thisArg?: This + ): number; + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach( + callbackfn: (this: This, value: number, index: number, array: this) => void, + thisArg?: This + ): void; + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map( + callbackfn: ( + this: This, + value: number, + index: number, + array: this + ) => number, + thisArg?: This + ): TypedNumberArray; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + */ + reduce( + callbackfn: ( + previousValue: number | U, + currentValue: number, + currentIndex: number, + array: this + ) => U + ): number | U; + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, + array: this + ) => U, + initialValue: U + ): U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + */ + reduceRight( + callbackfn: ( + previousValue: number | U, + currentValue: number, + currentIndex: number, + array: this + ) => U + ): number | U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight( + callbackfn: ( + previousValue: U, + currentValue: number, + currentIndex: number, + array: this + ) => U, + initialValue: U + ): U; + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ + some( + predicate: ( + this: This, + value: number, + index: number, + array: this + ) => boolean, + thisArg?: This + ): boolean; +} + +interface TypedNumberArrayConstructor { + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. + */ + from(source: ArrayLike): TypedNumberArray; + /** + * Creates an array from an array-like or iterable object. + * @param source An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from( + source: ArrayLike, + mapfn: (this: This, v: T, k: number) => number, + thisArg?: This + ): TypedNumberArray; +} diff --git a/tests/src/es2015.core.ts b/tests/src/es2015.core.ts index 7ad149a..bec0f1a 100644 --- a/tests/src/es2015.core.ts +++ b/tests/src/es2015.core.ts @@ -1,4 +1,20 @@ -import { expectType } from "tsd"; +import { expectError, expectType } from "tsd"; + +// ReadonlyArray +{ + // https://github.com/uhyo/better-typescript-lib/issues/7 + const a1: readonly number[] = [1, 2, 3]; + expectError(a1.find((x) => x)); + expectError(a1.findIndex((x) => x)); +} + +// Array +{ + // https://github.com/uhyo/better-typescript-lib/issues/7 + const a1: number[] = [1, 2, 3]; + expectError(a1.find((x) => x)); + expectError(a1.findIndex((x) => x)); +} // NumberConstructor { @@ -17,8 +33,10 @@ import { expectType } from "tsd"; expectType(n); } } + // ObjectConstructor { + expectType(Object.assign(null)); const obj1 = Object.assign({ foo: 123 }); expectType<{ foo: number }>(obj1); const obj2 = Object.assign({ foo: 123 }, { bar: "wow" }); diff --git a/tests/src/es2017.object.ts b/tests/src/es2017.object.ts index 007a050..904f8bb 100644 --- a/tests/src/es2017.object.ts +++ b/tests/src/es2017.object.ts @@ -8,6 +8,10 @@ function createGenericRecord( } { + expectType(Object.values(null)); + expectType(Object.entries(null)); + expectType(Object.getOwnPropertyDescriptors(null)); + const obj1: { [k: string]: number } = { foo: 123 }; const values1 = Object.values(obj1); const entries1 = Object.entries(obj1); diff --git a/tests/src/es2020.bigint.ts b/tests/src/es2020.bigint.ts new file mode 100644 index 0000000..8f05e40 --- /dev/null +++ b/tests/src/es2020.bigint.ts @@ -0,0 +1,12 @@ +import { expectError } from "tsd"; +// TypedNumberArray +{ + for (const TypedBigIntArray of [BigInt64Array, BigUint64Array]) { + const a1 = new TypedBigIntArray(); + expectError(a1.filter((x) => x)); + expectError(a1.every((x) => x)); + expectError(a1.some((x) => x)); + expectError(a1.find((x) => x)); + expectError(a1.findIndex((x) => x)); + } +} diff --git a/tests/src/es5.ts b/tests/src/es5.ts index 3bd7890..972bfa5 100644 --- a/tests/src/es5.ts +++ b/tests/src/es5.ts @@ -6,9 +6,16 @@ expectType(eval("foo")); expectType<{}>(Object()); expectType<{ foo: number }>(Object({ foo: 123 })); expectType<{}>(Object(123)); -// $ExpctType unknown +// Object.getPrototypeOf expectType(Object.getPrototypeOf([])); +expectType(Object.getPrototypeOf(null)); +// Object.getOwnPropertyDescriptor +expectType( + Object.getOwnPropertyDescriptor([], "foo") +); +expectType(Object.getOwnPropertyDescriptor(null, "foo")); // Object.getOwnPropertyNames +expectType(Object.getOwnPropertyNames([])); expectType(Object.getOwnPropertyNames(null)); // Object.create expectType<{}>(Object.create(null)); @@ -177,30 +184,78 @@ expectType<{ foo: number; bar: string; baz: boolean }>( { // https://github.com/uhyo/better-typescript-lib/issues/7 const a1: readonly number[] = [1, 2, 3]; - expectType(a1.filter((a1) => a1 > 2)); + expectType(a1.filter((x) => x > 2)); expectType<1[]>(a1.filter((x): x is 1 => x === 1)); if (a1.every((x): x is 2 => x === 2)) { expectType(a1); } + expectType( + a1.reduce((x) => { + expectType(x); + return "foo"; + }) + ); + expectType( + a1.reduce((x) => { + expectType(x); + return "foo"; + }, "foo") + ); + expectType(a1.reduceRight); expectError(a1.filter((x) => x)); expectError(a1.every((x) => x)); expectError(a1.some((x) => x)); + + const a2: readonly [number, number, number] = [1, 2, 3]; + if ( + a2.every((x, i, a3): x is 2 => { + expectType(a3); + return x === 2; + }) + ) { + expectType(a2); + } + expectType<[string, string, string]>(a2.map(() => "foo")); } // Array { // https://github.com/uhyo/better-typescript-lib/issues/7 const a1: number[] = [1, 2, 3]; - expectType(a1.filter((a1) => a1 > 2)); + expectType(a1.filter((x) => x > 2)); expectType<1[]>(a1.filter((x): x is 1 => x === 1)); if (a1.every((x): x is 2 => x === 2)) { expectType<2[]>(a1); } + expectType( + a1.reduce((x) => { + expectType(x); + return "foo"; + }) + ); + expectType( + a1.reduce((x) => { + expectType(x); + return "foo"; + }, "foo") + ); + expectType(a1.reduceRight); expectError(a1.filter((x) => x)); expectError(a1.every((x) => x)); expectError(a1.some((x) => x)); + + const a2: [number, number, number] = [1, 2, 3]; + if ( + a2.every((x, i, a3): x is 2 => { + expectType(a3); + return x === 2; + }) + ) { + expectType<[2, 2, 2]>(a2); + } + expectType<[string, string, string]>(a2.map(() => "foo")); } // ArrayConstructor @@ -232,4 +287,26 @@ expectType<{ foo: number; bar: string; baz: boolean }>( } } +// TypedNumberArray +{ + for (const TypedNumberArray of [ + Int8Array, + Uint8Array, + Uint8ClampedArray, + Int16Array, + Uint16Array, + Int32Array, + Uint32Array, + Float32Array, + Float64Array, + ]) { + const a1 = new TypedNumberArray(); + expectError(a1.filter((x) => x)); + expectError(a1.every((x) => x)); + expectError(a1.some((x) => x)); + expectError(a1.find((x) => x)); + expectError(a1.findIndex((x) => x)); + } +} + export {}; diff --git a/tsconfig.json b/tsconfig.json index ea52a4f..1cd6c7c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,7 @@ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ + "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ "outDir": "./dist", /* Redirect output structure to the directory. */ "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */