Skip to content

Make typed arrays generic over ArrayBufferLike #59407

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

Closed
wants to merge 1 commit 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
4 changes: 4 additions & 0 deletions src/harness/fourslashInterfaceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,10 @@ export namespace Completion {
interfaceEntry("ArrayBufferView"),
varEntry("DataView"),
interfaceEntry("DataViewConstructor"),
interfaceEntry("TypedArrayTypes"),
typeEntry("TypedArrayType"),
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<Tag extends string, T extends number | bigint, Buffer extends ArrayBufferLike> {
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
}
235 changes: 8 additions & 227 deletions src/lib/es2015.iterable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,258 +226,39 @@ interface String {
[Symbol.iterator](): BuiltinIterator<string, BuiltinIteratorReturn>;
}

interface Int8Array {
[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 Int8ArrayConstructor {
new (elements: Iterable<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): Int8Array;
}

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 Uint8ArrayConstructor {
new (elements: Iterable<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 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 Uint8ClampedArray {
[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 Uint8ClampedArrayConstructor {
new (elements: Iterable<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 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 Int16Array {
[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 Int16ArrayConstructor {
new (elements: Iterable<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): Int16Array;
}

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 Uint16ArrayConstructor {
new (elements: Iterable<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 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 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>;
interface TypedArray<Tag extends string, T extends number | bigint, Buffer extends ArrayBufferLike> {
[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 Uint32ArrayConstructor {
new (elements: Iterable<number>): Uint32Array;
interface TypedArrayConstructor<Tag extends keyof TypedArrayTypes<any>> {
new (elements: Iterable<TypedArrayType<Tag>[number]>): TypedArrayType<Tag, ArrayBuffer>;

/**
* 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 Float32ArrayConstructor {
new (elements: Iterable<number>): Float32Array;
from(arrayLike: Iterable<TypedArrayType<Tag>[number]>, mapfn?: (v: TypedArrayType<Tag>[number], k: number) => TypedArrayType<Tag>[number], thisArg?: any): TypedArrayType<Tag, ArrayBuffer>;

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

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;
}
36 changes: 2 additions & 34 deletions src/lib/es2015.symbol.wellknown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,40 +258,8 @@ interface DataView {
readonly [Symbol.toStringTag]: string;
}

interface Int8Array {
readonly [Symbol.toStringTag]: "Int8Array";
}

interface Uint8Array {
readonly [Symbol.toStringTag]: "Uint8Array";
}

interface Uint8ClampedArray {
readonly [Symbol.toStringTag]: "Uint8ClampedArray";
}

interface Int16Array {
readonly [Symbol.toStringTag]: "Int16Array";
}

interface Uint16Array {
readonly [Symbol.toStringTag]: "Uint16Array";
}

interface Int32Array {
readonly [Symbol.toStringTag]: "Int32Array";
}

interface Uint32Array {
readonly [Symbol.toStringTag]: "Uint32Array";
}

interface Float32Array {
readonly [Symbol.toStringTag]: "Float32Array";
}

interface Float64Array {
readonly [Symbol.toStringTag]: "Float64Array";
interface TypedArray<Tag extends string, T extends number | bigint, Buffer extends ArrayBufferLike> {
readonly [Symbol.toStringTag]: Tag;
}

interface ArrayConstructor {
Expand Down
Loading
Loading