Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lib): define TypedArray interface #59205

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/harness/fourslashInterfaceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,8 @@ export namespace Completion {
interfaceEntry("ArrayBufferView"),
varEntry("DataView"),
interfaceEntry("DataViewConstructor"),
interfaceEntry("TypedArray"),
interfaceEntry("TypedArrayConstructor"),
varEntry("Int8Array"),
interfaceEntry("Int8ArrayConstructor"),
varEntry("Uint8Array"),
Expand Down
34 changes: 1 addition & 33 deletions src/lib/es2015.core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,38 +542,6 @@ interface StringConstructor {
raw(template: { raw: readonly string[] | ArrayLike<string>; }, ...substitutions: any[]): string;
}

interface Int8Array {
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
}

interface Uint8Array {
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
}

interface Uint8ClampedArray {
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
}

interface Int16Array {
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
}

interface Uint16Array {
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
}

interface Int32Array {
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
}

interface Uint32Array {
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
}

interface Float32Array {
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
}

interface Float64Array {
interface TypedArray<T extends number | bigint, A extends TypedArray<T, A>> {
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
}
242 changes: 25 additions & 217 deletions src/lib/es2015.iterable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,258 +226,66 @@ interface String {
[Symbol.iterator](): BuiltinIterator<string, BuiltinIteratorReturn>;
}

interface Int8Array {
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
interface TypedArray<T extends number | bigint, A extends TypedArray<T, A>> {
[Symbol.iterator](): BuiltinIterator<T, BuiltinIteratorReturn>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
entries(): BuiltinIterator<[number, T], BuiltinIteratorReturn>;
/**
* Returns an list of keys in the array
*/
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an list of values in the array
*/
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
values(): BuiltinIterator<T, BuiltinIteratorReturn>;
}

interface Int8ArrayConstructor {
new (elements: Iterable<number>): Int8Array;
interface TypedArrayConstructor<T extends number | bigint, A extends TypedArray<T, A>> {
new (elements: Iterable<T>): A;

/**
* 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<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array;
from(arrayLike: Iterable<T>, mapfn?: (v: T, k: number) => T, thisArg?: any): A;
}

interface Uint8Array {
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
/**
* Returns an list of keys in the array
*/
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an list of values in the array
*/
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
}
interface Int8Array extends TypedArray<number, Int8Array> {}

interface Uint8ArrayConstructor {
new (elements: Iterable<number>): Uint8Array;
interface Int8ArrayConstructor extends TypedArrayConstructor<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 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<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array;
}
interface Uint8Array extends TypedArray<number, Uint8Array> {}

interface Uint8ClampedArray {
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
interface Uint8ArrayConstructor extends TypedArrayConstructor<number, Uint8Array> {}

/**
* Returns an list of keys in the array
*/
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
interface Uint8ClampedArray extends TypedArray<number, Uint8ClampedArray> {}

/**
* Returns an list of values in the array
*/
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
}
interface Uint8ClampedArrayConstructor extends TypedArrayConstructor<number, Uint8ClampedArray> {}

interface Uint8ClampedArrayConstructor {
new (elements: Iterable<number>): Uint8ClampedArray;
interface Int16Array extends TypedArray<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 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<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray;
}
interface Int16ArrayConstructor extends TypedArrayConstructor<number, Int16Array> {}

interface Int16Array {
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
interface Uint16Array extends TypedArray<number, Uint16Array> {}

/**
* Returns an list of keys in the array
*/
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
interface Uint16ArrayConstructor extends TypedArrayConstructor<number, Uint16Array> {}

/**
* Returns an list of values in the array
*/
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
}
interface Int32Array extends TypedArray<number, Int32Array> {}

interface Int16ArrayConstructor {
new (elements: Iterable<number>): Int16Array;
interface Int32ArrayConstructor extends TypedArrayConstructor<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 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<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array;
}
interface Uint32Array extends TypedArray<number, Uint32Array> {}

interface Uint16Array {
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
/**
* Returns an list of keys in the array
*/
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an list of values in the array
*/
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
}
interface Uint32ArrayConstructor extends TypedArrayConstructor<number, Uint32Array> {}

interface Uint16ArrayConstructor {
new (elements: Iterable<number>): Uint16Array;
interface Float32Array extends TypedArray<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 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<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array;
}
interface Float32ArrayConstructor extends TypedArrayConstructor<number, Float32Array> {}

interface Int32Array {
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
/**
* Returns an list of keys in the array
*/
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an list of values in the array
*/
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
}

interface Int32ArrayConstructor {
new (elements: Iterable<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 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<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array;
}

interface Uint32Array {
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
/**
* Returns an list of keys in the array
*/
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an list of values in the array
*/
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
}

interface Uint32ArrayConstructor {
new (elements: Iterable<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 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<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array;
}

interface Float32Array {
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
/**
* Returns an list of keys in the array
*/
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an list of values in the array
*/
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
}
interface Float64Array extends TypedArray<number, Float64Array> {}

interface Float32ArrayConstructor {
new (elements: Iterable<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 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<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array;
}

interface Float64Array {
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
/**
* Returns an list of keys in the array
*/
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
/**
* Returns an list of values in the array
*/
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
}

interface Float64ArrayConstructor {
new (elements: Iterable<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 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<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array;
}
interface Float64ArrayConstructor extends TypedArrayConstructor<number, Float64Array> {}
18 changes: 9 additions & 9 deletions src/lib/es2015.symbol.wellknown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,39 +258,39 @@ interface DataView {
readonly [Symbol.toStringTag]: string;
}

interface Int8Array {
interface Int8Array extends TypedArray<number, Int8Array> {
readonly [Symbol.toStringTag]: "Int8Array";
}

interface Uint8Array {
interface Uint8Array extends TypedArray<number, Uint8Array> {
readonly [Symbol.toStringTag]: "Uint8Array";
}

interface Uint8ClampedArray {
interface Uint8ClampedArray extends TypedArray<number, Uint8ClampedArray> {
readonly [Symbol.toStringTag]: "Uint8ClampedArray";
}

interface Int16Array {
interface Int16Array extends TypedArray<number, Int16Array> {
readonly [Symbol.toStringTag]: "Int16Array";
}

interface Uint16Array {
interface Uint16Array extends TypedArray<number, Uint16Array> {
readonly [Symbol.toStringTag]: "Uint16Array";
}

interface Int32Array {
interface Int32Array extends TypedArray<number, Int32Array> {
readonly [Symbol.toStringTag]: "Int32Array";
}

interface Uint32Array {
interface Uint32Array extends TypedArray<number, Uint32Array> {
readonly [Symbol.toStringTag]: "Uint32Array";
}

interface Float32Array {
interface Float32Array extends TypedArray<number, Float32Array> {
readonly [Symbol.toStringTag]: "Float32Array";
}

interface Float64Array {
interface Float64Array extends TypedArray<number, Float64Array> {
readonly [Symbol.toStringTag]: "Float64Array";
}

Expand Down
Loading