UNPKG

try-flow-website-js

Version:

An NPM package to hold compiled `flow.js` and libdefs for every Flow version.

1,074 lines (1,056 loc) 153 kB
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * Copyright (c) Microsoft Corporation. All rights reserved. * Modifications Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of the * License at http://www.apache.org/licenses/LICENSE-2.0 * THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED * WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, * MERCHANTABILITY OR NON-INFRINGEMENT. * See the Apache Version 2.0 License for specific language governing permissions * and limitations under the License. * * @flow */ // @lint-ignore-every LICENSELINT declare var NaN: number; declare var Infinity: number; declare var undefined: void; /** * Converts a string to an integer. * @param string A string to convert into a number. * @param radix A value between 2 and 36 that specifies the base of the number in numString. * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. * All other strings are considered decimal. */ declare function parseInt(string: mixed, radix?: number): number; /** * Converts a string to a floating-point number. * @param string A string that contains a floating-point number. */ declare function parseFloat(string: mixed): number; /** * Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). * @param number A numeric value. */ declare function isNaN(number: mixed): boolean; /** * Determines whether a supplied number is finite. * @param number Any numeric value. */ declare function isFinite(number: mixed): boolean; /** * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). * @param encodedURI A value representing an encoded URI. */ declare function decodeURI(encodedURI: string): string; /** * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). * @param encodedURIComponent A value representing an encoded URI component. */ declare function decodeURIComponent(encodedURIComponent: string): string; /** * Encodes a text string as a valid Uniform Resource Identifier (URI) * @param uri A value representing an encoded URI. */ declare function encodeURI(uri: string): string; /** * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). * @param uriComponent A value representing an encoded URI component. */ declare function encodeURIComponent(uriComponent: string): string; type PropertyDescriptor<T> = { +enumerable?: boolean, +configurable?: boolean, +writable?: boolean, +value?: T, +get?: () => T, +set?: (value: T) => void, ... }; type PropertyDescriptorMap = { [s: string]: PropertyDescriptor<any>, ... } type $NotNullOrVoid = | number | string | boolean | interface {} | $ReadOnlyArray<mixed> | symbol | bigint | EnumValue<> | Enum<>; declare class Object { static (o: ?void): { [key: any]: any, ... }; static (o: boolean): Boolean; static (o: number): Number; static (o: string): String; static <T>(o: T): T; /** * Copy the values of all of the enumerable own properties from one or more source objects to a * target object. Returns the target object. * @param target The target object to copy to. * @param sources The source object from which to copy properties. */ static assign: Object$Assign; /** * Creates an object that has the specified prototype, and that optionally contains specified properties. * @param o Object to use as a prototype. May be null * @param properties JavaScript object that contains one or more property descriptors. */ static create(o: any, properties?: PropertyDescriptorMap): any; // compiler magic /** * Adds one or more properties to an object, and/or modifies attributes of existing properties. * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. */ static defineProperties(o: any, properties: PropertyDescriptorMap): any; /** * Adds a property to an object, or modifies attributes of an existing property. * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. * @param p The property name. * @param attributes Descriptor for the property. It can be for a data property or an accessor property. */ static defineProperty<T>(o: any, p: any, attributes: PropertyDescriptor<T>): any; /** * Returns an array of key/values of the enumerable properties of an object * @param object Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ static entries(object: interface {}): Array<[string, mixed]>; /** * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. * @param o Object on which to lock the attributes. */ static freeze<T>(o: T): T; /** * 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. */ static fromEntries<K, V>(entries: Iterable<[K, V] | { '0': K, '1': V, ... }>): { [K]: V, ... }; /** * 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. */ static getOwnPropertyDescriptor<T = mixed>(o: $NotNullOrVoid, p: any): PropertyDescriptor<T> | void; /** * Gets the own property descriptors 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 properties. */ static getOwnPropertyDescriptors(o: {...}): PropertyDescriptorMap; // This is documentation only. Object.getOwnPropertyNames is implemented in OCaml code // https://github.com/facebook/flow/blob/8ac01bc604a6827e6ee9a71b197bb974f8080049/src/typing/statement.ml#L6308 /** * 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. */ static getOwnPropertyNames(o: $NotNullOrVoid): Array<string>; /** * Returns an array of all symbol properties found directly on object o. * @param o Object to retrieve the symbols from. */ static getOwnPropertySymbols(o: $NotNullOrVoid): Array<symbol>; /** * Returns the prototype of an object. * @param o The object that references the prototype. */ static getPrototypeOf(o: $NotNullOrVoid): any; /** * Returns true if the specified object has the indicated property as its own property. * If the property is inherited, or does not exist, the method returns false. * @param obj The JavaScript object instance to test. * @param prop The String name or Symbol of the property to test. */ static hasOwn(obj: $NotNullOrVoid, prop: mixed): boolean; /** * Returns true if the values are the same value, false otherwise. * @param a The first value. * @param b The second value. */ static is<T>(a: T, b: T): boolean; /** * Returns a value that indicates whether new properties can be added to an object. * @param o Object to test. */ static isExtensible(o: $NotNullOrVoid): boolean; /** * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. * @param o Object to test. */ static isFrozen(o: $NotNullOrVoid): boolean; static isSealed(o: $NotNullOrVoid): boolean; // This is documentation only. Object.keys is implemented in OCaml code. // https://github.com/facebook/flow/blob/8ac01bc604a6827e6ee9a71b197bb974f8080049/src/typing/statement.ml#L6308 /** * Returns the names of the enumerable string properties and methods 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. */ static keys(o: interface {}): Array<string>; /** * Prevents the addition of new properties to an object. * @param o Object to make non-extensible. */ static preventExtensions<T>(o: T): T; /** * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. * @param o Object on which to lock the attributes. */ static seal<T>(o: T): T; /** * Sets the prototype of a specified object o to object proto or null. Returns the object o. * @param o The object to change its prototype. * @param proto The value of the new prototype or null. */ static setPrototypeOf<T>(o: T, proto: ?{...}): T; /** * Returns an array of values of the enumerable properties of an object * @param object Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ static values(object: interface {}): Array<mixed>; /** * Groups members of an iterable according to the return value of the passed callback. * @param items An iterable. * @param keySelector A callback which will be invoked for each item in items. */ static groupBy<T, K: string | number | bigint | boolean | symbol>(items: Iterable<T>, keySelector: (item: T, index: number) => K): {[K]: Array<T> | void}; /** * Determines whether an object has a property with the specified name. * @param prop A property name. */ hasOwnProperty(prop: mixed): boolean; /** * Determines whether an object exists in another object's prototype chain. * @param o Another object whose prototype chain is to be checked. */ isPrototypeOf(o: mixed): boolean; /** * Determines whether a specified property is enumerable. * @param prop A property name. */ propertyIsEnumerable(prop: mixed): boolean; /** Returns a date converted to a string using the current locale. */ toLocaleString(): string; /** Returns a string representation of an object. */ toString(): string; /** Returns the primitive value of the specified object. */ valueOf(): mixed; } // Well known Symbols. declare opaque type $SymbolHasInstance: symbol; declare opaque type $SymbolIsConcatSpreadable: symbol; declare opaque type $SymbolIterator: symbol; declare opaque type $SymbolMatch: symbol; declare opaque type $SymbolMatchAll: symbol; declare opaque type $SymbolReplace: symbol; declare opaque type $SymbolSearch: symbol; declare opaque type $SymbolSpecies: symbol; declare opaque type $SymbolSplit: symbol; declare opaque type $SymbolToPrimitive: symbol; declare opaque type $SymbolToStringTag: symbol; declare opaque type $SymbolUnscopables: symbol; declare opaque type $SymbolDispose: symbol; declare opaque type $SymbolAsyncDispose: symbol; declare class Symbol { /** * Returns a new unique Symbol value. * @param value Description of the new Symbol object. */ static (value?: mixed): symbol; /** * A method that returns the default async iterator for an object. Called by the semantics of * the for-await-of statement. */ static +asyncIterator: '@@asyncIterator'; // polyfill '@@asyncIterator' /** * Returns a Symbol object from the global symbol registry matching the given key if found. * Otherwise, returns a new symbol with this key. * @param key key to search for. */ static for(key: string): symbol; /** * Expose the [[Description]] internal slot of a symbol directly. */ +description: string | void; /** * A method that determines if a constructor object recognizes an object as one of the * constructor's instances. Called by the semantics of the instanceof operator. */ static +hasInstance: $SymbolHasInstance; /** * A Boolean value that if true indicates that an object should flatten to its array elements * by Array.prototype.concat. */ static +isConcatSpreadable: $SymbolIsConcatSpreadable; /** * A method that returns the default iterator for an object. Called by the semantics of the * for-of statement. */ static +iterator: '@@iterator'; // polyfill '@@iterator' /** * Returns a key from the global symbol registry matching the given Symbol if found. * Otherwise, returns a undefined. * @param sym Symbol to find the key for. */ static keyFor(sym: symbol): ?string; static +length: 0; /** * A regular expression method that matches the regular expression against a string. Called * by the String.prototype.match method. */ static +match: $SymbolMatch; /** * A regular expression method that matches the regular expression against a string. Called * by the String.prototype.matchAll method. */ static +matchAll: $SymbolMatchAll; /** * A regular expression method that replaces matched substrings of a string. Called by the * String.prototype.replace method. */ static +replace: $SymbolReplace; /** * A regular expression method that returns the index within a string that matches the * regular expression. Called by the String.prototype.search method. */ static +search: $SymbolSearch; /** * A function valued property that is the constructor function that is used to create * derived objects. */ static +species: $SymbolSpecies; /** * A regular expression method that splits a string at the indices that match the regular * expression. Called by the String.prototype.split method. */ static +split: $SymbolSplit; /** * A method that converts an object to a corresponding primitive value. * Called by the ToPrimitive abstract operation. */ static +toPrimitive: $SymbolToPrimitive; /** * A String value that is used in the creation of the default string description of an object. * Called by the built-in method Object.prototype.toString. */ static +toStringTag: $SymbolToStringTag; /** * An Object whose own property names are property names that are excluded from the 'with' * environment bindings of the associated objects. */ static +unscopables: $SymbolUnscopables; /** * A symbol that would be used to define cleanup behavior when an object is disposed. * Note: Flow does not currently support the `using` declaration syntax. */ static +dispose: '@@dispose'; // polyfill '@@dispose' /** * A symbol that would be used to define cleanup behavior when an object is disposed asynchronously. * Note: Flow does not currently support the `using` declaration syntax. */ static +asyncDispose: '@@asyncDispose'; // polyfill '@@asyncDispose' toString(): string; valueOf(): ?symbol; } // TODO: instance, static declare class Function { proto apply: (<T, R, A: $ArrayLike<mixed> = []>(this: (this: T, ...args: A) => R, thisArg: T, args?: A) => R); proto bind: Function$Prototype$Bind; // (thisArg: any, ...argArray: Array<any>) => any; proto call: <T, R, A: $ArrayLike<mixed> = []>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R; /** Returns a string representation of a function. */ toString(): string; arguments: any; caller: any | null; +length: number; /** * Returns the name of the function. */ +name: string; } declare class Boolean { constructor(value?: mixed): void; static (value:mixed):boolean; /** Returns the primitive value of the specified object. */ valueOf(): boolean; toString(): string; } /** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ declare class Number { /** * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 * that is representable as a Number value, which is approximately: * 2.2204460492503130808472633361816 x 10^-16. */ static EPSILON: number; /** * The value of the largest integer n such that n and n + 1 are both exactly representable as * a Number value. * The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 - 1. */ static MAX_SAFE_INTEGER: number; /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ static MAX_VALUE: number; /** * The value of the smallest integer n such that n and n - 1 are both exactly representable as * a Number value. * The value of Number.MIN_SAFE_INTEGER is -9007199254740991 (-(2^53 - 1)). */ static MIN_SAFE_INTEGER: number; /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ static MIN_VALUE: number; /** * A value that is not a number. * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. */ static NaN: number; /** * A value that is less than the largest negative number that can be represented in JavaScript. * JavaScript displays NEGATIVE_INFINITY values as -infinity. */ static NEGATIVE_INFINITY: number; /** * A value greater than the largest number that can be represented in JavaScript. * JavaScript displays POSITIVE_INFINITY values as infinity. */ static POSITIVE_INFINITY: number; static (value:mixed):number; /** * Returns true if passed value is finite. * Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a * number. Only finite values of the type number, result in true. * @param value A numeric value. */ static isFinite(value: mixed): implies value is number; /** * Returns true if the value passed is an integer, false otherwise. * @param value A numeric value. */ static isInteger(value: mixed): implies value is number; /** * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter * to a number. Only values of the type number, that are also NaN, result in true. * @param value A numeric value. */ static isNaN(value: mixed): implies value is number; /** * Returns true if the value passed is a safe integer. * @param value A numeric value. */ static isSafeInteger(value: mixed): implies value is number; /** * Converts a string to a floating-point number. * @param value A string that contains a floating-point number. */ static parseFloat(value: string): number; /** * Converts A string to an integer. * @param value A string to convert into a number. * @param radix A value between 2 and 36 that specifies the base of the number in numString. * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. * All other strings are considered decimal. */ static parseInt(value: string, radix?: number): number; constructor(value?: mixed): void; /** * Returns a string containing a number represented in exponential notation. * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. */ toExponential(fractionDigits?: number): string; /** * Returns a string representing a number in fixed-point notation. * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. */ toFixed(fractionDigits?: number): string; /** * Converts a number to a string by using the current or specified locale. * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locales?: string | Array<string>, options?: Intl$NumberFormatOptions): string; /** * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. */ toPrecision(precision?: number): string; /** * Returns a string representation of an object. * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. */ toString(radix?: number): string; /** Returns the primitive value of the specified object. */ valueOf(): number; } /** An intrinsic object that provides basic mathematics functionality and constants. */ declare var Math: { /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ E: number, /** The natural logarithm of 10. */ LN10: number, /** The natural logarithm of 2. */ LN2: number, /** The base-10 logarithm of e. */ LOG10E: number, /** The base-2 logarithm of e. */ LOG2E: number, /** Pi. This is the ratio of the circumference of a circle to its diameter. */ PI: number, /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ SQRT1_2: number, /** The square root of 2. */ SQRT2: number, /** * Returns the absolute value of a number (the value without regard to whether it is positive or negative). * For example, the absolute value of -5 is the same as the absolute value of 5. * @param x A numeric expression for which the absolute value is needed. */ abs(x: number): number, /** * Returns the arc cosine (or inverse cosine) of a number. * @param x A numeric expression. */ acos(x: number): number, /** * Returns the inverse hyperbolic cosine of a number. * @param x A numeric expression that contains an angle measured in radians. */ acosh(x: number): number, /** * Returns the arcsine of a number. * @param x A numeric expression. */ asin(x: number): number, /** * Returns the inverse hyperbolic sine of a number. * @param x A numeric expression that contains an angle measured in radians. */ asinh(x: number): number, /** * Returns the arctangent of a number. * @param x A numeric expression for which the arctangent is needed. */ atan(x: number): number, /** * Returns the angle (in radians) from the X axis to a point. * @param y A numeric expression representing the cartesian y-coordinate. * @param x A numeric expression representing the cartesian x-coordinate. */ atan2(y: number, x: number): number, /** * Returns the inverse hyperbolic tangent of a number. * @param x A numeric expression that contains an angle measured in radians. */ atanh(x: number): number, /** * Returns an implementation-dependent approximation to the cube root of number. * @param x A numeric expression. */ cbrt(x: number): number, /** * Returns the smallest integer greater than or equal to its numeric argument. * @param x A numeric expression. */ ceil(x: number): number, /** * Returns the number of leading zero bits in the 32-bit binary representation of a number. * @param x A numeric expression. */ clz32(x: number): number, /** * Returns the cosine of a number. * @param x A numeric expression that contains an angle measured in radians. */ cos(x: number): number, /** * Returns the hyperbolic cosine of a number. * @param x A numeric expression that contains an angle measured in radians. */ cosh(x: number): number, /** * Returns e (the base of natural logarithms) raised to a power. * @param x A numeric expression representing the power of e. */ exp(x: number): number, /** * Returns the result of (e^x - 1), which is an implementation-dependent approximation to * subtracting 1 from the exponential function of x (e raised to the power of x, where e * is the base of the natural logarithms). * @param x A numeric expression. */ expm1(x: number): number, /** * Returns the greatest integer less than or equal to its numeric argument. * @param x A numeric expression. */ floor(x: number): number, /** * Returns the nearest 16-bit half precision float representation of a number. * @param x A numeric expression. */ f16round(x: number): number, /** * Returns the nearest single precision float representation of a number. * @param x A numeric expression. */ fround(x: number): number, /** * Returns the square root of the sum of squares of its arguments. * @param values Values to compute the square root for. * If no arguments are passed, the result is +0. * If there is only one argument, the result is the absolute value. * If any argument is +Infinity or -Infinity, the result is +Infinity. * If any argument is NaN, the result is NaN. * If all arguments are either +0 or -0, the result is +0. */ hypot(...values: Array<number>): number, /** * Returns the result of 32-bit multiplication of two numbers. * @param x First number * @param y Second number */ imul(x: number, y: number): number, /** * Returns the natural logarithm (base e) of a number. * @param x A numeric expression. */ log(x: number): number, /** * Returns the base 10 logarithm of a number. * @param x A numeric expression. */ log10(x: number): number, /** * Returns the natural logarithm of 1 + x. * @param x A numeric expression. */ log1p(x: number): number, /** * Returns the base 2 logarithm of a number. * @param x A numeric expression. */ log2(x: number): number, /** * Returns the larger of a set of supplied numeric expressions. * @param values Numeric expressions to be evaluated. */ max(...values: Array<number>): number, /** * Returns the smaller of a set of supplied numeric expressions. * @param values Numeric expressions to be evaluated. */ min(...values: Array<number>): number, /** * Returns the value of a base expression taken to a specified power. * @param x The base value of the expression. * @param y The exponent value of the expression. */ pow(x: number, y: number): number, /** Returns a pseudorandom number between 0 and 1. */ random(): number, /** * Returns a supplied numeric expression rounded to the nearest integer. * @param x The value to be rounded to the nearest integer. */ round(x: number): number, /** * Returns the sign of the x, indicating whether x is positive, negative or zero. * @param x The numeric expression to test */ sign(x: number): number, /** * Returns the sine of a number. * @param x A numeric expression that contains an angle measured in radians. */ sin(x: number): number, /** * Returns the hyperbolic sine of a number. * @param x A numeric expression that contains an angle measured in radians. */ sinh(x: number): number, /** * Returns the square root of a number. * @param x A numeric expression. */ sqrt(x: number): number, /** * Returns the tangent of a number. * @param x A numeric expression that contains an angle measured in radians. */ tan(x: number): number, /** * Returns the hyperbolic tangent of a number. * @param x A numeric expression that contains an angle measured in radians. */ tanh(x: number): number, /** * Returns the integral part of the a numeric expression, x, removing any fractional digits. * If x is already an integer, the result is x. * @param x A numeric expression. */ trunc(x: number): number, ... }; // Unused if `experimental.ts_syntax` is off type ReadonlyArray<+T> = $ReadOnlyArray<T>; /** * A class of Array methods and properties that don't mutate the array. */ declare class $ReadOnlyArray<+T> { @@iterator(): Iterator<T>; /** * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. */ toLocaleString(): string; /** * Returns the item located at the specified index. * @param index The zero-based index of the desired item. A negative index will count back from the last item. */ at(index: number): T | void; // concat creates a new array /** * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ concat< // $FlowFixMe[incompatible-variance] S = T // $FlowFixMe[incompatible-variance] >(...items: Array<$ReadOnlyArray<S> | S>): Array<T | S>; /** * Returns an iterable of key, value pairs for every entry in the array */ // $FlowFixMe[incompatible-variance] entries(): Iterator<[number, T]>; /** * Determines whether all the members of an array satisfy the specified test. * @param callbackfn 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<This>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg: This): boolean; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. */ filter(callbackfn: typeof Boolean): Array<$NonMaybeType<T>>; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A predicate 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. * @returns An array whose type is specified by the predicate function passed as callbackfn. */ filter< // $FlowFixMe[incompatible-variance] This, S: T >(callbackfn: (this: This, value: T, index: number, array: $ReadOnlyArray<T>) => implies value is S, thisArg: This): Array<S>; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn 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<This>( callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg : This // $FlowFixMe[incompatible-variance] ): Array<T>; /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. * @param callbackfn 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< // $FlowFixMe[incompatible-variance] This, S: T >(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => implies value is S, thisArg: This): S | void; /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. * @param callbackfn 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<This>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg: This): T | void; /** * Returns the index of the first element in the array where predicate is true, and -1 * otherwise. * @param callbackfn 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<This>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg: This): number; /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. * @param callbackfn find calls predicate once for each element of the array, in reverse * 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. */ findLast<This>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg: This): T | void; /** * Returns the index of the last element in the array where predicate is true, and -1 * otherwise. * @param callbackfn find calls predicate once for each element of the array, in reverse * order, until it finds one where predicate returns true. If such an element is found, * findLastIndex immediately returns that element index. Otherwise, findLastIndex 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. */ findLastIndex<This>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, 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<This>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg: This): void; /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. * @param fromIndex The position in this array at which to begin searching for searchElement. */ includes( // $FlowFixMe[incompatible-variance] searchElement: T, fromIndex?: number ): implies searchElement is T; /** * Returns the index of the first occurrence of a value in an array. * @param searchElement The value to locate in the array. * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. */ indexOf( // $FlowFixMe[incompatible-variance] searchElement: T, fromIndex?: number ): number; /** * Adds all the elements of an array separated by the specified separator string. * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; /** * Returns an iterable of keys in the array */ keys(): Iterator<number>; /** * Returns the index of the last occurrence of a specified value in an array. * @param searchElement The value to locate in the array. * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. */ lastIndexOf( // $FlowFixMe[incompatible-variance] searchElement: T, fromIndex?: number ): 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<U, This>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => U, thisArg: This): Array<U>; /** * Calls a defined callback function on each element of an array. Then, flattens the result into * a new array. * This is identical to a map followed by flat with depth 1. * * @param callbackfn A function that accepts up to three arguments. The flatMap method calls the * callback function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callback function. If * thisArg is omitted, undefined is used as the this value. */ flatMap<U, This>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => $ReadOnlyArray<U> | U, thisArg: This): Array<U>; /** * Returns a new array with all sub-array elements concatenated into it recursively up to the * specified depth. * * @param depth The maximum recursion depth */ flat( depth: 0 // $FlowFixMe[incompatible-variance] ): Array<T>; /** * Returns a new array with all sub-array elements concatenated into it recursively up to the * specified depth. * * @param depth The maximum recursion depth */ flat(depth: void | 1): Array<T extends $ReadOnlyArray<infer E> ? E : T>; /** * Returns a new array with all sub-array elements concatenated into it recursively up to the * specified depth. * * @param depth The maximum recursion depth */ flat(depth: number): Array<mixed>; /** * 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( // $FlowFixMe[incompatible-variance] callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: $ReadOnlyArray<T>) => 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<U>( callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: $ReadOnlyArray<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. */ reduceRight( // $FlowFixMe[incompatible-variance] callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: $ReadOnlyArray<T>) => 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<U>( callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: $ReadOnlyArray<T>) => U, initialValue: U ): U; /** * Returns a section of an array. * @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 // $FlowFixMe[incompatible-variance] ): Array<T>; /** * Determines whether the specified callback function returns true for any element of an array. * @param callbackfn 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<This>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg: This): boolean; /** * Returns a new array with the elements in reversed order. * It is the copying counterpart of the reverse() method. */ toReversed( // $FlowFixMe[incompatible-variance] ): Array<T>; /** * Returns a new array with the elements sorted in ascending order. * It is the copying counterpart of the sort() method. * @param compareFn Specifies a function that defines the sort order. * If omitted, the array elements are converted to strings, then sorted according * to each character's Unicode code point value. */ toSorted( compareFn?: (a: T, b: T) => number // $FlowFixMe[incompatible-variance] ): Array<T>; /** * Returns a new array with some elements removed and/or replaced at a given index. * It is the copying counterpart of the splice() method. * @param start Zero-based index at which to start changing the array, converted to an integer. * @param deleteCount An integer indicating the number of elements in the array to remove from start. * @param items The elements to add to the array, beginning from start. */ toSpliced<S>( start: number, deleteCount?: number, ...items: Array<S> // $FlowFixMe[incompatible-variance] ): Array<T | S>; /** * Returns an iterable of values in the array */ values(): Iterator<T>; /** * Returns a new array with the element at the given index replaced with the given value. * It is the copying version of using the bracket notation to change the value of a given index. * @param index Zero-based index at which to change the array, converted to an integer. * @param value Any value to be assigned to the given index. */ with( // $FlowFixMe[incompatible-variance] index: number, value: T // $FlowFixMe[incompatible-variance] ): Array<T>; +[key: number]: T; /** * Gets the length of the array. This is a number one higher than the highest element defined in an array. */ +length: number; } declare class Array<T> extends $ReadOnlyArray<T> { /** * Returns a new JavaScript array with its length property set to that number. * (Note: this implies an array of arrayLength empty slots, not slots with actual undefined * values. See [sparse arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays)). */ constructor(arrayLength?: number): void; /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target * @param target If target is negative, it is treated as length+target where length is the * length of the array. * @param start If start is negative, it is treated as length+start. If end is negative, it * 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): T[]; /** * Determines whether all the members of an array satisfy the specified test. * @param callbackfn 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<This>(callbackfn: (this : This, value: T, index: number, array: Array<T>) => mixed, thisArg: This): boolean; /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with * @param begin index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: T, begin?: number, end?: number): Array<T>; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. */ filter(callbackfn: typeof Boolean): Array<$NonMaybeType<T>>; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A predicate 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. * @returns An array whose type is specified by the predicate function passed as callbackfn. */ filter<This, S: T>(callbackfn: (this: This, value: T, index: number, array: $ReadOnlyArray<T>) => implies value is S, thisArg: This): Array<S>; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the