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

Add ESNext float16 features and fix TypedArrays of BigInt types #60151

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ const libEntries: [string, string][] = [
["esnext.string", "lib.es2024.string.d.ts"],
["esnext.iterator", "lib.esnext.iterator.d.ts"],
["esnext.promise", "lib.esnext.promise.d.ts"],
["esnext.float16", "lib.esnext.float16.d.ts"],
["decorators", "lib.decorators.d.ts"],
["decorators.legacy", "lib.decorators.legacy.d.ts"],
];
Expand Down
10 changes: 10 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,9 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
"fround",
"cbrt",
],
esnext: [
"f16round",
],
})),
Map: new Map(Object.entries({
es2015: [
Expand Down Expand Up @@ -1727,6 +1730,10 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
"getBigInt64",
"getBigUint64",
],
esnext: [
"setFloat16",
"getFloat16",
],
})),
BigInt: new Map(Object.entries({
es2020: emptyArray,
Expand Down Expand Up @@ -1829,6 +1836,9 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
"with",
],
})),
Float16Array: new Map(Object.entries({
esnext: emptyArray,
})),
Float32Array: new Map(Object.entries({
es2022: [
"at",
Expand Down
123 changes: 69 additions & 54 deletions src/lib/es2015.iterable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,12 @@ interface SetIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknow
interface Set<T> {
/** Iterates over values in the set. */
[Symbol.iterator](): SetIterator<T>;

/**
* Returns an iterable of [v,v] pairs for every value `v` in the set.
*/
entries(): SetIterator<[T, T]>;

/**
* Despite its name, returns an iterable of the values in the set.
*/
Expand Down Expand Up @@ -254,14 +256,17 @@ interface String {

interface Int8Array<TArrayBuffer extends ArrayBufferLike> {
[Symbol.iterator](): ArrayIterator<number>;

/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): ArrayIterator<[number, number]>;

/**
* Returns an list of keys in the array
*/
keys(): ArrayIterator<number>;

/**
* Returns an list of values in the array
*/
Expand All @@ -273,30 +278,32 @@ interface Int8ArrayConstructor {

/**
* 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.
* @param elements An iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Int8Array<ArrayBuffer>;
from(elements: Iterable<number>): Int8Array<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 elements 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<T>(arrayLike: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Int8Array<ArrayBuffer>;
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Int8Array<ArrayBuffer>;
}

interface Uint8Array<TArrayBuffer extends ArrayBufferLike> {
[Symbol.iterator](): ArrayIterator<number>;

/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): ArrayIterator<[number, number]>;

/**
* Returns an list of keys in the array
*/
keys(): ArrayIterator<number>;

/**
* Returns an list of values in the array
*/
Expand All @@ -308,22 +315,22 @@ interface Uint8ArrayConstructor {

/**
* 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.
* @param elements An iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Uint8Array<ArrayBuffer>;
from(elements: Iterable<number>): Uint8Array<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 elements 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<T>(arrayLike: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint8Array<ArrayBuffer>;
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint8Array<ArrayBuffer>;
}

interface Uint8ClampedArray<TArrayBuffer extends ArrayBufferLike> {
[Symbol.iterator](): ArrayIterator<number>;

/**
* Returns an array of key, value pairs for every entry in the array
*/
Expand All @@ -345,18 +352,17 @@ interface Uint8ClampedArrayConstructor {

/**
* 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.
* @param elements An iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Uint8ClampedArray<ArrayBuffer>;
from(elements: Iterable<number>): Uint8ClampedArray<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 elements 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<T>(arrayLike: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray<ArrayBuffer>;
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray<ArrayBuffer>;
}

interface Int16Array<TArrayBuffer extends ArrayBufferLike> {
Expand All @@ -382,30 +388,32 @@ interface Int16ArrayConstructor {

/**
* 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.
* @param elements An iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Int16Array<ArrayBuffer>;
from(elements: Iterable<number>): Int16Array<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 elements 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<T>(arrayLike: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Int16Array<ArrayBuffer>;
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Int16Array<ArrayBuffer>;
}

interface Uint16Array<TArrayBuffer extends ArrayBufferLike> {
[Symbol.iterator](): ArrayIterator<number>;

/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): ArrayIterator<[number, number]>;

/**
* Returns an list of keys in the array
*/
keys(): ArrayIterator<number>;

/**
* Returns an list of values in the array
*/
Expand All @@ -417,30 +425,32 @@ interface Uint16ArrayConstructor {

/**
* 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.
* @param elements An iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Uint16Array<ArrayBuffer>;
from(elements: Iterable<number>): Uint16Array<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 elements 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<T>(arrayLike: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint16Array<ArrayBuffer>;
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint16Array<ArrayBuffer>;
}

interface Int32Array<TArrayBuffer extends ArrayBufferLike> {
[Symbol.iterator](): ArrayIterator<number>;

/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): ArrayIterator<[number, number]>;

/**
* Returns an list of keys in the array
*/
keys(): ArrayIterator<number>;

/**
* Returns an list of values in the array
*/
Expand All @@ -452,30 +462,32 @@ interface Int32ArrayConstructor {

/**
* 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.
* @param elements An iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Int32Array<ArrayBuffer>;
from(elements: Iterable<number>): Int32Array<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 elements 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<T>(arrayLike: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Int32Array<ArrayBuffer>;
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Int32Array<ArrayBuffer>;
}

interface Uint32Array<TArrayBuffer extends ArrayBufferLike> {
[Symbol.iterator](): ArrayIterator<number>;

/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): ArrayIterator<[number, number]>;

/**
* Returns an list of keys in the array
*/
keys(): ArrayIterator<number>;

/**
* Returns an list of values in the array
*/
Expand All @@ -487,30 +499,32 @@ interface Uint32ArrayConstructor {

/**
* 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.
* @param elements An iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Uint32Array<ArrayBuffer>;
from(elements: Iterable<number>): Uint32Array<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 elements 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<T>(arrayLike: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint32Array<ArrayBuffer>;
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint32Array<ArrayBuffer>;
}

interface Float32Array<TArrayBuffer extends ArrayBufferLike> {
[Symbol.iterator](): ArrayIterator<number>;

/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): ArrayIterator<[number, number]>;

/**
* Returns an list of keys in the array
*/
keys(): ArrayIterator<number>;

/**
* Returns an list of values in the array
*/
Expand All @@ -522,30 +536,32 @@ interface Float32ArrayConstructor {

/**
* 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.
* @param elements An iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Float32Array<ArrayBuffer>;
from(elements: Iterable<number>): Float32Array<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 elements 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<T>(arrayLike: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Float32Array<ArrayBuffer>;
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Float32Array<ArrayBuffer>;
}

interface Float64Array<TArrayBuffer extends ArrayBufferLike> {
[Symbol.iterator](): ArrayIterator<number>;

/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): ArrayIterator<[number, number]>;

/**
* Returns an list of keys in the array
*/
keys(): ArrayIterator<number>;

/**
* Returns an list of values in the array
*/
Expand All @@ -557,16 +573,15 @@ interface Float64ArrayConstructor {

/**
* 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.
* @param elements An iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Float64Array<ArrayBuffer>;
from(elements: Iterable<number>): Float64Array<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 elements 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<T>(arrayLike: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Float64Array<ArrayBuffer>;
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Float64Array<ArrayBuffer>;
}
Loading