From 61cbb9d711cde76940fbc8487cdc66948a306387 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 17 Apr 2025 15:24:50 +0700 Subject: [PATCH 001/315] Proposals type definitions --- .../accessible-object-hasownproperty.d.ts | 6 + .../types/proposals/array-buffer-base64.d.ts | 28 +++++ .../proposals/array-buffer-transfer.d.ts | 9 ++ .../types/proposals/array-filtering.d.ts | 49 ++++++++ .../types/proposals/array-find-from-last.d.ts | 106 ++++++++++++++++++ .../types/proposals/array-flat-map.d.ts | 8 ++ .../types/proposals/array-from-async.d.ts | 8 ++ .../types/proposals/array-grouping.d.ts | 11 ++ .../types/proposals/array-includes.d.ts | 49 ++++++++ .../proposals/array-is-template-object.d.ts | 5 + .../core-js/types/proposals/array-unique.d.ts | 49 ++++++++ .../types/proposals/async-iteration.d.ts | 6 + .../proposals/async-iterator-helpers.d.ts | 35 ++++++ .../types/proposals/change-array-by-copy.d.ts | 104 +++++++++++++++++ .../types/proposals/collection-of-from.d.ts | 25 +++++ .../data-view-get-set-uint8-clamped.d.ts | 6 + .../types/proposals/decorator-metadata.d.ts | 9 ++ .../explicit-resource-management.d.ts | 84 ++++++++++++++ .../core-js/types/proposals/extractors.d.ts | 5 + .../types/proposals/function-demethodize.d.ts | 5 + .../core-js/types/proposals/is-error.d.ts | 5 + .../types/proposals/iterator-range.d.ts | 17 +++ .../types/proposals/iterator-sequencing.d.ts | 5 + .../proposals/json-parse-with-source.d.ts | 5 + .../core-js/types/proposals/map-upsert.d.ts | 11 ++ .../core-js/types/proposals/math-clamp.d.ts | 5 + .../core-js/types/proposals/math-sum.d.ts | 5 + .../types/proposals/string-cooked.d.ts | 5 + .../types/proposals/string-dedent.d.ts | 5 + .../types/proposals/symbol-predicates.d.ts | 5 + 30 files changed, 675 insertions(+) create mode 100644 packages/core-js/types/proposals/accessible-object-hasownproperty.d.ts create mode 100644 packages/core-js/types/proposals/array-buffer-base64.d.ts create mode 100644 packages/core-js/types/proposals/array-buffer-transfer.d.ts create mode 100644 packages/core-js/types/proposals/array-filtering.d.ts create mode 100644 packages/core-js/types/proposals/array-find-from-last.d.ts create mode 100644 packages/core-js/types/proposals/array-flat-map.d.ts create mode 100644 packages/core-js/types/proposals/array-from-async.d.ts create mode 100644 packages/core-js/types/proposals/array-grouping.d.ts create mode 100644 packages/core-js/types/proposals/array-includes.d.ts create mode 100644 packages/core-js/types/proposals/array-is-template-object.d.ts create mode 100644 packages/core-js/types/proposals/array-unique.d.ts create mode 100644 packages/core-js/types/proposals/async-iteration.d.ts create mode 100644 packages/core-js/types/proposals/async-iterator-helpers.d.ts create mode 100644 packages/core-js/types/proposals/change-array-by-copy.d.ts create mode 100644 packages/core-js/types/proposals/collection-of-from.d.ts create mode 100644 packages/core-js/types/proposals/data-view-get-set-uint8-clamped.d.ts create mode 100644 packages/core-js/types/proposals/decorator-metadata.d.ts create mode 100644 packages/core-js/types/proposals/explicit-resource-management.d.ts create mode 100644 packages/core-js/types/proposals/extractors.d.ts create mode 100644 packages/core-js/types/proposals/function-demethodize.d.ts create mode 100644 packages/core-js/types/proposals/is-error.d.ts create mode 100644 packages/core-js/types/proposals/iterator-range.d.ts create mode 100644 packages/core-js/types/proposals/iterator-sequencing.d.ts create mode 100644 packages/core-js/types/proposals/json-parse-with-source.d.ts create mode 100644 packages/core-js/types/proposals/map-upsert.d.ts create mode 100644 packages/core-js/types/proposals/math-clamp.d.ts create mode 100644 packages/core-js/types/proposals/math-sum.d.ts create mode 100644 packages/core-js/types/proposals/string-cooked.d.ts create mode 100644 packages/core-js/types/proposals/string-dedent.d.ts create mode 100644 packages/core-js/types/proposals/symbol-predicates.d.ts diff --git a/packages/core-js/types/proposals/accessible-object-hasownproperty.d.ts b/packages/core-js/types/proposals/accessible-object-hasownproperty.d.ts new file mode 100644 index 000000000000..192513c61f2c --- /dev/null +++ b/packages/core-js/types/proposals/accessible-object-hasownproperty.d.ts @@ -0,0 +1,6 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-accessible-object-hasownproperty +interface ObjectConstructor { + // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2022.object.d.ts + hasOwn(o: object, v: PropertyKey): boolean; +} diff --git a/packages/core-js/types/proposals/array-buffer-base64.d.ts b/packages/core-js/types/proposals/array-buffer-base64.d.ts new file mode 100644 index 000000000000..fd0477d57029 --- /dev/null +++ b/packages/core-js/types/proposals/array-buffer-base64.d.ts @@ -0,0 +1,28 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-arraybuffer-base64 +type alphabet = 'base64' | 'base64url'; +type lastChunkHandling = 'loose' | 'strict' | 'stop-before-partial'; +type fromBase64Options = { + alphabet?: alphabet; + lastChunkHandling?: lastChunkHandling; +} +type toBase64Options = { + alphabet?: alphabet; + omitPadding?: boolean; +} +type processMetadata = { + read: number; + written: number; +} + +interface Uint8ArrayConstructor { + fromBase64(str: string, opts?: fromBase64Options): Uint8Array; + fromHex(str: string): Uint8Array; +} + +interface Uint8Array { + setFromBase64(str: string, opts?: fromBase64Options): Uint8Array; + setFromHex(str: string): processMetadata; + toBase64(opts?: toBase64Options): string; + toHex(): string; +} diff --git a/packages/core-js/types/proposals/array-buffer-transfer.d.ts b/packages/core-js/types/proposals/array-buffer-transfer.d.ts new file mode 100644 index 000000000000..9b92e92c6926 --- /dev/null +++ b/packages/core-js/types/proposals/array-buffer-transfer.d.ts @@ -0,0 +1,9 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-arraybuffer-transfer +interface ArrayBuffer { + readonly detached: boolean; + + slice(start?: number, end?: number): ArrayBuffer; + transfer(newByteLength?: number): ArrayBuffer; + transferToFixedLength(newByteLength?: number): ArrayBuffer; +} diff --git a/packages/core-js/types/proposals/array-filtering.d.ts b/packages/core-js/types/proposals/array-filtering.d.ts new file mode 100644 index 000000000000..1a9a8fb8aa06 --- /dev/null +++ b/packages/core-js/types/proposals/array-filtering.d.ts @@ -0,0 +1,49 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-array-filtering +interface Array { + filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; +} + +interface Int8Array { + filterReject(callbackFn: (value: number, index: number, target: Int8Array) => boolean, thisArg?: any): Int8Array; +} + +interface Uint8Array { + filterReject(callbackFn: (value: number, index: number, target: Uint8Array) => boolean, thisArg?: any): Uint8Array; +} + +interface Uint8ClampedArray { + filterReject(callbackFn: (value: number, index: number, target: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; +} + +interface Int16Array { + filterReject(callbackFn: (value: number, index: number, target: Int16Array) => boolean, thisArg?: any): Int16Array; +} + +interface Uint16Array { + filterReject(callbackFn: (value: number, index: number, target: Uint16Array) => boolean, thisArg?: any): Uint16Array; +} + +interface Int32Array { + filterReject(callbackFn: (value: number, index: number, target: Int32Array) => boolean, thisArg?: any): Int32Array; +} + +interface Uint32Array { + filterReject(callbackFn: (value: number, index: number, target: Uint32Array) => boolean, thisArg?: any): Uint32Array; +} + +interface Float32Array { + filterReject(callbackFn: (value: number, index: number, target: Float32Array) => boolean, thisArg?: any): Float32Array; +} + +interface Float64Array { + filterReject(callbackFn: (value: number, index: number, target: Float64Array) => boolean, thisArg?: any): Float64Array; +} + +interface BigInt64Array { + filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array; +} + +interface BigUint64Array { + filterReject(callbackFn: (value: bigint, index: number, target: BigUint64Array) => boolean, thisArg?: any): BigUint64Array; +} diff --git a/packages/core-js/types/proposals/array-find-from-last.d.ts b/packages/core-js/types/proposals/array-find-from-last.d.ts new file mode 100644 index 000000000000..41ae4a0f12ab --- /dev/null +++ b/packages/core-js/types/proposals/array-find-from-last.d.ts @@ -0,0 +1,106 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-array-find-from-last +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts#L5 +interface Array { + findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T | undefined; + + findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; +} + +interface Int8Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Uint8Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Uint8Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Uint8ClampedArray { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Int16Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Uint16Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Int32Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Uint32Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Float32Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Float64Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface BigInt64Array { + findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface BigUint64Array { + findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; +} diff --git a/packages/core-js/types/proposals/array-flat-map.d.ts b/packages/core-js/types/proposals/array-flat-map.d.ts new file mode 100644 index 000000000000..270e759a426f --- /dev/null +++ b/packages/core-js/types/proposals/array-flat-map.d.ts @@ -0,0 +1,8 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-flatMap +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 +interface Array { + flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): U[]; + + flat(this: A, depth?: D): FlatArray[]; +} diff --git a/packages/core-js/types/proposals/array-from-async.d.ts b/packages/core-js/types/proposals/array-from-async.d.ts new file mode 100644 index 000000000000..98097c3c5f81 --- /dev/null +++ b/packages/core-js/types/proposals/array-from-async.d.ts @@ -0,0 +1,8 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-array-from-async +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/esnext.array.d.ts#L6 +interface ArrayConstructor { + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; + + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; +} diff --git a/packages/core-js/types/proposals/array-grouping.d.ts b/packages/core-js/types/proposals/array-grouping.d.ts new file mode 100644 index 000000000000..eb63fc247326 --- /dev/null +++ b/packages/core-js/types/proposals/array-grouping.d.ts @@ -0,0 +1,11 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-array-grouping +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.object.d.ts#L7 +interface ObjectConstructor { + groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Partial>; +} + +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.collection.d.ts#L7 +interface MapConstructor { + groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Map; +} diff --git a/packages/core-js/types/proposals/array-includes.d.ts b/packages/core-js/types/proposals/array-includes.d.ts new file mode 100644 index 000000000000..d4e5a6a39820 --- /dev/null +++ b/packages/core-js/types/proposals/array-includes.d.ts @@ -0,0 +1,49 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-Array.prototype.includes +interface Array { + includes(searchElement: T, fromIndex?: number): boolean; +} + +interface Int8Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint8Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint8ClampedArray { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Int16Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint16Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Int32Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint32Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Float32Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Float64Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface BigInt64Array { + includes(searchElement: bigint, fromIndex?: number): boolean; +} + +interface BigUint64Array { + includes(searchElement: bigint, fromIndex?: number): boolean; +} diff --git a/packages/core-js/types/proposals/array-is-template-object.d.ts b/packages/core-js/types/proposals/array-is-template-object.d.ts new file mode 100644 index 000000000000..6ce9d9aa6ae7 --- /dev/null +++ b/packages/core-js/types/proposals/array-is-template-object.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-array-is-template-object +interface ArrayConstructor { + isTemplateObject(value: unknown): value is TemplateStringsArray; +} \ No newline at end of file diff --git a/packages/core-js/types/proposals/array-unique.d.ts b/packages/core-js/types/proposals/array-unique.d.ts new file mode 100644 index 000000000000..8fcfd97a7a3d --- /dev/null +++ b/packages/core-js/types/proposals/array-unique.d.ts @@ -0,0 +1,49 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-array-unique +interface Array { + uniqueBy(resolver?: keyof T | ((value: T) => PropertyKey)): Array; +} + +interface Int8Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Int8Array; +} + +interface Uint8Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Uint8Array; +} + +interface Uint8ClampedArray { + uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Uint8ClampedArray; +} + +interface Int16Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Int16Array; +} + +interface Uint16Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Uint16Array; +} + +interface Int32Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Int32Array; +} + +interface Uint32Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Uint32Array; +} + +interface Float32Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Float32Array; +} + +interface Float64Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Float64Array; +} + +interface BigInt64Array { + uniqueBy(resolver?: PropertyKey | ((value: bigint) => PropertyKey)): BigInt64Array; +} + +interface BigUint64Array { + uniqueBy(resolver?: PropertyKey | ((value: bigint) => PropertyKey)): BigUint64Array; +} diff --git a/packages/core-js/types/proposals/async-iteration.d.ts b/packages/core-js/types/proposals/async-iteration.d.ts new file mode 100644 index 000000000000..37fd697a790d --- /dev/null +++ b/packages/core-js/types/proposals/async-iteration.d.ts @@ -0,0 +1,6 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-async-iteration +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2018.asynciterable.d.ts#L4 +interface SymbolConstructor { + readonly asyncIterator: unique symbol; // todo check +} diff --git a/packages/core-js/types/proposals/async-iterator-helpers.d.ts b/packages/core-js/types/proposals/async-iterator-helpers.d.ts new file mode 100644 index 000000000000..27794f32ce6c --- /dev/null +++ b/packages/core-js/types/proposals/async-iterator-helpers.d.ts @@ -0,0 +1,35 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-async-iterator-helpers +interface AsyncIteratorConstructor { + from(iterable: AsyncIterable | Iterable | AsyncIterator): AsyncIterator; +} + +declare const AsyncIterator: AsyncIteratorConstructor; + +interface AsyncIterator { + drop(limit: number): AsyncIterator; + + every(predicate: (value: T, index: number) => boolean): Promise; + + filter(predicate: (value: T, index: number) => boolean): AsyncIterator; + + find(predicate: (value: T, index: number) => boolean): Promise; + + flatMap(mapper: (value: T, index: number) => any): AsyncIterator; + + forEach(callbackFn: (value: T, index: number) => void): Promise; + + map(mapper: (value: T, index: number) => any): AsyncIterator; + + reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; + + some(predicate: (value: T, index: number) => boolean): Promise; + + take(limit: number): AsyncIterator; + + toArray(): Promise; +} + +interface Iterator { + toAsync(): AsyncIterator; +} diff --git a/packages/core-js/types/proposals/change-array-by-copy.d.ts b/packages/core-js/types/proposals/change-array-by-copy.d.ts new file mode 100644 index 000000000000..bac72b7ff955 --- /dev/null +++ b/packages/core-js/types/proposals/change-array-by-copy.d.ts @@ -0,0 +1,104 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-change-array-by-copy +interface Array { + // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L28 + toReversed(): T[]; + + // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L39 + toSorted(compareFn?: (a: T, b: T) => number): T[]; + + // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L48 + toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; + toSpliced(start: number, deleteCount?: number): T[]; + + // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L67 + with(index: number, value: T): T[]; +} + +interface Int8Array { + toReversed(): Int8Array; + + toSorted(compareFn?: (a: number, b: number) => number): Int8Array; + + with(index: number, value: number): Int8Array; +} + +interface Uint8Array { + toReversed(): Uint8Array; + + toSorted(compareFn?: (a: number, b: number) => number): Uint8Array; + + with(index: number, value: number): Uint8Array; +} + +interface Uint8ClampedArray { + toReversed(): Uint8ClampedArray; + + toSorted(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + with(index: number, value: number): Uint8ClampedArray; +} + +interface Int16Array { + toReversed(): Int16Array; + + toSorted(compareFn?: (a: number, b: number) => number): Int16Array; + + with(index: number, value: number): Int16Array; +} + +interface Uint16Array { + toReversed(): Uint16Array; + + toSorted(compareFn?: (a: number, b: number) => number): Uint16Array; + + with(index: number, value: number): Uint16Array; +} + +interface Int32Array { + toReversed(): Int32Array; + + toSorted(compareFn?: (a: number, b: number) => number): Int32Array; + + with(index: number, value: number): Int32Array; +} + +interface Uint32Array { + toReversed(): Uint32Array; + + toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; + + with(index: number, value: number): Uint32Array; +} + +interface Float32Array { + toReversed(): Float32Array; + + toSorted(compareFn?: (a: number, b: number) => number): Float32Array; + + with(index: number, value: number): Float32Array; +} + +interface Float64Array { + toReversed(): Float64Array; + + toSorted(compareFn?: (a: number, b: number) => number): Float64Array; + + with(index: number, value: number): Float64Array; +} + +interface BigInt64Array { + toReversed(): BigInt64Array; + + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; + + with(index: number, value: bigint): BigInt64Array; +} + +interface BigUint64Array { + toReversed(): BigUint64Array; + + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; + + with(index: number, value: bigint): BigUint64Array; +} diff --git a/packages/core-js/types/proposals/collection-of-from.d.ts b/packages/core-js/types/proposals/collection-of-from.d.ts new file mode 100644 index 000000000000..6e6bdeb8e2bd --- /dev/null +++ b/packages/core-js/types/proposals/collection-of-from.d.ts @@ -0,0 +1,25 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-setmap-offrom +interface MapConstructor { + from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): Map; + + of(...items: [K, V][]): Map; +} + +interface SetConstructor { + from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): Set; + + of(...items: T[]): Set; +} + +interface WeakMapConstructor { + from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): WeakMap; + + of(...items: [K, V][]): WeakMap; +} + +interface WeakSetConstructor { + from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): WeakSet; + + of(...items: T[]): WeakSet; +} diff --git a/packages/core-js/types/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js/types/proposals/data-view-get-set-uint8-clamped.d.ts new file mode 100644 index 000000000000..6def9aad49cf --- /dev/null +++ b/packages/core-js/types/proposals/data-view-get-set-uint8-clamped.d.ts @@ -0,0 +1,6 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-setmap-offrom +interface DataView { + getUint8Clamped(byteOffset: number): number; + setUint8Clamped(byteOffset: number, value: number): void; +} diff --git a/packages/core-js/types/proposals/decorator-metadata.d.ts b/packages/core-js/types/proposals/decorator-metadata.d.ts new file mode 100644 index 000000000000..9a277111cba8 --- /dev/null +++ b/packages/core-js/types/proposals/decorator-metadata.d.ts @@ -0,0 +1,9 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-decorator-metadata +interface SymbolConstructor { + readonly metadata: unique symbol; +} + +interface Object { + [Symbol.metadata]?: object; +} diff --git a/packages/core-js/types/proposals/explicit-resource-management.d.ts b/packages/core-js/types/proposals/explicit-resource-management.d.ts new file mode 100644 index 000000000000..4baa47c3792d --- /dev/null +++ b/packages/core-js/types/proposals/explicit-resource-management.d.ts @@ -0,0 +1,84 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-explicit-resource-management +// https://github.com/microsoft/TypeScript/blob/0a1aa6d6ebdfa16b82f4a6aaf282089b1d484e05/src/lib/esnext.disposable.d.ts +interface SymbolConstructor { + readonly dispose: unique symbol; + + readonly asyncDispose: unique symbol; +} + +interface Disposable { + [Symbol.dispose](): void; +} + +interface AsyncDisposable { + [Symbol.asyncDispose](): PromiseLike; +} + +interface SuppressedError extends Error { + error: any; + suppressed: any; +} + +interface SuppressedErrorConstructor { + new (error: any, suppressed: any, message?: string): SuppressedError; + (error: any, suppressed: any, message?: string): SuppressedError; + readonly prototype: SuppressedError; +} + +declare var SuppressedError: SuppressedErrorConstructor; + +interface DisposableStack { + readonly disposed: boolean; + + dispose(): void; + + use(value: T): T; + + adopt(value: T, onDispose: (value: T) => void): T; + + defer(onDispose: () => void): void; + + move(): DisposableStack; + + [Symbol.dispose](): void; + + readonly [Symbol.toStringTag]: string; +} + +interface DisposableStackConstructor { + new (): DisposableStack; + readonly prototype: DisposableStack; +} +declare var DisposableStack: DisposableStackConstructor; + +interface AsyncDisposableStack { + readonly disposed: boolean; + + disposeAsync(): Promise; + + use(value: T): T; + + adopt(value: T, onDisposeAsync: (value: T) => PromiseLike | void): T; + + defer(onDisposeAsync: () => PromiseLike | void): void; + + move(): AsyncDisposableStack; + + [Symbol.asyncDispose](): Promise; + + readonly [Symbol.toStringTag]: string; +} + +interface AsyncDisposableStackConstructor { + new (): AsyncDisposableStack; + + readonly prototype: AsyncDisposableStack; +} +declare var AsyncDisposableStack: AsyncDisposableStackConstructor; + +interface IteratorObject extends Disposable { +} + +interface AsyncIteratorObject extends AsyncDisposable { +} diff --git a/packages/core-js/types/proposals/extractors.d.ts b/packages/core-js/types/proposals/extractors.d.ts new file mode 100644 index 000000000000..63b2c5d2c2b2 --- /dev/null +++ b/packages/core-js/types/proposals/extractors.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-extractors +interface SymbolConstructor { + readonly customExtractor: unique symbol; +} diff --git a/packages/core-js/types/proposals/function-demethodize.d.ts b/packages/core-js/types/proposals/function-demethodize.d.ts new file mode 100644 index 000000000000..d4660c6ea3a9 --- /dev/null +++ b/packages/core-js/types/proposals/function-demethodize.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 0 +// https://github.com/js-choi/proposal-function-demethodize +interface Function { + demethodize(this: (this: T, ...args: Args) => R): (thisArg: T, ...args: Args) => R; +} diff --git a/packages/core-js/types/proposals/is-error.d.ts b/packages/core-js/types/proposals/is-error.d.ts new file mode 100644 index 000000000000..f7ebf0af180f --- /dev/null +++ b/packages/core-js/types/proposals/is-error.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-is-error +interface ErrorConstructor { + isError(value: unknown): value is Error; +} diff --git a/packages/core-js/types/proposals/iterator-range.d.ts b/packages/core-js/types/proposals/iterator-range.d.ts new file mode 100644 index 000000000000..799788c2c7b2 --- /dev/null +++ b/packages/core-js/types/proposals/iterator-range.d.ts @@ -0,0 +1,17 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-Number.range +type RangeOptionsNumber = { + step?: number; + inclusive?: boolean; +}; + +type RangeOptionsBigInt = { + step?: bigint; + inclusive?: boolean; +}; + +interface IteratorConstructor { + range(start: number, end: number, options?: number | RangeOptionsNumber): Iterator; + + range(start: bigint, end: bigint, options?: bigint | RangeOptionsBigInt): Iterator; +} diff --git a/packages/core-js/types/proposals/iterator-sequencing.d.ts b/packages/core-js/types/proposals/iterator-sequencing.d.ts new file mode 100644 index 000000000000..b8dac410badc --- /dev/null +++ b/packages/core-js/types/proposals/iterator-sequencing.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 2.7 +// https://github.com/tc39/proposal-iterator-sequencing +interface Iterator { + concat(...iterators: Array | Iterator>): Iterator; +} diff --git a/packages/core-js/types/proposals/json-parse-with-source.d.ts b/packages/core-js/types/proposals/json-parse-with-source.d.ts new file mode 100644 index 000000000000..4d81a5c2708d --- /dev/null +++ b/packages/core-js/types/proposals/json-parse-with-source.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-json-parse-with-source +interface JSON { + isRawJSON(value: unknown): value is string; +} diff --git a/packages/core-js/types/proposals/map-upsert.d.ts b/packages/core-js/types/proposals/map-upsert.d.ts new file mode 100644 index 000000000000..de0a7d38804a --- /dev/null +++ b/packages/core-js/types/proposals/map-upsert.d.ts @@ -0,0 +1,11 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-upsert +interface Map { + getOrInsert(key: K, value: V): V; + getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; +} + +interface WeakMap { + getOrInsert(key: K, value: V): V; + getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; +} diff --git a/packages/core-js/types/proposals/math-clamp.d.ts b/packages/core-js/types/proposals/math-clamp.d.ts new file mode 100644 index 000000000000..f465d79738f8 --- /dev/null +++ b/packages/core-js/types/proposals/math-clamp.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-math-clamp +interface Math { + clamp(value: number, lower: number, upper: number): number; +} diff --git a/packages/core-js/types/proposals/math-sum.d.ts b/packages/core-js/types/proposals/math-sum.d.ts new file mode 100644 index 000000000000..b6086c79854c --- /dev/null +++ b/packages/core-js/types/proposals/math-sum.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-math-sum +interface Math { + sumPrecise(...values: number[]): number; +} diff --git a/packages/core-js/types/proposals/string-cooked.d.ts b/packages/core-js/types/proposals/string-cooked.d.ts new file mode 100644 index 000000000000..bc04a4cecbc5 --- /dev/null +++ b/packages/core-js/types/proposals/string-cooked.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-string-cooked +interface String { + cooked(...values: unknown[]): string; +} \ No newline at end of file diff --git a/packages/core-js/types/proposals/string-dedent.d.ts b/packages/core-js/types/proposals/string-dedent.d.ts new file mode 100644 index 000000000000..8dfc94cde579 --- /dev/null +++ b/packages/core-js/types/proposals/string-dedent.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-string-dedent +interface StringConstructor { + dedent(strings: TemplateStringsArray, ...values: unknown[]): string; +} \ No newline at end of file diff --git a/packages/core-js/types/proposals/symbol-predicates.d.ts b/packages/core-js/types/proposals/symbol-predicates.d.ts new file mode 100644 index 000000000000..35ae774c1bbe --- /dev/null +++ b/packages/core-js/types/proposals/symbol-predicates.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-symbol-predicates +interface SymbolConstructor { + isRegisteredSymbol(value: unknown): value is symbol; +} \ No newline at end of file From e898dd7068bbe3ecad899136041bc9dda6727ab3 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 22 Apr 2025 02:28:59 +0700 Subject: [PATCH 002/315] Tests for types --- .../core-js/types/proposals/math-sum.d.ts | 10 +++++++ tests/types/package-lock.json | 26 +++++++++++++++++ tests/types/package.json | 8 ++++++ tests/types/tests/sum-precise.test.ts | 28 +++++++++++++++++++ tests/types/tsconfig.json | 10 +++++++ 5 files changed, 82 insertions(+) create mode 100644 tests/types/package-lock.json create mode 100644 tests/types/package.json create mode 100644 tests/types/tests/sum-precise.test.ts create mode 100644 tests/types/tsconfig.json diff --git a/packages/core-js/types/proposals/math-sum.d.ts b/packages/core-js/types/proposals/math-sum.d.ts index b6086c79854c..3f32a94aabdc 100644 --- a/packages/core-js/types/proposals/math-sum.d.ts +++ b/packages/core-js/types/proposals/math-sum.d.ts @@ -1,5 +1,15 @@ // proposal stage: 3 // https://github.com/tc39/proposal-math-sum +declare module 'core-js-pure/actual/math/sum-precise' { + function sumPrecise(...values: number[]): number; + export default sumPrecise; +} + +declare module 'core-js-pure/full/math/sum-precise' { + function sumPrecise(...values: number[]): number; + export default sumPrecise; +} + interface Math { sumPrecise(...values: number[]): number; } diff --git a/tests/types/package-lock.json b/tests/types/package-lock.json new file mode 100644 index 000000000000..5fcb75abaafd --- /dev/null +++ b/tests/types/package-lock.json @@ -0,0 +1,26 @@ +{ + "name": "proposals-types", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "typescript": "^5.8.3" + } + }, + "node_modules/typescript": { + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + } + } +} diff --git a/tests/types/package.json b/tests/types/package.json new file mode 100644 index 000000000000..97132f90bc3b --- /dev/null +++ b/tests/types/package.json @@ -0,0 +1,8 @@ +{ + "scripts": { + "test:types": "tsc" + }, + "devDependencies": { + "typescript": "^5.8.3" + } +} diff --git a/tests/types/tests/sum-precise.test.ts b/tests/types/tests/sum-precise.test.ts new file mode 100644 index 000000000000..380014fcc800 --- /dev/null +++ b/tests/types/tests/sum-precise.test.ts @@ -0,0 +1,28 @@ +import sumPreciseActual from 'core-js-pure/actual/math/sum-precise'; +import sumPreciseFull from 'core-js-pure/full/math/sum-precise'; + +function acceptsNumber(x: number) {} + +const a = sumPreciseActual(0.1, 0.2); +const b: number = a; +// @ts-expect-error +sumPreciseActual('10'); +// @ts-expect-error +sumPreciseActual([1, 2]); +acceptsNumber(sumPreciseActual(1, 2)); + +const af = sumPreciseFull(0.1, 0.2); +const bf: number = af; +// @ts-expect-error +sumPreciseFull('10'); +// @ts-expect-error +sumPreciseFull([1, 2]); +acceptsNumber(sumPreciseFull(1, 2)); + +const ga = Math.sumPrecise(0.1, 0.2); +const gb: number = ga; +// @ts-expect-error +Math.sumPrecise('10'); +// @ts-expect-error +Math.sumPrecise([1, 2]); +acceptsNumber(Math.sumPrecise(1, 2)); diff --git a/tests/types/tsconfig.json b/tests/types/tsconfig.json new file mode 100644 index 000000000000..0fd3a6403158 --- /dev/null +++ b/tests/types/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "ESNext", + "strict": true, + "typeRoots": ["../../packages/core-js/types/**/*.d.ts", "./node_modules/@types"], + "noEmit": true + }, + "include": ["tests", "../../packages/core-js/types/**/*.d.ts"] +} From 067e77c03ce5217e1ab3221c4c894e94c02ab406 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 23 Apr 2025 01:30:20 +0700 Subject: [PATCH 003/315] Tests for types --- .../types/proposals/array-buffer-base64.d.ts | 2 +- .../core-js/types/proposals/math-sum.d.ts | 10 ---- tests/types/tests/array-buffer-base64.test.ts | 39 ++++++++++++ tests/types/tests/array-filtering.test.ts | 60 +++++++++++++++++++ tests/types/tests/array-from-async.test.ts | 37 ++++++++++++ .../tests/array-is-template-object.test.ts | 13 ++++ tests/types/tests/math-sum.test.ts | 10 ++++ tests/types/tests/sum-precise.test.ts | 28 --------- 8 files changed, 160 insertions(+), 39 deletions(-) create mode 100644 tests/types/tests/array-buffer-base64.test.ts create mode 100644 tests/types/tests/array-filtering.test.ts create mode 100644 tests/types/tests/array-from-async.test.ts create mode 100644 tests/types/tests/array-is-template-object.test.ts create mode 100644 tests/types/tests/math-sum.test.ts delete mode 100644 tests/types/tests/sum-precise.test.ts diff --git a/packages/core-js/types/proposals/array-buffer-base64.d.ts b/packages/core-js/types/proposals/array-buffer-base64.d.ts index fd0477d57029..f4c6f75f2a7f 100644 --- a/packages/core-js/types/proposals/array-buffer-base64.d.ts +++ b/packages/core-js/types/proposals/array-buffer-base64.d.ts @@ -21,7 +21,7 @@ interface Uint8ArrayConstructor { } interface Uint8Array { - setFromBase64(str: string, opts?: fromBase64Options): Uint8Array; + setFromBase64(str: string, opts?: fromBase64Options): processMetadata; setFromHex(str: string): processMetadata; toBase64(opts?: toBase64Options): string; toHex(): string; diff --git a/packages/core-js/types/proposals/math-sum.d.ts b/packages/core-js/types/proposals/math-sum.d.ts index 3f32a94aabdc..b6086c79854c 100644 --- a/packages/core-js/types/proposals/math-sum.d.ts +++ b/packages/core-js/types/proposals/math-sum.d.ts @@ -1,15 +1,5 @@ // proposal stage: 3 // https://github.com/tc39/proposal-math-sum -declare module 'core-js-pure/actual/math/sum-precise' { - function sumPrecise(...values: number[]): number; - export default sumPrecise; -} - -declare module 'core-js-pure/full/math/sum-precise' { - function sumPrecise(...values: number[]): number; - export default sumPrecise; -} - interface Math { sumPrecise(...values: number[]): number; } diff --git a/tests/types/tests/array-buffer-base64.test.ts b/tests/types/tests/array-buffer-base64.test.ts new file mode 100644 index 000000000000..d915fb7d0959 --- /dev/null +++ b/tests/types/tests/array-buffer-base64.test.ts @@ -0,0 +1,39 @@ +function acceptUint8Array(v: Uint8Array) {} +function acceptProcessMetadata(v: { read: number; written: number }) {} +function acceptString(v: string) {} + +acceptUint8Array(Uint8Array.fromBase64('SGVsbG8gd29ybGQ=', { alphabet: 'base64', lastChunkHandling: 'loose' })); +acceptUint8Array(Uint8Array.fromHex('ddddeeeassd')); +const ar = new Uint8Array(16); +acceptProcessMetadata(ar.setFromBase64('PGI+ TURO PC9i Pg==', { alphabet: 'base64', lastChunkHandling: 'loose' })); +acceptProcessMetadata(ar.setFromHex('ddddeeeassd')); +acceptString(ar.toBase64({ alphabet: 'base64', omitPadding: true })); +acceptString(ar.toBase64()); +acceptString(ar.toHex()); + +// @ts-expect-error +Uint8Array.fromBase64('SGVsbG8gd29ybGQ', { alphabet: 'some' }); +// @ts-expect-error +Uint8Array.fromBase64('SGVsbG8gd29ybGQ', { lastChunkHandling: 'some' }); +// @ts-expect-error +Uint8Array.fromBase64(123); + +// @ts-expect-error +Uint8Array.fromHex([0, 1]); +// @ts-expect-error +Uint8Array.fromHex(123); + +// @ts-expect-error +ar.setFromBase64(5); +// @ts-expect-error +ar.setFromBase64('PGI+ TURO PC9i Pg==', { alphabet: 'some' }); +// @ts-expect-error +ar.setFromBase64('PGI+ TURO PC9i Pg==', { lastChunkHandling: 'some' }); + +// @ts-expect-error +ar.setFromHex(123); + +// @ts-expect-error +ar.toBase64({ alphabet: 'some' }); +// @ts-expect-error +ar.toBase64({ omitPadding: 'some' }); diff --git a/tests/types/tests/array-filtering.test.ts b/tests/types/tests/array-filtering.test.ts new file mode 100644 index 000000000000..190a2abd31f5 --- /dev/null +++ b/tests/types/tests/array-filtering.test.ts @@ -0,0 +1,60 @@ +function testFilterReject(arr: TArr & { filterReject: any }, _: TValue) { + const res: typeof arr = arr.filterReject((x: TValue) => false); + + arr.filterReject(function(value: TValue, index: number, target: typeof arr) { + return false; + }); + + arr.filterReject(function(this: { test: string }, value: TValue) { + return false; + }, { test: 'hello' }); +} + +testFilterReject([1,2,3], 1); +testFilterReject(new Int8Array([1,2]), 1); +testFilterReject(new Uint8Array([1,2]), 1); +testFilterReject(new Uint8ClampedArray([1,2]), 1); +testFilterReject(new Int16Array([1,2]), 1); +testFilterReject(new Uint16Array([1,2]), 1); +testFilterReject(new Int32Array([1,2]), 1); +testFilterReject(new Uint32Array([1,2]), 1); +testFilterReject(new Float32Array([1,2]), 1); +testFilterReject(new Float64Array([1,2]), 1); +testFilterReject(new BigInt64Array([1n,2n]), 1n); +testFilterReject(new BigUint64Array([1n,2n]), 1n); + +// @ts-expect-error +[1,2,3].filterReject((x: string) => false); + +// @ts-expect-error +(new Int8Array([1,2,3])).filterReject((x: string) => false); + +// @ts-expect-error +(new Uint8Array([1,2,3])).filterReject((x: string) => false); + +// @ts-expect-error +(new Uint8ClampedArray([1,2,3])).filterReject((x: string) => false); + +// @ts-expect-error +(new Int16Array([1,2,3])).filterReject((x: string) => false); + +// @ts-expect-error +(new Uint16Array([1,2,3])).filterReject((x: string) => false); + +// @ts-expect-error +(new Int32Array([1,2,3])).filterReject((x: string) => false); + +// @ts-expect-error +(new Uint32Array([1,2,3])).filterReject((x: string) => false); + +// @ts-expect-error +(new Float32Array([1,2,3])).filterReject((x: string) => false); + +// @ts-expect-error +(new Float64Array([1,2,3])).filterReject((x: string) => false); + +// @ts-expect-error +(new BigInt64Array([1n,2n,3n])).filterReject((x: number) => false); + +// @ts-expect-error +(new BigUint64Array([1n,2n,3n])).filterReject((x: number) => false); \ No newline at end of file diff --git a/tests/types/tests/array-from-async.test.ts b/tests/types/tests/array-from-async.test.ts new file mode 100644 index 000000000000..04890ba6615a --- /dev/null +++ b/tests/types/tests/array-from-async.test.ts @@ -0,0 +1,37 @@ +Array.fromAsync([1, 2, 3]); +Array.fromAsync([Promise.resolve(1), 2, 3]); +Array.fromAsync((async function* () { yield 1; })()); +Array.fromAsync([1, 2, 3], (value: number, index: number) => value.toString()); +Array.fromAsync([Promise.resolve(1), 2, 3], (value: number) => value + 1); +Array.fromAsync((async function* () { yield 1; })(), function (value: number) { return value * 2; }); +Array.fromAsync([1, 2, 3], function (this: {foo: string}, value: number) { return value.toString(); }, {foo: "str"}); + +async function t1() { + const n: number[] = await Array.fromAsync([1, 2, 3]); + const m: number[] = await Array.fromAsync([Promise.resolve(1), 2, 3]); + const s: string[] = await Array.fromAsync([1, 2, 3], (value: number) => value.toString()); +} + +async function t2() { + const bar: number[] = await Array.fromAsync([1, 2, 3], async (v: number) => v + 1); + const foo: string[] = await Array.fromAsync([Promise.resolve(1), 2], async (v: number) => String(v)); +} + +declare const arrLike: { [index: number]: PromiseLike; length: 2 }; +Array.fromAsync(arrLike); +Array.fromAsync(arrLike, (value: number) => value); + +// @ts-expect-error +Array.fromAsync([1, 2, 3], (value: string) => value); +// @ts-expect-error +Array.fromAsync([1, 2, 3], (value: string) => 1); +// @ts-expect-error +Array.fromAsync(["a", "b", "c"], (value: number) => value); +// @ts-expect-error +Array.fromAsync([Promise.resolve(1), 2, 3], (value: string) => value); +// @ts-expect-error +Array.fromAsync((async function* () { yield "a"; })(), (value: number) => value); + +declare const strArrLike: { [index: number]: string; length: 3 }; +// @ts-expect-error +Array.fromAsync(strArrLike, (value: number) => value); \ No newline at end of file diff --git a/tests/types/tests/array-is-template-object.test.ts b/tests/types/tests/array-is-template-object.test.ts new file mode 100644 index 000000000000..a5031199ec51 --- /dev/null +++ b/tests/types/tests/array-is-template-object.test.ts @@ -0,0 +1,13 @@ +const t: boolean = Array.isTemplateObject([]); +Array.isTemplateObject({}); +Array.isTemplateObject(["a", "b"]); +Array.isTemplateObject(Object.freeze(["foo", "bar"])); +Array.isTemplateObject(123); +Array.isTemplateObject("str"); +Array.isTemplateObject(Symbol()); + +declare const x: unknown; +if (Array.isTemplateObject(x)) { + x.raw; + const _: readonly string[] = x.raw; +} diff --git a/tests/types/tests/math-sum.test.ts b/tests/types/tests/math-sum.test.ts new file mode 100644 index 000000000000..dcf747e97766 --- /dev/null +++ b/tests/types/tests/math-sum.test.ts @@ -0,0 +1,10 @@ +function acceptsNumber(x: number) {} + +acceptsNumber(Math.sumPrecise(0.1, 0.2)); +acceptsNumber(Math.sumPrecise(1, 2)); + +// @ts-expect-error +Math.sumPrecise('10'); + +// @ts-expect-error +Math.sumPrecise([1, 2]); diff --git a/tests/types/tests/sum-precise.test.ts b/tests/types/tests/sum-precise.test.ts deleted file mode 100644 index 380014fcc800..000000000000 --- a/tests/types/tests/sum-precise.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import sumPreciseActual from 'core-js-pure/actual/math/sum-precise'; -import sumPreciseFull from 'core-js-pure/full/math/sum-precise'; - -function acceptsNumber(x: number) {} - -const a = sumPreciseActual(0.1, 0.2); -const b: number = a; -// @ts-expect-error -sumPreciseActual('10'); -// @ts-expect-error -sumPreciseActual([1, 2]); -acceptsNumber(sumPreciseActual(1, 2)); - -const af = sumPreciseFull(0.1, 0.2); -const bf: number = af; -// @ts-expect-error -sumPreciseFull('10'); -// @ts-expect-error -sumPreciseFull([1, 2]); -acceptsNumber(sumPreciseFull(1, 2)); - -const ga = Math.sumPrecise(0.1, 0.2); -const gb: number = ga; -// @ts-expect-error -Math.sumPrecise('10'); -// @ts-expect-error -Math.sumPrecise([1, 2]); -acceptsNumber(Math.sumPrecise(1, 2)); From a1d089cb4ed29b7d919723e4ad09829fbe4f8870 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 23 Apr 2025 02:22:37 +0700 Subject: [PATCH 004/315] Tests for types --- .../core-js/types/proposals/array-unique.d.ts | 24 +++++++++--------- tests/types/tests/array-unique.test.ts | 25 +++++++++++++++++++ 2 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 tests/types/tests/array-unique.test.ts diff --git a/packages/core-js/types/proposals/array-unique.d.ts b/packages/core-js/types/proposals/array-unique.d.ts index 8fcfd97a7a3d..12f3a5720faa 100644 --- a/packages/core-js/types/proposals/array-unique.d.ts +++ b/packages/core-js/types/proposals/array-unique.d.ts @@ -1,49 +1,49 @@ // proposal stage: 1 // https://github.com/tc39/proposal-array-unique interface Array { - uniqueBy(resolver?: keyof T | ((value: T) => PropertyKey)): Array; + uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; } interface Int8Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Int8Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int8Array; } interface Uint8Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Uint8Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8Array; } interface Uint8ClampedArray { - uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Uint8ClampedArray; + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8ClampedArray; } interface Int16Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Int16Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int16Array; } interface Uint16Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Uint16Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint16Array; } interface Int32Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Int32Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int32Array; } interface Uint32Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Uint32Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint32Array; } interface Float32Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Float32Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float32Array; } interface Float64Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => PropertyKey)): Float64Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float64Array; } interface BigInt64Array { - uniqueBy(resolver?: PropertyKey | ((value: bigint) => PropertyKey)): BigInt64Array; + uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigInt64Array; } interface BigUint64Array { - uniqueBy(resolver?: PropertyKey | ((value: bigint) => PropertyKey)): BigUint64Array; + uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigUint64Array; } diff --git a/tests/types/tests/array-unique.test.ts b/tests/types/tests/array-unique.test.ts new file mode 100644 index 000000000000..22f4ab9b1072 --- /dev/null +++ b/tests/types/tests/array-unique.test.ts @@ -0,0 +1,25 @@ +function testTypedArrayUniqueBy( + arr: { uniqueBy(resolver?: PropertyKey | ((value: T) => any)): any }, + key: PropertyKey +) { + arr.uniqueBy(); + arr.uniqueBy(key); + arr.uniqueBy((x: T) => x); + // @ts-expect-error + arr.uniqueBy({}); + // @ts-expect-error + arr.uniqueBy((x: T) => x['notExist']); +} + +testTypedArrayUniqueBy([{ id: '1', bar: '1' }, { id: '2', bar: '2' }, { id: '3', bar: '2' }], 'bar'); +testTypedArrayUniqueBy(new Int8Array([1, 2, 3]), 1); +testTypedArrayUniqueBy(new Uint8Array([1, 2, 3]), 1); +testTypedArrayUniqueBy(new Uint8ClampedArray([1, 2, 3]), 1); +testTypedArrayUniqueBy(new Int16Array([1, 2, 3]), 1); +testTypedArrayUniqueBy(new Uint16Array([1, 2, 3]), 1); +testTypedArrayUniqueBy(new Int32Array([1, 2, 3]), 1); +testTypedArrayUniqueBy(new Uint32Array([1, 2, 3]), 1); +testTypedArrayUniqueBy(new Float32Array([1.0, 2.2, 3.0]), 1); +testTypedArrayUniqueBy(new Float64Array([1.0, 2.2, 3.0]), 1); +testTypedArrayUniqueBy(new BigInt64Array([1n, 2n, 3n]), 1); +testTypedArrayUniqueBy(new BigUint64Array([1n, 2n, 3n]), 1); From 4e483024cb0d9379be6c9b1cab1fe2ed97fa22d3 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 23 Apr 2025 22:33:00 +0700 Subject: [PATCH 005/315] Tests for types & types fixes --- .../types/proposals/async-iteration.d.ts | 2 +- .../proposals/async-iterator-helpers.d.ts | 2 +- .../types/proposals/iterator-range.d.ts | 2 + .../proposals/json-parse-with-source.d.ts | 6 +- tests/types/tests/array-from-async.test.ts | 6 +- .../tests/array-is-template-object.test.ts | 6 +- .../types/tests/async-iterator-helper.test.ts | 77 +++++++++++++++++++ tests/types/tests/collection-of-from.test.ts | 64 +++++++++++++++ .../data-view-get-set-uint8-clamped.test.ts | 19 +++++ tests/types/tests/decorator-metadata.test.ts | 16 ++++ tests/types/tests/extractors.test.ts | 7 ++ .../types/tests/function-demethodize.test.ts | 12 +++ tests/types/tests/is-error.test.ts | 10 +++ tests/types/tests/iterator-range.test.ts | 16 ++++ tests/types/tests/iterator-sequencing.test.ts | 23 ++++++ .../tests/json-parse-with-source.test.ts | 20 +++++ tests/types/tests/map-upsert.test.ts | 22 ++++++ 17 files changed, 301 insertions(+), 9 deletions(-) create mode 100644 tests/types/tests/async-iterator-helper.test.ts create mode 100644 tests/types/tests/collection-of-from.test.ts create mode 100644 tests/types/tests/data-view-get-set-uint8-clamped.test.ts create mode 100644 tests/types/tests/decorator-metadata.test.ts create mode 100644 tests/types/tests/extractors.test.ts create mode 100644 tests/types/tests/function-demethodize.test.ts create mode 100644 tests/types/tests/is-error.test.ts create mode 100644 tests/types/tests/iterator-range.test.ts create mode 100644 tests/types/tests/iterator-sequencing.test.ts create mode 100644 tests/types/tests/json-parse-with-source.test.ts create mode 100644 tests/types/tests/map-upsert.test.ts diff --git a/packages/core-js/types/proposals/async-iteration.d.ts b/packages/core-js/types/proposals/async-iteration.d.ts index 37fd697a790d..4b0b640a7659 100644 --- a/packages/core-js/types/proposals/async-iteration.d.ts +++ b/packages/core-js/types/proposals/async-iteration.d.ts @@ -2,5 +2,5 @@ // https://github.com/tc39/proposal-async-iteration // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2018.asynciterable.d.ts#L4 interface SymbolConstructor { - readonly asyncIterator: unique symbol; // todo check + readonly asyncIterator: unique symbol; } diff --git a/packages/core-js/types/proposals/async-iterator-helpers.d.ts b/packages/core-js/types/proposals/async-iterator-helpers.d.ts index 27794f32ce6c..0c5551c515a5 100644 --- a/packages/core-js/types/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js/types/proposals/async-iterator-helpers.d.ts @@ -4,7 +4,7 @@ interface AsyncIteratorConstructor { from(iterable: AsyncIterable | Iterable | AsyncIterator): AsyncIterator; } -declare const AsyncIterator: AsyncIteratorConstructor; +declare var AsyncIterator: AsyncIteratorConstructor; interface AsyncIterator { drop(limit: number): AsyncIterator; diff --git a/packages/core-js/types/proposals/iterator-range.d.ts b/packages/core-js/types/proposals/iterator-range.d.ts index 799788c2c7b2..2d76a2d87b01 100644 --- a/packages/core-js/types/proposals/iterator-range.d.ts +++ b/packages/core-js/types/proposals/iterator-range.d.ts @@ -15,3 +15,5 @@ interface IteratorConstructor { range(start: bigint, end: bigint, options?: bigint | RangeOptionsBigInt): Iterator; } + +declare const Iterator: IteratorConstructor; diff --git a/packages/core-js/types/proposals/json-parse-with-source.d.ts b/packages/core-js/types/proposals/json-parse-with-source.d.ts index 4d81a5c2708d..a93482d4e307 100644 --- a/packages/core-js/types/proposals/json-parse-with-source.d.ts +++ b/packages/core-js/types/proposals/json-parse-with-source.d.ts @@ -1,5 +1,9 @@ // proposal stage: 3 // https://github.com/tc39/proposal-json-parse-with-source +type RawJSONObject = { + rawJSON: string; +} interface JSON { - isRawJSON(value: unknown): value is string; + isRawJSON(value: unknown): value is RawJSONObject; + rawJSON(value: string): RawJSONObject; } diff --git a/tests/types/tests/array-from-async.test.ts b/tests/types/tests/array-from-async.test.ts index 04890ba6615a..762ce3f450a8 100644 --- a/tests/types/tests/array-from-async.test.ts +++ b/tests/types/tests/array-from-async.test.ts @@ -4,7 +4,7 @@ Array.fromAsync((async function* () { yield 1; })()); Array.fromAsync([1, 2, 3], (value: number, index: number) => value.toString()); Array.fromAsync([Promise.resolve(1), 2, 3], (value: number) => value + 1); Array.fromAsync((async function* () { yield 1; })(), function (value: number) { return value * 2; }); -Array.fromAsync([1, 2, 3], function (this: {foo: string}, value: number) { return value.toString(); }, {foo: "str"}); +Array.fromAsync([1, 2, 3], function (this: {foo: string}, value: number) { return value.toString(); }, {foo: 'str'}); async function t1() { const n: number[] = await Array.fromAsync([1, 2, 3]); @@ -26,11 +26,11 @@ Array.fromAsync([1, 2, 3], (value: string) => value); // @ts-expect-error Array.fromAsync([1, 2, 3], (value: string) => 1); // @ts-expect-error -Array.fromAsync(["a", "b", "c"], (value: number) => value); +Array.fromAsync(['a', 'b', 'c'], (value: number) => value); // @ts-expect-error Array.fromAsync([Promise.resolve(1), 2, 3], (value: string) => value); // @ts-expect-error -Array.fromAsync((async function* () { yield "a"; })(), (value: number) => value); +Array.fromAsync((async function* () { yield 'a'; })(), (value: number) => value); declare const strArrLike: { [index: number]: string; length: 3 }; // @ts-expect-error diff --git a/tests/types/tests/array-is-template-object.test.ts b/tests/types/tests/array-is-template-object.test.ts index a5031199ec51..e6d71a7d85ca 100644 --- a/tests/types/tests/array-is-template-object.test.ts +++ b/tests/types/tests/array-is-template-object.test.ts @@ -1,9 +1,9 @@ const t: boolean = Array.isTemplateObject([]); Array.isTemplateObject({}); -Array.isTemplateObject(["a", "b"]); -Array.isTemplateObject(Object.freeze(["foo", "bar"])); +Array.isTemplateObject(['a', 'b']); +Array.isTemplateObject(Object.freeze(['foo', 'bar'])); Array.isTemplateObject(123); -Array.isTemplateObject("str"); +Array.isTemplateObject('str'); Array.isTemplateObject(Symbol()); declare const x: unknown; diff --git a/tests/types/tests/async-iterator-helper.test.ts b/tests/types/tests/async-iterator-helper.test.ts new file mode 100644 index 000000000000..914b551b08f4 --- /dev/null +++ b/tests/types/tests/async-iterator-helper.test.ts @@ -0,0 +1,77 @@ +AsyncIterator.from([1, 2, 3]); +AsyncIterator.from(new Set([1, 2, 3])); +AsyncIterator.from((async function* () { yield 1; yield 2; })()); +AsyncIterator.from((function* () { yield 3; })()); +AsyncIterator.from('abc'); + +declare const ain: AsyncIterator; +declare const aio: AsyncIterator<{ x: number }>; +declare const ais: AsyncIterator; +declare const ilb: Iterable; +declare const is: Iterator; +declare const itn: Iterator; +declare const ailb: AsyncIterable; +async function* ag(): AsyncIterable { yield 'foo'; } + +AsyncIterator.from(ain); +AsyncIterator.from(ag()); +AsyncIterator.from(ilb); +AsyncIterator.from(ailb); +AsyncIterator.from(aio); + +// @ts-expect-error +AsyncIterator.from(123); +// @ts-expect-error +AsyncIterator.from({}); +// @ts-expect-error +AsyncIterator.from(); +// @ts-expect-error +AsyncIterator.from(null); +// @ts-expect-error +AsyncIterator.from(undefined); +// @ts-expect-error +AsyncIterator.from({ next: () => 1 }); + +const raits: AsyncIterator = is.toAsync(); +const raitn: AsyncIterator = itn.toAsync(); + +const r1: AsyncIterator = ain.drop(3); +const r2: Promise = ain.every((v: number, i: number) => v > 0); +const r3: AsyncIterator = ain.filter((v: number, i: number) => v > 0); +const r4: Promise = ain.find((v: number, i: number) => v > 0); +const r5: AsyncIterator = ain.flatMap((v: number, i: number) => `${v}`); +const r6: Promise = ain.forEach((v: number, i: number) => { }); +const r7: AsyncIterator = ain.map((v: number, i: number) => v * 2); +const r8: Promise = ain.reduce((acc: number, v: number, i: number) => acc + v, 0); +const r9: Promise = ain.some((v: number, i: number) => v > 0); +const r10: AsyncIterator = ain.take(10); +const r11: Promise = ain.toArray(); + +// @ts-expect-error +ain.drop(); +// @ts-expect-error +ain.every(); +// @ts-expect-error +ain.filter(); +// @ts-expect-error +ain.find(); +// @ts-expect-error +ain.flatMap(); +// @ts-expect-error +ain.forEach(); +// @ts-expect-error +ain.map(); +// @ts-expect-error +ain.reduce(); +// @ts-expect-error +ain.some(); +// @ts-expect-error +ain.take(); +// @ts-expect-error +ain.toArray(1); + +const s0: Promise = ais.toArray(); +const f0: Promise = ais.find((v: string, i: number) => v.length === 1); + +// @ts-expect-error +ais.map((v: string, i: number) => v.length === 1, 'extra'); diff --git a/tests/types/tests/collection-of-from.test.ts b/tests/types/tests/collection-of-from.test.ts new file mode 100644 index 000000000000..9fc98e111126 --- /dev/null +++ b/tests/types/tests/collection-of-from.test.ts @@ -0,0 +1,64 @@ +const rm: Map = Map.from([[1, 'a'], [2, 'b']]); +const rm2: Map = Map.from([[1, 10], [2, 20]], (v: number, k: number) => v + k); +Map.from([[1, 10], [2, 20]], function (this: { n: number }, v: number) { return v + this.n; }, { n: 2 }); +// @ts-expect-error +Map.from([['a', 1], ['b', 2]], (v: string, k: number) => v); +// @ts-expect-error +Map.from([1, 2]); +// @ts-expect-error +Map.from(); + +Map.of(['a', 1], ['b', 2]); +const rm4: Map = Map.of(['a', 1], ['b', 2]); +// @ts-expect-error +Map.of([1, 2, 3]); +// @ts-expect-error +Map.of(1, 2); + +const rs1: Set = Set.from([1, 2, 3]); +const rs2: Set = Set.from([1, 2, 3], x => x.toString()); +const rs3: Set<[string, number]> = Set.from([['a', 1], ['b', 2]]); +Set.from(['a', 'b'], function (this: { s: string }, value: string) { return value + this.s; }, { s: '-' }); +// @ts-expect-error +Set.from([1, 2, 3], (v: string) => v); +// @ts-expect-error +Set.from(); + +const rso1: Set = Set.of(1, 2, 3); +const rso2: Set = Set.of('a', 'b', 'c'); +// @ts-expect-error +Set.of({ 'foo': 'bar' }, 2); + +const rwm1: WeakMap<{ a: number }, string> = WeakMap.from([[{ a: 1 }, 'x']]); +const rwm2: WeakMap = WeakMap.from([[{}, 1], [{}, 2]], (v, k) => v.toString()); +WeakMap.from([[{}, 1], [{}, 2]], function (this: { s: string }, v: number) { return this.s + v; }, { s: '-' }); +// @ts-expect-error +WeakMap.from([[1, 2], [2, 3]]); +// @ts-expect-error +WeakMap.from([[{}, 1], [{}, 2]], (v: string, k: string) => v); +// @ts-expect-error +WeakMap.from([1, 2]); +// @ts-expect-error +WeakMap.from(); + +const rwmo1: WeakMap = WeakMap.of([{}, 2]); +// @ts-expect-error +WeakMap.of([1, 2]); +// @ts-expect-error +WeakMap.of({}); + +const rws1: WeakSet = WeakSet.from([{}]); +const rws2: WeakSet = WeakSet.from([{}, {}], x => x); +WeakSet.from([{}], function (this: { s: string }, obj: object) { return obj; }, { s: '-' }); +// @ts-expect-error +WeakSet.from([1, 2]); +// @ts-expect-error +WeakSet.from([{}], (v: number) => v); +// @ts-expect-error +WeakSet.from(); +// @ts-expect-error +WeakSet.from([{}], x => 'not-an-object'); + +const rwso1: WeakSet = WeakSet.of({}); +// @ts-expect-error +WeakSet.of(1); diff --git a/tests/types/tests/data-view-get-set-uint8-clamped.test.ts b/tests/types/tests/data-view-get-set-uint8-clamped.test.ts new file mode 100644 index 000000000000..71be5cc11577 --- /dev/null +++ b/tests/types/tests/data-view-get-set-uint8-clamped.test.ts @@ -0,0 +1,19 @@ +declare const dv: DataView; + +const rdv: number = dv.getUint8Clamped(0); +dv.setUint8Clamped(0, 255); + +// @ts-expect-error +dv.getUint8Clamped(); +// @ts-expect-error +dv.getUint8Clamped('0'); +// @ts-expect-error +dv.getUint8Clamped(0, 2); +// @ts-expect-error +dv.setUint8Clamped(0); +// @ts-expect-error +dv.setUint8Clamped('0', 2); +// @ts-expect-error +dv.setUint8Clamped(0, '2'); +// @ts-expect-error +dv.setUint8Clamped(); diff --git a/tests/types/tests/decorator-metadata.test.ts b/tests/types/tests/decorator-metadata.test.ts new file mode 100644 index 000000000000..7595f1edd06e --- /dev/null +++ b/tests/types/tests/decorator-metadata.test.ts @@ -0,0 +1,16 @@ +const rsmd1: symbol = Symbol.metadata; +const rsmd2: typeof Symbol.metadata = Symbol.metadata; + +type T = { + [Symbol.metadata]?: object; +}; + +const obj: T = {}; +obj[Symbol.metadata] = { foo: 1 }; + +const maybeMeta: object | undefined = obj[Symbol.metadata]; + +// @ts-expect-error +Symbol['metadata'] = Symbol('other'); +// @ts-expect-error +obj[Symbol.metadata] = 123; \ No newline at end of file diff --git a/tests/types/tests/extractors.test.ts b/tests/types/tests/extractors.test.ts new file mode 100644 index 000000000000..c5e96f4b8b0d --- /dev/null +++ b/tests/types/tests/extractors.test.ts @@ -0,0 +1,7 @@ +const rscs1: symbol = Symbol.customExtractor; +const rscs2: typeof Symbol.customExtractor = Symbol.customExtractor; + +// @ts-expect-error +Symbol['customExtractor'] = Symbol("other"); +// @ts-expect-error +const n: number = Symbol.customExtractor; diff --git a/tests/types/tests/function-demethodize.test.ts b/tests/types/tests/function-demethodize.test.ts new file mode 100644 index 000000000000..40c67b598d88 --- /dev/null +++ b/tests/types/tests/function-demethodize.test.ts @@ -0,0 +1,12 @@ +function sumTo(this: { base: number }, a: number, b: number): number { + return this.base + a + b; +} +const sumToD = sumTo.demethodize(); +const rsumd: number = sumToD({ base: 1 }, 2, 3); +// @ts-expect-error +sumToD(2, 3); + +const sliceD: (thisArg: string, start: number, end?: number) => string = String.prototype.slice.demethodize(); +const rs = sliceD('foobar', 1, 3); +// @ts-expect-error +sliceD(); diff --git a/tests/types/tests/is-error.test.ts b/tests/types/tests/is-error.test.ts new file mode 100644 index 000000000000..c230efe6be96 --- /dev/null +++ b/tests/types/tests/is-error.test.ts @@ -0,0 +1,10 @@ +const e = new Error(); +const ne = { foo: 1 }; + +const re1: boolean = Error.isError(e); +Error.isError(ne); +Error.isError(undefined); +Error.isError('str'); + +// @ts-expect-error +Error.isError(); diff --git a/tests/types/tests/iterator-range.test.ts b/tests/types/tests/iterator-range.test.ts new file mode 100644 index 000000000000..97923d356ab3 --- /dev/null +++ b/tests/types/tests/iterator-range.test.ts @@ -0,0 +1,16 @@ +const rir1: Iterator = Iterator.range(1, 10); +Iterator.range(1, 10, 1); +Iterator.range(1, 10, { step: 1 }); +Iterator.range(1, 10, { inclusive: true }); +const rir2: Iterator< bigint> = Iterator.range(0n, 10n, { step: 2n, inclusive: true }); + +// @ts-expect-error +Iterator.range(0, 10, 'not-a-number'); +// @ts-expect-error +Iterator.range(0, 10, { step: 1n }); +// @ts-expect-error +Iterator.range(0, 10, { inclusive: 3 }); +// @ts-expect-error +Iterator.range(0, 10, { step: 'smth' }); +// @ts-expect-error +Iterator.range(0, 10, { foo: 'bar' }); diff --git a/tests/types/tests/iterator-sequencing.test.ts b/tests/types/tests/iterator-sequencing.test.ts new file mode 100644 index 000000000000..3667e9fe5fdf --- /dev/null +++ b/tests/types/tests/iterator-sequencing.test.ts @@ -0,0 +1,23 @@ +declare const itn1: Iterator; +declare const its1: Iterator; +declare const arrs: string[]; +declare const arrn: number[]; +declare const arrb: boolean[]; +declare const itb1: Iterator; + +const ri1: Iterator = itn1.concat(its1); +const ri2: Iterator = itn1.concat(arrs); +const ri3: Iterator = itn1.concat(arrn); +const ri4: Iterator = itn1.concat(arrb, itb1); +const ri5: Iterator = itn1.concat(); + +// @ts-expect-error +itn.concat(1); +// @ts-expect-error +itn.concat(true); +// @ts-expect-error +itn.concat({}); +// @ts-expect-error +itn.concat(null); +// @ts-expect-error +itn.concat(undefined); diff --git a/tests/types/tests/json-parse-with-source.test.ts b/tests/types/tests/json-parse-with-source.test.ts new file mode 100644 index 000000000000..dffe8415602a --- /dev/null +++ b/tests/types/tests/json-parse-with-source.test.ts @@ -0,0 +1,20 @@ +const r: RawJSONObject = JSON.rawJSON('{"a":123}'); + +const isr1: boolean = JSON.isRawJSON(r); +const isr2: boolean = JSON.isRawJSON({}); +const isr3: boolean = JSON.isRawJSON('abc'); +const isr4: boolean = JSON.isRawJSON(undefined); + +declare const smth: unknown; + +if (JSON.isRawJSON(smth)) { + smth.rawJSON; + const s: string = smth.rawJSON; + // @ts-expect-error + smth.noProp; +} + +// @ts-expect-error +JSON.rawJSON(123); +// @ts-expect-error +JSON.rawJSON(); diff --git a/tests/types/tests/map-upsert.test.ts b/tests/types/tests/map-upsert.test.ts new file mode 100644 index 000000000000..6ff08d33acb8 --- /dev/null +++ b/tests/types/tests/map-upsert.test.ts @@ -0,0 +1,22 @@ +declare const map: Map; + +const a: number = map.getOrInsert('x', 42); +const b: number = map.getOrInsertComputed('y', k => k.length); + +// @ts-expect-error +map.getOrInsert(1, 2); +// @ts-expect-error +map.getOrInsert('x'); +// @ts-expect-error +map.getOrInsertComputed('x', (k: number) => k + 1); + +declare const wmap: WeakMap<{ id: number }, boolean>; + +const wb: boolean = wmap.getOrInsert({ id: 1 }, true); +wmap.getOrInsertComputed({ id: 2 }, obj => obj.id === 2); +// @ts-expect-error +wmap.getOrInsert(123, true); +// @ts-expect-error +wmap.getOrInsert({ id: 1 }); +// @ts-expect-error +wmap.getOrInsertComputed({ id: 1 }, (obj: string) => true); From ab3de8cfaf2ef31fbd28a03244333b00712ef22f Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 24 Apr 2025 21:30:42 +0700 Subject: [PATCH 006/315] Tests for types & types fixes --- .../core-js/types/proposals/string-cooked.d.ts | 6 ++++-- .../types/proposals/symbol-predicates.d.ts | 3 ++- .../tests/explicit-resource-management.test.ts | 1 + tests/types/tests/math-clamp.test.ts | 6 ++++++ tests/types/tests/string-cooked.test.ts | 8 ++++++++ tests/types/tests/string-dedent.test.ts | 14 ++++++++++++++ tests/types/tests/symbol-predicates.test.ts | 16 ++++++++++++++++ 7 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 tests/types/tests/explicit-resource-management.test.ts create mode 100644 tests/types/tests/math-clamp.test.ts create mode 100644 tests/types/tests/string-cooked.test.ts create mode 100644 tests/types/tests/string-dedent.test.ts create mode 100644 tests/types/tests/symbol-predicates.test.ts diff --git a/packages/core-js/types/proposals/string-cooked.d.ts b/packages/core-js/types/proposals/string-cooked.d.ts index bc04a4cecbc5..0663d7c3e089 100644 --- a/packages/core-js/types/proposals/string-cooked.d.ts +++ b/packages/core-js/types/proposals/string-cooked.d.ts @@ -1,5 +1,7 @@ // proposal stage: 1 // https://github.com/tc39/proposal-string-cooked -interface String { - cooked(...values: unknown[]): string; +interface StringConstructor { + cooked(template: readonly string[], ...substitutions: unknown[]): string; + + cooked(template: string, ...substitutions: unknown[]): string; } \ No newline at end of file diff --git a/packages/core-js/types/proposals/symbol-predicates.d.ts b/packages/core-js/types/proposals/symbol-predicates.d.ts index 35ae774c1bbe..081b6c56da2f 100644 --- a/packages/core-js/types/proposals/symbol-predicates.d.ts +++ b/packages/core-js/types/proposals/symbol-predicates.d.ts @@ -1,5 +1,6 @@ // proposal stage: 2 // https://github.com/tc39/proposal-symbol-predicates interface SymbolConstructor { - isRegisteredSymbol(value: unknown): value is symbol; + isRegisteredSymbol(value: unknown): boolean; + isWellKnownSymbol(value: unknown): boolean; } \ No newline at end of file diff --git a/tests/types/tests/explicit-resource-management.test.ts b/tests/types/tests/explicit-resource-management.test.ts new file mode 100644 index 000000000000..8826b5238d73 --- /dev/null +++ b/tests/types/tests/explicit-resource-management.test.ts @@ -0,0 +1 @@ +// todo \ No newline at end of file diff --git a/tests/types/tests/math-clamp.test.ts b/tests/types/tests/math-clamp.test.ts new file mode 100644 index 000000000000..8f5fa6871be0 --- /dev/null +++ b/tests/types/tests/math-clamp.test.ts @@ -0,0 +1,6 @@ +const rc1: number = Math.clamp(1, 2, 5); + +// @ts-expect-error +Math.clamp(1, 2); +// @ts-expect-error +Math.clamp(2, 2, '4'); diff --git a/tests/types/tests/string-cooked.test.ts b/tests/types/tests/string-cooked.test.ts new file mode 100644 index 000000000000..d111acef5926 --- /dev/null +++ b/tests/types/tests/string-cooked.test.ts @@ -0,0 +1,8 @@ +const rcooked1: string = String.cooked('foo', 1, 2, 3); +String.cooked(['foo', 'bar'], 1, 2); +String.cooked([]); + +// @ts-expect-error +String.cooked([null]); +// @ts-expect-error +String.cooked([undefined]); diff --git a/tests/types/tests/string-dedent.test.ts b/tests/types/tests/string-dedent.test.ts new file mode 100644 index 000000000000..babb236909aa --- /dev/null +++ b/tests/types/tests/string-dedent.test.ts @@ -0,0 +1,14 @@ +const rdedent1: string = String.dedent`foo\nbar`; +const rdedent2: string = String.dedent`line1 + line2 + line3`; + +const tpl = Object.assign(['foo', 'bar'], { raw: ['foo', 'bar'] }) as TemplateStringsArray; +String.dedent(tpl, 1, 2); + +// @ts-expect-error +String.dedent(['foo', 'bar'], 1, 2); +// @ts-expect-error +String.dedent('foo', 1, 2); +// @ts-expect-error +String.dedent(); diff --git a/tests/types/tests/symbol-predicates.test.ts b/tests/types/tests/symbol-predicates.test.ts new file mode 100644 index 000000000000..9601b0fb3049 --- /dev/null +++ b/tests/types/tests/symbol-predicates.test.ts @@ -0,0 +1,16 @@ +const rsymbol1: boolean = Symbol.isRegisteredSymbol(Symbol.for('foo')); +const rsymbol2: boolean = Symbol.isRegisteredSymbol(undefined); +const rsymbol3: boolean = Symbol.isRegisteredSymbol(Symbol('bar')); + +const rsymbol4: boolean = Symbol.isWellKnownSymbol(Symbol.iterator); +const rsymbol5: boolean = Symbol.isWellKnownSymbol({}); +const rsymbol6: boolean = Symbol.isWellKnownSymbol(Symbol('baz')); + +declare const u: unknown; +Symbol.isRegisteredSymbol(u); +Symbol.isWellKnownSymbol(u); + +// @ts-expect-error +Symbol.isRegisteredSymbol(); +// @ts-expect-error +Symbol.isWellKnownSymbol(); From d13ad38de57c1a4ec7ba8fbab446508175795571 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 25 Apr 2025 00:19:49 +0700 Subject: [PATCH 007/315] Tests for types & types fixes --- .../core-js/types/proposals/array-is-template-object.d.ts | 2 +- .../core-js/types/proposals/json-parse-with-source.d.ts | 7 +++++++ packages/core-js/types/proposals/string-cooked.d.ts | 2 +- packages/core-js/types/proposals/string-dedent.d.ts | 2 +- packages/core-js/types/proposals/symbol-predicates.d.ts | 2 +- tests/types/tests/json-parse-with-source.test.ts | 4 ++++ 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/core-js/types/proposals/array-is-template-object.d.ts b/packages/core-js/types/proposals/array-is-template-object.d.ts index 6ce9d9aa6ae7..3766181e3097 100644 --- a/packages/core-js/types/proposals/array-is-template-object.d.ts +++ b/packages/core-js/types/proposals/array-is-template-object.d.ts @@ -2,4 +2,4 @@ // https://github.com/tc39/proposal-array-is-template-object interface ArrayConstructor { isTemplateObject(value: unknown): value is TemplateStringsArray; -} \ No newline at end of file +} diff --git a/packages/core-js/types/proposals/json-parse-with-source.d.ts b/packages/core-js/types/proposals/json-parse-with-source.d.ts index a93482d4e307..eaba2385ad43 100644 --- a/packages/core-js/types/proposals/json-parse-with-source.d.ts +++ b/packages/core-js/types/proposals/json-parse-with-source.d.ts @@ -1,9 +1,16 @@ // proposal stage: 3 // https://github.com/tc39/proposal-json-parse-with-source +interface ReviverContext { + source: string; + keys: string[]; +} + type RawJSONObject = { rawJSON: string; } + interface JSON { isRawJSON(value: unknown): value is RawJSONObject; + parse(text: string, reviver?: (key: string, value: any, context: ReviverContext) => any): T; rawJSON(value: string): RawJSONObject; } diff --git a/packages/core-js/types/proposals/string-cooked.d.ts b/packages/core-js/types/proposals/string-cooked.d.ts index 0663d7c3e089..6570cf4d2846 100644 --- a/packages/core-js/types/proposals/string-cooked.d.ts +++ b/packages/core-js/types/proposals/string-cooked.d.ts @@ -4,4 +4,4 @@ interface StringConstructor { cooked(template: readonly string[], ...substitutions: unknown[]): string; cooked(template: string, ...substitutions: unknown[]): string; -} \ No newline at end of file +} diff --git a/packages/core-js/types/proposals/string-dedent.d.ts b/packages/core-js/types/proposals/string-dedent.d.ts index 8dfc94cde579..2ec9e401bf4b 100644 --- a/packages/core-js/types/proposals/string-dedent.d.ts +++ b/packages/core-js/types/proposals/string-dedent.d.ts @@ -2,4 +2,4 @@ // https://github.com/tc39/proposal-string-dedent interface StringConstructor { dedent(strings: TemplateStringsArray, ...values: unknown[]): string; -} \ No newline at end of file +} diff --git a/packages/core-js/types/proposals/symbol-predicates.d.ts b/packages/core-js/types/proposals/symbol-predicates.d.ts index 081b6c56da2f..c043e5bfa55d 100644 --- a/packages/core-js/types/proposals/symbol-predicates.d.ts +++ b/packages/core-js/types/proposals/symbol-predicates.d.ts @@ -3,4 +3,4 @@ interface SymbolConstructor { isRegisteredSymbol(value: unknown): boolean; isWellKnownSymbol(value: unknown): boolean; -} \ No newline at end of file +} diff --git a/tests/types/tests/json-parse-with-source.test.ts b/tests/types/tests/json-parse-with-source.test.ts index dffe8415602a..bae432cc81d3 100644 --- a/tests/types/tests/json-parse-with-source.test.ts +++ b/tests/types/tests/json-parse-with-source.test.ts @@ -18,3 +18,7 @@ if (JSON.isRawJSON(smth)) { JSON.rawJSON(123); // @ts-expect-error JSON.rawJSON(); + +JSON.parse('{"tooBigForNumber":9007199254740993}', (key: string, value: any, context: ReviverContext) => {}); +// @ts-expect-error +JSON.parse('{"tooBigForNumber":9007199254740993}', (key: string, value: any, context: []) => {}); From 12d9b8f0cfaa51d22b9e5568cfce3885cd419e84 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 25 Apr 2025 01:30:24 +0700 Subject: [PATCH 008/315] Tests for types & types fixes --- .../explicit-resource-management.d.ts | 7 +- .../types/proposals/iterator-range.d.ts | 2 +- .../explicit-resource-management.test.ts | 105 +++++++++++++++++- 3 files changed, 107 insertions(+), 7 deletions(-) diff --git a/packages/core-js/types/proposals/explicit-resource-management.d.ts b/packages/core-js/types/proposals/explicit-resource-management.d.ts index 4baa47c3792d..313f13ab8ce3 100644 --- a/packages/core-js/types/proposals/explicit-resource-management.d.ts +++ b/packages/core-js/types/proposals/explicit-resource-management.d.ts @@ -25,7 +25,6 @@ interface SuppressedErrorConstructor { (error: any, suppressed: any, message?: string): SuppressedError; readonly prototype: SuppressedError; } - declare var SuppressedError: SuppressedErrorConstructor; interface DisposableStack { @@ -77,8 +76,6 @@ interface AsyncDisposableStackConstructor { } declare var AsyncDisposableStack: AsyncDisposableStackConstructor; -interface IteratorObject extends Disposable { -} +interface IteratorObject extends Disposable {} -interface AsyncIteratorObject extends AsyncDisposable { -} +interface AsyncIteratorObject extends AsyncDisposable {} diff --git a/packages/core-js/types/proposals/iterator-range.d.ts b/packages/core-js/types/proposals/iterator-range.d.ts index 2d76a2d87b01..c0c6a20989d6 100644 --- a/packages/core-js/types/proposals/iterator-range.d.ts +++ b/packages/core-js/types/proposals/iterator-range.d.ts @@ -16,4 +16,4 @@ interface IteratorConstructor { range(start: bigint, end: bigint, options?: bigint | RangeOptionsBigInt): Iterator; } -declare const Iterator: IteratorConstructor; +declare var Iterator: IteratorConstructor; diff --git a/tests/types/tests/explicit-resource-management.test.ts b/tests/types/tests/explicit-resource-management.test.ts index 8826b5238d73..f9ec60bea904 100644 --- a/tests/types/tests/explicit-resource-management.test.ts +++ b/tests/types/tests/explicit-resource-management.test.ts @@ -1 +1,104 @@ -// todo \ No newline at end of file +const d: symbol = Symbol.dispose; +const ad: symbol = Symbol.asyncDispose; + +// @ts-expect-error +const wrong: number = Symbol.dispose; +// @ts-expect-error +Symbol['dispose'] = Symbol("foo"); +// @ts-expect-error +Symbol['asyncDispose'] = Symbol("bar"); + +const objD: Disposable = { + [Symbol.dispose]() { /* empty */ } +}; +objD[Symbol.dispose](); + +// @ts-expect-error +objD.dispose(); + +const objAD: AsyncDisposable = { + [Symbol.asyncDispose]() { return Promise.resolve(); } +} +objAD[Symbol.asyncDispose](); + +// @ts-expect-error +objAD.asyncDispose(); + +const err1 = new SuppressedError('err', 'suppressed', 'msg'); +err1.error; +err1.suppressed; +const m1: string = err1.message; +const _: Error = err1; + +const err2 = SuppressedError(123, 456); +err2.error; +err2.suppressed; +err2.message; + +const proto: SuppressedError = SuppressedError.prototype; + +// @ts-expect-error +new SuppressedError(); +// @ts-expect-error +new SuppressedError(1, 2, 3, 4); + +const protoDS: DisposableStack = DisposableStack.prototype; +const objDS: DisposableStack = new DisposableStack(); +const disposed: boolean = objDS.disposed; +objDS.dispose(); +const ruse1: Disposable = objDS.use(objD); +const ruse2: null = objDS.use(null); +const ruse3: undefined = objDS.use(undefined); +const radopt1: string = objDS.adopt('foo', (value: string) => { /* empty */ }); +objDS.defer(() => { /* empty */ }); +const rmove1: DisposableStack = objDS.move(); +objDS[Symbol.dispose](); +const rts1: string = objDS[Symbol.toStringTag]; + +// @ts-expect-error +objDS.dispose(1); +// @ts-expect-error +objDS.use('foo'); +// @ts-expect-error +objDS.defer('bar'); +// @ts-expect-error +objDS.move(1); +// @ts-expect-error +objDS[Symbol.toStringTag] = 'foo'; + +const protoADS: AsyncDisposableStack = AsyncDisposableStack.prototype; +const objADS: AsyncDisposableStack = new AsyncDisposableStack(); +const disposedASD: boolean = objDS.disposed; +const rda: Promise = objADS.disposeAsync(); +const ruseASD1: AsyncDisposable = objADS.use(objAD); +const ruseASD2: Disposable = objADS.use(objD); +const ruseASD3: null = objADS.use(null); +const ruseASD4: undefined = objADS.use(undefined); +const radoptASD1: string = objADS.adopt('foo', (value: string) => { /* empty */ }); +const radoptASD2: string = objADS.adopt('foo', async (value: string) => { /* empty */ }); +const radoptASD3: string = objADS.adopt('foo', (value: string) => Promise.resolve()); +const radoptASD4: string = objADS.adopt('foo', async (value: string) => Promise.resolve()); +objADS.defer(() => { /* empty */ }); +objADS.defer(async () => { /* empty */ }); +objADS.defer(() => Promise.resolve()); +objADS.defer(async () => Promise.resolve()); +const rmoveASD1: AsyncDisposableStack = objADS.move(); +objADS[Symbol.asyncDispose](); +const rtsASD1: string = objADS[Symbol.toStringTag]; + +// @ts-expect-error +objADS.disposeAsync(1).then(); +// @ts-expect-error +objADS.use('foo').then(); +// @ts-expect-error +objADS.defer('bar'); +// @ts-expect-error +objADS.move(1); +// @ts-expect-error +objADS[Symbol.toStringTag] = 'foo'; + +declare const iter: IteratorObject; +iter[Symbol.dispose](); + +declare const asyncIter: AsyncIteratorObject; +asyncIter[Symbol.asyncDispose](); From a13b985634557ed7de72219ec200fe69b9c49d00 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 29 Apr 2025 01:05:38 +0700 Subject: [PATCH 009/315] Type definitions builder --- scripts/build-entries/get-dependencies.mjs | 21 ++++++++++++++++++--- scripts/build-entries/index.mjs | 13 +++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/scripts/build-entries/get-dependencies.mjs b/scripts/build-entries/get-dependencies.mjs index ad02c0383ee3..9005318f3b0f 100644 --- a/scripts/build-entries/get-dependencies.mjs +++ b/scripts/build-entries/get-dependencies.mjs @@ -7,8 +7,10 @@ const allModulesSet = new Set(modules); const MODULE_PATH = /\/(?(?:internals|modules)\/[\d\-.a-z]+)$/; const DIRECTIVE = /^ *\/\/ @dependency: (?(?:es|esnext|web)\.[\d\-.a-z]+)$/gm; +const TYPES_DIRECTIVE = /^ *\/\/ type: (?[\d\-\/.a-z]+)$/gm; -const cache = new Map(); +const dependenciesCache = new Map(); +const typesCache = new Map(); function unique(array) { return [...new Set(array)]; @@ -29,7 +31,7 @@ function normalizeModulePath(unnormalizedPath) { } async function getSetOfAllDependenciesForModule(path, stack = new Set()) { - if (cache.has(path)) return cache.get(path); + if (dependenciesCache.has(path)) return dependenciesCache.get(path); if (stack.has(path)) throw new Error(red(`Circular dependency: ${ cyan(path) }`)); stack.add(path); const module = String(await fs.readFile(`./packages/core-js/${ path }.js`)); @@ -41,7 +43,7 @@ async function getSetOfAllDependenciesForModule(path, stack = new Set()) { const dependenciesOfDependency = await getSetOfAllDependenciesForModule(dependency, new Set(stack)); dependenciesOfDependency.forEach(it => result.add(it)); } - cache.set(path, result); + dependenciesCache.set(path, result); return result; } @@ -52,3 +54,16 @@ export async function getListOfDependencies(paths) { } return sort(unique(dependencies).filter(it => it.startsWith('modules/')).map(it => it.slice(8))); } + +export async function getListOfTypes(modulePaths) { + if (typesCache.has(modulePaths)) return typesCache.get(modulePaths); + const typesSet = new Set(); + for (const modulePath of modulePaths) { + const module = String(await fs.readFile(`./packages/core-js/modules/${ modulePath }.js`)); + [...module.matchAll(TYPES_DIRECTIVE)].map(it => typesSet.add(it.groups.type)); + } + const types = Array.from(typesSet); + typesCache.set(modulePaths, types); + + return types; +} diff --git a/scripts/build-entries/index.mjs b/scripts/build-entries/index.mjs index ca1353ebc455..5718a38b765e 100644 --- a/scripts/build-entries/index.mjs +++ b/scripts/build-entries/index.mjs @@ -1,6 +1,6 @@ -import { getListOfDependencies, sort } from './get-dependencies.mjs'; +import { getListOfDependencies, getListOfTypes, sort } from './get-dependencies.mjs'; import { features, proposals } from './entries-definitions.mjs'; -import { $proposal, $path } from './templates.mjs'; +import { $proposal, $path, wrapDts, wrapEntry } from './templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; const { mkdir, writeFile, readJson, writeJson } = fs; @@ -84,11 +84,16 @@ async function buildEntry(entry, options) { modules = await getListOfDependencies(modules); if (filter) modules = modules.filter(it => filter.has(it)); - const file = template({ ...options, modules, rawModules, level, entry }); + const types = await getListOfTypes(modules, level); + + const tpl = template({ ...options, modules, rawModules, level, entry, types }); const filepath = `./packages/core-js/${ entry }.js`; await mkdir(dirname(filepath), { recursive: true }); - await writeFile(filepath, file); + await writeFile(filepath, wrapEntry(tpl.entry)); + + const typePath = `./packages/core-js/${ entry }.d.ts`; + await writeFile(typePath, wrapDts(tpl.dts, { types, level })); built++; From e8ae7f4a131e5570ffec8c49a754dd3fd6a5dea6 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 29 Apr 2025 01:37:41 +0700 Subject: [PATCH 010/315] Added type definition comments to proposals --- packages/core-js/modules/es.array.from-async.js | 1 + .../core-js/modules/es.async-disposable-stack.constructor.js | 1 + packages/core-js/modules/es.async-iterator.async-dispose.js | 1 + packages/core-js/modules/es.disposable-stack.constructor.js | 1 + packages/core-js/modules/es.error.is-error.js | 1 + packages/core-js/modules/es.iterator.concat.js | 1 + packages/core-js/modules/es.iterator.dispose.js | 1 + packages/core-js/modules/es.json.is-raw-json.js | 1 + packages/core-js/modules/es.json.parse.js | 1 + packages/core-js/modules/es.map.get-or-insert-computed.js | 1 + packages/core-js/modules/es.map.get-or-insert.js | 1 + packages/core-js/modules/es.math.sum-precise.js | 1 + packages/core-js/modules/es.suppressed-error.constructor.js | 1 + packages/core-js/modules/es.symbol.async-dispose.js | 1 + packages/core-js/modules/es.symbol.dispose.js | 1 + packages/core-js/modules/es.uint8-array.from-base64.js | 1 + packages/core-js/modules/es.uint8-array.from-hex.js | 1 + packages/core-js/modules/es.uint8-array.set-from-base64.js | 1 + packages/core-js/modules/es.uint8-array.set-from-hex.js | 1 + packages/core-js/modules/es.uint8-array.to-base64.js | 1 + packages/core-js/modules/es.uint8-array.to-hex.js | 1 + packages/core-js/modules/es.weak-map.get-or-insert-computed.js | 1 + packages/core-js/modules/es.weak-map.get-or-insert.js | 1 + packages/core-js/modules/esnext.array.filter-reject.js | 1 + packages/core-js/modules/esnext.array.is-template-object.js | 1 + packages/core-js/modules/esnext.array.unique-by.js | 1 + packages/core-js/modules/esnext.async-iterator.constructor.js | 1 + packages/core-js/modules/esnext.async-iterator.drop.js | 1 + packages/core-js/modules/esnext.async-iterator.every.js | 1 + packages/core-js/modules/esnext.async-iterator.filter.js | 1 + packages/core-js/modules/esnext.async-iterator.find.js | 1 + packages/core-js/modules/esnext.async-iterator.flat-map.js | 1 + packages/core-js/modules/esnext.async-iterator.for-each.js | 1 + packages/core-js/modules/esnext.async-iterator.from.js | 1 + packages/core-js/modules/esnext.async-iterator.map.js | 1 + packages/core-js/modules/esnext.async-iterator.reduce.js | 1 + packages/core-js/modules/esnext.async-iterator.some.js | 1 + packages/core-js/modules/esnext.async-iterator.take.js | 1 + packages/core-js/modules/esnext.async-iterator.to-array.js | 1 + packages/core-js/modules/esnext.data-view.get-uint8-clamped.js | 1 + packages/core-js/modules/esnext.data-view.set-uint8-clamped.js | 1 + packages/core-js/modules/esnext.function.demethodize.js | 1 + packages/core-js/modules/esnext.function.metadata.js | 1 + packages/core-js/modules/esnext.iterator.range.js | 1 + packages/core-js/modules/esnext.iterator.to-async.js | 1 + packages/core-js/modules/esnext.map.from.js | 1 + packages/core-js/modules/esnext.map.of.js | 1 + packages/core-js/modules/esnext.set.from.js | 1 + packages/core-js/modules/esnext.set.of.js | 1 + packages/core-js/modules/esnext.string.cooked.js | 1 + packages/core-js/modules/esnext.string.dedent.js | 1 + packages/core-js/modules/esnext.symbol.custom-matcher.js | 1 + packages/core-js/modules/esnext.symbol.is-registered-symbol.js | 1 + packages/core-js/modules/esnext.symbol.is-well-known-symbol.js | 2 +- packages/core-js/modules/esnext.symbol.metadata.js | 1 + packages/core-js/modules/esnext.typed-array.filter-reject.js | 1 + packages/core-js/modules/esnext.typed-array.unique-by.js | 1 + packages/core-js/modules/esnext.weak-map.from.js | 1 + packages/core-js/modules/esnext.weak-map.of.js | 1 + packages/core-js/modules/esnext.weak-set.from.js | 1 + packages/core-js/modules/esnext.weak-set.of.js | 1 + 61 files changed, 61 insertions(+), 1 deletion(-) diff --git a/packages/core-js/modules/es.array.from-async.js b/packages/core-js/modules/es.array.from-async.js index 04b7874fdd70..9f2224ce7810 100644 --- a/packages/core-js/modules/es.array.from-async.js +++ b/packages/core-js/modules/es.array.from-async.js @@ -1,3 +1,4 @@ +// type: proposals/array-from-async.d.ts 'use strict'; var $ = require('../internals/export'); var bind = require('../internals/function-bind-context'); diff --git a/packages/core-js/modules/es.async-disposable-stack.constructor.js b/packages/core-js/modules/es.async-disposable-stack.constructor.js index c697b1810ec6..02b859685ba2 100644 --- a/packages/core-js/modules/es.async-disposable-stack.constructor.js +++ b/packages/core-js/modules/es.async-disposable-stack.constructor.js @@ -1,3 +1,4 @@ +// type: proposals/explicit-resource-management.d.ts 'use strict'; // https://github.com/tc39/proposal-async-explicit-resource-management var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.async-iterator.async-dispose.js b/packages/core-js/modules/es.async-iterator.async-dispose.js index 5b58e53d7ab9..2cafb2ac7afd 100644 --- a/packages/core-js/modules/es.async-iterator.async-dispose.js +++ b/packages/core-js/modules/es.async-iterator.async-dispose.js @@ -1,3 +1,4 @@ +// type: proposals/explicit-resource-management.d.ts 'use strict'; // https://github.com/tc39/proposal-async-explicit-resource-management var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.disposable-stack.constructor.js b/packages/core-js/modules/es.disposable-stack.constructor.js index 8375a086d8ca..5f20a096ccd8 100644 --- a/packages/core-js/modules/es.disposable-stack.constructor.js +++ b/packages/core-js/modules/es.disposable-stack.constructor.js @@ -1,3 +1,4 @@ +// type: proposals/explicit-resource-management.d.ts 'use strict'; // https://github.com/tc39/proposal-explicit-resource-management var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.error.is-error.js b/packages/core-js/modules/es.error.is-error.js index e8ab5f0b3ba9..b63a91853177 100644 --- a/packages/core-js/modules/es.error.is-error.js +++ b/packages/core-js/modules/es.error.is-error.js @@ -1,3 +1,4 @@ +// type: proposals/is-error.d.ts 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/es.iterator.concat.js b/packages/core-js/modules/es.iterator.concat.js index b92b25c7e4f4..24bb5678181c 100644 --- a/packages/core-js/modules/es.iterator.concat.js +++ b/packages/core-js/modules/es.iterator.concat.js @@ -1,3 +1,4 @@ +// type: proposals/iterator-sequencing.d.ts 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.dispose.js b/packages/core-js/modules/es.iterator.dispose.js index eb5dda71b2e5..dc7fa7db9760 100644 --- a/packages/core-js/modules/es.iterator.dispose.js +++ b/packages/core-js/modules/es.iterator.dispose.js @@ -1,3 +1,4 @@ +// type: proposals/explicit-resource-management.d.ts 'use strict'; // https://github.com/tc39/proposal-explicit-resource-management var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.json.is-raw-json.js b/packages/core-js/modules/es.json.is-raw-json.js index 90290c4853be..7c94d5cef661 100644 --- a/packages/core-js/modules/es.json.is-raw-json.js +++ b/packages/core-js/modules/es.json.is-raw-json.js @@ -1,3 +1,4 @@ +// type: proposals/json-parse-with-source.d.ts 'use strict'; var $ = require('../internals/export'); var NATIVE_RAW_JSON = require('../internals/native-raw-json'); diff --git a/packages/core-js/modules/es.json.parse.js b/packages/core-js/modules/es.json.parse.js index 8af7e7e8d4db..4cee97fa7c31 100644 --- a/packages/core-js/modules/es.json.parse.js +++ b/packages/core-js/modules/es.json.parse.js @@ -1,3 +1,4 @@ +// type: proposals/json-parse-with-source.d.ts 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/es.map.get-or-insert-computed.js b/packages/core-js/modules/es.map.get-or-insert-computed.js index dde93056b820..8afd3bd24879 100644 --- a/packages/core-js/modules/es.map.get-or-insert-computed.js +++ b/packages/core-js/modules/es.map.get-or-insert-computed.js @@ -1,3 +1,4 @@ +// type: proposals/map-upsert.d.ts 'use strict'; var $ = require('../internals/export'); var aCallable = require('../internals/a-callable'); diff --git a/packages/core-js/modules/es.map.get-or-insert.js b/packages/core-js/modules/es.map.get-or-insert.js index f1461c1336f9..afa18b418845 100644 --- a/packages/core-js/modules/es.map.get-or-insert.js +++ b/packages/core-js/modules/es.map.get-or-insert.js @@ -1,3 +1,4 @@ +// type: proposals/map-upsert.d.ts 'use strict'; var $ = require('../internals/export'); var MapHelpers = require('../internals/map-helpers'); diff --git a/packages/core-js/modules/es.math.sum-precise.js b/packages/core-js/modules/es.math.sum-precise.js index 6c1653f086f8..c97327e8d96b 100644 --- a/packages/core-js/modules/es.math.sum-precise.js +++ b/packages/core-js/modules/es.math.sum-precise.js @@ -1,3 +1,4 @@ +// type: proposals/math-sum.d.ts 'use strict'; // based on Shewchuk's algorithm for exactly floating point addition // adapted from https://github.com/tc39/proposal-math-sum/blob/3513d58323a1ae25560e8700aa5294500c6c9287/polyfill/polyfill.mjs diff --git a/packages/core-js/modules/es.suppressed-error.constructor.js b/packages/core-js/modules/es.suppressed-error.constructor.js index 4926fd5edd69..94fd355cd95b 100644 --- a/packages/core-js/modules/es.suppressed-error.constructor.js +++ b/packages/core-js/modules/es.suppressed-error.constructor.js @@ -1,3 +1,4 @@ +// type: proposals/explicit-resource-management.d.ts 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/es.symbol.async-dispose.js b/packages/core-js/modules/es.symbol.async-dispose.js index 14a719f64581..577fd501eb88 100644 --- a/packages/core-js/modules/es.symbol.async-dispose.js +++ b/packages/core-js/modules/es.symbol.async-dispose.js @@ -1,3 +1,4 @@ +// type: proposals/explicit-resource-management.d.ts 'use strict'; var globalThis = require('../internals/global-this'); var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/es.symbol.dispose.js b/packages/core-js/modules/es.symbol.dispose.js index 6124e641c75f..ca8b08c26249 100644 --- a/packages/core-js/modules/es.symbol.dispose.js +++ b/packages/core-js/modules/es.symbol.dispose.js @@ -1,3 +1,4 @@ +// type: proposals/explicit-resource-management.d.ts 'use strict'; var globalThis = require('../internals/global-this'); var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/es.uint8-array.from-base64.js b/packages/core-js/modules/es.uint8-array.from-base64.js index aed350b3a67b..775e39400c93 100644 --- a/packages/core-js/modules/es.uint8-array.from-base64.js +++ b/packages/core-js/modules/es.uint8-array.from-base64.js @@ -1,3 +1,4 @@ +// type: proposals/array-buffer-base64.d.ts 'use strict'; /* eslint-disable es/no-uint8array-frombase64 -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.uint8-array.from-hex.js b/packages/core-js/modules/es.uint8-array.from-hex.js index efb7d1c6d645..fe568259b4ce 100644 --- a/packages/core-js/modules/es.uint8-array.from-hex.js +++ b/packages/core-js/modules/es.uint8-array.from-hex.js @@ -1,3 +1,4 @@ +// type: proposals/array-buffer-base64.d.ts 'use strict'; var $ = require('../internals/export'); var aString = require('../internals/a-string'); diff --git a/packages/core-js/modules/es.uint8-array.set-from-base64.js b/packages/core-js/modules/es.uint8-array.set-from-base64.js index 7f9d314fd6bb..90942ec8d5d6 100644 --- a/packages/core-js/modules/es.uint8-array.set-from-base64.js +++ b/packages/core-js/modules/es.uint8-array.set-from-base64.js @@ -1,3 +1,4 @@ +// type: proposals/array-buffer-base64.d.ts 'use strict'; /* eslint-disable es/no-uint8array-prototype-setfrombase64 -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.uint8-array.set-from-hex.js b/packages/core-js/modules/es.uint8-array.set-from-hex.js index fa3e9ec9483a..ac4492ebbf11 100644 --- a/packages/core-js/modules/es.uint8-array.set-from-hex.js +++ b/packages/core-js/modules/es.uint8-array.set-from-hex.js @@ -1,3 +1,4 @@ +// type: proposals/array-buffer-base64.d.ts 'use strict'; var $ = require('../internals/export'); var aString = require('../internals/a-string'); diff --git a/packages/core-js/modules/es.uint8-array.to-base64.js b/packages/core-js/modules/es.uint8-array.to-base64.js index 1a9d890b0925..5c721ee149c2 100644 --- a/packages/core-js/modules/es.uint8-array.to-base64.js +++ b/packages/core-js/modules/es.uint8-array.to-base64.js @@ -1,3 +1,4 @@ +// type: proposals/array-buffer-base64.d.ts 'use strict'; /* eslint-disable es/no-uint8array-prototype-tobase64 -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.uint8-array.to-hex.js b/packages/core-js/modules/es.uint8-array.to-hex.js index d96d3b405b5d..ec1145a10b14 100644 --- a/packages/core-js/modules/es.uint8-array.to-hex.js +++ b/packages/core-js/modules/es.uint8-array.to-hex.js @@ -1,3 +1,4 @@ +// type: proposals/array-buffer-base64.d.ts 'use strict'; /* eslint-disable es/no-uint8array-prototype-tohex -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.weak-map.get-or-insert-computed.js b/packages/core-js/modules/es.weak-map.get-or-insert-computed.js index e96e759896a7..c806f4b6d4ff 100644 --- a/packages/core-js/modules/es.weak-map.get-or-insert-computed.js +++ b/packages/core-js/modules/es.weak-map.get-or-insert-computed.js @@ -1,3 +1,4 @@ +// type: proposals/map-upsert.d.ts 'use strict'; var $ = require('../internals/export'); var aCallable = require('../internals/a-callable'); diff --git a/packages/core-js/modules/es.weak-map.get-or-insert.js b/packages/core-js/modules/es.weak-map.get-or-insert.js index 1d1cac4fca28..80b2b376e3d5 100644 --- a/packages/core-js/modules/es.weak-map.get-or-insert.js +++ b/packages/core-js/modules/es.weak-map.get-or-insert.js @@ -1,3 +1,4 @@ +// type: proposals/map-upsert.d.ts 'use strict'; var $ = require('../internals/export'); var WeakMapHelpers = require('../internals/weak-map-helpers'); diff --git a/packages/core-js/modules/esnext.array.filter-reject.js b/packages/core-js/modules/esnext.array.filter-reject.js index 9e0604e3ef6d..b44752ab22a4 100644 --- a/packages/core-js/modules/esnext.array.filter-reject.js +++ b/packages/core-js/modules/esnext.array.filter-reject.js @@ -1,3 +1,4 @@ +// type: proposals/array-filtering.d.ts 'use strict'; var $ = require('../internals/export'); var $filterReject = require('../internals/array-iteration').filterReject; diff --git a/packages/core-js/modules/esnext.array.is-template-object.js b/packages/core-js/modules/esnext.array.is-template-object.js index 65c26f7e5b3d..6201af2fa14c 100644 --- a/packages/core-js/modules/esnext.array.is-template-object.js +++ b/packages/core-js/modules/esnext.array.is-template-object.js @@ -1,3 +1,4 @@ +// type: proposals/array-is-template-object.d.ts 'use strict'; var $ = require('../internals/export'); diff --git a/packages/core-js/modules/esnext.array.unique-by.js b/packages/core-js/modules/esnext.array.unique-by.js index efc5b7daeffa..b751df97bcd9 100644 --- a/packages/core-js/modules/esnext.array.unique-by.js +++ b/packages/core-js/modules/esnext.array.unique-by.js @@ -1,3 +1,4 @@ +// type: proposals/array-unique.d.ts 'use strict'; var $ = require('../internals/export'); var addToUnscopables = require('../internals/add-to-unscopables'); diff --git a/packages/core-js/modules/esnext.async-iterator.constructor.js b/packages/core-js/modules/esnext.async-iterator.constructor.js index de9ea36c5162..8b109abcc3a1 100644 --- a/packages/core-js/modules/esnext.async-iterator.constructor.js +++ b/packages/core-js/modules/esnext.async-iterator.constructor.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var anInstance = require('../internals/an-instance'); diff --git a/packages/core-js/modules/esnext.async-iterator.drop.js b/packages/core-js/modules/esnext.async-iterator.drop.js index 1f4ee18573f6..d8a14fd98eb5 100644 --- a/packages/core-js/modules/esnext.async-iterator.drop.js +++ b/packages/core-js/modules/esnext.async-iterator.drop.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.every.js b/packages/core-js/modules/esnext.async-iterator.every.js index 7bd692b2656a..bb6821ebe5f2 100644 --- a/packages/core-js/modules/esnext.async-iterator.every.js +++ b/packages/core-js/modules/esnext.async-iterator.every.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var $every = require('../internals/async-iterator-iteration').every; diff --git a/packages/core-js/modules/esnext.async-iterator.filter.js b/packages/core-js/modules/esnext.async-iterator.filter.js index 9b1ace720df2..50fc87301bd7 100644 --- a/packages/core-js/modules/esnext.async-iterator.filter.js +++ b/packages/core-js/modules/esnext.async-iterator.filter.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.find.js b/packages/core-js/modules/esnext.async-iterator.find.js index 7af8b67e4001..b97992da633d 100644 --- a/packages/core-js/modules/esnext.async-iterator.find.js +++ b/packages/core-js/modules/esnext.async-iterator.find.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var $find = require('../internals/async-iterator-iteration').find; diff --git a/packages/core-js/modules/esnext.async-iterator.flat-map.js b/packages/core-js/modules/esnext.async-iterator.flat-map.js index 0f260a727264..cff8197e1948 100644 --- a/packages/core-js/modules/esnext.async-iterator.flat-map.js +++ b/packages/core-js/modules/esnext.async-iterator.flat-map.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.for-each.js b/packages/core-js/modules/esnext.async-iterator.for-each.js index 901b310806f1..4af79073ed1e 100644 --- a/packages/core-js/modules/esnext.async-iterator.for-each.js +++ b/packages/core-js/modules/esnext.async-iterator.for-each.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var $forEach = require('../internals/async-iterator-iteration').forEach; diff --git a/packages/core-js/modules/esnext.async-iterator.from.js b/packages/core-js/modules/esnext.async-iterator.from.js index e28915ffd9e3..1241a371fe03 100644 --- a/packages/core-js/modules/esnext.async-iterator.from.js +++ b/packages/core-js/modules/esnext.async-iterator.from.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var toObject = require('../internals/to-object'); diff --git a/packages/core-js/modules/esnext.async-iterator.map.js b/packages/core-js/modules/esnext.async-iterator.map.js index 2acb598e92c1..661e4dac649b 100644 --- a/packages/core-js/modules/esnext.async-iterator.map.js +++ b/packages/core-js/modules/esnext.async-iterator.map.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.reduce.js b/packages/core-js/modules/esnext.async-iterator.reduce.js index 3e52016ee3ae..fc5104423d15 100644 --- a/packages/core-js/modules/esnext.async-iterator.reduce.js +++ b/packages/core-js/modules/esnext.async-iterator.reduce.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.some.js b/packages/core-js/modules/esnext.async-iterator.some.js index 1586d1726213..52650f4e8703 100644 --- a/packages/core-js/modules/esnext.async-iterator.some.js +++ b/packages/core-js/modules/esnext.async-iterator.some.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var $some = require('../internals/async-iterator-iteration').some; diff --git a/packages/core-js/modules/esnext.async-iterator.take.js b/packages/core-js/modules/esnext.async-iterator.take.js index c05b3ef98389..7a7b65b66081 100644 --- a/packages/core-js/modules/esnext.async-iterator.take.js +++ b/packages/core-js/modules/esnext.async-iterator.take.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.to-array.js b/packages/core-js/modules/esnext.async-iterator.to-array.js index 54b52a38a8eb..1153e04706ec 100644 --- a/packages/core-js/modules/esnext.async-iterator.to-array.js +++ b/packages/core-js/modules/esnext.async-iterator.to-array.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var $toArray = require('../internals/async-iterator-iteration').toArray; diff --git a/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js b/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js index 00f08a7b08d2..518f62414652 100644 --- a/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js +++ b/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js @@ -1,3 +1,4 @@ +// type: proposals/data-view-get-set-uint8-clamped.d.ts 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js b/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js index 8b524379ad80..221a52348820 100644 --- a/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js +++ b/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js @@ -1,3 +1,4 @@ +// type: proposals/data-view-get-set-uint8-clamped.d.ts 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/esnext.function.demethodize.js b/packages/core-js/modules/esnext.function.demethodize.js index 1d8f9ec11418..82cd0daa4a9c 100644 --- a/packages/core-js/modules/esnext.function.demethodize.js +++ b/packages/core-js/modules/esnext.function.demethodize.js @@ -1,3 +1,4 @@ +// type: proposals/function-demethodize.d.ts 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/esnext.function.metadata.js b/packages/core-js/modules/esnext.function.metadata.js index fb2c188c43b2..13c030e72fe6 100644 --- a/packages/core-js/modules/esnext.function.metadata.js +++ b/packages/core-js/modules/esnext.function.metadata.js @@ -1,3 +1,4 @@ +// type: proposals/decorator-metadata.d.ts 'use strict'; var wellKnownSymbol = require('../internals/well-known-symbol'); diff --git a/packages/core-js/modules/esnext.iterator.range.js b/packages/core-js/modules/esnext.iterator.range.js index 174b28fa65e4..613c9032480b 100644 --- a/packages/core-js/modules/esnext.iterator.range.js +++ b/packages/core-js/modules/esnext.iterator.range.js @@ -1,3 +1,4 @@ +// type: proposals/iterator-range.d.ts 'use strict'; /* eslint-disable es/no-bigint -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/esnext.iterator.to-async.js b/packages/core-js/modules/esnext.iterator.to-async.js index 684047a20dab..324ad221b7a7 100644 --- a/packages/core-js/modules/esnext.iterator.to-async.js +++ b/packages/core-js/modules/esnext.iterator.to-async.js @@ -1,3 +1,4 @@ +// type: proposals/async-iterator-helpers.d.ts 'use strict'; var $ = require('../internals/export'); var anObject = require('../internals/an-object'); diff --git a/packages/core-js/modules/esnext.map.from.js b/packages/core-js/modules/esnext.map.from.js index 48e53210b841..ad54df2a205e 100644 --- a/packages/core-js/modules/esnext.map.from.js +++ b/packages/core-js/modules/esnext.map.from.js @@ -1,3 +1,4 @@ +// type: proposals/collection-of-from.d.ts 'use strict'; var $ = require('../internals/export'); var MapHelpers = require('../internals/map-helpers'); diff --git a/packages/core-js/modules/esnext.map.of.js b/packages/core-js/modules/esnext.map.of.js index 4d0a9a1d5bd0..9eb44d7e6a6f 100644 --- a/packages/core-js/modules/esnext.map.of.js +++ b/packages/core-js/modules/esnext.map.of.js @@ -1,3 +1,4 @@ +// type: proposals/collection-of-from.d.ts 'use strict'; var $ = require('../internals/export'); var MapHelpers = require('../internals/map-helpers'); diff --git a/packages/core-js/modules/esnext.set.from.js b/packages/core-js/modules/esnext.set.from.js index dc5f5b50c7b5..ce82886064c4 100644 --- a/packages/core-js/modules/esnext.set.from.js +++ b/packages/core-js/modules/esnext.set.from.js @@ -1,3 +1,4 @@ +// type: proposals/collection-of-from.d.ts 'use strict'; var $ = require('../internals/export'); var SetHelpers = require('../internals/set-helpers'); diff --git a/packages/core-js/modules/esnext.set.of.js b/packages/core-js/modules/esnext.set.of.js index 498a9ea416d7..c32a7cad01a0 100644 --- a/packages/core-js/modules/esnext.set.of.js +++ b/packages/core-js/modules/esnext.set.of.js @@ -1,3 +1,4 @@ +// type: proposals/collection-of-from.d.ts 'use strict'; var $ = require('../internals/export'); var SetHelpers = require('../internals/set-helpers'); diff --git a/packages/core-js/modules/esnext.string.cooked.js b/packages/core-js/modules/esnext.string.cooked.js index 3b4e9511b176..341f88732e4d 100644 --- a/packages/core-js/modules/esnext.string.cooked.js +++ b/packages/core-js/modules/esnext.string.cooked.js @@ -1,3 +1,4 @@ +// type: proposals/string-cooked.d.ts 'use strict'; var $ = require('../internals/export'); var cooked = require('../internals/string-cooked'); diff --git a/packages/core-js/modules/esnext.string.dedent.js b/packages/core-js/modules/esnext.string.dedent.js index 077ef58e050d..2271d9392825 100644 --- a/packages/core-js/modules/esnext.string.dedent.js +++ b/packages/core-js/modules/esnext.string.dedent.js @@ -1,3 +1,4 @@ +// type: proposals/string-dedent.d.ts 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/esnext.symbol.custom-matcher.js b/packages/core-js/modules/esnext.symbol.custom-matcher.js index 0950470bffc0..7b1b6906d2ce 100644 --- a/packages/core-js/modules/esnext.symbol.custom-matcher.js +++ b/packages/core-js/modules/esnext.symbol.custom-matcher.js @@ -1,3 +1,4 @@ +// type: proposals/extractors.d.ts 'use strict'; var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/esnext.symbol.is-registered-symbol.js b/packages/core-js/modules/esnext.symbol.is-registered-symbol.js index 7b0ff1656ae1..2fca648a62ff 100644 --- a/packages/core-js/modules/esnext.symbol.is-registered-symbol.js +++ b/packages/core-js/modules/esnext.symbol.is-registered-symbol.js @@ -1,3 +1,4 @@ +// type: proposals/symbol-predicates.d.ts 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js b/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js index e6d2502af89f..c6adf7f75946 100644 --- a/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js +++ b/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js @@ -1,4 +1,4 @@ - +// type: proposals/symbol-predicates.d.ts 'use strict'; var $ = require('../internals/export'); var shared = require('../internals/shared'); diff --git a/packages/core-js/modules/esnext.symbol.metadata.js b/packages/core-js/modules/esnext.symbol.metadata.js index 182c9363265c..55ca4e11da3d 100644 --- a/packages/core-js/modules/esnext.symbol.metadata.js +++ b/packages/core-js/modules/esnext.symbol.metadata.js @@ -1,3 +1,4 @@ +// type: proposals/decorator-metadata.d.ts 'use strict'; var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/esnext.typed-array.filter-reject.js b/packages/core-js/modules/esnext.typed-array.filter-reject.js index 0842660a06f5..51ef0c92063f 100644 --- a/packages/core-js/modules/esnext.typed-array.filter-reject.js +++ b/packages/core-js/modules/esnext.typed-array.filter-reject.js @@ -1,3 +1,4 @@ +// type: proposals/array-filtering.d.ts 'use strict'; var exportTypedArrayMethod = require('../internals/export-typed-array-method'); var aTypedArray = require('../internals/a-typed-array'); diff --git a/packages/core-js/modules/esnext.typed-array.unique-by.js b/packages/core-js/modules/esnext.typed-array.unique-by.js index 49dd23c9b2af..fe85bc3844f9 100644 --- a/packages/core-js/modules/esnext.typed-array.unique-by.js +++ b/packages/core-js/modules/esnext.typed-array.unique-by.js @@ -1,3 +1,4 @@ +// type: proposals/array-unique.d.ts 'use strict'; var uncurryThis = require('../internals/function-uncurry-this'); var exportTypedArrayMethod = require('../internals/export-typed-array-method'); diff --git a/packages/core-js/modules/esnext.weak-map.from.js b/packages/core-js/modules/esnext.weak-map.from.js index cf62a6838ac5..21788d8ab95d 100644 --- a/packages/core-js/modules/esnext.weak-map.from.js +++ b/packages/core-js/modules/esnext.weak-map.from.js @@ -1,3 +1,4 @@ +// type: proposals/collection-of-from.d.ts 'use strict'; var $ = require('../internals/export'); var WeakMapHelpers = require('../internals/weak-map-helpers'); diff --git a/packages/core-js/modules/esnext.weak-map.of.js b/packages/core-js/modules/esnext.weak-map.of.js index 636c11246506..a1981b850cc9 100644 --- a/packages/core-js/modules/esnext.weak-map.of.js +++ b/packages/core-js/modules/esnext.weak-map.of.js @@ -1,3 +1,4 @@ +// type: proposals/collection-of-from.d.ts 'use strict'; var $ = require('../internals/export'); var WeakMapHelpers = require('../internals/weak-map-helpers'); diff --git a/packages/core-js/modules/esnext.weak-set.from.js b/packages/core-js/modules/esnext.weak-set.from.js index d8360bdfd72d..0e3dd6fa0486 100644 --- a/packages/core-js/modules/esnext.weak-set.from.js +++ b/packages/core-js/modules/esnext.weak-set.from.js @@ -1,3 +1,4 @@ +// type: proposals/collection-of-from.d.ts 'use strict'; var $ = require('../internals/export'); var WeakSetHelpers = require('../internals/weak-set-helpers'); diff --git a/packages/core-js/modules/esnext.weak-set.of.js b/packages/core-js/modules/esnext.weak-set.of.js index d7b439dafdd9..eaa006140125 100644 --- a/packages/core-js/modules/esnext.weak-set.of.js +++ b/packages/core-js/modules/esnext.weak-set.of.js @@ -1,3 +1,4 @@ +// type: proposals/collection-of-from.d.ts 'use strict'; var $ = require('../internals/export'); var WeakSetHelpers = require('../internals/weak-set-helpers'); From fc13679bcf897248a9382f671d516d9353051d07 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 29 Apr 2025 01:39:34 +0700 Subject: [PATCH 011/315] Added type definitions files to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c2fcdb0697c5..f1641746df37 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ node_modules/ /packages/core-js/stable/ /packages/core-js/stage/ /packages/core-js/index.js +/packages/core-js/index.d.ts /packages/core-js/package.json /packages/core-js/LICENSE /packages/core-js-babel-plugin/LICENSE @@ -45,6 +46,7 @@ node_modules/ /packages/core-js-pure/proposals/ /packages/core-js-pure/stable/ /packages/core-js-pure/stage/ +/packages/core-js-pure/types/ /packages/core-js-pure/index.js /packages/core-js-pure/configurator.js /packages/core-js-pure/package.json From eddc454d871ce58fb09f95787a68ee9710900524 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 29 Apr 2025 02:25:46 +0700 Subject: [PATCH 012/315] Code style fix --- scripts/build-entries/get-dependencies.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-entries/get-dependencies.mjs b/scripts/build-entries/get-dependencies.mjs index 9005318f3b0f..c580c468bb11 100644 --- a/scripts/build-entries/get-dependencies.mjs +++ b/scripts/build-entries/get-dependencies.mjs @@ -7,7 +7,7 @@ const allModulesSet = new Set(modules); const MODULE_PATH = /\/(?(?:internals|modules)\/[\d\-.a-z]+)$/; const DIRECTIVE = /^ *\/\/ @dependency: (?(?:es|esnext|web)\.[\d\-.a-z]+)$/gm; -const TYPES_DIRECTIVE = /^ *\/\/ type: (?[\d\-\/.a-z]+)$/gm; +const TYPES_DIRECTIVE = /^ *\/\/ type: (?[\d\-./a-z]+)$/gm; const dependenciesCache = new Map(); const typesCache = new Map(); From 45cfd34891ff378c58eaedf6f00fd29a19ff16ce Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 30 Apr 2025 01:45:41 +0700 Subject: [PATCH 013/315] Fix definition comments & build types logic --- .../core-js/modules/es.array.from-async.js | 2 +- .../es.async-disposable-stack.constructor.js | 2 +- .../es.async-iterator.async-dispose.js | 2 +- .../es.disposable-stack.constructor.js | 2 +- packages/core-js/modules/es.error.is-error.js | 2 +- .../core-js/modules/es.iterator.concat.js | 2 +- .../core-js/modules/es.iterator.dispose.js | 2 +- .../core-js/modules/es.json.is-raw-json.js | 2 +- packages/core-js/modules/es.json.parse.js | 2 +- .../modules/es.map.get-or-insert-computed.js | 2 +- .../core-js/modules/es.map.get-or-insert.js | 2 +- .../core-js/modules/es.math.sum-precise.js | 2 +- .../es.suppressed-error.constructor.js | 2 +- .../modules/es.symbol.async-dispose.js | 2 +- packages/core-js/modules/es.symbol.dispose.js | 2 +- .../modules/es.uint8-array.from-base64.js | 2 +- .../modules/es.uint8-array.from-hex.js | 2 +- .../modules/es.uint8-array.set-from-base64.js | 2 +- .../modules/es.uint8-array.set-from-hex.js | 2 +- .../modules/es.uint8-array.to-base64.js | 2 +- .../core-js/modules/es.uint8-array.to-hex.js | 2 +- .../es.weak-map.get-or-insert-computed.js | 2 +- .../modules/es.weak-map.get-or-insert.js | 2 +- .../modules/esnext.array.filter-reject.js | 2 +- .../esnext.array.is-template-object.js | 2 +- .../core-js/modules/esnext.array.unique-by.js | 2 +- .../esnext.async-iterator.constructor.js | 2 +- .../modules/esnext.async-iterator.drop.js | 2 +- .../modules/esnext.async-iterator.every.js | 2 +- .../modules/esnext.async-iterator.filter.js | 2 +- .../modules/esnext.async-iterator.find.js | 2 +- .../modules/esnext.async-iterator.flat-map.js | 2 +- .../modules/esnext.async-iterator.for-each.js | 2 +- .../modules/esnext.async-iterator.from.js | 2 +- .../modules/esnext.async-iterator.map.js | 2 +- .../modules/esnext.async-iterator.reduce.js | 2 +- .../modules/esnext.async-iterator.some.js | 2 +- .../modules/esnext.async-iterator.take.js | 2 +- .../modules/esnext.async-iterator.to-array.js | 2 +- .../esnext.data-view.get-uint8-clamped.js | 2 +- .../esnext.data-view.set-uint8-clamped.js | 2 +- .../modules/esnext.function.demethodize.js | 2 +- .../modules/esnext.function.metadata.js | 2 +- .../core-js/modules/esnext.iterator.range.js | 2 +- .../modules/esnext.iterator.to-async.js | 2 +- packages/core-js/modules/esnext.map.from.js | 2 +- packages/core-js/modules/esnext.map.of.js | 2 +- packages/core-js/modules/esnext.set.from.js | 2 +- packages/core-js/modules/esnext.set.of.js | 2 +- .../core-js/modules/esnext.string.cooked.js | 2 +- .../core-js/modules/esnext.string.dedent.js | 2 +- .../modules/esnext.symbol.custom-matcher.js | 2 +- .../esnext.symbol.is-registered-symbol.js | 2 +- .../esnext.symbol.is-well-known-symbol.js | 2 +- .../core-js/modules/esnext.symbol.metadata.js | 2 +- .../esnext.typed-array.filter-reject.js | 2 +- .../modules/esnext.typed-array.unique-by.js | 2 +- .../core-js/modules/esnext.weak-map.from.js | 2 +- .../core-js/modules/esnext.weak-map.of.js | 2 +- .../core-js/modules/esnext.weak-set.from.js | 2 +- .../core-js/modules/esnext.weak-set.of.js | 2 +- scripts/build-entries/get-dependencies.mjs | 44 +++++++++---------- scripts/build-entries/index.mjs | 8 ++-- 63 files changed, 87 insertions(+), 87 deletions(-) diff --git a/packages/core-js/modules/es.array.from-async.js b/packages/core-js/modules/es.array.from-async.js index 9f2224ce7810..4057d06bb7e1 100644 --- a/packages/core-js/modules/es.array.from-async.js +++ b/packages/core-js/modules/es.array.from-async.js @@ -1,4 +1,4 @@ -// type: proposals/array-from-async.d.ts +// types: proposals/array-from-async 'use strict'; var $ = require('../internals/export'); var bind = require('../internals/function-bind-context'); diff --git a/packages/core-js/modules/es.async-disposable-stack.constructor.js b/packages/core-js/modules/es.async-disposable-stack.constructor.js index 02b859685ba2..394e3228e3f6 100644 --- a/packages/core-js/modules/es.async-disposable-stack.constructor.js +++ b/packages/core-js/modules/es.async-disposable-stack.constructor.js @@ -1,4 +1,4 @@ -// type: proposals/explicit-resource-management.d.ts +// types: proposals/explicit-resource-management 'use strict'; // https://github.com/tc39/proposal-async-explicit-resource-management var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.async-iterator.async-dispose.js b/packages/core-js/modules/es.async-iterator.async-dispose.js index 2cafb2ac7afd..c43ce1f0339c 100644 --- a/packages/core-js/modules/es.async-iterator.async-dispose.js +++ b/packages/core-js/modules/es.async-iterator.async-dispose.js @@ -1,4 +1,4 @@ -// type: proposals/explicit-resource-management.d.ts +// types: proposals/explicit-resource-management 'use strict'; // https://github.com/tc39/proposal-async-explicit-resource-management var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.disposable-stack.constructor.js b/packages/core-js/modules/es.disposable-stack.constructor.js index 5f20a096ccd8..bd62fb8bc9c6 100644 --- a/packages/core-js/modules/es.disposable-stack.constructor.js +++ b/packages/core-js/modules/es.disposable-stack.constructor.js @@ -1,4 +1,4 @@ -// type: proposals/explicit-resource-management.d.ts +// types: proposals/explicit-resource-management 'use strict'; // https://github.com/tc39/proposal-explicit-resource-management var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.error.is-error.js b/packages/core-js/modules/es.error.is-error.js index b63a91853177..c3a6509beda4 100644 --- a/packages/core-js/modules/es.error.is-error.js +++ b/packages/core-js/modules/es.error.is-error.js @@ -1,4 +1,4 @@ -// type: proposals/is-error.d.ts +// types: proposals/is-error 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/es.iterator.concat.js b/packages/core-js/modules/es.iterator.concat.js index 24bb5678181c..dc744cb12099 100644 --- a/packages/core-js/modules/es.iterator.concat.js +++ b/packages/core-js/modules/es.iterator.concat.js @@ -1,4 +1,4 @@ -// type: proposals/iterator-sequencing.d.ts +// types: proposals/iterator-sequencing 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.dispose.js b/packages/core-js/modules/es.iterator.dispose.js index dc7fa7db9760..0d4abefdd197 100644 --- a/packages/core-js/modules/es.iterator.dispose.js +++ b/packages/core-js/modules/es.iterator.dispose.js @@ -1,4 +1,4 @@ -// type: proposals/explicit-resource-management.d.ts +// types: proposals/explicit-resource-management 'use strict'; // https://github.com/tc39/proposal-explicit-resource-management var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.json.is-raw-json.js b/packages/core-js/modules/es.json.is-raw-json.js index 7c94d5cef661..8f954c97db49 100644 --- a/packages/core-js/modules/es.json.is-raw-json.js +++ b/packages/core-js/modules/es.json.is-raw-json.js @@ -1,4 +1,4 @@ -// type: proposals/json-parse-with-source.d.ts +// types: proposals/json-parse-with-source 'use strict'; var $ = require('../internals/export'); var NATIVE_RAW_JSON = require('../internals/native-raw-json'); diff --git a/packages/core-js/modules/es.json.parse.js b/packages/core-js/modules/es.json.parse.js index 4cee97fa7c31..ebf72ce72ec4 100644 --- a/packages/core-js/modules/es.json.parse.js +++ b/packages/core-js/modules/es.json.parse.js @@ -1,4 +1,4 @@ -// type: proposals/json-parse-with-source.d.ts +// types: proposals/json-parse-with-source 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/es.map.get-or-insert-computed.js b/packages/core-js/modules/es.map.get-or-insert-computed.js index 8afd3bd24879..31f7cc6c3924 100644 --- a/packages/core-js/modules/es.map.get-or-insert-computed.js +++ b/packages/core-js/modules/es.map.get-or-insert-computed.js @@ -1,4 +1,4 @@ -// type: proposals/map-upsert.d.ts +// types: proposals/map-upsert 'use strict'; var $ = require('../internals/export'); var aCallable = require('../internals/a-callable'); diff --git a/packages/core-js/modules/es.map.get-or-insert.js b/packages/core-js/modules/es.map.get-or-insert.js index afa18b418845..1a23b9c6bf77 100644 --- a/packages/core-js/modules/es.map.get-or-insert.js +++ b/packages/core-js/modules/es.map.get-or-insert.js @@ -1,4 +1,4 @@ -// type: proposals/map-upsert.d.ts +// types: proposals/map-upsert 'use strict'; var $ = require('../internals/export'); var MapHelpers = require('../internals/map-helpers'); diff --git a/packages/core-js/modules/es.math.sum-precise.js b/packages/core-js/modules/es.math.sum-precise.js index c97327e8d96b..2f74b363c19f 100644 --- a/packages/core-js/modules/es.math.sum-precise.js +++ b/packages/core-js/modules/es.math.sum-precise.js @@ -1,4 +1,4 @@ -// type: proposals/math-sum.d.ts +// types: proposals/math-sum 'use strict'; // based on Shewchuk's algorithm for exactly floating point addition // adapted from https://github.com/tc39/proposal-math-sum/blob/3513d58323a1ae25560e8700aa5294500c6c9287/polyfill/polyfill.mjs diff --git a/packages/core-js/modules/es.suppressed-error.constructor.js b/packages/core-js/modules/es.suppressed-error.constructor.js index 94fd355cd95b..d5029621b1fa 100644 --- a/packages/core-js/modules/es.suppressed-error.constructor.js +++ b/packages/core-js/modules/es.suppressed-error.constructor.js @@ -1,4 +1,4 @@ -// type: proposals/explicit-resource-management.d.ts +// types: proposals/explicit-resource-management 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/es.symbol.async-dispose.js b/packages/core-js/modules/es.symbol.async-dispose.js index 577fd501eb88..05ca2d794b84 100644 --- a/packages/core-js/modules/es.symbol.async-dispose.js +++ b/packages/core-js/modules/es.symbol.async-dispose.js @@ -1,4 +1,4 @@ -// type: proposals/explicit-resource-management.d.ts +// types: proposals/explicit-resource-management 'use strict'; var globalThis = require('../internals/global-this'); var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/es.symbol.dispose.js b/packages/core-js/modules/es.symbol.dispose.js index ca8b08c26249..d0bd8d15cdab 100644 --- a/packages/core-js/modules/es.symbol.dispose.js +++ b/packages/core-js/modules/es.symbol.dispose.js @@ -1,4 +1,4 @@ -// type: proposals/explicit-resource-management.d.ts +// types: proposals/explicit-resource-management 'use strict'; var globalThis = require('../internals/global-this'); var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/es.uint8-array.from-base64.js b/packages/core-js/modules/es.uint8-array.from-base64.js index 775e39400c93..837782775e28 100644 --- a/packages/core-js/modules/es.uint8-array.from-base64.js +++ b/packages/core-js/modules/es.uint8-array.from-base64.js @@ -1,4 +1,4 @@ -// type: proposals/array-buffer-base64.d.ts +// types: proposals/array-buffer-base64 'use strict'; /* eslint-disable es/no-uint8array-frombase64 -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.uint8-array.from-hex.js b/packages/core-js/modules/es.uint8-array.from-hex.js index fe568259b4ce..f9d7d9094032 100644 --- a/packages/core-js/modules/es.uint8-array.from-hex.js +++ b/packages/core-js/modules/es.uint8-array.from-hex.js @@ -1,4 +1,4 @@ -// type: proposals/array-buffer-base64.d.ts +// types: proposals/array-buffer-base64 'use strict'; var $ = require('../internals/export'); var aString = require('../internals/a-string'); diff --git a/packages/core-js/modules/es.uint8-array.set-from-base64.js b/packages/core-js/modules/es.uint8-array.set-from-base64.js index 90942ec8d5d6..449fa1eb853b 100644 --- a/packages/core-js/modules/es.uint8-array.set-from-base64.js +++ b/packages/core-js/modules/es.uint8-array.set-from-base64.js @@ -1,4 +1,4 @@ -// type: proposals/array-buffer-base64.d.ts +// types: proposals/array-buffer-base64 'use strict'; /* eslint-disable es/no-uint8array-prototype-setfrombase64 -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.uint8-array.set-from-hex.js b/packages/core-js/modules/es.uint8-array.set-from-hex.js index ac4492ebbf11..a1468bf59284 100644 --- a/packages/core-js/modules/es.uint8-array.set-from-hex.js +++ b/packages/core-js/modules/es.uint8-array.set-from-hex.js @@ -1,4 +1,4 @@ -// type: proposals/array-buffer-base64.d.ts +// types: proposals/array-buffer-base64 'use strict'; var $ = require('../internals/export'); var aString = require('../internals/a-string'); diff --git a/packages/core-js/modules/es.uint8-array.to-base64.js b/packages/core-js/modules/es.uint8-array.to-base64.js index 5c721ee149c2..18539763c492 100644 --- a/packages/core-js/modules/es.uint8-array.to-base64.js +++ b/packages/core-js/modules/es.uint8-array.to-base64.js @@ -1,4 +1,4 @@ -// type: proposals/array-buffer-base64.d.ts +// types: proposals/array-buffer-base64 'use strict'; /* eslint-disable es/no-uint8array-prototype-tobase64 -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.uint8-array.to-hex.js b/packages/core-js/modules/es.uint8-array.to-hex.js index ec1145a10b14..81fc9e7dad55 100644 --- a/packages/core-js/modules/es.uint8-array.to-hex.js +++ b/packages/core-js/modules/es.uint8-array.to-hex.js @@ -1,4 +1,4 @@ -// type: proposals/array-buffer-base64.d.ts +// types: proposals/array-buffer-base64 'use strict'; /* eslint-disable es/no-uint8array-prototype-tohex -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.weak-map.get-or-insert-computed.js b/packages/core-js/modules/es.weak-map.get-or-insert-computed.js index c806f4b6d4ff..5bfe32dde90d 100644 --- a/packages/core-js/modules/es.weak-map.get-or-insert-computed.js +++ b/packages/core-js/modules/es.weak-map.get-or-insert-computed.js @@ -1,4 +1,4 @@ -// type: proposals/map-upsert.d.ts +// types: proposals/map-upsert 'use strict'; var $ = require('../internals/export'); var aCallable = require('../internals/a-callable'); diff --git a/packages/core-js/modules/es.weak-map.get-or-insert.js b/packages/core-js/modules/es.weak-map.get-or-insert.js index 80b2b376e3d5..4abfb54840d3 100644 --- a/packages/core-js/modules/es.weak-map.get-or-insert.js +++ b/packages/core-js/modules/es.weak-map.get-or-insert.js @@ -1,4 +1,4 @@ -// type: proposals/map-upsert.d.ts +// types: proposals/map-upsert 'use strict'; var $ = require('../internals/export'); var WeakMapHelpers = require('../internals/weak-map-helpers'); diff --git a/packages/core-js/modules/esnext.array.filter-reject.js b/packages/core-js/modules/esnext.array.filter-reject.js index b44752ab22a4..740395a4e01d 100644 --- a/packages/core-js/modules/esnext.array.filter-reject.js +++ b/packages/core-js/modules/esnext.array.filter-reject.js @@ -1,4 +1,4 @@ -// type: proposals/array-filtering.d.ts +// types: proposals/array-filtering 'use strict'; var $ = require('../internals/export'); var $filterReject = require('../internals/array-iteration').filterReject; diff --git a/packages/core-js/modules/esnext.array.is-template-object.js b/packages/core-js/modules/esnext.array.is-template-object.js index 6201af2fa14c..2c1f0ecc46fb 100644 --- a/packages/core-js/modules/esnext.array.is-template-object.js +++ b/packages/core-js/modules/esnext.array.is-template-object.js @@ -1,4 +1,4 @@ -// type: proposals/array-is-template-object.d.ts +// types: proposals/array-is-template-object 'use strict'; var $ = require('../internals/export'); diff --git a/packages/core-js/modules/esnext.array.unique-by.js b/packages/core-js/modules/esnext.array.unique-by.js index b751df97bcd9..3b680aa3ace2 100644 --- a/packages/core-js/modules/esnext.array.unique-by.js +++ b/packages/core-js/modules/esnext.array.unique-by.js @@ -1,4 +1,4 @@ -// type: proposals/array-unique.d.ts +// types: proposals/array-unique 'use strict'; var $ = require('../internals/export'); var addToUnscopables = require('../internals/add-to-unscopables'); diff --git a/packages/core-js/modules/esnext.async-iterator.constructor.js b/packages/core-js/modules/esnext.async-iterator.constructor.js index 8b109abcc3a1..920ef2dc4765 100644 --- a/packages/core-js/modules/esnext.async-iterator.constructor.js +++ b/packages/core-js/modules/esnext.async-iterator.constructor.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var anInstance = require('../internals/an-instance'); diff --git a/packages/core-js/modules/esnext.async-iterator.drop.js b/packages/core-js/modules/esnext.async-iterator.drop.js index d8a14fd98eb5..1c052f8ee770 100644 --- a/packages/core-js/modules/esnext.async-iterator.drop.js +++ b/packages/core-js/modules/esnext.async-iterator.drop.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.every.js b/packages/core-js/modules/esnext.async-iterator.every.js index bb6821ebe5f2..15c763082d90 100644 --- a/packages/core-js/modules/esnext.async-iterator.every.js +++ b/packages/core-js/modules/esnext.async-iterator.every.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var $every = require('../internals/async-iterator-iteration').every; diff --git a/packages/core-js/modules/esnext.async-iterator.filter.js b/packages/core-js/modules/esnext.async-iterator.filter.js index 50fc87301bd7..a9f30c545946 100644 --- a/packages/core-js/modules/esnext.async-iterator.filter.js +++ b/packages/core-js/modules/esnext.async-iterator.filter.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.find.js b/packages/core-js/modules/esnext.async-iterator.find.js index b97992da633d..fc8e196c001d 100644 --- a/packages/core-js/modules/esnext.async-iterator.find.js +++ b/packages/core-js/modules/esnext.async-iterator.find.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var $find = require('../internals/async-iterator-iteration').find; diff --git a/packages/core-js/modules/esnext.async-iterator.flat-map.js b/packages/core-js/modules/esnext.async-iterator.flat-map.js index cff8197e1948..8dec19e2743a 100644 --- a/packages/core-js/modules/esnext.async-iterator.flat-map.js +++ b/packages/core-js/modules/esnext.async-iterator.flat-map.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.for-each.js b/packages/core-js/modules/esnext.async-iterator.for-each.js index 4af79073ed1e..49bf32f48657 100644 --- a/packages/core-js/modules/esnext.async-iterator.for-each.js +++ b/packages/core-js/modules/esnext.async-iterator.for-each.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var $forEach = require('../internals/async-iterator-iteration').forEach; diff --git a/packages/core-js/modules/esnext.async-iterator.from.js b/packages/core-js/modules/esnext.async-iterator.from.js index 1241a371fe03..872c1f53cad1 100644 --- a/packages/core-js/modules/esnext.async-iterator.from.js +++ b/packages/core-js/modules/esnext.async-iterator.from.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var toObject = require('../internals/to-object'); diff --git a/packages/core-js/modules/esnext.async-iterator.map.js b/packages/core-js/modules/esnext.async-iterator.map.js index 661e4dac649b..f6b8c112b924 100644 --- a/packages/core-js/modules/esnext.async-iterator.map.js +++ b/packages/core-js/modules/esnext.async-iterator.map.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.reduce.js b/packages/core-js/modules/esnext.async-iterator.reduce.js index fc5104423d15..a3b771b06eaa 100644 --- a/packages/core-js/modules/esnext.async-iterator.reduce.js +++ b/packages/core-js/modules/esnext.async-iterator.reduce.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.some.js b/packages/core-js/modules/esnext.async-iterator.some.js index 52650f4e8703..e93052381c67 100644 --- a/packages/core-js/modules/esnext.async-iterator.some.js +++ b/packages/core-js/modules/esnext.async-iterator.some.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var $some = require('../internals/async-iterator-iteration').some; diff --git a/packages/core-js/modules/esnext.async-iterator.take.js b/packages/core-js/modules/esnext.async-iterator.take.js index 7a7b65b66081..55685f746895 100644 --- a/packages/core-js/modules/esnext.async-iterator.take.js +++ b/packages/core-js/modules/esnext.async-iterator.take.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.to-array.js b/packages/core-js/modules/esnext.async-iterator.to-array.js index 1153e04706ec..a85a0cd50ba7 100644 --- a/packages/core-js/modules/esnext.async-iterator.to-array.js +++ b/packages/core-js/modules/esnext.async-iterator.to-array.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var $toArray = require('../internals/async-iterator-iteration').toArray; diff --git a/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js b/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js index 518f62414652..d7d608d14997 100644 --- a/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js +++ b/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js @@ -1,4 +1,4 @@ -// type: proposals/data-view-get-set-uint8-clamped.d.ts +// types: proposals/data-view-get-set-uint8-clamped 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js b/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js index 221a52348820..2794124f9d35 100644 --- a/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js +++ b/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js @@ -1,4 +1,4 @@ -// type: proposals/data-view-get-set-uint8-clamped.d.ts +// types: proposals/data-view-get-set-uint8-clamped 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/esnext.function.demethodize.js b/packages/core-js/modules/esnext.function.demethodize.js index 82cd0daa4a9c..a9392fd48d4a 100644 --- a/packages/core-js/modules/esnext.function.demethodize.js +++ b/packages/core-js/modules/esnext.function.demethodize.js @@ -1,4 +1,4 @@ -// type: proposals/function-demethodize.d.ts +// types: proposals/function-demethodize 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/esnext.function.metadata.js b/packages/core-js/modules/esnext.function.metadata.js index 13c030e72fe6..1f9d6a1036fe 100644 --- a/packages/core-js/modules/esnext.function.metadata.js +++ b/packages/core-js/modules/esnext.function.metadata.js @@ -1,4 +1,4 @@ -// type: proposals/decorator-metadata.d.ts +// types: proposals/decorator-metadata 'use strict'; var wellKnownSymbol = require('../internals/well-known-symbol'); diff --git a/packages/core-js/modules/esnext.iterator.range.js b/packages/core-js/modules/esnext.iterator.range.js index 613c9032480b..14cd0141c72c 100644 --- a/packages/core-js/modules/esnext.iterator.range.js +++ b/packages/core-js/modules/esnext.iterator.range.js @@ -1,4 +1,4 @@ -// type: proposals/iterator-range.d.ts +// types: proposals/iterator-range 'use strict'; /* eslint-disable es/no-bigint -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/esnext.iterator.to-async.js b/packages/core-js/modules/esnext.iterator.to-async.js index 324ad221b7a7..8ae383c18971 100644 --- a/packages/core-js/modules/esnext.iterator.to-async.js +++ b/packages/core-js/modules/esnext.iterator.to-async.js @@ -1,4 +1,4 @@ -// type: proposals/async-iterator-helpers.d.ts +// types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var anObject = require('../internals/an-object'); diff --git a/packages/core-js/modules/esnext.map.from.js b/packages/core-js/modules/esnext.map.from.js index ad54df2a205e..7d6e6e7fe26a 100644 --- a/packages/core-js/modules/esnext.map.from.js +++ b/packages/core-js/modules/esnext.map.from.js @@ -1,4 +1,4 @@ -// type: proposals/collection-of-from.d.ts +// types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var MapHelpers = require('../internals/map-helpers'); diff --git a/packages/core-js/modules/esnext.map.of.js b/packages/core-js/modules/esnext.map.of.js index 9eb44d7e6a6f..6f21c8112d3d 100644 --- a/packages/core-js/modules/esnext.map.of.js +++ b/packages/core-js/modules/esnext.map.of.js @@ -1,4 +1,4 @@ -// type: proposals/collection-of-from.d.ts +// types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var MapHelpers = require('../internals/map-helpers'); diff --git a/packages/core-js/modules/esnext.set.from.js b/packages/core-js/modules/esnext.set.from.js index ce82886064c4..e1428f8c845e 100644 --- a/packages/core-js/modules/esnext.set.from.js +++ b/packages/core-js/modules/esnext.set.from.js @@ -1,4 +1,4 @@ -// type: proposals/collection-of-from.d.ts +// types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var SetHelpers = require('../internals/set-helpers'); diff --git a/packages/core-js/modules/esnext.set.of.js b/packages/core-js/modules/esnext.set.of.js index c32a7cad01a0..861fadc26518 100644 --- a/packages/core-js/modules/esnext.set.of.js +++ b/packages/core-js/modules/esnext.set.of.js @@ -1,4 +1,4 @@ -// type: proposals/collection-of-from.d.ts +// types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var SetHelpers = require('../internals/set-helpers'); diff --git a/packages/core-js/modules/esnext.string.cooked.js b/packages/core-js/modules/esnext.string.cooked.js index 341f88732e4d..9a96a7539ad9 100644 --- a/packages/core-js/modules/esnext.string.cooked.js +++ b/packages/core-js/modules/esnext.string.cooked.js @@ -1,4 +1,4 @@ -// type: proposals/string-cooked.d.ts +// types: proposals/string-cooked 'use strict'; var $ = require('../internals/export'); var cooked = require('../internals/string-cooked'); diff --git a/packages/core-js/modules/esnext.string.dedent.js b/packages/core-js/modules/esnext.string.dedent.js index 2271d9392825..e4cdeee965f2 100644 --- a/packages/core-js/modules/esnext.string.dedent.js +++ b/packages/core-js/modules/esnext.string.dedent.js @@ -1,4 +1,4 @@ -// type: proposals/string-dedent.d.ts +// types: proposals/string-dedent 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/esnext.symbol.custom-matcher.js b/packages/core-js/modules/esnext.symbol.custom-matcher.js index 7b1b6906d2ce..e5cd845dd8ae 100644 --- a/packages/core-js/modules/esnext.symbol.custom-matcher.js +++ b/packages/core-js/modules/esnext.symbol.custom-matcher.js @@ -1,4 +1,4 @@ -// type: proposals/extractors.d.ts +// types: proposals/extractors 'use strict'; var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/esnext.symbol.is-registered-symbol.js b/packages/core-js/modules/esnext.symbol.is-registered-symbol.js index 2fca648a62ff..1d5e6e3d19d5 100644 --- a/packages/core-js/modules/esnext.symbol.is-registered-symbol.js +++ b/packages/core-js/modules/esnext.symbol.is-registered-symbol.js @@ -1,4 +1,4 @@ -// type: proposals/symbol-predicates.d.ts +// types: proposals/symbol-predicates 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js b/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js index c6adf7f75946..ceabd077c2b5 100644 --- a/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js +++ b/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js @@ -1,4 +1,4 @@ -// type: proposals/symbol-predicates.d.ts +// types: proposals/symbol-predicates 'use strict'; var $ = require('../internals/export'); var shared = require('../internals/shared'); diff --git a/packages/core-js/modules/esnext.symbol.metadata.js b/packages/core-js/modules/esnext.symbol.metadata.js index 55ca4e11da3d..ed4d4448b4f3 100644 --- a/packages/core-js/modules/esnext.symbol.metadata.js +++ b/packages/core-js/modules/esnext.symbol.metadata.js @@ -1,4 +1,4 @@ -// type: proposals/decorator-metadata.d.ts +// types: proposals/decorator-metadata 'use strict'; var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/esnext.typed-array.filter-reject.js b/packages/core-js/modules/esnext.typed-array.filter-reject.js index 51ef0c92063f..898891ee744c 100644 --- a/packages/core-js/modules/esnext.typed-array.filter-reject.js +++ b/packages/core-js/modules/esnext.typed-array.filter-reject.js @@ -1,4 +1,4 @@ -// type: proposals/array-filtering.d.ts +// types: proposals/array-filtering 'use strict'; var exportTypedArrayMethod = require('../internals/export-typed-array-method'); var aTypedArray = require('../internals/a-typed-array'); diff --git a/packages/core-js/modules/esnext.typed-array.unique-by.js b/packages/core-js/modules/esnext.typed-array.unique-by.js index fe85bc3844f9..e1427b8dfa1c 100644 --- a/packages/core-js/modules/esnext.typed-array.unique-by.js +++ b/packages/core-js/modules/esnext.typed-array.unique-by.js @@ -1,4 +1,4 @@ -// type: proposals/array-unique.d.ts +// types: proposals/array-unique 'use strict'; var uncurryThis = require('../internals/function-uncurry-this'); var exportTypedArrayMethod = require('../internals/export-typed-array-method'); diff --git a/packages/core-js/modules/esnext.weak-map.from.js b/packages/core-js/modules/esnext.weak-map.from.js index 21788d8ab95d..dc8277045834 100644 --- a/packages/core-js/modules/esnext.weak-map.from.js +++ b/packages/core-js/modules/esnext.weak-map.from.js @@ -1,4 +1,4 @@ -// type: proposals/collection-of-from.d.ts +// types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var WeakMapHelpers = require('../internals/weak-map-helpers'); diff --git a/packages/core-js/modules/esnext.weak-map.of.js b/packages/core-js/modules/esnext.weak-map.of.js index a1981b850cc9..dfc6ea2f20cb 100644 --- a/packages/core-js/modules/esnext.weak-map.of.js +++ b/packages/core-js/modules/esnext.weak-map.of.js @@ -1,4 +1,4 @@ -// type: proposals/collection-of-from.d.ts +// types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var WeakMapHelpers = require('../internals/weak-map-helpers'); diff --git a/packages/core-js/modules/esnext.weak-set.from.js b/packages/core-js/modules/esnext.weak-set.from.js index 0e3dd6fa0486..c7b32e8a41b0 100644 --- a/packages/core-js/modules/esnext.weak-set.from.js +++ b/packages/core-js/modules/esnext.weak-set.from.js @@ -1,4 +1,4 @@ -// type: proposals/collection-of-from.d.ts +// types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var WeakSetHelpers = require('../internals/weak-set-helpers'); diff --git a/packages/core-js/modules/esnext.weak-set.of.js b/packages/core-js/modules/esnext.weak-set.of.js index eaa006140125..26f97989747c 100644 --- a/packages/core-js/modules/esnext.weak-set.of.js +++ b/packages/core-js/modules/esnext.weak-set.of.js @@ -1,4 +1,4 @@ -// type: proposals/collection-of-from.d.ts +// types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var WeakSetHelpers = require('../internals/weak-set-helpers'); diff --git a/scripts/build-entries/get-dependencies.mjs b/scripts/build-entries/get-dependencies.mjs index c580c468bb11..6b7bd9517105 100644 --- a/scripts/build-entries/get-dependencies.mjs +++ b/scripts/build-entries/get-dependencies.mjs @@ -7,10 +7,9 @@ const allModulesSet = new Set(modules); const MODULE_PATH = /\/(?(?:internals|modules)\/[\d\-.a-z]+)$/; const DIRECTIVE = /^ *\/\/ @dependency: (?(?:es|esnext|web)\.[\d\-.a-z]+)$/gm; -const TYPES_DIRECTIVE = /^ *\/\/ type: (?[\d\-./a-z]+)$/gm; +const TYPES_DIRECTIVE = /^ *\/\/ types: (?[\d\-./a-z]+)$/gm; -const dependenciesCache = new Map(); -const typesCache = new Map(); +const cache = new Map(); function unique(array) { return [...new Set(array)]; @@ -31,39 +30,40 @@ function normalizeModulePath(unnormalizedPath) { } async function getSetOfAllDependenciesForModule(path, stack = new Set()) { - if (dependenciesCache.has(path)) return dependenciesCache.get(path); + if (cache.has(path)) return cache.get(path); if (stack.has(path)) throw new Error(red(`Circular dependency: ${ cyan(path) }`)); stack.add(path); const module = String(await fs.readFile(`./packages/core-js/${ path }.js`)); const directDependencies = konan(module).strings.map(normalizeModulePath); const declaredDependencies = [...module.matchAll(DIRECTIVE)].map(it => normalizeModulePath(it.groups.module)); const dependencies = unique([...directDependencies, ...declaredDependencies]); - const result = new Set([path]); + const paths = new Set([path]); + const types = new Set(); + for (const it of module.matchAll(TYPES_DIRECTIVE)) { + types.add(it.groups.types); + } for (const dependency of dependencies) { const dependenciesOfDependency = await getSetOfAllDependenciesForModule(dependency, new Set(stack)); - dependenciesOfDependency.forEach(it => result.add(it)); + dependenciesOfDependency.dependencies.forEach(it => paths.add(it)); } - dependenciesCache.set(path, result); + const result = { + dependencies: paths, + types, + }; + cache.set(path, result); return result; } export async function getListOfDependencies(paths) { const dependencies = []; + const types = []; for (const module of paths.map(normalizeModulePath)) { - dependencies.push(...await getSetOfAllDependenciesForModule(module)); + const result = await getSetOfAllDependenciesForModule(module); + dependencies.push(...result.dependencies); + types.push(...result.types); } - return sort(unique(dependencies).filter(it => it.startsWith('modules/')).map(it => it.slice(8))); -} - -export async function getListOfTypes(modulePaths) { - if (typesCache.has(modulePaths)) return typesCache.get(modulePaths); - const typesSet = new Set(); - for (const modulePath of modulePaths) { - const module = String(await fs.readFile(`./packages/core-js/modules/${ modulePath }.js`)); - [...module.matchAll(TYPES_DIRECTIVE)].map(it => typesSet.add(it.groups.type)); - } - const types = Array.from(typesSet); - typesCache.set(modulePaths, types); - - return types; + return { + dependencies: sort(unique(dependencies).filter(it => it.startsWith('modules/')).map(it => it.slice(8))), + types: unique(types), + }; } diff --git a/scripts/build-entries/index.mjs b/scripts/build-entries/index.mjs index 5718a38b765e..5c3f1b8cf4f8 100644 --- a/scripts/build-entries/index.mjs +++ b/scripts/build-entries/index.mjs @@ -1,4 +1,4 @@ -import { getListOfDependencies, getListOfTypes, sort } from './get-dependencies.mjs'; +import { getListOfDependencies, sort } from './get-dependencies.mjs'; import { features, proposals } from './entries-definitions.mjs'; import { $proposal, $path, wrapDts, wrapEntry } from './templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; @@ -81,10 +81,10 @@ async function buildEntry(entry, options) { const level = entry.split('/').length - 1; - modules = await getListOfDependencies(modules); - if (filter) modules = modules.filter(it => filter.has(it)); + const { dependencies, types } = await getListOfDependencies(modules); + modules = dependencies; - const types = await getListOfTypes(modules, level); + if (filter) modules = modules.filter(it => filter.has(it)); const tpl = template({ ...options, modules, rawModules, level, entry, types }); From a7f53384895ca443a743abbaba085241ef131529 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 30 Apr 2025 02:13:48 +0700 Subject: [PATCH 014/315] Tests for build-entries templates --- package.json | 1 + tests/build-entries/templates.mjs | 93 +++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 tests/build-entries/templates.mjs diff --git a/package.json b/package.json index 99e5e9aa6650..9eba58ae1432 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "test-builder": "npm run zxi tests/builder/builder.mjs", "test-compat-data": "npm run zxi tests/compat-data/index.mjs", "test-compat-tools": "npm run zxi tests/compat-tools/index.mjs", + "test-templates": "npm run zxi tests/build-entries/templates.mjs", "test-type-definitions": "npm run zxi time cd tests/type-definitions/runner.mjs", "test262": "npm run zxi time cd tests/test262/runner.mjs", "refresh": "UPDATE_DEPENDENCIES=1 npm run prepare-monorepo && npm run test-raw", diff --git a/tests/build-entries/templates.mjs b/tests/build-entries/templates.mjs new file mode 100644 index 000000000000..ae2896a57d03 --- /dev/null +++ b/tests/build-entries/templates.mjs @@ -0,0 +1,93 @@ +import { + $justImport, $patchableStatic, + $prototype, + $prototypeIterator, $static, $staticWithContext, + $virtual, + $virtualIterator, +} from '../../scripts/build-entries/templates.mjs'; +import { deepEqual } from 'node:assert/strict'; + +const props = { + modules: ['module1', 'module2'], + namespace: 'namespace', + name: 'name', + level: 2, + types: ['type1', 'type2'], + source: 'source', +}; + +deepEqual( + $justImport(props), + { dts: '// it has no exports', entry: "require('../../modules/module1');\nrequire('../../modules/module2');" }, + 'Template $justImport incorrect', +); +deepEqual( + $virtual(props), + { + dts: 'declare const method: typeof namespace.prototype.name;\nexport = method;', + entry: "require('../../modules/module1');\nrequire('../../modules/module2');\n" + + "\nvar getBuiltInPrototypeMethod = require('../../internals/get-built-in-prototype-method');\n\nmodule.exports = getBuiltInPrototypeMethod('namespace', 'name');", + }, + 'Template $virtual incorrect', +); +deepEqual( + $virtualIterator(props), + { + dts: 'declare const method: typeof Array.prototype[typeof Symbol.iterator];\nexport = method;', + entry: "require('../../modules/module1');\nrequire('../../modules/module2');\n" + + "\nvar getIteratorMethod = require('../../internals/get-iterator-method');\n\nmodule.exports = getIteratorMethod(source);", + }, + 'Template $virtualIterator incorrect', +); +deepEqual( + $prototype(props), + { + dts: 'declare const method: (\n thisArg: any,\n ...args: Parameters\n) => ReturnType;\nexport = method;', + entry: "require('../../modules/module1');\nrequire('../../modules/module2');\n" + + "\nvar entryUnbind = require('../../internals/entry-unbind');\n\nmodule.exports = entryUnbind('namespace', 'name');", + }, + 'Template $prototype incorrect', +); + +deepEqual( + $prototypeIterator(props), + { + dts: 'declare const method: typeof Array.prototype[typeof Symbol.iterator];\nexport = method;', + entry: "require('../../modules/module1');\nrequire('../../modules/module2');\n" + + "\nvar uncurryThis = require('../../internals/function-uncurry-this');\nvar getIteratorMethod = require('../../internals/get-iterator-method');\n" + + '\nmodule.exports = uncurryThis(getIteratorMethod(source));', + }, + 'Template $prototypeIterator incorrect', +); + +deepEqual( + $static(props), + { + dts: 'declare const method: typeof namespace.name;\nexport = method;', + entry: "require('../../modules/module1');\nrequire('../../modules/module2');\n" + + "\nvar getBuiltInStaticMethod = require('../../internals/get-built-in-static-method');\n\nmodule.exports = getBuiltInStaticMethod('namespace', 'name');", + }, + 'Template $static incorrect', +); + +deepEqual( + $staticWithContext(props), { + dts: 'declare const method: (\n this: Function | void,\n ...args: Parameters\n) => ReturnType;\nexport = method;', + entry: "require('../../modules/module1');\nrequire('../../modules/module2');\n\nvar getBuiltIn = require('../../internals/get-built-in');\n" + + "var getBuiltInStaticMethod = require('../../internals/get-built-in-static-method');\nvar isCallable = require('../../internals/is-callable');\n" + + "var apply = require('../../internals/function-apply');\n\nvar method = getBuiltInStaticMethod('namespace', 'name');\n" + + "\nmodule.exports = function name() {\n return apply(method, isCallable(this) ? this : getBuiltIn('namespace'), arguments);\n};", + }, + 'Template $staticWithContext incorrect', +); + +deepEqual( + $patchableStatic(props), + { + dts: 'declare const method: typeof namespace.name;\nexport = method;', + entry: "require('../../modules/module1');\nrequire('../../modules/module2');\n\nvar getBuiltInStaticMethod = require('../../internals/get-built-in-static-method');\n" + + "var apply = require('../../internals/function-apply');\n" + + "\nmodule.exports = function name() {\n return apply(getBuiltInStaticMethod('namespace', 'name'), this, arguments);\n};", + }, + 'Template $patchableStatic incorrect', +); From ffbf452f741279738f96032c35681ec5e854fcec Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 30 Apr 2025 22:14:11 +0700 Subject: [PATCH 015/315] Fix types & build types script --- .../core-js/types/proposals/array-buffer-transfer.d.ts | 1 - .../core-js/types/proposals/array-find-from-last.d.ts | 6 +++--- packages/core-js/types/proposals/array-includes.d.ts | 1 + .../types/proposals/array-is-template-object.d.ts | 2 +- .../core-js/types/proposals/decorator-metadata.d.ts | 2 +- .../core-js/types/proposals/function-demethodize.d.ts | 2 +- packages/core-js/types/proposals/is-error.d.ts | 2 +- packages/core-js/types/proposals/iterator-range.d.ts | 2 +- .../core-js/types/proposals/iterator-sequencing.d.ts | 2 +- .../types/proposals/json-parse-with-source.d.ts | 3 +-- packages/core-js/types/proposals/map-upsert.d.ts | 2 +- packages/core-js/types/proposals/string-cooked.d.ts | 4 ++-- packages/core-js/types/proposals/string-dedent.d.ts | 2 +- .../core-js/types/proposals/symbol-predicates.d.ts | 4 ++-- scripts/build-entries/entries-definitions.mjs | 4 ++++ scripts/build-entries/get-dependencies.mjs | 10 +++++----- scripts/build-entries/index.mjs | 4 ++-- tests/build-entries/templates.mjs | 5 +++-- .../debug-get-dependencies/debug-get-dependencies.mjs | 4 ++-- 19 files changed, 33 insertions(+), 29 deletions(-) diff --git a/packages/core-js/types/proposals/array-buffer-transfer.d.ts b/packages/core-js/types/proposals/array-buffer-transfer.d.ts index 9b92e92c6926..59979863ea69 100644 --- a/packages/core-js/types/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js/types/proposals/array-buffer-transfer.d.ts @@ -3,7 +3,6 @@ interface ArrayBuffer { readonly detached: boolean; - slice(start?: number, end?: number): ArrayBuffer; transfer(newByteLength?: number): ArrayBuffer; transferToFixedLength(newByteLength?: number): ArrayBuffer; } diff --git a/packages/core-js/types/proposals/array-find-from-last.d.ts b/packages/core-js/types/proposals/array-find-from-last.d.ts index 41ae4a0f12ab..c89141b53801 100644 --- a/packages/core-js/types/proposals/array-find-from-last.d.ts +++ b/packages/core-js/types/proposals/array-find-from-last.d.ts @@ -1,6 +1,6 @@ // proposal stage: 4 // https://github.com/tc39/proposal-array-find-from-last -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts#L5 +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts interface Array { findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; @@ -92,7 +92,7 @@ interface Float64Array { interface BigInt64Array { findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number | undefined; + findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): bigint | undefined; findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; } @@ -100,7 +100,7 @@ interface BigInt64Array { interface BigUint64Array { findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number | undefined; + findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): bigint | undefined; findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; } diff --git a/packages/core-js/types/proposals/array-includes.d.ts b/packages/core-js/types/proposals/array-includes.d.ts index d4e5a6a39820..7752b0975d5b 100644 --- a/packages/core-js/types/proposals/array-includes.d.ts +++ b/packages/core-js/types/proposals/array-includes.d.ts @@ -1,5 +1,6 @@ // proposal stage: 4 // https://github.com/tc39/proposal-Array.prototype.includes +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2016.array.include.d.ts interface Array { includes(searchElement: T, fromIndex?: number): boolean; } diff --git a/packages/core-js/types/proposals/array-is-template-object.d.ts b/packages/core-js/types/proposals/array-is-template-object.d.ts index 3766181e3097..6ab53db2e94a 100644 --- a/packages/core-js/types/proposals/array-is-template-object.d.ts +++ b/packages/core-js/types/proposals/array-is-template-object.d.ts @@ -1,5 +1,5 @@ // proposal stage: 2 // https://github.com/tc39/proposal-array-is-template-object interface ArrayConstructor { - isTemplateObject(value: unknown): value is TemplateStringsArray; + isTemplateObject(value: any): value is TemplateStringsArray; } diff --git a/packages/core-js/types/proposals/decorator-metadata.d.ts b/packages/core-js/types/proposals/decorator-metadata.d.ts index 9a277111cba8..4c5bee1c1113 100644 --- a/packages/core-js/types/proposals/decorator-metadata.d.ts +++ b/packages/core-js/types/proposals/decorator-metadata.d.ts @@ -4,6 +4,6 @@ interface SymbolConstructor { readonly metadata: unique symbol; } -interface Object { +interface Function { [Symbol.metadata]?: object; } diff --git a/packages/core-js/types/proposals/function-demethodize.d.ts b/packages/core-js/types/proposals/function-demethodize.d.ts index d4660c6ea3a9..0c829273ed92 100644 --- a/packages/core-js/types/proposals/function-demethodize.d.ts +++ b/packages/core-js/types/proposals/function-demethodize.d.ts @@ -1,5 +1,5 @@ // proposal stage: 0 // https://github.com/js-choi/proposal-function-demethodize interface Function { - demethodize(this: (this: T, ...args: Args) => R): (thisArg: T, ...args: Args) => R; + demethodize(this: (this: T, ...args: Args) => R): (thisArg: T, ...args: Args) => R; } diff --git a/packages/core-js/types/proposals/is-error.d.ts b/packages/core-js/types/proposals/is-error.d.ts index f7ebf0af180f..fc6a8d1fac03 100644 --- a/packages/core-js/types/proposals/is-error.d.ts +++ b/packages/core-js/types/proposals/is-error.d.ts @@ -1,5 +1,5 @@ // proposal stage: 3 // https://github.com/tc39/proposal-is-error interface ErrorConstructor { - isError(value: unknown): value is Error; + isError(value: any): value is Error; } diff --git a/packages/core-js/types/proposals/iterator-range.d.ts b/packages/core-js/types/proposals/iterator-range.d.ts index c0c6a20989d6..74b0b48f817a 100644 --- a/packages/core-js/types/proposals/iterator-range.d.ts +++ b/packages/core-js/types/proposals/iterator-range.d.ts @@ -13,7 +13,7 @@ type RangeOptionsBigInt = { interface IteratorConstructor { range(start: number, end: number, options?: number | RangeOptionsNumber): Iterator; - range(start: bigint, end: bigint, options?: bigint | RangeOptionsBigInt): Iterator; + range(start: bigint, end: bigint | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: bigint | RangeOptionsBigInt): Iterator; } declare var Iterator: IteratorConstructor; diff --git a/packages/core-js/types/proposals/iterator-sequencing.d.ts b/packages/core-js/types/proposals/iterator-sequencing.d.ts index b8dac410badc..aab81bab0610 100644 --- a/packages/core-js/types/proposals/iterator-sequencing.d.ts +++ b/packages/core-js/types/proposals/iterator-sequencing.d.ts @@ -1,5 +1,5 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-sequencing interface Iterator { - concat(...iterators: Array | Iterator>): Iterator; + concat(...iterators: Iterable[]): IteratorObject; } diff --git a/packages/core-js/types/proposals/json-parse-with-source.d.ts b/packages/core-js/types/proposals/json-parse-with-source.d.ts index eaba2385ad43..d6d36ab0d6ed 100644 --- a/packages/core-js/types/proposals/json-parse-with-source.d.ts +++ b/packages/core-js/types/proposals/json-parse-with-source.d.ts @@ -2,7 +2,6 @@ // https://github.com/tc39/proposal-json-parse-with-source interface ReviverContext { source: string; - keys: string[]; } type RawJSONObject = { @@ -10,7 +9,7 @@ type RawJSONObject = { } interface JSON { - isRawJSON(value: unknown): value is RawJSONObject; + isRawJSON(value: any): value is RawJSONObject; parse(text: string, reviver?: (key: string, value: any, context: ReviverContext) => any): T; rawJSON(value: string): RawJSONObject; } diff --git a/packages/core-js/types/proposals/map-upsert.d.ts b/packages/core-js/types/proposals/map-upsert.d.ts index de0a7d38804a..d3a0229a010e 100644 --- a/packages/core-js/types/proposals/map-upsert.d.ts +++ b/packages/core-js/types/proposals/map-upsert.d.ts @@ -5,7 +5,7 @@ interface Map { getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } -interface WeakMap { +interface WeakMap { getOrInsert(key: K, value: V): V; getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } diff --git a/packages/core-js/types/proposals/string-cooked.d.ts b/packages/core-js/types/proposals/string-cooked.d.ts index 6570cf4d2846..997d27f10ee3 100644 --- a/packages/core-js/types/proposals/string-cooked.d.ts +++ b/packages/core-js/types/proposals/string-cooked.d.ts @@ -1,7 +1,7 @@ // proposal stage: 1 // https://github.com/tc39/proposal-string-cooked interface StringConstructor { - cooked(template: readonly string[], ...substitutions: unknown[]): string; + cooked(template: readonly string[], ...substitutions: any[]): string; - cooked(template: string, ...substitutions: unknown[]): string; + cooked(template: string, ...substitutions: any[]): string; } diff --git a/packages/core-js/types/proposals/string-dedent.d.ts b/packages/core-js/types/proposals/string-dedent.d.ts index 2ec9e401bf4b..241b621bc2a7 100644 --- a/packages/core-js/types/proposals/string-dedent.d.ts +++ b/packages/core-js/types/proposals/string-dedent.d.ts @@ -1,5 +1,5 @@ // proposal stage: 2 // https://github.com/tc39/proposal-string-dedent interface StringConstructor { - dedent(strings: TemplateStringsArray, ...values: unknown[]): string; + dedent(strings: TemplateStringsArray, ...values: any[]): string; } diff --git a/packages/core-js/types/proposals/symbol-predicates.d.ts b/packages/core-js/types/proposals/symbol-predicates.d.ts index c043e5bfa55d..5188f97cccc0 100644 --- a/packages/core-js/types/proposals/symbol-predicates.d.ts +++ b/packages/core-js/types/proposals/symbol-predicates.d.ts @@ -1,6 +1,6 @@ // proposal stage: 2 // https://github.com/tc39/proposal-symbol-predicates interface SymbolConstructor { - isRegisteredSymbol(value: unknown): boolean; - isWellKnownSymbol(value: unknown): boolean; + isRegisteredSymbol(value: any): boolean; + isWellKnownSymbol(value: any): boolean; } diff --git a/scripts/build-entries/entries-definitions.mjs b/scripts/build-entries/entries-definitions.mjs index 6bb1a55d0e29..6ad1bcaa72c9 100644 --- a/scripts/build-entries/entries-definitions.mjs +++ b/scripts/build-entries/entries-definitions.mjs @@ -375,11 +375,13 @@ export const features = { modules: ['es.array.iterator'], template: $uncurriedIterator, source: '[]', + namespace: 'Array', }, 'array/prototype/iterator': { modules: ['es.array.iterator'], template: $prototypeIterator, source: '[]', + namespace: 'Array', }, 'array/join': { modules: ['es.array.join'], @@ -2446,11 +2448,13 @@ export const features = { modules: ['es.string.iterator'], template: $uncurriedIterator, source: "''", + namespace: 'String', }, 'string/prototype/iterator': { modules: ['es.string.iterator'], template: $prototypeIterator, source: "''", + namespace: 'String', }, 'string/link': { modules: ['es.string.link'], diff --git a/scripts/build-entries/get-dependencies.mjs b/scripts/build-entries/get-dependencies.mjs index 6b7bd9517105..a5493fba0b61 100644 --- a/scripts/build-entries/get-dependencies.mjs +++ b/scripts/build-entries/get-dependencies.mjs @@ -29,7 +29,7 @@ function normalizeModulePath(unnormalizedPath) { return path.endsWith('.js') ? path.slice(0, -3) : path; } -async function getSetOfAllDependenciesForModule(path, stack = new Set()) { +async function getModuleMetadata(path, stack = new Set()) { if (cache.has(path)) return cache.get(path); if (stack.has(path)) throw new Error(red(`Circular dependency: ${ cyan(path) }`)); stack.add(path); @@ -43,8 +43,8 @@ async function getSetOfAllDependenciesForModule(path, stack = new Set()) { types.add(it.groups.types); } for (const dependency of dependencies) { - const dependenciesOfDependency = await getSetOfAllDependenciesForModule(dependency, new Set(stack)); - dependenciesOfDependency.dependencies.forEach(it => paths.add(it)); + const moduleMetadata = await getModuleMetadata(dependency, new Set(stack)); + moduleMetadata.dependencies.forEach(it => paths.add(it)); } const result = { dependencies: paths, @@ -54,11 +54,11 @@ async function getSetOfAllDependenciesForModule(path, stack = new Set()) { return result; } -export async function getListOfDependencies(paths) { +export async function getModulesMetadata(paths) { const dependencies = []; const types = []; for (const module of paths.map(normalizeModulePath)) { - const result = await getSetOfAllDependenciesForModule(module); + const result = await getModuleMetadata(module); dependencies.push(...result.dependencies); types.push(...result.types); } diff --git a/scripts/build-entries/index.mjs b/scripts/build-entries/index.mjs index 5c3f1b8cf4f8..9448bdd54e29 100644 --- a/scripts/build-entries/index.mjs +++ b/scripts/build-entries/index.mjs @@ -1,4 +1,4 @@ -import { getListOfDependencies, sort } from './get-dependencies.mjs'; +import { getModulesMetadata, sort } from './get-dependencies.mjs'; import { features, proposals } from './entries-definitions.mjs'; import { $proposal, $path, wrapDts, wrapEntry } from './templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; @@ -81,7 +81,7 @@ async function buildEntry(entry, options) { const level = entry.split('/').length - 1; - const { dependencies, types } = await getListOfDependencies(modules); + const { dependencies, types } = await getModulesMetadata(modules); modules = dependencies; if (filter) modules = modules.filter(it => filter.has(it)); diff --git a/tests/build-entries/templates.mjs b/tests/build-entries/templates.mjs index ae2896a57d03..56f74d37a9d9 100644 --- a/tests/build-entries/templates.mjs +++ b/tests/build-entries/templates.mjs @@ -33,7 +33,7 @@ deepEqual( deepEqual( $virtualIterator(props), { - dts: 'declare const method: typeof Array.prototype[typeof Symbol.iterator];\nexport = method;', + dts: 'declare const method: typeof source.prototype[typeof Symbol.iterator];\nexport = method;', entry: "require('../../modules/module1');\nrequire('../../modules/module2');\n" + "\nvar getIteratorMethod = require('../../internals/get-iterator-method');\n\nmodule.exports = getIteratorMethod(source);", }, @@ -52,7 +52,8 @@ deepEqual( deepEqual( $prototypeIterator(props), { - dts: 'declare const method: typeof Array.prototype[typeof Symbol.iterator];\nexport = method;', + dts: 'declare const method: (\n thisArg: any,\n ...args: Parameters\n' + + ') => ReturnType;\nexport = method;', entry: "require('../../modules/module1');\nrequire('../../modules/module2');\n" + "\nvar uncurryThis = require('../../internals/function-uncurry-this');\nvar getIteratorMethod = require('../../internals/get-iterator-method');\n" + '\nmodule.exports = uncurryThis(getIteratorMethod(source));', diff --git a/tests/debug-get-dependencies/debug-get-dependencies.mjs b/tests/debug-get-dependencies/debug-get-dependencies.mjs index 5799f589409c..4c049aca0a1a 100644 --- a/tests/debug-get-dependencies/debug-get-dependencies.mjs +++ b/tests/debug-get-dependencies/debug-get-dependencies.mjs @@ -1,4 +1,4 @@ import { modules } from '@core-js/compat/src/data.mjs'; -import { getListOfDependencies } from '../../scripts/build-entries/get-dependencies.mjs'; +import { getModulesMetadata } from '../../scripts/build-entries/get-dependencies.mjs'; -for (const module of modules) console.log(module, await getListOfDependencies([module])); +for (const module of modules) console.log(module, await getModulesMetadata([module])); From 795330d75961f8ab8671156b6602de837d25656f Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 1 May 2025 00:14:06 +0700 Subject: [PATCH 016/315] Templates tests --- package.json | 2 +- tests/templates/entries.mjs | 79 +++++++++++++++++++ tests/templates/index.mjs | 2 + .../templates.mjs | 4 +- 4 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 tests/templates/entries.mjs create mode 100644 tests/templates/index.mjs rename tests/{build-entries => templates}/templates.mjs (96%) diff --git a/package.json b/package.json index 9eba58ae1432..84b6c6bcbf6b 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "test-builder": "npm run zxi tests/builder/builder.mjs", "test-compat-data": "npm run zxi tests/compat-data/index.mjs", "test-compat-tools": "npm run zxi tests/compat-tools/index.mjs", - "test-templates": "npm run zxi tests/build-entries/templates.mjs", + "test-templates": "npm run zxi tests/templates/index.mjs", "test-type-definitions": "npm run zxi time cd tests/type-definitions/runner.mjs", "test262": "npm run zxi time cd tests/test262/runner.mjs", "refresh": "UPDATE_DEPENDENCIES=1 npm run prepare-monorepo && npm run test-raw", diff --git a/tests/templates/entries.mjs b/tests/templates/entries.mjs new file mode 100644 index 000000000000..a2a739fccbb1 --- /dev/null +++ b/tests/templates/entries.mjs @@ -0,0 +1,79 @@ +/* eslint-disable import/no-dynamic-require, node/global-require -- required */ +import { ok } from 'node:assert/strict'; + +const PATH = 'core-js'; +const NS = 'full'; + +function load(...components) { + const path = [PATH, ...components].join('/'); + return require(path); +} + +// $justImport +load(NS, 'array-buffer/detached'); +// $virtual +ok(load(NS, 'array/virtual/at').call([1, 2, 3], -2) === 2); +// $virtualIterator +ok('next' in load(NS, 'array/virtual/iterator').call([])); +// $prototype +ok(load(NS, 'array/at')([1, 2, 3], -2) === 2); +// $prototypeIterator +ok('next' in load(NS, 'array/iterator')([])); +// $static +ok(Array.isArray(load(NS, 'array/from')('qwe'))); +// $staticWithContext +ok(load(NS, 'promise/all-settled')([1, 2, 3]) instanceof Promise); +// $patchableStatic +ok(load(NS, 'json/stringify')([1]) === '[1]'); +// $namespace +ok(typeof load(NS, 'async-disposable-stack/constructor') == 'function'); +// $helper +ok('next' in load(NS, 'get-iterator')([])); +// $path +ok(new (load(NS, 'error/constructor').Error)(1, { cause: 7 }).cause === 7); +// $instanceArray +const instanceConcat = load(NS, 'instance/concat'); +ok(typeof instanceConcat == 'function'); +ok(instanceConcat({}) === undefined); +ok(typeof instanceConcat([]) == 'function'); +ok(instanceConcat([]).call([1, 2, 3], [4, 5, 6]).length === 6); +// $instanceString +const instanceCodePointAt = load(NS, 'instance/code-point-at'); +ok(typeof instanceCodePointAt == 'function'); +ok(instanceCodePointAt({}) === undefined); +ok(typeof instanceCodePointAt('') == 'function'); +ok(instanceCodePointAt('').call('a', 0) === 97); +// $instanceFunction +const instanceDemethodize = load(NS, 'instance/demethodize'); +ok(typeof instanceDemethodize == 'function'); +ok(instanceDemethodize({}) === undefined); +ok(typeof instanceDemethodize([].slice) == 'function'); +ok(instanceDemethodize([].slice).call([].slice)([1, 2, 3], 1)[0] === 2); +// $instanceDOMIterables +const instanceForEach = load(NS, 'instance/for-each'); +ok(typeof instanceForEach == 'function'); +ok(instanceForEach({}) === undefined); +ok(typeof instanceForEach([]) == 'function'); +// $instanceArrayString +const instanceAt = load(NS, 'instance/at'); +ok(typeof instanceAt == 'function'); +ok(instanceAt({}) === undefined); +ok(typeof instanceAt([]) == 'function'); +ok(typeof instanceAt('') == 'function'); +ok(instanceAt([]).call([1, 2, 3], 2) === 3); +ok(instanceAt('').call('123', 2) === '3'); +// $instanceArrayDOMIterables +const instanceEntries = load(NS, 'instance/entries'); +ok(typeof instanceEntries == 'function'); +ok(instanceEntries({}) === undefined); +ok(typeof instanceEntries([]) == 'function'); +ok(instanceEntries([]).call([1, 2, 3]).next().value[1] === 1); +// $instanceRegExpFlags +const instanceFlags = load(NS, 'instance/flags'); +ok(typeof instanceFlags == 'function'); +ok(instanceFlags({}) === undefined); +ok(instanceFlags(/./g) === 'g'); +// $proposal +load('proposals/accessible-object-hasownproperty'); + +echo(chalk.green('templates entry points tested')); diff --git a/tests/templates/index.mjs b/tests/templates/index.mjs new file mode 100644 index 000000000000..30642295bcf3 --- /dev/null +++ b/tests/templates/index.mjs @@ -0,0 +1,2 @@ +await import('./templates.mjs'); +await import('./entries.mjs'); diff --git a/tests/build-entries/templates.mjs b/tests/templates/templates.mjs similarity index 96% rename from tests/build-entries/templates.mjs rename to tests/templates/templates.mjs index 56f74d37a9d9..54b9eeeebce4 100644 --- a/tests/build-entries/templates.mjs +++ b/tests/templates/templates.mjs @@ -33,7 +33,7 @@ deepEqual( deepEqual( $virtualIterator(props), { - dts: 'declare const method: typeof source.prototype[typeof Symbol.iterator];\nexport = method;', + dts: 'declare const method: typeof namespace.prototype[typeof Symbol.iterator];\nexport = method;', entry: "require('../../modules/module1');\nrequire('../../modules/module2');\n" + "\nvar getIteratorMethod = require('../../internals/get-iterator-method');\n\nmodule.exports = getIteratorMethod(source);", }, @@ -92,3 +92,5 @@ deepEqual( }, 'Template $patchableStatic incorrect', ); + +echo(chalk.green('templates tested')); From d5a89ee257a87bfd9d9b49f3840fc0a937e34804 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 1 May 2025 13:48:27 +0700 Subject: [PATCH 017/315] Test templates entry point types --- package.json | 2 +- tests/templates/entries.mjs | 79 ------------------ tests/templates/entries.ts | 130 ++++++++++++++++++++++++++++++ tests/templates/index.mjs | 2 - tests/templates/package-lock.json | 45 +++++++++++ tests/templates/package.json | 10 +++ tests/templates/tsconfig.json | 13 +++ 7 files changed, 199 insertions(+), 82 deletions(-) delete mode 100644 tests/templates/entries.mjs create mode 100644 tests/templates/entries.ts delete mode 100644 tests/templates/index.mjs create mode 100644 tests/templates/package-lock.json create mode 100644 tests/templates/package.json create mode 100644 tests/templates/tsconfig.json diff --git a/package.json b/package.json index 84b6c6bcbf6b..8deea3e56ba1 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "test-builder": "npm run zxi tests/builder/builder.mjs", "test-compat-data": "npm run zxi tests/compat-data/index.mjs", "test-compat-tools": "npm run zxi tests/compat-tools/index.mjs", - "test-templates": "npm run zxi tests/templates/index.mjs", + "test-templates": "npm run zxi tests/templates/templates.mjs", "test-type-definitions": "npm run zxi time cd tests/type-definitions/runner.mjs", "test262": "npm run zxi time cd tests/test262/runner.mjs", "refresh": "UPDATE_DEPENDENCIES=1 npm run prepare-monorepo && npm run test-raw", diff --git a/tests/templates/entries.mjs b/tests/templates/entries.mjs deleted file mode 100644 index a2a739fccbb1..000000000000 --- a/tests/templates/entries.mjs +++ /dev/null @@ -1,79 +0,0 @@ -/* eslint-disable import/no-dynamic-require, node/global-require -- required */ -import { ok } from 'node:assert/strict'; - -const PATH = 'core-js'; -const NS = 'full'; - -function load(...components) { - const path = [PATH, ...components].join('/'); - return require(path); -} - -// $justImport -load(NS, 'array-buffer/detached'); -// $virtual -ok(load(NS, 'array/virtual/at').call([1, 2, 3], -2) === 2); -// $virtualIterator -ok('next' in load(NS, 'array/virtual/iterator').call([])); -// $prototype -ok(load(NS, 'array/at')([1, 2, 3], -2) === 2); -// $prototypeIterator -ok('next' in load(NS, 'array/iterator')([])); -// $static -ok(Array.isArray(load(NS, 'array/from')('qwe'))); -// $staticWithContext -ok(load(NS, 'promise/all-settled')([1, 2, 3]) instanceof Promise); -// $patchableStatic -ok(load(NS, 'json/stringify')([1]) === '[1]'); -// $namespace -ok(typeof load(NS, 'async-disposable-stack/constructor') == 'function'); -// $helper -ok('next' in load(NS, 'get-iterator')([])); -// $path -ok(new (load(NS, 'error/constructor').Error)(1, { cause: 7 }).cause === 7); -// $instanceArray -const instanceConcat = load(NS, 'instance/concat'); -ok(typeof instanceConcat == 'function'); -ok(instanceConcat({}) === undefined); -ok(typeof instanceConcat([]) == 'function'); -ok(instanceConcat([]).call([1, 2, 3], [4, 5, 6]).length === 6); -// $instanceString -const instanceCodePointAt = load(NS, 'instance/code-point-at'); -ok(typeof instanceCodePointAt == 'function'); -ok(instanceCodePointAt({}) === undefined); -ok(typeof instanceCodePointAt('') == 'function'); -ok(instanceCodePointAt('').call('a', 0) === 97); -// $instanceFunction -const instanceDemethodize = load(NS, 'instance/demethodize'); -ok(typeof instanceDemethodize == 'function'); -ok(instanceDemethodize({}) === undefined); -ok(typeof instanceDemethodize([].slice) == 'function'); -ok(instanceDemethodize([].slice).call([].slice)([1, 2, 3], 1)[0] === 2); -// $instanceDOMIterables -const instanceForEach = load(NS, 'instance/for-each'); -ok(typeof instanceForEach == 'function'); -ok(instanceForEach({}) === undefined); -ok(typeof instanceForEach([]) == 'function'); -// $instanceArrayString -const instanceAt = load(NS, 'instance/at'); -ok(typeof instanceAt == 'function'); -ok(instanceAt({}) === undefined); -ok(typeof instanceAt([]) == 'function'); -ok(typeof instanceAt('') == 'function'); -ok(instanceAt([]).call([1, 2, 3], 2) === 3); -ok(instanceAt('').call('123', 2) === '3'); -// $instanceArrayDOMIterables -const instanceEntries = load(NS, 'instance/entries'); -ok(typeof instanceEntries == 'function'); -ok(instanceEntries({}) === undefined); -ok(typeof instanceEntries([]) == 'function'); -ok(instanceEntries([]).call([1, 2, 3]).next().value[1] === 1); -// $instanceRegExpFlags -const instanceFlags = load(NS, 'instance/flags'); -ok(typeof instanceFlags == 'function'); -ok(instanceFlags({}) === undefined); -ok(instanceFlags(/./g) === 'g'); -// $proposal -load('proposals/accessible-object-hasownproperty'); - -echo(chalk.green('templates entry points tested')); diff --git a/tests/templates/entries.ts b/tests/templates/entries.ts new file mode 100644 index 000000000000..5fbdbd3adbbf --- /dev/null +++ b/tests/templates/entries.ts @@ -0,0 +1,130 @@ +// $justImport +require('@core-js/pure/full/array-buffer/detached'); +// @ts-expect-error it has no exports +import abd from '@core-js/pure/full/array-buffer/detached'; + +// $virtual +require('@core-js/pure/full/array/virtual/at').call([1, 2, 3], -2); +import at from '@core-js/pure/full/array/virtual/at'; +at.call([1, 2, 3], -2); +// @ts-expect-error +at(null, 0); + +// $virtualIterator +require('@core-js/pure/full/array/virtual/iterator').call([1]).next().value; +import avit from '@core-js/pure/full/array/virtual/iterator'; +avit.call([1]).next().value; +// @ts-expect-error +avit(1); + +// $prototype +require('@core-js/pure/full/array/at')([1, 2, 3], -2); +import aat from '@core-js/pure/full/array/at'; +aat([1, 2, 3], -2); +// @ts-expect-error +aat(1, 0, 0); + +// $prototypeIterator +require('@core-js/pure/full/array/iterator')([]).next().value; +import ait from '@core-js/pure/full/array/iterator'; +ait([]).next().value; +// @ts-expect-error +ait(); + +// $static +require('@core-js/pure/full/array/from')('qwe'); +import af from '@core-js/pure/full/array/from'; +af('qwe', (it) => it.toUpperCase(), {}); +// @ts-expect-error +af(1); +// @ts-expect-error +af('qwe', 1); + +// $staticWithContext +require('@core-js/pure/full/promise/all-settled')([1, 2, 3]); +import pas from '@core-js/pure/full/promise/all-settled'; +pas([1, 2, 3]); +// @ts-expect-error +pas(1); + +// $patchableStatic +require('@core-js/pure/full/json/stringify')([1]); +import js from '@core-js/pure/full/json/stringify'; +js({ a: 1, b: 2, c: 'asd'}, (_key, val) => typeof val === 'number' ? val * 2 : val, 4); +// @ts-expect-error +js([1], 1); + +// $namespace +require('@core-js/pure/full/async-disposable-stack/constructor'); +import adc from '@core-js/pure/full/async-disposable-stack/constructor'; +new adc(); +// @ts-expect-error +adc.prototype = 1; + +// $helper +require('@core-js/pure/full/get-iterator')([]); +import it from '@core-js/pure/full/get-iterator'; +it([]).next().value; +// @ts-expect-error +it(); + +// $path +new (require('@core-js/pure/full/error/constructor').Error)(); +import ec from '@core-js/pure/full/error/constructor'; +new ec.Error('er'); +// @ts-expect-error +ec(); + +// $instanceArray +require('@core-js/pure/full/instance/concat')(1); +import ic from '@core-js/pure/full/instance/concat'; +ic({}); +// @ts-expect-error +ic(); + +// $instanceString +require('@core-js/pure/full/instance/code-point-at')(''); +import icp from '@core-js/pure/full/instance/code-point-at'; +icp('').call('a', 0); +// @ts-expect-error +icp(); + +// $instanceFunction +require('@core-js/pure/full/instance/demethodize')({}); +import id from '@core-js/pure/full/instance/demethodize'; +id([].slice)([1, 2, 3], 1); +// @ts-expect-error +id(); + +// $instanceDOMIterables +require('@core-js/pure/full/instance/for-each')({}); +import ife from '@core-js/pure/full/instance/for-each'; +ife({}); +// @ts-expect-error +ife(); + +// $instanceArrayString +require('@core-js/pure/full/instance/at')(''); +import ia from '@core-js/pure/full/instance/at'; +ia('').call('123', 2); +// @ts-expect-error +ia(); + +// $instanceArrayDOMIterables +require('@core-js/pure/full/instance/entries')({}); +import ie from '@core-js/pure/full/instance/entries'; +ie([]).call([1, 2, 3]).next().value; +// @ts-expect-error +ie(); + +// $instanceRegExpFlags +require('@core-js/pure/full/instance/flags')({}); +import inf from '@core-js/pure/full/instance/flags'; +inf(/./g); +// @ts-expect-error +inf(); + +// $proposal +require('@core-js/pure/proposals/accessible-object-hasownproperty'); +// @ts-expect-error it has no exports +import pahp from '@core-js/pure/proposals/accessible-object-hasownproperty'; diff --git a/tests/templates/index.mjs b/tests/templates/index.mjs deleted file mode 100644 index 30642295bcf3..000000000000 --- a/tests/templates/index.mjs +++ /dev/null @@ -1,2 +0,0 @@ -await import('./templates.mjs'); -await import('./entries.mjs'); diff --git a/tests/templates/package-lock.json b/tests/templates/package-lock.json new file mode 100644 index 000000000000..26e61d65c3db --- /dev/null +++ b/tests/templates/package-lock.json @@ -0,0 +1,45 @@ +{ + "name": "tests/templates", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "tests/templates", + "devDependencies": { + "@types/node": "^22.15.3", + "typescript": "^5.8.3" + } + }, + "node_modules/@types/node": { + "version": "22.15.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.3.tgz", + "integrity": "sha512-lX7HFZeHf4QG/J7tBZqrCAXwz9J5RD56Y6MpP0eJkka8p+K0RY/yBTW7CYFJ4VGCclxqOLKmiGP5juQc6MKgcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/typescript": { + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + } + } +} diff --git a/tests/templates/package.json b/tests/templates/package.json new file mode 100644 index 000000000000..9a2d60e8b8ea --- /dev/null +++ b/tests/templates/package.json @@ -0,0 +1,10 @@ +{ + "name": "tests/templates", + "scripts": { + "test-templates": "tsc" + }, + "devDependencies": { + "@types/node": "^22.15.3", + "typescript": "^5.8.3" + } +} diff --git a/tests/templates/tsconfig.json b/tests/templates/tsconfig.json new file mode 100644 index 000000000000..f23fe05cf7e0 --- /dev/null +++ b/tests/templates/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "NodeNext", + "strict": true, + "typeRoots": ["../../packages/**/*.d.ts", "./node_modules/@types"], + "noEmit": true, + "esModuleInterop": true, + "moduleResolution": "NodeNext" + }, + "files": ["entries.ts"], + "exclude": ["node_modules"] +} From 91bb41357812afb832f3e719fdfddd4a7c5c3b69 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 1 May 2025 13:56:44 +0700 Subject: [PATCH 018/315] Move entry point types tests & rename proposals types tests --- tests/templates/package-lock.json | 45 ------------------- tests/templates/package.json | 10 ----- tests/templates/tsconfig.json | 13 ------ .../entries.ts => types/entries.test.ts} | 2 +- tests/types/package-lock.json | 20 ++++++++- tests/types/package.json | 4 +- .../array-buffer-base64.test.ts | 0 .../array-filtering.test.ts | 0 .../array-from-async.test.ts | 0 .../array-is-template-object.test.ts | 0 .../{tests => proposals}/array-unique.test.ts | 0 .../async-iterator-helper.test.ts | 0 .../collection-of-from.test.ts | 0 .../data-view-get-set-uint8-clamped.test.ts | 0 .../decorator-metadata.test.ts | 0 .../explicit-resource-management.test.ts | 0 .../{tests => proposals}/extractors.test.ts | 0 .../function-demethodize.test.ts | 0 .../{tests => proposals}/is-error.test.ts | 0 .../iterator-range.test.ts | 0 .../iterator-sequencing.test.ts | 4 +- .../json-parse-with-source.test.ts | 0 .../{tests => proposals}/map-upsert.test.ts | 0 .../{tests => proposals}/math-clamp.test.ts | 0 .../{tests => proposals}/math-sum.test.ts | 0 .../string-cooked.test.ts | 0 .../string-dedent.test.ts | 0 .../symbol-predicates.test.ts | 0 tests/types/tsconfig.json | 18 ++++++-- 29 files changed, 39 insertions(+), 77 deletions(-) delete mode 100644 tests/templates/package-lock.json delete mode 100644 tests/templates/package.json delete mode 100644 tests/templates/tsconfig.json rename tests/{templates/entries.ts => types/entries.test.ts} (98%) rename tests/types/{tests => proposals}/array-buffer-base64.test.ts (100%) rename tests/types/{tests => proposals}/array-filtering.test.ts (100%) rename tests/types/{tests => proposals}/array-from-async.test.ts (100%) rename tests/types/{tests => proposals}/array-is-template-object.test.ts (100%) rename tests/types/{tests => proposals}/array-unique.test.ts (100%) rename tests/types/{tests => proposals}/async-iterator-helper.test.ts (100%) rename tests/types/{tests => proposals}/collection-of-from.test.ts (100%) rename tests/types/{tests => proposals}/data-view-get-set-uint8-clamped.test.ts (100%) rename tests/types/{tests => proposals}/decorator-metadata.test.ts (100%) rename tests/types/{tests => proposals}/explicit-resource-management.test.ts (100%) rename tests/types/{tests => proposals}/extractors.test.ts (100%) rename tests/types/{tests => proposals}/function-demethodize.test.ts (100%) rename tests/types/{tests => proposals}/is-error.test.ts (100%) rename tests/types/{tests => proposals}/iterator-range.test.ts (100%) rename tests/types/{tests => proposals}/iterator-sequencing.test.ts (88%) rename tests/types/{tests => proposals}/json-parse-with-source.test.ts (100%) rename tests/types/{tests => proposals}/map-upsert.test.ts (100%) rename tests/types/{tests => proposals}/math-clamp.test.ts (100%) rename tests/types/{tests => proposals}/math-sum.test.ts (100%) rename tests/types/{tests => proposals}/string-cooked.test.ts (100%) rename tests/types/{tests => proposals}/string-dedent.test.ts (100%) rename tests/types/{tests => proposals}/symbol-predicates.test.ts (100%) diff --git a/tests/templates/package-lock.json b/tests/templates/package-lock.json deleted file mode 100644 index 26e61d65c3db..000000000000 --- a/tests/templates/package-lock.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "tests/templates", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "tests/templates", - "devDependencies": { - "@types/node": "^22.15.3", - "typescript": "^5.8.3" - } - }, - "node_modules/@types/node": { - "version": "22.15.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.3.tgz", - "integrity": "sha512-lX7HFZeHf4QG/J7tBZqrCAXwz9J5RD56Y6MpP0eJkka8p+K0RY/yBTW7CYFJ4VGCclxqOLKmiGP5juQc6MKgcw==", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~6.21.0" - } - }, - "node_modules/typescript": { - "version": "5.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", - "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, - "node_modules/undici-types": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", - "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", - "dev": true, - "license": "MIT" - } - } -} diff --git a/tests/templates/package.json b/tests/templates/package.json deleted file mode 100644 index 9a2d60e8b8ea..000000000000 --- a/tests/templates/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "tests/templates", - "scripts": { - "test-templates": "tsc" - }, - "devDependencies": { - "@types/node": "^22.15.3", - "typescript": "^5.8.3" - } -} diff --git a/tests/templates/tsconfig.json b/tests/templates/tsconfig.json deleted file mode 100644 index f23fe05cf7e0..000000000000 --- a/tests/templates/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "NodeNext", - "strict": true, - "typeRoots": ["../../packages/**/*.d.ts", "./node_modules/@types"], - "noEmit": true, - "esModuleInterop": true, - "moduleResolution": "NodeNext" - }, - "files": ["entries.ts"], - "exclude": ["node_modules"] -} diff --git a/tests/templates/entries.ts b/tests/types/entries.test.ts similarity index 98% rename from tests/templates/entries.ts rename to tests/types/entries.test.ts index 5fbdbd3adbbf..055524a700ad 100644 --- a/tests/templates/entries.ts +++ b/tests/types/entries.test.ts @@ -1,7 +1,7 @@ // $justImport require('@core-js/pure/full/array-buffer/detached'); // @ts-expect-error it has no exports -import abd from '@core-js/pure/full/array-buffer/detached'; +import abdetach from '@core-js/pure/full/array-buffer/detached'; // $virtual require('@core-js/pure/full/array/virtual/at').call([1, 2, 3], -2); diff --git a/tests/types/package-lock.json b/tests/types/package-lock.json index 5fcb75abaafd..419d832da185 100644 --- a/tests/types/package-lock.json +++ b/tests/types/package-lock.json @@ -1,13 +1,24 @@ { - "name": "proposals-types", + "name": "types", "lockfileVersion": 3, "requires": true, "packages": { "": { "devDependencies": { + "@types/node": "^22.15.3", "typescript": "^5.8.3" } }, + "node_modules/@types/node": { + "version": "22.15.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.3.tgz", + "integrity": "sha512-lX7HFZeHf4QG/J7tBZqrCAXwz9J5RD56Y6MpP0eJkka8p+K0RY/yBTW7CYFJ4VGCclxqOLKmiGP5juQc6MKgcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, "node_modules/typescript": { "version": "5.8.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", @@ -21,6 +32,13 @@ "engines": { "node": ">=14.17" } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" } } } diff --git a/tests/types/package.json b/tests/types/package.json index 97132f90bc3b..6e5c436216c3 100644 --- a/tests/types/package.json +++ b/tests/types/package.json @@ -1,8 +1,10 @@ { + "name": "test-types", "scripts": { - "test:types": "tsc" + "test-types": "tsc" }, "devDependencies": { + "@types/node": "^22.15.3", "typescript": "^5.8.3" } } diff --git a/tests/types/tests/array-buffer-base64.test.ts b/tests/types/proposals/array-buffer-base64.test.ts similarity index 100% rename from tests/types/tests/array-buffer-base64.test.ts rename to tests/types/proposals/array-buffer-base64.test.ts diff --git a/tests/types/tests/array-filtering.test.ts b/tests/types/proposals/array-filtering.test.ts similarity index 100% rename from tests/types/tests/array-filtering.test.ts rename to tests/types/proposals/array-filtering.test.ts diff --git a/tests/types/tests/array-from-async.test.ts b/tests/types/proposals/array-from-async.test.ts similarity index 100% rename from tests/types/tests/array-from-async.test.ts rename to tests/types/proposals/array-from-async.test.ts diff --git a/tests/types/tests/array-is-template-object.test.ts b/tests/types/proposals/array-is-template-object.test.ts similarity index 100% rename from tests/types/tests/array-is-template-object.test.ts rename to tests/types/proposals/array-is-template-object.test.ts diff --git a/tests/types/tests/array-unique.test.ts b/tests/types/proposals/array-unique.test.ts similarity index 100% rename from tests/types/tests/array-unique.test.ts rename to tests/types/proposals/array-unique.test.ts diff --git a/tests/types/tests/async-iterator-helper.test.ts b/tests/types/proposals/async-iterator-helper.test.ts similarity index 100% rename from tests/types/tests/async-iterator-helper.test.ts rename to tests/types/proposals/async-iterator-helper.test.ts diff --git a/tests/types/tests/collection-of-from.test.ts b/tests/types/proposals/collection-of-from.test.ts similarity index 100% rename from tests/types/tests/collection-of-from.test.ts rename to tests/types/proposals/collection-of-from.test.ts diff --git a/tests/types/tests/data-view-get-set-uint8-clamped.test.ts b/tests/types/proposals/data-view-get-set-uint8-clamped.test.ts similarity index 100% rename from tests/types/tests/data-view-get-set-uint8-clamped.test.ts rename to tests/types/proposals/data-view-get-set-uint8-clamped.test.ts diff --git a/tests/types/tests/decorator-metadata.test.ts b/tests/types/proposals/decorator-metadata.test.ts similarity index 100% rename from tests/types/tests/decorator-metadata.test.ts rename to tests/types/proposals/decorator-metadata.test.ts diff --git a/tests/types/tests/explicit-resource-management.test.ts b/tests/types/proposals/explicit-resource-management.test.ts similarity index 100% rename from tests/types/tests/explicit-resource-management.test.ts rename to tests/types/proposals/explicit-resource-management.test.ts diff --git a/tests/types/tests/extractors.test.ts b/tests/types/proposals/extractors.test.ts similarity index 100% rename from tests/types/tests/extractors.test.ts rename to tests/types/proposals/extractors.test.ts diff --git a/tests/types/tests/function-demethodize.test.ts b/tests/types/proposals/function-demethodize.test.ts similarity index 100% rename from tests/types/tests/function-demethodize.test.ts rename to tests/types/proposals/function-demethodize.test.ts diff --git a/tests/types/tests/is-error.test.ts b/tests/types/proposals/is-error.test.ts similarity index 100% rename from tests/types/tests/is-error.test.ts rename to tests/types/proposals/is-error.test.ts diff --git a/tests/types/tests/iterator-range.test.ts b/tests/types/proposals/iterator-range.test.ts similarity index 100% rename from tests/types/tests/iterator-range.test.ts rename to tests/types/proposals/iterator-range.test.ts diff --git a/tests/types/tests/iterator-sequencing.test.ts b/tests/types/proposals/iterator-sequencing.test.ts similarity index 88% rename from tests/types/tests/iterator-sequencing.test.ts rename to tests/types/proposals/iterator-sequencing.test.ts index 3667e9fe5fdf..cf22343b302e 100644 --- a/tests/types/tests/iterator-sequencing.test.ts +++ b/tests/types/proposals/iterator-sequencing.test.ts @@ -1,9 +1,9 @@ declare const itn1: Iterator; -declare const its1: Iterator; +declare const its1: Iterable; declare const arrs: string[]; declare const arrn: number[]; declare const arrb: boolean[]; -declare const itb1: Iterator; +declare const itb1: Iterable; const ri1: Iterator = itn1.concat(its1); const ri2: Iterator = itn1.concat(arrs); diff --git a/tests/types/tests/json-parse-with-source.test.ts b/tests/types/proposals/json-parse-with-source.test.ts similarity index 100% rename from tests/types/tests/json-parse-with-source.test.ts rename to tests/types/proposals/json-parse-with-source.test.ts diff --git a/tests/types/tests/map-upsert.test.ts b/tests/types/proposals/map-upsert.test.ts similarity index 100% rename from tests/types/tests/map-upsert.test.ts rename to tests/types/proposals/map-upsert.test.ts diff --git a/tests/types/tests/math-clamp.test.ts b/tests/types/proposals/math-clamp.test.ts similarity index 100% rename from tests/types/tests/math-clamp.test.ts rename to tests/types/proposals/math-clamp.test.ts diff --git a/tests/types/tests/math-sum.test.ts b/tests/types/proposals/math-sum.test.ts similarity index 100% rename from tests/types/tests/math-sum.test.ts rename to tests/types/proposals/math-sum.test.ts diff --git a/tests/types/tests/string-cooked.test.ts b/tests/types/proposals/string-cooked.test.ts similarity index 100% rename from tests/types/tests/string-cooked.test.ts rename to tests/types/proposals/string-cooked.test.ts diff --git a/tests/types/tests/string-dedent.test.ts b/tests/types/proposals/string-dedent.test.ts similarity index 100% rename from tests/types/tests/string-dedent.test.ts rename to tests/types/proposals/string-dedent.test.ts diff --git a/tests/types/tests/symbol-predicates.test.ts b/tests/types/proposals/symbol-predicates.test.ts similarity index 100% rename from tests/types/tests/symbol-predicates.test.ts rename to tests/types/proposals/symbol-predicates.test.ts diff --git a/tests/types/tsconfig.json b/tests/types/tsconfig.json index 0fd3a6403158..1c611913cd65 100644 --- a/tests/types/tsconfig.json +++ b/tests/types/tsconfig.json @@ -1,10 +1,20 @@ { "compilerOptions": { "target": "ES2020", - "module": "ESNext", + "module": "NodeNext", "strict": true, - "typeRoots": ["../../packages/core-js/types/**/*.d.ts", "./node_modules/@types"], - "noEmit": true + "typeRoots": [ + "../../packages/core-js/**/*.d.ts", + "../../packages/core-js-pure/**/*.d.ts", + "./node_modules/@types" + ], + "noEmit": true, + "esModuleInterop": true, + "moduleResolution": "NodeNext" }, - "include": ["tests", "../../packages/core-js/types/**/*.d.ts"] + "include": [ + "proposals", + "../../packages/core-js/types/**/*.d.ts" + ], + "files": ["entries.test.ts"] } From 11efa7dd3a66de3ec6edb2df31aceeb69a2899b7 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 2 May 2025 20:12:53 +0700 Subject: [PATCH 019/315] Added new lines at the end --- tests/types/proposals/array-filtering.test.ts | 2 +- tests/types/proposals/array-from-async.test.ts | 2 +- tests/types/proposals/decorator-metadata.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/types/proposals/array-filtering.test.ts b/tests/types/proposals/array-filtering.test.ts index 190a2abd31f5..b47d3eafe707 100644 --- a/tests/types/proposals/array-filtering.test.ts +++ b/tests/types/proposals/array-filtering.test.ts @@ -57,4 +57,4 @@ testFilterReject(new BigUint64Array([1n,2n]), 1n); (new BigInt64Array([1n,2n,3n])).filterReject((x: number) => false); // @ts-expect-error -(new BigUint64Array([1n,2n,3n])).filterReject((x: number) => false); \ No newline at end of file +(new BigUint64Array([1n,2n,3n])).filterReject((x: number) => false); diff --git a/tests/types/proposals/array-from-async.test.ts b/tests/types/proposals/array-from-async.test.ts index 762ce3f450a8..ce54915dd1f8 100644 --- a/tests/types/proposals/array-from-async.test.ts +++ b/tests/types/proposals/array-from-async.test.ts @@ -34,4 +34,4 @@ Array.fromAsync((async function* () { yield 'a'; })(), (value: number) => value) declare const strArrLike: { [index: number]: string; length: 3 }; // @ts-expect-error -Array.fromAsync(strArrLike, (value: number) => value); \ No newline at end of file +Array.fromAsync(strArrLike, (value: number) => value); diff --git a/tests/types/proposals/decorator-metadata.test.ts b/tests/types/proposals/decorator-metadata.test.ts index 7595f1edd06e..bc03a7169186 100644 --- a/tests/types/proposals/decorator-metadata.test.ts +++ b/tests/types/proposals/decorator-metadata.test.ts @@ -13,4 +13,4 @@ const maybeMeta: object | undefined = obj[Symbol.metadata]; // @ts-expect-error Symbol['metadata'] = Symbol('other'); // @ts-expect-error -obj[Symbol.metadata] = 123; \ No newline at end of file +obj[Symbol.metadata] = 123; From ddd437e5ded18304ccc8fb5e26db880cf97881d2 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 2 May 2025 21:50:01 +0700 Subject: [PATCH 020/315] Change Iterator to IteratorObject in types --- .../types/proposals/async-iterator-helpers.d.ts | 14 +++++++------- .../core-js/types/proposals/iterator-range.d.ts | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/core-js/types/proposals/async-iterator-helpers.d.ts b/packages/core-js/types/proposals/async-iterator-helpers.d.ts index 0c5551c515a5..b768b006475d 100644 --- a/packages/core-js/types/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js/types/proposals/async-iterator-helpers.d.ts @@ -1,35 +1,35 @@ // proposal stage: 2 // https://github.com/tc39/proposal-async-iterator-helpers interface AsyncIteratorConstructor { - from(iterable: AsyncIterable | Iterable | AsyncIterator): AsyncIterator; + from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; } declare var AsyncIterator: AsyncIteratorConstructor; interface AsyncIterator { - drop(limit: number): AsyncIterator; + drop(limit: number): AsyncIteratorObject; every(predicate: (value: T, index: number) => boolean): Promise; - filter(predicate: (value: T, index: number) => boolean): AsyncIterator; + filter(predicate: (value: T, index: number) => boolean): AsyncIteratorObject; find(predicate: (value: T, index: number) => boolean): Promise; - flatMap(mapper: (value: T, index: number) => any): AsyncIterator; + flatMap(mapper: (value: T, index: number) => any): AsyncIteratorObject; forEach(callbackFn: (value: T, index: number) => void): Promise; - map(mapper: (value: T, index: number) => any): AsyncIterator; + map(mapper: (value: T, index: number) => any): AsyncIteratorObject; reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; some(predicate: (value: T, index: number) => boolean): Promise; - take(limit: number): AsyncIterator; + take(limit: number): AsyncIteratorObject; toArray(): Promise; } interface Iterator { - toAsync(): AsyncIterator; + toAsync(): AsyncIteratorObject; } diff --git a/packages/core-js/types/proposals/iterator-range.d.ts b/packages/core-js/types/proposals/iterator-range.d.ts index 74b0b48f817a..3a5e1a9755e9 100644 --- a/packages/core-js/types/proposals/iterator-range.d.ts +++ b/packages/core-js/types/proposals/iterator-range.d.ts @@ -11,9 +11,9 @@ type RangeOptionsBigInt = { }; interface IteratorConstructor { - range(start: number, end: number, options?: number | RangeOptionsNumber): Iterator; + range(start: number, end: number, options?: number | RangeOptionsNumber): IteratorObject; - range(start: bigint, end: bigint | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: bigint | RangeOptionsBigInt): Iterator; + range(start: bigint, end: bigint | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: bigint | RangeOptionsBigInt): IteratorObject; } declare var Iterator: IteratorConstructor; From f3a3e6598e97365532c2cbee41cdbe6622d61aff Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 2 May 2025 21:52:57 +0700 Subject: [PATCH 021/315] Move type tests to folder type-definitions & add some entry point tests --- .../entries.test.ts | 7 +++ .../proposals/array-buffer-base64.test.ts | 2 + .../proposals/array-filtering.test.ts | 26 ++++++----- .../proposals/array-from-async.test.ts | 2 + .../array-is-template-object.test.ts | 2 + .../proposals/array-unique.test.ts | 2 + .../proposals/async-iterator-helper.test.ts | 8 ++-- .../proposals/collection-of-from.test.ts | 2 + .../data-view-get-set-uint8-clamped.test.ts | 2 + .../proposals/decorator-metadata.test.ts | 2 + .../explicit-resource-management.test.ts | 2 + .../proposals/extractors.test.ts | 2 + .../proposals/function-demethodize.test.ts | 2 + .../proposals/is-error.test.ts | 2 + .../proposals/iterator-range.test.ts | 2 + .../proposals/iterator-sequencing.test.ts | 2 + .../proposals/json-parse-with-source.test.ts | 2 + .../proposals/map-upsert.test.ts | 2 + .../proposals/math-clamp.test.ts | 2 + .../proposals/math-sum.test.ts | 2 + .../proposals/string-cooked.test.ts | 2 + .../proposals/string-dedent.test.ts | 2 + .../proposals/symbol-predicates.test.ts | 2 + tests/type-definitions/tsconfig.json | 10 ++++- tests/types/package-lock.json | 44 ------------------- tests/types/package.json | 10 ----- tests/types/tsconfig.json | 20 --------- 27 files changed, 74 insertions(+), 91 deletions(-) rename tests/{types => type-definitions}/entries.test.ts (96%) rename tests/{types => type-definitions}/proposals/array-buffer-base64.test.ts (98%) rename tests/{types => type-definitions}/proposals/array-filtering.test.ts (70%) rename tests/{types => type-definitions}/proposals/array-from-async.test.ts (98%) rename tests/{types => type-definitions}/proposals/array-is-template-object.test.ts (93%) rename tests/{types => type-definitions}/proposals/array-unique.test.ts (97%) rename tests/{types => type-definitions}/proposals/async-iterator-helper.test.ts (92%) rename tests/{types => type-definitions}/proposals/collection-of-from.test.ts (98%) rename tests/{types => type-definitions}/proposals/data-view-get-set-uint8-clamped.test.ts (94%) rename tests/{types => type-definitions}/proposals/decorator-metadata.test.ts (93%) rename tests/{types => type-definitions}/proposals/explicit-resource-management.test.ts (99%) rename tests/{types => type-definitions}/proposals/extractors.test.ts (91%) rename tests/{types => type-definitions}/proposals/function-demethodize.test.ts (94%) rename tests/{types => type-definitions}/proposals/is-error.test.ts (88%) rename tests/{types => type-definitions}/proposals/iterator-range.test.ts (95%) rename tests/{types => type-definitions}/proposals/iterator-sequencing.test.ts (96%) rename tests/{types => type-definitions}/proposals/json-parse-with-source.test.ts (96%) rename tests/{types => type-definitions}/proposals/map-upsert.test.ts (96%) rename tests/{types => type-definitions}/proposals/math-clamp.test.ts (83%) rename tests/{types => type-definitions}/proposals/math-sum.test.ts (89%) rename tests/{types => type-definitions}/proposals/string-cooked.test.ts (89%) rename tests/{types => type-definitions}/proposals/string-dedent.test.ts (93%) rename tests/{types => type-definitions}/proposals/symbol-predicates.test.ts (96%) delete mode 100644 tests/types/package-lock.json delete mode 100644 tests/types/package.json delete mode 100644 tests/types/tsconfig.json diff --git a/tests/types/entries.test.ts b/tests/type-definitions/entries.test.ts similarity index 96% rename from tests/types/entries.test.ts rename to tests/type-definitions/entries.test.ts index 055524a700ad..a4687e26af3b 100644 --- a/tests/types/entries.test.ts +++ b/tests/type-definitions/entries.test.ts @@ -7,6 +7,13 @@ import abdetach from '@core-js/pure/full/array-buffer/detached'; require('@core-js/pure/full/array/virtual/at').call([1, 2, 3], -2); import at from '@core-js/pure/full/array/virtual/at'; at.call([1, 2, 3], -2); +at.apply([1, 2, 3], [-2]); +// @ts-expect-error +at.call([1, 2, 3], null); +// @ts-expect-error +at.call(-2); +// @ts-expect-error +at('string'); // @ts-expect-error at(null, 0); diff --git a/tests/types/proposals/array-buffer-base64.test.ts b/tests/type-definitions/proposals/array-buffer-base64.test.ts similarity index 98% rename from tests/types/proposals/array-buffer-base64.test.ts rename to tests/type-definitions/proposals/array-buffer-base64.test.ts index d915fb7d0959..22d0162d6899 100644 --- a/tests/types/proposals/array-buffer-base64.test.ts +++ b/tests/type-definitions/proposals/array-buffer-base64.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + function acceptUint8Array(v: Uint8Array) {} function acceptProcessMetadata(v: { read: number; written: number }) {} function acceptString(v: string) {} diff --git a/tests/types/proposals/array-filtering.test.ts b/tests/type-definitions/proposals/array-filtering.test.ts similarity index 70% rename from tests/types/proposals/array-filtering.test.ts rename to tests/type-definitions/proposals/array-filtering.test.ts index b47d3eafe707..2fe610569f4c 100644 --- a/tests/types/proposals/array-filtering.test.ts +++ b/tests/type-definitions/proposals/array-filtering.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + function testFilterReject(arr: TArr & { filterReject: any }, _: TValue) { const res: typeof arr = arr.filterReject((x: TValue) => false); @@ -10,18 +12,18 @@ function testFilterReject(arr: TArr & { filterReject: any }, _: TV }, { test: 'hello' }); } -testFilterReject([1,2,3], 1); -testFilterReject(new Int8Array([1,2]), 1); -testFilterReject(new Uint8Array([1,2]), 1); -testFilterReject(new Uint8ClampedArray([1,2]), 1); -testFilterReject(new Int16Array([1,2]), 1); -testFilterReject(new Uint16Array([1,2]), 1); -testFilterReject(new Int32Array([1,2]), 1); -testFilterReject(new Uint32Array([1,2]), 1); -testFilterReject(new Float32Array([1,2]), 1); -testFilterReject(new Float64Array([1,2]), 1); -testFilterReject(new BigInt64Array([1n,2n]), 1n); -testFilterReject(new BigUint64Array([1n,2n]), 1n); +testFilterReject([1, 2, 3], 1); +testFilterReject(new Int8Array([1, 2]), 1); +testFilterReject(new Uint8Array([1, 2]), 1); +testFilterReject(new Uint8ClampedArray([1, 2]), 1); +testFilterReject(new Int16Array([1, 2]), 1); +testFilterReject(new Uint16Array([1, 2]), 1); +testFilterReject(new Int32Array([1, 2]), 1); +testFilterReject(new Uint32Array([1, 2]), 1); +testFilterReject(new Float32Array([1, 2]), 1); +testFilterReject(new Float64Array([1, 2]), 1); +testFilterReject(new BigInt64Array([1n, 2n]), 1n); +testFilterReject(new BigUint64Array([1n, 2n]), 1n); // @ts-expect-error [1,2,3].filterReject((x: string) => false); diff --git a/tests/types/proposals/array-from-async.test.ts b/tests/type-definitions/proposals/array-from-async.test.ts similarity index 98% rename from tests/types/proposals/array-from-async.test.ts rename to tests/type-definitions/proposals/array-from-async.test.ts index ce54915dd1f8..fa8209bf9c1d 100644 --- a/tests/types/proposals/array-from-async.test.ts +++ b/tests/type-definitions/proposals/array-from-async.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + Array.fromAsync([1, 2, 3]); Array.fromAsync([Promise.resolve(1), 2, 3]); Array.fromAsync((async function* () { yield 1; })()); diff --git a/tests/types/proposals/array-is-template-object.test.ts b/tests/type-definitions/proposals/array-is-template-object.test.ts similarity index 93% rename from tests/types/proposals/array-is-template-object.test.ts rename to tests/type-definitions/proposals/array-is-template-object.test.ts index e6d71a7d85ca..bc54ef0bd82d 100644 --- a/tests/types/proposals/array-is-template-object.test.ts +++ b/tests/type-definitions/proposals/array-is-template-object.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + const t: boolean = Array.isTemplateObject([]); Array.isTemplateObject({}); Array.isTemplateObject(['a', 'b']); diff --git a/tests/types/proposals/array-unique.test.ts b/tests/type-definitions/proposals/array-unique.test.ts similarity index 97% rename from tests/types/proposals/array-unique.test.ts rename to tests/type-definitions/proposals/array-unique.test.ts index 22f4ab9b1072..52ec9a3e15fc 100644 --- a/tests/types/proposals/array-unique.test.ts +++ b/tests/type-definitions/proposals/array-unique.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + function testTypedArrayUniqueBy( arr: { uniqueBy(resolver?: PropertyKey | ((value: T) => any)): any }, key: PropertyKey diff --git a/tests/types/proposals/async-iterator-helper.test.ts b/tests/type-definitions/proposals/async-iterator-helper.test.ts similarity index 92% rename from tests/types/proposals/async-iterator-helper.test.ts rename to tests/type-definitions/proposals/async-iterator-helper.test.ts index 914b551b08f4..01aa003c4603 100644 --- a/tests/types/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/proposals/async-iterator-helper.test.ts @@ -1,12 +1,14 @@ +import 'core-js/full'; + AsyncIterator.from([1, 2, 3]); AsyncIterator.from(new Set([1, 2, 3])); AsyncIterator.from((async function* () { yield 1; yield 2; })()); AsyncIterator.from((function* () { yield 3; })()); AsyncIterator.from('abc'); -declare const ain: AsyncIterator; -declare const aio: AsyncIterator<{ x: number }>; -declare const ais: AsyncIterator; +declare const ain: AsyncIteratorObject; +declare const aio: AsyncIteratorObject<{ x: number }>; +declare const ais: AsyncIteratorObject; declare const ilb: Iterable; declare const is: Iterator; declare const itn: Iterator; diff --git a/tests/types/proposals/collection-of-from.test.ts b/tests/type-definitions/proposals/collection-of-from.test.ts similarity index 98% rename from tests/types/proposals/collection-of-from.test.ts rename to tests/type-definitions/proposals/collection-of-from.test.ts index 9fc98e111126..a88f3d6d9d20 100644 --- a/tests/types/proposals/collection-of-from.test.ts +++ b/tests/type-definitions/proposals/collection-of-from.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + const rm: Map = Map.from([[1, 'a'], [2, 'b']]); const rm2: Map = Map.from([[1, 10], [2, 20]], (v: number, k: number) => v + k); Map.from([[1, 10], [2, 20]], function (this: { n: number }, v: number) { return v + this.n; }, { n: 2 }); diff --git a/tests/types/proposals/data-view-get-set-uint8-clamped.test.ts b/tests/type-definitions/proposals/data-view-get-set-uint8-clamped.test.ts similarity index 94% rename from tests/types/proposals/data-view-get-set-uint8-clamped.test.ts rename to tests/type-definitions/proposals/data-view-get-set-uint8-clamped.test.ts index 71be5cc11577..da6e0703bfaa 100644 --- a/tests/types/proposals/data-view-get-set-uint8-clamped.test.ts +++ b/tests/type-definitions/proposals/data-view-get-set-uint8-clamped.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + declare const dv: DataView; const rdv: number = dv.getUint8Clamped(0); diff --git a/tests/types/proposals/decorator-metadata.test.ts b/tests/type-definitions/proposals/decorator-metadata.test.ts similarity index 93% rename from tests/types/proposals/decorator-metadata.test.ts rename to tests/type-definitions/proposals/decorator-metadata.test.ts index bc03a7169186..4abbf2decd7d 100644 --- a/tests/types/proposals/decorator-metadata.test.ts +++ b/tests/type-definitions/proposals/decorator-metadata.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + const rsmd1: symbol = Symbol.metadata; const rsmd2: typeof Symbol.metadata = Symbol.metadata; diff --git a/tests/types/proposals/explicit-resource-management.test.ts b/tests/type-definitions/proposals/explicit-resource-management.test.ts similarity index 99% rename from tests/types/proposals/explicit-resource-management.test.ts rename to tests/type-definitions/proposals/explicit-resource-management.test.ts index f9ec60bea904..8ba78348bf4f 100644 --- a/tests/types/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/proposals/explicit-resource-management.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + const d: symbol = Symbol.dispose; const ad: symbol = Symbol.asyncDispose; diff --git a/tests/types/proposals/extractors.test.ts b/tests/type-definitions/proposals/extractors.test.ts similarity index 91% rename from tests/types/proposals/extractors.test.ts rename to tests/type-definitions/proposals/extractors.test.ts index c5e96f4b8b0d..8959fabf131b 100644 --- a/tests/types/proposals/extractors.test.ts +++ b/tests/type-definitions/proposals/extractors.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + const rscs1: symbol = Symbol.customExtractor; const rscs2: typeof Symbol.customExtractor = Symbol.customExtractor; diff --git a/tests/types/proposals/function-demethodize.test.ts b/tests/type-definitions/proposals/function-demethodize.test.ts similarity index 94% rename from tests/types/proposals/function-demethodize.test.ts rename to tests/type-definitions/proposals/function-demethodize.test.ts index 40c67b598d88..be44d65caf70 100644 --- a/tests/types/proposals/function-demethodize.test.ts +++ b/tests/type-definitions/proposals/function-demethodize.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + function sumTo(this: { base: number }, a: number, b: number): number { return this.base + a + b; } diff --git a/tests/types/proposals/is-error.test.ts b/tests/type-definitions/proposals/is-error.test.ts similarity index 88% rename from tests/types/proposals/is-error.test.ts rename to tests/type-definitions/proposals/is-error.test.ts index c230efe6be96..fde89158e17f 100644 --- a/tests/types/proposals/is-error.test.ts +++ b/tests/type-definitions/proposals/is-error.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + const e = new Error(); const ne = { foo: 1 }; diff --git a/tests/types/proposals/iterator-range.test.ts b/tests/type-definitions/proposals/iterator-range.test.ts similarity index 95% rename from tests/types/proposals/iterator-range.test.ts rename to tests/type-definitions/proposals/iterator-range.test.ts index 97923d356ab3..eaeddcbfce54 100644 --- a/tests/types/proposals/iterator-range.test.ts +++ b/tests/type-definitions/proposals/iterator-range.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + const rir1: Iterator = Iterator.range(1, 10); Iterator.range(1, 10, 1); Iterator.range(1, 10, { step: 1 }); diff --git a/tests/types/proposals/iterator-sequencing.test.ts b/tests/type-definitions/proposals/iterator-sequencing.test.ts similarity index 96% rename from tests/types/proposals/iterator-sequencing.test.ts rename to tests/type-definitions/proposals/iterator-sequencing.test.ts index cf22343b302e..65ee2ddd5f67 100644 --- a/tests/types/proposals/iterator-sequencing.test.ts +++ b/tests/type-definitions/proposals/iterator-sequencing.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + declare const itn1: Iterator; declare const its1: Iterable; declare const arrs: string[]; diff --git a/tests/types/proposals/json-parse-with-source.test.ts b/tests/type-definitions/proposals/json-parse-with-source.test.ts similarity index 96% rename from tests/types/proposals/json-parse-with-source.test.ts rename to tests/type-definitions/proposals/json-parse-with-source.test.ts index bae432cc81d3..ca303a3c1d7b 100644 --- a/tests/types/proposals/json-parse-with-source.test.ts +++ b/tests/type-definitions/proposals/json-parse-with-source.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + const r: RawJSONObject = JSON.rawJSON('{"a":123}'); const isr1: boolean = JSON.isRawJSON(r); diff --git a/tests/types/proposals/map-upsert.test.ts b/tests/type-definitions/proposals/map-upsert.test.ts similarity index 96% rename from tests/types/proposals/map-upsert.test.ts rename to tests/type-definitions/proposals/map-upsert.test.ts index 6ff08d33acb8..67e80f422712 100644 --- a/tests/types/proposals/map-upsert.test.ts +++ b/tests/type-definitions/proposals/map-upsert.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + declare const map: Map; const a: number = map.getOrInsert('x', 42); diff --git a/tests/types/proposals/math-clamp.test.ts b/tests/type-definitions/proposals/math-clamp.test.ts similarity index 83% rename from tests/types/proposals/math-clamp.test.ts rename to tests/type-definitions/proposals/math-clamp.test.ts index 8f5fa6871be0..53a65c663104 100644 --- a/tests/types/proposals/math-clamp.test.ts +++ b/tests/type-definitions/proposals/math-clamp.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + const rc1: number = Math.clamp(1, 2, 5); // @ts-expect-error diff --git a/tests/types/proposals/math-sum.test.ts b/tests/type-definitions/proposals/math-sum.test.ts similarity index 89% rename from tests/types/proposals/math-sum.test.ts rename to tests/type-definitions/proposals/math-sum.test.ts index dcf747e97766..2b48e4628c20 100644 --- a/tests/types/proposals/math-sum.test.ts +++ b/tests/type-definitions/proposals/math-sum.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + function acceptsNumber(x: number) {} acceptsNumber(Math.sumPrecise(0.1, 0.2)); diff --git a/tests/types/proposals/string-cooked.test.ts b/tests/type-definitions/proposals/string-cooked.test.ts similarity index 89% rename from tests/types/proposals/string-cooked.test.ts rename to tests/type-definitions/proposals/string-cooked.test.ts index d111acef5926..2f440f249886 100644 --- a/tests/types/proposals/string-cooked.test.ts +++ b/tests/type-definitions/proposals/string-cooked.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + const rcooked1: string = String.cooked('foo', 1, 2, 3); String.cooked(['foo', 'bar'], 1, 2); String.cooked([]); diff --git a/tests/types/proposals/string-dedent.test.ts b/tests/type-definitions/proposals/string-dedent.test.ts similarity index 93% rename from tests/types/proposals/string-dedent.test.ts rename to tests/type-definitions/proposals/string-dedent.test.ts index babb236909aa..19d3004c1f13 100644 --- a/tests/types/proposals/string-dedent.test.ts +++ b/tests/type-definitions/proposals/string-dedent.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + const rdedent1: string = String.dedent`foo\nbar`; const rdedent2: string = String.dedent`line1 line2 diff --git a/tests/types/proposals/symbol-predicates.test.ts b/tests/type-definitions/proposals/symbol-predicates.test.ts similarity index 96% rename from tests/types/proposals/symbol-predicates.test.ts rename to tests/type-definitions/proposals/symbol-predicates.test.ts index 9601b0fb3049..5cad02b9fd39 100644 --- a/tests/types/proposals/symbol-predicates.test.ts +++ b/tests/type-definitions/proposals/symbol-predicates.test.ts @@ -1,3 +1,5 @@ +import 'core-js/full'; + const rsymbol1: boolean = Symbol.isRegisteredSymbol(Symbol.for('foo')); const rsymbol2: boolean = Symbol.isRegisteredSymbol(undefined); const rsymbol3: boolean = Symbol.isRegisteredSymbol(Symbol('bar')); diff --git a/tests/type-definitions/tsconfig.json b/tests/type-definitions/tsconfig.json index 8809cf496f3e..725a94db0b79 100644 --- a/tests/type-definitions/tsconfig.json +++ b/tests/type-definitions/tsconfig.json @@ -1,13 +1,19 @@ { "compilerOptions": { "strict": true, - "target": "esnext", + "target": "es2020", "module": "esnext", "moduleResolution": "node", "esModuleInterop": true, "noEmit": true }, + "typeRoots": [ + "../../packages/core-js/**/*.d.ts", + "../../packages/core-js-pure/**/*.d.ts", + "./node_modules/@types" + ], "include": [ - "*.ts" + "*.ts", + "proposals/*.ts", ] } diff --git a/tests/types/package-lock.json b/tests/types/package-lock.json deleted file mode 100644 index 419d832da185..000000000000 --- a/tests/types/package-lock.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "types", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "devDependencies": { - "@types/node": "^22.15.3", - "typescript": "^5.8.3" - } - }, - "node_modules/@types/node": { - "version": "22.15.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.3.tgz", - "integrity": "sha512-lX7HFZeHf4QG/J7tBZqrCAXwz9J5RD56Y6MpP0eJkka8p+K0RY/yBTW7CYFJ4VGCclxqOLKmiGP5juQc6MKgcw==", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~6.21.0" - } - }, - "node_modules/typescript": { - "version": "5.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", - "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, - "node_modules/undici-types": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", - "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", - "dev": true, - "license": "MIT" - } - } -} diff --git a/tests/types/package.json b/tests/types/package.json deleted file mode 100644 index 6e5c436216c3..000000000000 --- a/tests/types/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "test-types", - "scripts": { - "test-types": "tsc" - }, - "devDependencies": { - "@types/node": "^22.15.3", - "typescript": "^5.8.3" - } -} diff --git a/tests/types/tsconfig.json b/tests/types/tsconfig.json deleted file mode 100644 index 1c611913cd65..000000000000 --- a/tests/types/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "module": "NodeNext", - "strict": true, - "typeRoots": [ - "../../packages/core-js/**/*.d.ts", - "../../packages/core-js-pure/**/*.d.ts", - "./node_modules/@types" - ], - "noEmit": true, - "esModuleInterop": true, - "moduleResolution": "NodeNext" - }, - "include": [ - "proposals", - "../../packages/core-js/types/**/*.d.ts" - ], - "files": ["entries.test.ts"] -} From b93652a41232a3cf430ace5eec39966d5fc1862b Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 2 May 2025 21:53:28 +0700 Subject: [PATCH 022/315] Add core-js-pure/index.d.ts to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f1641746df37..4d3e6e5bd869 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ node_modules/ /packages/core-js-pure/stage/ /packages/core-js-pure/types/ /packages/core-js-pure/index.js +/packages/core-js-pure/index.d.ts /packages/core-js-pure/configurator.js /packages/core-js-pure/package.json /packages/core-js-pure/LICENSE From e81bded90ccc3a92322c47d23fd4c2aabd979a1e Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 2 May 2025 22:05:11 +0700 Subject: [PATCH 023/315] The entry point tests are split into two files --- .../{entries.test.ts => entries.import.ts} | 23 +------- tests/type-definitions/entries.require.ts | 56 +++++++++++++++++++ 2 files changed, 59 insertions(+), 20 deletions(-) rename tests/type-definitions/{entries.test.ts => entries.import.ts} (68%) create mode 100644 tests/type-definitions/entries.require.ts diff --git a/tests/type-definitions/entries.test.ts b/tests/type-definitions/entries.import.ts similarity index 68% rename from tests/type-definitions/entries.test.ts rename to tests/type-definitions/entries.import.ts index a4687e26af3b..2d78009a53cd 100644 --- a/tests/type-definitions/entries.test.ts +++ b/tests/type-definitions/entries.import.ts @@ -1,10 +1,9 @@ // $justImport -require('@core-js/pure/full/array-buffer/detached'); +import '@core-js/pure/full/array-buffer/detached'; // @ts-expect-error it has no exports -import abdetach from '@core-js/pure/full/array-buffer/detached'; +import detached from '@core-js/pure/full/array-buffer/detached'; // $virtual -require('@core-js/pure/full/array/virtual/at').call([1, 2, 3], -2); import at from '@core-js/pure/full/array/virtual/at'; at.call([1, 2, 3], -2); at.apply([1, 2, 3], [-2]); @@ -18,28 +17,24 @@ at('string'); at(null, 0); // $virtualIterator -require('@core-js/pure/full/array/virtual/iterator').call([1]).next().value; import avit from '@core-js/pure/full/array/virtual/iterator'; avit.call([1]).next().value; // @ts-expect-error avit(1); // $prototype -require('@core-js/pure/full/array/at')([1, 2, 3], -2); import aat from '@core-js/pure/full/array/at'; aat([1, 2, 3], -2); // @ts-expect-error aat(1, 0, 0); // $prototypeIterator -require('@core-js/pure/full/array/iterator')([]).next().value; import ait from '@core-js/pure/full/array/iterator'; ait([]).next().value; // @ts-expect-error ait(); // $static -require('@core-js/pure/full/array/from')('qwe'); import af from '@core-js/pure/full/array/from'; af('qwe', (it) => it.toUpperCase(), {}); // @ts-expect-error @@ -48,90 +43,78 @@ af(1); af('qwe', 1); // $staticWithContext -require('@core-js/pure/full/promise/all-settled')([1, 2, 3]); import pas from '@core-js/pure/full/promise/all-settled'; pas([1, 2, 3]); // @ts-expect-error pas(1); // $patchableStatic -require('@core-js/pure/full/json/stringify')([1]); import js from '@core-js/pure/full/json/stringify'; js({ a: 1, b: 2, c: 'asd'}, (_key, val) => typeof val === 'number' ? val * 2 : val, 4); // @ts-expect-error js([1], 1); // $namespace -require('@core-js/pure/full/async-disposable-stack/constructor'); import adc from '@core-js/pure/full/async-disposable-stack/constructor'; new adc(); // @ts-expect-error adc.prototype = 1; // $helper -require('@core-js/pure/full/get-iterator')([]); import it from '@core-js/pure/full/get-iterator'; it([]).next().value; // @ts-expect-error it(); // $path -new (require('@core-js/pure/full/error/constructor').Error)(); import ec from '@core-js/pure/full/error/constructor'; new ec.Error('er'); // @ts-expect-error ec(); // $instanceArray -require('@core-js/pure/full/instance/concat')(1); import ic from '@core-js/pure/full/instance/concat'; ic({}); // @ts-expect-error ic(); // $instanceString -require('@core-js/pure/full/instance/code-point-at')(''); import icp from '@core-js/pure/full/instance/code-point-at'; icp('').call('a', 0); // @ts-expect-error icp(); // $instanceFunction -require('@core-js/pure/full/instance/demethodize')({}); import id from '@core-js/pure/full/instance/demethodize'; id([].slice)([1, 2, 3], 1); // @ts-expect-error id(); // $instanceDOMIterables -require('@core-js/pure/full/instance/for-each')({}); import ife from '@core-js/pure/full/instance/for-each'; ife({}); // @ts-expect-error ife(); // $instanceArrayString -require('@core-js/pure/full/instance/at')(''); import ia from '@core-js/pure/full/instance/at'; ia('').call('123', 2); // @ts-expect-error ia(); // $instanceArrayDOMIterables -require('@core-js/pure/full/instance/entries')({}); import ie from '@core-js/pure/full/instance/entries'; ie([]).call([1, 2, 3]).next().value; // @ts-expect-error ie(); // $instanceRegExpFlags -require('@core-js/pure/full/instance/flags')({}); import inf from '@core-js/pure/full/instance/flags'; inf(/./g); // @ts-expect-error inf(); // $proposal -require('@core-js/pure/proposals/accessible-object-hasownproperty'); +import '@core-js/pure/proposals/accessible-object-hasownproperty'; // @ts-expect-error it has no exports import pahp from '@core-js/pure/proposals/accessible-object-hasownproperty'; diff --git a/tests/type-definitions/entries.require.ts b/tests/type-definitions/entries.require.ts new file mode 100644 index 000000000000..d5216828658d --- /dev/null +++ b/tests/type-definitions/entries.require.ts @@ -0,0 +1,56 @@ +// $justImport +require('@core-js/pure/full/array-buffer/detached'); + +// $virtual +require('@core-js/pure/full/array/virtual/at').call([1, 2, 3], -2); + +// $virtualIterator +require('@core-js/pure/full/array/virtual/iterator').call([1]).next().value; + +// $prototype +require('@core-js/pure/full/array/at')([1, 2, 3], -2); + +// $prototypeIterator +require('@core-js/pure/full/array/iterator')([]).next().value; + +// $static +require('@core-js/pure/full/array/from')('qwe'); + +// $staticWithContext +require('@core-js/pure/full/promise/all-settled')([1, 2, 3]); + +// $patchableStatic +require('@core-js/pure/full/json/stringify')([1]); + +// $namespace +require('@core-js/pure/full/async-disposable-stack/constructor'); + +// $helper +require('@core-js/pure/full/get-iterator')([]); + +// $path +new (require('@core-js/pure/full/error/constructor').Error)(); + +// $instanceArray +require('@core-js/pure/full/instance/concat')(1); + +// $instanceString +require('@core-js/pure/full/instance/code-point-at')(''); + +// $instanceFunction +require('@core-js/pure/full/instance/demethodize')({}); + +// $instanceDOMIterables +require('@core-js/pure/full/instance/for-each')({}); + +// $instanceArrayString +require('@core-js/pure/full/instance/at')(''); + +// $instanceArrayDOMIterables +require('@core-js/pure/full/instance/entries')({}); + +// $instanceRegExpFlags +require('@core-js/pure/full/instance/flags')({}); + +// $proposal +require('@core-js/pure/proposals/accessible-object-hasownproperty'); From fefdd7972be61822f15d250972eeb4c16dba1f31 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 2 May 2025 22:05:21 +0700 Subject: [PATCH 024/315] Fix code style --- tests/type-definitions/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/type-definitions/tsconfig.json b/tests/type-definitions/tsconfig.json index 725a94db0b79..b0ba55f7a757 100644 --- a/tests/type-definitions/tsconfig.json +++ b/tests/type-definitions/tsconfig.json @@ -14,6 +14,6 @@ ], "include": [ "*.ts", - "proposals/*.ts", + "proposals/*.ts" ] } From 809e94b948d64113aeb76b4bfe6cd9bd8e1616e7 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 2 May 2025 22:33:35 +0700 Subject: [PATCH 025/315] Added some tests for entry points types --- tests/type-definitions/entries.import.ts | 115 +++++++++++++---------- 1 file changed, 63 insertions(+), 52 deletions(-) diff --git a/tests/type-definitions/entries.import.ts b/tests/type-definitions/entries.import.ts index 2d78009a53cd..ef095bde695a 100644 --- a/tests/type-definitions/entries.import.ts +++ b/tests/type-definitions/entries.import.ts @@ -5,114 +5,125 @@ import detached from '@core-js/pure/full/array-buffer/detached'; // $virtual import at from '@core-js/pure/full/array/virtual/at'; -at.call([1, 2, 3], -2); +const atResult1: number = at.call([1, 2, 3], -2); at.apply([1, 2, 3], [-2]); // @ts-expect-error at.call([1, 2, 3], null); // @ts-expect-error -at.call(-2); +at.call(123); // @ts-expect-error at('string'); // @ts-expect-error -at(null, 0); +at(null); // $virtualIterator -import avit from '@core-js/pure/full/array/virtual/iterator'; -avit.call([1]).next().value; +import arrayVirtualIterator from '@core-js/pure/full/array/virtual/iterator'; +const aviValue1: number = arrayVirtualIterator.call([1]).next().value; +const aviResult1: IterableIterator = arrayVirtualIterator.call([1, 2, 3]); +const aviResult2: IterableIterator = arrayVirtualIterator.call(['a', 'b']); +const aviResult3: IterableIterator = arrayVirtualIterator.call([true, false]); // @ts-expect-error -avit(1); +arrayVirtualIterator(1); +// @ts-expect-error +arrayVirtualIterator.call([1, 2, 3], 1); // $prototype -import aat from '@core-js/pure/full/array/at'; -aat([1, 2, 3], -2); +import arrayAt from '@core-js/pure/full/array/at'; +const arrayAtResult1: number = arrayAt([1, 2, 3], -2); +const arrayAtResult2: string = arrayAt(['a', 'b'], -2); +const arrayAtResult3: undefined = arrayAt([], 1); +// @ts-expect-error +arrayAt([1, 2], 'string'); +// @ts-expect-error +arrayAt(); // @ts-expect-error -aat(1, 0, 0); +arrayAt(1, 0, 0); // $prototypeIterator -import ait from '@core-js/pure/full/array/iterator'; -ait([]).next().value; +import arrayIterator from '@core-js/pure/full/array/iterator'; +arrayIterator([]).next().value; // @ts-expect-error -ait(); +arrayIterator(); // $static -import af from '@core-js/pure/full/array/from'; -af('qwe', (it) => it.toUpperCase(), {}); +import arrayFrom from '@core-js/pure/full/array/from'; +arrayFrom('qwe', (it) => it.toUpperCase(), {}); // @ts-expect-error -af(1); +arrayFrom(1); // @ts-expect-error -af('qwe', 1); +arrayFrom('qwe', 1); // $staticWithContext -import pas from '@core-js/pure/full/promise/all-settled'; -pas([1, 2, 3]); +import allSettled from '@core-js/pure/full/promise/all-settled'; +allSettled([1, 2, 3]); // @ts-expect-error -pas(1); +allSettled(1); // $patchableStatic -import js from '@core-js/pure/full/json/stringify'; -js({ a: 1, b: 2, c: 'asd'}, (_key, val) => typeof val === 'number' ? val * 2 : val, 4); +import stringify from '@core-js/pure/full/json/stringify'; +stringify({ a: 1, b: 2, c: 'asd'}, (_key, val) => typeof val === 'number' ? val * 2 : val, 4); // @ts-expect-error -js([1], 1); +stringify([1], 1); // $namespace -import adc from '@core-js/pure/full/async-disposable-stack/constructor'; -new adc(); +import adsConstructor from '@core-js/pure/full/async-disposable-stack/constructor'; +new adsConstructor(); // @ts-expect-error -adc.prototype = 1; +adsConstructor.prototype = 1; // $helper -import it from '@core-js/pure/full/get-iterator'; -it([]).next().value; +import getIterator from '@core-js/pure/full/get-iterator'; +getIterator([]).next().value; // @ts-expect-error -it(); +getIterator(); // $path -import ec from '@core-js/pure/full/error/constructor'; -new ec.Error('er'); +import errorConstructor from '@core-js/pure/full/error/constructor'; +new errorConstructor.Error('er'); // @ts-expect-error -ec(); +errorConstructor(); // $instanceArray -import ic from '@core-js/pure/full/instance/concat'; -ic({}); +import iConcat from '@core-js/pure/full/instance/concat'; +iConcat({}); // @ts-expect-error -ic(); +iConcat(); // $instanceString -import icp from '@core-js/pure/full/instance/code-point-at'; -icp('').call('a', 0); +import iCodePointAt from '@core-js/pure/full/instance/code-point-at'; +iCodePointAt('').call('a', 0); // @ts-expect-error -icp(); +iCodePointAt(); // $instanceFunction -import id from '@core-js/pure/full/instance/demethodize'; -id([].slice)([1, 2, 3], 1); +import iDemethodize from '@core-js/pure/full/instance/demethodize'; +iDemethodize([].slice)([1, 2, 3], 1); // @ts-expect-error -id(); +iDemethodize(); // $instanceDOMIterables -import ife from '@core-js/pure/full/instance/for-each'; -ife({}); +import iForEach from '@core-js/pure/full/instance/for-each'; +iForEach({}); // @ts-expect-error -ife(); +iForEach(); // $instanceArrayString -import ia from '@core-js/pure/full/instance/at'; -ia('').call('123', 2); +import iAt from '@core-js/pure/full/instance/at'; +iAt('').call('123', 2); // @ts-expect-error -ia(); +iAt(); // $instanceArrayDOMIterables -import ie from '@core-js/pure/full/instance/entries'; -ie([]).call([1, 2, 3]).next().value; +import iEntries from '@core-js/pure/full/instance/entries'; +iEntries([]).call([1, 2, 3]).next().value; // @ts-expect-error -ie(); +iEntries(); // $instanceRegExpFlags -import inf from '@core-js/pure/full/instance/flags'; -inf(/./g); +import iFlags from '@core-js/pure/full/instance/flags'; +iFlags(/./g); // @ts-expect-error -inf(); +iFlags(); // $proposal import '@core-js/pure/proposals/accessible-object-hasownproperty'; From 4e5d0cd57171d8edb17e5b8c21ecf7fdd5a04958 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 9 Jul 2025 18:40:45 +0700 Subject: [PATCH 026/315] Fixes after rebase --- packages/core-js/modules/esnext.number.clamp.js | 1 + tests/type-definitions/tsconfig.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core-js/modules/esnext.number.clamp.js b/packages/core-js/modules/esnext.number.clamp.js index c3730d79a5d5..f44310de4fd0 100644 --- a/packages/core-js/modules/esnext.number.clamp.js +++ b/packages/core-js/modules/esnext.number.clamp.js @@ -1,3 +1,4 @@ +// types: proposals/math-clamp 'use strict'; var $ = require('../internals/export'); var aNumber = require('../internals/a-number'); diff --git a/tests/type-definitions/tsconfig.json b/tests/type-definitions/tsconfig.json index b0ba55f7a757..1e02e9d94698 100644 --- a/tests/type-definitions/tsconfig.json +++ b/tests/type-definitions/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "strict": true, - "target": "es2020", + "target": "es2022", "module": "esnext", "moduleResolution": "node", "esModuleInterop": true, From 0def4fe52016627abc0d6db473ed9da16e712a90 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 11 Jul 2025 00:46:30 +0700 Subject: [PATCH 027/315] Number#clamp type --- packages/core-js/types/proposals/math-clamp.d.ts | 5 ----- packages/core-js/types/proposals/number-clamp.d.ts | 5 +++++ tests/type-definitions/proposals/math-clamp.test.ts | 8 -------- tests/type-definitions/proposals/number-clamp.test.ts | 9 +++++++++ 4 files changed, 14 insertions(+), 13 deletions(-) delete mode 100644 packages/core-js/types/proposals/math-clamp.d.ts create mode 100644 packages/core-js/types/proposals/number-clamp.d.ts delete mode 100644 tests/type-definitions/proposals/math-clamp.test.ts create mode 100644 tests/type-definitions/proposals/number-clamp.test.ts diff --git a/packages/core-js/types/proposals/math-clamp.d.ts b/packages/core-js/types/proposals/math-clamp.d.ts deleted file mode 100644 index f465d79738f8..000000000000 --- a/packages/core-js/types/proposals/math-clamp.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -// proposal stage: 1 -// https://github.com/tc39/proposal-math-clamp -interface Math { - clamp(value: number, lower: number, upper: number): number; -} diff --git a/packages/core-js/types/proposals/number-clamp.d.ts b/packages/core-js/types/proposals/number-clamp.d.ts new file mode 100644 index 000000000000..d60bf3838c44 --- /dev/null +++ b/packages/core-js/types/proposals/number-clamp.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-math-clamp +interface Number { + clamp(lower: number, upper: number): number; +} diff --git a/tests/type-definitions/proposals/math-clamp.test.ts b/tests/type-definitions/proposals/math-clamp.test.ts deleted file mode 100644 index 53a65c663104..000000000000 --- a/tests/type-definitions/proposals/math-clamp.test.ts +++ /dev/null @@ -1,8 +0,0 @@ -import 'core-js/full'; - -const rc1: number = Math.clamp(1, 2, 5); - -// @ts-expect-error -Math.clamp(1, 2); -// @ts-expect-error -Math.clamp(2, 2, '4'); diff --git a/tests/type-definitions/proposals/number-clamp.test.ts b/tests/type-definitions/proposals/number-clamp.test.ts new file mode 100644 index 000000000000..44617c511b3f --- /dev/null +++ b/tests/type-definitions/proposals/number-clamp.test.ts @@ -0,0 +1,9 @@ +import 'core-js/full'; + +declare const num: number; +const clamped: number = num.clamp(0, 100); + +// @ts-expect-error +num.clamp(); +// @ts-expect-error +num.clamp('1', '2'); From d245fdff72a89150500c46e1e35ef45c134f0be7 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 11 Jul 2025 00:46:52 +0700 Subject: [PATCH 028/315] Iterator chunking types --- .../core-js/modules/esnext.iterator.chunks.js | 1 + .../modules/esnext.iterator.sliding.js | 0 .../modules/esnext.iterator.windows.js | 1 + .../core-js/modules/esnext.number.clamp.js | 2 +- .../types/proposals/iterator-chunking.d.ts | 7 ++++ .../proposals/iterator-chunking.test.ts | 34 +++++++++++++++++++ 6 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 packages/core-js/modules/esnext.iterator.sliding.js create mode 100644 packages/core-js/types/proposals/iterator-chunking.d.ts create mode 100644 tests/type-definitions/proposals/iterator-chunking.test.ts diff --git a/packages/core-js/modules/esnext.iterator.chunks.js b/packages/core-js/modules/esnext.iterator.chunks.js index a6f9d2a8e7b3..77eb9ee0beb9 100644 --- a/packages/core-js/modules/esnext.iterator.chunks.js +++ b/packages/core-js/modules/esnext.iterator.chunks.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-chunking 'use strict'; var $ = require('../internals/export'); var anObject = require('../internals/an-object'); diff --git a/packages/core-js/modules/esnext.iterator.sliding.js b/packages/core-js/modules/esnext.iterator.sliding.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js/modules/esnext.iterator.windows.js b/packages/core-js/modules/esnext.iterator.windows.js index 8baea78c06c7..22ebc0845d20 100644 --- a/packages/core-js/modules/esnext.iterator.windows.js +++ b/packages/core-js/modules/esnext.iterator.windows.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-chunking 'use strict'; var $ = require('../internals/export'); var anObject = require('../internals/an-object'); diff --git a/packages/core-js/modules/esnext.number.clamp.js b/packages/core-js/modules/esnext.number.clamp.js index f44310de4fd0..d052b01ae2f3 100644 --- a/packages/core-js/modules/esnext.number.clamp.js +++ b/packages/core-js/modules/esnext.number.clamp.js @@ -1,4 +1,4 @@ -// types: proposals/math-clamp +// types: proposals/number-clamp 'use strict'; var $ = require('../internals/export'); var aNumber = require('../internals/a-number'); diff --git a/packages/core-js/types/proposals/iterator-chunking.d.ts b/packages/core-js/types/proposals/iterator-chunking.d.ts new file mode 100644 index 000000000000..04c835d8a657 --- /dev/null +++ b/packages/core-js/types/proposals/iterator-chunking.d.ts @@ -0,0 +1,7 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-iterator-chunking +interface Iterator { + chunks(size: number): IteratorObject; + sliding(size: number): IteratorObject; + windows(size: number): IteratorObject; +} diff --git a/tests/type-definitions/proposals/iterator-chunking.test.ts b/tests/type-definitions/proposals/iterator-chunking.test.ts new file mode 100644 index 000000000000..0e0e02090576 --- /dev/null +++ b/tests/type-definitions/proposals/iterator-chunking.test.ts @@ -0,0 +1,34 @@ +import 'core-js/full'; + +declare function getNumberIterator(): Iterator; + +const numbersIter = getNumberIterator(); + +const chunks: IteratorObject = numbersIter.chunks(2); +const sliding: IteratorObject = numbersIter.sliding(3); +const windows: IteratorObject = numbersIter.windows(4); + +const chunkNext = chunks.next(); +const slidingNext = sliding.next(); +const windowsNext = windows.next(); + +// @ts-expect-error +numbersIter.chunks(); +// @ts-expect-error +numbersIter.chunks("2"); +// @ts-expect-error +numbersIter.chunks(2, 3); + +// @ts-expect-error +numbersIter.sliding(); +// @ts-expect-error +numbersIter.sliding(true); +// @ts-expect-error +numbersIter.sliding(2, 3); + +// @ts-expect-error +numbersIter.windows(); +// @ts-expect-error +numbersIter.windows({}); +// @ts-expect-error +numbersIter.windows(4, 1); From 7502cbc2cbd3ba82c992c58c19da147631956d04 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 11 Jul 2025 17:12:57 +0700 Subject: [PATCH 029/315] Fix types for all targets --- .../types/proposals/decorator-metadata.d.ts | 6 +++- .../proposals/array-filtering.test.ts | 28 +++++++++---------- .../proposals/array-unique.test.ts | 4 +-- .../proposals/iterator-range.test.ts | 4 +-- tests/type-definitions/tsconfig.json | 9 +++--- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/packages/core-js/types/proposals/decorator-metadata.d.ts b/packages/core-js/types/proposals/decorator-metadata.d.ts index 4c5bee1c1113..532d58638822 100644 --- a/packages/core-js/types/proposals/decorator-metadata.d.ts +++ b/packages/core-js/types/proposals/decorator-metadata.d.ts @@ -4,6 +4,10 @@ interface SymbolConstructor { readonly metadata: unique symbol; } +type DecoratorMetadataCoreJS = typeof globalThis extends { DecoratorMetadataObject: infer T } + ? T + : Record & object; + interface Function { - [Symbol.metadata]?: object; + [Symbol.metadata]: DecoratorMetadataCoreJS | null; } diff --git a/tests/type-definitions/proposals/array-filtering.test.ts b/tests/type-definitions/proposals/array-filtering.test.ts index 2fe610569f4c..161f77d66a14 100644 --- a/tests/type-definitions/proposals/array-filtering.test.ts +++ b/tests/type-definitions/proposals/array-filtering.test.ts @@ -22,41 +22,41 @@ testFilterReject(new Int32Array([1, 2]), 1); testFilterReject(new Uint32Array([1, 2]), 1); testFilterReject(new Float32Array([1, 2]), 1); testFilterReject(new Float64Array([1, 2]), 1); -testFilterReject(new BigInt64Array([1n, 2n]), 1n); -testFilterReject(new BigUint64Array([1n, 2n]), 1n); +testFilterReject(new BigInt64Array([BigInt(1), BigInt(2)]), BigInt(1)); +testFilterReject(new BigUint64Array([BigInt(1), BigInt(2)]), BigInt(1)); // @ts-expect-error -[1,2,3].filterReject((x: string) => false); +[1, 2, 3].filterReject((x: string) => false); // @ts-expect-error -(new Int8Array([1,2,3])).filterReject((x: string) => false); +(new Int8Array([1, 2, 3])).filterReject((x: string) => false); // @ts-expect-error -(new Uint8Array([1,2,3])).filterReject((x: string) => false); +(new Uint8Array([1, 2, 3])).filterReject((x: string) => false); // @ts-expect-error -(new Uint8ClampedArray([1,2,3])).filterReject((x: string) => false); +(new Uint8ClampedArray([1, 2, 3])).filterReject((x: string) => false); // @ts-expect-error -(new Int16Array([1,2,3])).filterReject((x: string) => false); +(new Int16Array([1, 2, 3])).filterReject((x: string) => false); // @ts-expect-error -(new Uint16Array([1,2,3])).filterReject((x: string) => false); +(new Uint16Array([1, 2, 3])).filterReject((x: string) => false); // @ts-expect-error -(new Int32Array([1,2,3])).filterReject((x: string) => false); +(new Int32Array([1, 2, 3])).filterReject((x: string) => false); // @ts-expect-error -(new Uint32Array([1,2,3])).filterReject((x: string) => false); +(new Uint32Array([1, 2, 3])).filterReject((x: string) => false); // @ts-expect-error -(new Float32Array([1,2,3])).filterReject((x: string) => false); +(new Float32Array([1, 2, 3])).filterReject((x: string) => false); // @ts-expect-error -(new Float64Array([1,2,3])).filterReject((x: string) => false); +(new Float64Array([1, 2, 3])).filterReject((x: string) => false); // @ts-expect-error -(new BigInt64Array([1n,2n,3n])).filterReject((x: number) => false); +(new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((x: number) => false); // @ts-expect-error -(new BigUint64Array([1n,2n,3n])).filterReject((x: number) => false); +(new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((x: number) => false); diff --git a/tests/type-definitions/proposals/array-unique.test.ts b/tests/type-definitions/proposals/array-unique.test.ts index 52ec9a3e15fc..7c3afc53aee4 100644 --- a/tests/type-definitions/proposals/array-unique.test.ts +++ b/tests/type-definitions/proposals/array-unique.test.ts @@ -23,5 +23,5 @@ testTypedArrayUniqueBy(new Int32Array([1, 2, 3]), 1); testTypedArrayUniqueBy(new Uint32Array([1, 2, 3]), 1); testTypedArrayUniqueBy(new Float32Array([1.0, 2.2, 3.0]), 1); testTypedArrayUniqueBy(new Float64Array([1.0, 2.2, 3.0]), 1); -testTypedArrayUniqueBy(new BigInt64Array([1n, 2n, 3n]), 1); -testTypedArrayUniqueBy(new BigUint64Array([1n, 2n, 3n]), 1); +testTypedArrayUniqueBy(new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)]), 1); +testTypedArrayUniqueBy(new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)]), 1); diff --git a/tests/type-definitions/proposals/iterator-range.test.ts b/tests/type-definitions/proposals/iterator-range.test.ts index eaeddcbfce54..b7d89bcaba4a 100644 --- a/tests/type-definitions/proposals/iterator-range.test.ts +++ b/tests/type-definitions/proposals/iterator-range.test.ts @@ -4,12 +4,12 @@ const rir1: Iterator = Iterator.range(1, 10); Iterator.range(1, 10, 1); Iterator.range(1, 10, { step: 1 }); Iterator.range(1, 10, { inclusive: true }); -const rir2: Iterator< bigint> = Iterator.range(0n, 10n, { step: 2n, inclusive: true }); +const rir2: Iterator< bigint> = Iterator.range(BigInt(0), BigInt(10), { step: BigInt(2), inclusive: true }); // @ts-expect-error Iterator.range(0, 10, 'not-a-number'); // @ts-expect-error -Iterator.range(0, 10, { step: 1n }); +Iterator.range(0, 10, { step: BigInt(1) }); // @ts-expect-error Iterator.range(0, 10, { inclusive: 3 }); // @ts-expect-error diff --git a/tests/type-definitions/tsconfig.json b/tests/type-definitions/tsconfig.json index 1e02e9d94698..77c0035a93ae 100644 --- a/tests/type-definitions/tsconfig.json +++ b/tests/type-definitions/tsconfig.json @@ -1,19 +1,20 @@ { "compilerOptions": { "strict": true, - "target": "es2022", + "target": "esnext", "module": "esnext", "moduleResolution": "node", "esModuleInterop": true, "noEmit": true }, "typeRoots": [ - "../../packages/core-js/**/*.d.ts", - "../../packages/core-js-pure/**/*.d.ts", +// "../../packages/core-js/**/*.d.ts", +// "../../packages/core-js-pure/**/*.d.ts", + "../../packages/core-js/types/proposals/*.d.ts", "./node_modules/@types" ], "include": [ - "*.ts", +// "*.ts", "proposals/*.ts" ] } From 61a2cabe1ab226ee0af3cdfeec9a6f3f48f96455 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 11 Jul 2025 19:57:14 +0700 Subject: [PATCH 030/315] Iterator joint proposal types --- .../modules/esnext.iterator.zip-keyed.js | 1 + .../core-js/modules/esnext.iterator.zip.js | 1 + .../types/proposals/iterator-joint.d.ts | 17 ++++++++++++++ .../proposals/iterator-joint.test.ts | 22 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 packages/core-js/types/proposals/iterator-joint.d.ts create mode 100644 tests/type-definitions/proposals/iterator-joint.test.ts diff --git a/packages/core-js/modules/esnext.iterator.zip-keyed.js b/packages/core-js/modules/esnext.iterator.zip-keyed.js index 1590b617fd35..0e8fba2f1338 100644 --- a/packages/core-js/modules/esnext.iterator.zip-keyed.js +++ b/packages/core-js/modules/esnext.iterator.zip-keyed.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-joint 'use strict'; var $ = require('../internals/export'); var anObject = require('../internals/an-object'); diff --git a/packages/core-js/modules/esnext.iterator.zip.js b/packages/core-js/modules/esnext.iterator.zip.js index a832d49a0b1d..a79b28afbcfb 100644 --- a/packages/core-js/modules/esnext.iterator.zip.js +++ b/packages/core-js/modules/esnext.iterator.zip.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-joint 'use strict'; var $ = require('../internals/export'); var anObject = require('../internals/an-object'); diff --git a/packages/core-js/types/proposals/iterator-joint.d.ts b/packages/core-js/types/proposals/iterator-joint.d.ts new file mode 100644 index 000000000000..74797980a9a8 --- /dev/null +++ b/packages/core-js/types/proposals/iterator-joint.d.ts @@ -0,0 +1,17 @@ +// proposal stage: 2.7 +// https://github.com/tc39/proposal-joint-iteration +type IteratorObjectCoreJs = typeof globalThis extends { IteratorObject: infer O } + ? O + : Iterator; + +type ZipOptions = { + mode?: "shortest" | "longest" | "strict"; + padding?: object; +}; + +interface Iterator { + zip(iterables: Iterable, options?: ZipOptions): IteratorObjectCoreJs<[T, U]>; + + zipKeyed(iterables: Iterable, options?: ZipOptions): IteratorObjectCoreJs<[number, T, U]>; + zipKeyed(record: Record>, options?: ZipOptions): IteratorObjectCoreJs<[PropertyKey, T, U]>; +} diff --git a/tests/type-definitions/proposals/iterator-joint.test.ts b/tests/type-definitions/proposals/iterator-joint.test.ts new file mode 100644 index 000000000000..423d36cf6a31 --- /dev/null +++ b/tests/type-definitions/proposals/iterator-joint.test.ts @@ -0,0 +1,22 @@ +import 'core-js/full'; + +declare function getNumberIterator(): Iterator; +declare function getStringIterator(): Iterator; + +const numIter = getNumberIterator(); +const strIter = getStringIterator(); + +numIter.zip([[1, 2, 3], [4, 5, 6]]); +strIter.zip([['a', 'b', 'c'], ['d', 'e', 'f']]); +numIter.zip([[1, 2, 3], [4, 5, 6]], { mode: "shortest" }); +numIter.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); +numIter.zipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: "shortest" }); + +// @ts-expect-error +numIter.zip(true); +// @ts-expect-error +numIter.zip([[1, 2, 3], [4, 5, 6]], { mode: "incorrect" }); +// @ts-expect-error +numIter.zipKeyed(42); +// @ts-expect-error +numIter.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }, { foo: "bar" }); From b5ac60261facf3845193c99d6a10db17240f5c4d Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 15 Jul 2025 19:30:30 +0700 Subject: [PATCH 031/315] Fix tsconfig --- tests/type-definitions/tsconfig.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/type-definitions/tsconfig.json b/tests/type-definitions/tsconfig.json index 77c0035a93ae..a214570ef4c7 100644 --- a/tests/type-definitions/tsconfig.json +++ b/tests/type-definitions/tsconfig.json @@ -8,13 +8,12 @@ "noEmit": true }, "typeRoots": [ -// "../../packages/core-js/**/*.d.ts", -// "../../packages/core-js-pure/**/*.d.ts", - "../../packages/core-js/types/proposals/*.d.ts", + "../../packages/core-js/**/*.d.ts", + "../../packages/core-js-pure/**/*.d.ts", "./node_modules/@types" ], "include": [ -// "*.ts", + "*.ts", "proposals/*.ts" ] } From c9676770bd1dfafbf771c92bede5640e6d2aa9eb Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 25 Sep 2025 15:02:51 +0700 Subject: [PATCH 032/315] Update type for iterator chunking --- packages/core-js/types/proposals/iterator-chunking.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core-js/types/proposals/iterator-chunking.d.ts b/packages/core-js/types/proposals/iterator-chunking.d.ts index 04c835d8a657..9917046c3814 100644 --- a/packages/core-js/types/proposals/iterator-chunking.d.ts +++ b/packages/core-js/types/proposals/iterator-chunking.d.ts @@ -1,7 +1,7 @@ -// proposal stage: 2 +// proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-chunking interface Iterator { chunks(size: number): IteratorObject; - sliding(size: number): IteratorObject; - windows(size: number): IteratorObject; + sliding(size: number): IteratorObject; // todo remove after rebase + windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): IteratorObject; } From 341eda03bb597b8b0466808e78b616297feb0553 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 30 Sep 2025 18:51:41 +0700 Subject: [PATCH 033/315] Fixes after rebase --- .../modules/esnext.iterator.sliding.js | 0 .../types/proposals/iterator-chunking.d.ts | 3 +-- tests/templates/templates.mjs | 22 +++++++++---------- tests/type-definitions/entries.import.ts | 12 +++++----- tests/type-definitions/entries.require.ts | 12 +++++----- .../proposals/iterator-chunking.test.ts | 9 -------- 6 files changed, 24 insertions(+), 34 deletions(-) delete mode 100644 packages/core-js/modules/esnext.iterator.sliding.js diff --git a/packages/core-js/modules/esnext.iterator.sliding.js b/packages/core-js/modules/esnext.iterator.sliding.js deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/core-js/types/proposals/iterator-chunking.d.ts b/packages/core-js/types/proposals/iterator-chunking.d.ts index 9917046c3814..b042628b6efe 100644 --- a/packages/core-js/types/proposals/iterator-chunking.d.ts +++ b/packages/core-js/types/proposals/iterator-chunking.d.ts @@ -1,7 +1,6 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-chunking interface Iterator { - chunks(size: number): IteratorObject; - sliding(size: number): IteratorObject; // todo remove after rebase + chunks(chunkSize: number): IteratorObject; windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): IteratorObject; } diff --git a/tests/templates/templates.mjs b/tests/templates/templates.mjs index 54b9eeeebce4..fba935c8e2df 100644 --- a/tests/templates/templates.mjs +++ b/tests/templates/templates.mjs @@ -1,9 +1,9 @@ import { $justImport, $patchableStatic, + $uncurried, + $uncurriedIterator, $static, $staticWithContext, $prototype, - $prototypeIterator, $static, $staticWithContext, - $virtual, - $virtualIterator, + $prototypeIterator, } from '../../scripts/build-entries/templates.mjs'; import { deepEqual } from 'node:assert/strict'; @@ -22,35 +22,35 @@ deepEqual( 'Template $justImport incorrect', ); deepEqual( - $virtual(props), + $prototype(props), { dts: 'declare const method: typeof namespace.prototype.name;\nexport = method;', entry: "require('../../modules/module1');\nrequire('../../modules/module2');\n" + "\nvar getBuiltInPrototypeMethod = require('../../internals/get-built-in-prototype-method');\n\nmodule.exports = getBuiltInPrototypeMethod('namespace', 'name');", }, - 'Template $virtual incorrect', + 'Template $prototype incorrect', ); deepEqual( - $virtualIterator(props), + $prototypeIterator(props), { dts: 'declare const method: typeof namespace.prototype[typeof Symbol.iterator];\nexport = method;', entry: "require('../../modules/module1');\nrequire('../../modules/module2');\n" + "\nvar getIteratorMethod = require('../../internals/get-iterator-method');\n\nmodule.exports = getIteratorMethod(source);", }, - 'Template $virtualIterator incorrect', + 'Template $prototypeIterator incorrect', ); deepEqual( - $prototype(props), + $uncurried(props), { dts: 'declare const method: (\n thisArg: any,\n ...args: Parameters\n) => ReturnType;\nexport = method;', entry: "require('../../modules/module1');\nrequire('../../modules/module2');\n" + "\nvar entryUnbind = require('../../internals/entry-unbind');\n\nmodule.exports = entryUnbind('namespace', 'name');", }, - 'Template $prototype incorrect', + 'Template $uncurried incorrect', ); deepEqual( - $prototypeIterator(props), + $uncurriedIterator(props), { dts: 'declare const method: (\n thisArg: any,\n ...args: Parameters\n' + ') => ReturnType;\nexport = method;', @@ -58,7 +58,7 @@ deepEqual( "\nvar uncurryThis = require('../../internals/function-uncurry-this');\nvar getIteratorMethod = require('../../internals/get-iterator-method');\n" + '\nmodule.exports = uncurryThis(getIteratorMethod(source));', }, - 'Template $prototypeIterator incorrect', + 'Template $uncurriedIterator incorrect', ); deepEqual( diff --git a/tests/type-definitions/entries.import.ts b/tests/type-definitions/entries.import.ts index ef095bde695a..53bf1cb3aa96 100644 --- a/tests/type-definitions/entries.import.ts +++ b/tests/type-definitions/entries.import.ts @@ -3,8 +3,8 @@ import '@core-js/pure/full/array-buffer/detached'; // @ts-expect-error it has no exports import detached from '@core-js/pure/full/array-buffer/detached'; -// $virtual -import at from '@core-js/pure/full/array/virtual/at'; +// $prototype +import at from '@core-js/pure/full/array/prototype/at'; const atResult1: number = at.call([1, 2, 3], -2); at.apply([1, 2, 3], [-2]); // @ts-expect-error @@ -16,8 +16,8 @@ at('string'); // @ts-expect-error at(null); -// $virtualIterator -import arrayVirtualIterator from '@core-js/pure/full/array/virtual/iterator'; +// $prototypeIterator +import arrayVirtualIterator from '@core-js/pure/full/array/prototype/iterator'; const aviValue1: number = arrayVirtualIterator.call([1]).next().value; const aviResult1: IterableIterator = arrayVirtualIterator.call([1, 2, 3]); const aviResult2: IterableIterator = arrayVirtualIterator.call(['a', 'b']); @@ -27,7 +27,7 @@ arrayVirtualIterator(1); // @ts-expect-error arrayVirtualIterator.call([1, 2, 3], 1); -// $prototype +// $uncurried import arrayAt from '@core-js/pure/full/array/at'; const arrayAtResult1: number = arrayAt([1, 2, 3], -2); const arrayAtResult2: string = arrayAt(['a', 'b'], -2); @@ -39,7 +39,7 @@ arrayAt(); // @ts-expect-error arrayAt(1, 0, 0); -// $prototypeIterator +// $uncurriedIterator import arrayIterator from '@core-js/pure/full/array/iterator'; arrayIterator([]).next().value; // @ts-expect-error diff --git a/tests/type-definitions/entries.require.ts b/tests/type-definitions/entries.require.ts index d5216828658d..0d391c194961 100644 --- a/tests/type-definitions/entries.require.ts +++ b/tests/type-definitions/entries.require.ts @@ -1,16 +1,16 @@ // $justImport require('@core-js/pure/full/array-buffer/detached'); -// $virtual -require('@core-js/pure/full/array/virtual/at').call([1, 2, 3], -2); +// $prototype +require('@core-js/pure/full/array/prototype/at').call([1, 2, 3], -2); -// $virtualIterator -require('@core-js/pure/full/array/virtual/iterator').call([1]).next().value; +// $prototypeIterator +require('@core-js/pure/full/array/prototype/iterator').call([1]).next().value; -// $prototype +// $uncurried require('@core-js/pure/full/array/at')([1, 2, 3], -2); -// $prototypeIterator +// $uncurriedIterator require('@core-js/pure/full/array/iterator')([]).next().value; // $static diff --git a/tests/type-definitions/proposals/iterator-chunking.test.ts b/tests/type-definitions/proposals/iterator-chunking.test.ts index 0e0e02090576..b22ac1aa036d 100644 --- a/tests/type-definitions/proposals/iterator-chunking.test.ts +++ b/tests/type-definitions/proposals/iterator-chunking.test.ts @@ -5,11 +5,9 @@ declare function getNumberIterator(): Iterator; const numbersIter = getNumberIterator(); const chunks: IteratorObject = numbersIter.chunks(2); -const sliding: IteratorObject = numbersIter.sliding(3); const windows: IteratorObject = numbersIter.windows(4); const chunkNext = chunks.next(); -const slidingNext = sliding.next(); const windowsNext = windows.next(); // @ts-expect-error @@ -19,13 +17,6 @@ numbersIter.chunks("2"); // @ts-expect-error numbersIter.chunks(2, 3); -// @ts-expect-error -numbersIter.sliding(); -// @ts-expect-error -numbersIter.sliding(true); -// @ts-expect-error -numbersIter.sliding(2, 3); - // @ts-expect-error numbersIter.windows(); // @ts-expect-error From 81f60878ee97e62bf08572fce2bc54ef4272788f Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 2 Oct 2025 02:33:35 +0700 Subject: [PATCH 034/315] Update proposal types --- packages/core-js/types/proposals/iterator-joint.d.ts | 8 ++++---- .../core-js/types/proposals/iterator-sequencing.d.ts | 2 +- .../types/proposals/json-parse-with-source.d.ts | 12 +++++++----- .../proposals/json-parse-with-source.test.ts | 4 ++-- tests/type-definitions/tsconfig.json | 2 -- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/core-js/types/proposals/iterator-joint.d.ts b/packages/core-js/types/proposals/iterator-joint.d.ts index 74797980a9a8..98f18695e3d4 100644 --- a/packages/core-js/types/proposals/iterator-joint.d.ts +++ b/packages/core-js/types/proposals/iterator-joint.d.ts @@ -1,6 +1,6 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-joint-iteration -type IteratorObjectCoreJs = typeof globalThis extends { IteratorObject: infer O } +type CoreJsIteratorObject = typeof globalThis extends { IteratorObject: infer O } ? O : Iterator; @@ -10,8 +10,8 @@ type ZipOptions = { }; interface Iterator { - zip(iterables: Iterable, options?: ZipOptions): IteratorObjectCoreJs<[T, U]>; + zip(iterables: Iterable, options?: ZipOptions): CoreJsIteratorObject<[T, U]>; - zipKeyed(iterables: Iterable, options?: ZipOptions): IteratorObjectCoreJs<[number, T, U]>; - zipKeyed(record: Record>, options?: ZipOptions): IteratorObjectCoreJs<[PropertyKey, T, U]>; + zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJsIteratorObject<[number, T, U]>; + zipKeyed(record: Record>, options?: ZipOptions): CoreJsIteratorObject<[PropertyKey, T, U]>; } diff --git a/packages/core-js/types/proposals/iterator-sequencing.d.ts b/packages/core-js/types/proposals/iterator-sequencing.d.ts index aab81bab0610..1e2254a8b9c3 100644 --- a/packages/core-js/types/proposals/iterator-sequencing.d.ts +++ b/packages/core-js/types/proposals/iterator-sequencing.d.ts @@ -1,5 +1,5 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-sequencing interface Iterator { - concat(...iterators: Iterable[]): IteratorObject; + concat(...iterators: Iterable[]): CoreJsIteratorObject; } diff --git a/packages/core-js/types/proposals/json-parse-with-source.d.ts b/packages/core-js/types/proposals/json-parse-with-source.d.ts index d6d36ab0d6ed..9300e8ffd25a 100644 --- a/packages/core-js/types/proposals/json-parse-with-source.d.ts +++ b/packages/core-js/types/proposals/json-parse-with-source.d.ts @@ -1,15 +1,17 @@ // proposal stage: 3 // https://github.com/tc39/proposal-json-parse-with-source -interface ReviverContext { +interface CoreJSReviverContext { + readonly __brand: unique symbol; source: string; } -type RawJSONObject = { +interface CoreJSRawJSON { + readonly __brand: unique symbol; rawJSON: string; } interface JSON { - isRawJSON(value: any): value is RawJSONObject; - parse(text: string, reviver?: (key: string, value: any, context: ReviverContext) => any): T; - rawJSON(value: string): RawJSONObject; + isRawJSON(value: any): value is CoreJSRawJSON; + parse(text: string, reviver?: (key: string, value: any, context: CoreJSReviverContext) => any): T; + rawJSON(value: string): CoreJSRawJSON; } diff --git a/tests/type-definitions/proposals/json-parse-with-source.test.ts b/tests/type-definitions/proposals/json-parse-with-source.test.ts index ca303a3c1d7b..d8c9a4944fd8 100644 --- a/tests/type-definitions/proposals/json-parse-with-source.test.ts +++ b/tests/type-definitions/proposals/json-parse-with-source.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; -const r: RawJSONObject = JSON.rawJSON('{"a":123}'); +const r: CoreJSRawJSON = JSON.rawJSON('{"a":123}'); const isr1: boolean = JSON.isRawJSON(r); const isr2: boolean = JSON.isRawJSON({}); @@ -21,6 +21,6 @@ JSON.rawJSON(123); // @ts-expect-error JSON.rawJSON(); -JSON.parse('{"tooBigForNumber":9007199254740993}', (key: string, value: any, context: ReviverContext) => {}); +JSON.parse('{"tooBigForNumber":9007199254740993}', (key: string, value: any, context: CoreJSReviverContext) => {}); // @ts-expect-error JSON.parse('{"tooBigForNumber":9007199254740993}', (key: string, value: any, context: []) => {}); diff --git a/tests/type-definitions/tsconfig.json b/tests/type-definitions/tsconfig.json index a214570ef4c7..a8d048da6c3b 100644 --- a/tests/type-definitions/tsconfig.json +++ b/tests/type-definitions/tsconfig.json @@ -8,8 +8,6 @@ "noEmit": true }, "typeRoots": [ - "../../packages/core-js/**/*.d.ts", - "../../packages/core-js-pure/**/*.d.ts", "./node_modules/@types" ], "include": [ From 431d0b4272f3edb89e827c562a36ef3ddabdb6e2 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 7 Oct 2025 19:57:11 +0700 Subject: [PATCH 035/315] Update proposal types & type tests --- .../types/proposals/iterator-joint.d.ts | 10 +- .../types/proposals/iterator-sequencing.d.ts | 6 +- .../{ => global}/array-buffer-base64.test.ts | 0 .../{ => global}/array-filtering.test.ts | 0 .../{ => global}/array-from-async.test.ts | 0 .../array-is-template-object.test.ts | 0 .../{ => global}/array-unique.test.ts | 0 .../async-iterator-helper.test.ts | 4 - .../{ => global}/collection-of-from.test.ts | 0 .../data-view-get-set-uint8-clamped.test.ts | 0 .../{ => global}/decorator-metadata.test.ts | 0 .../explicit-resource-management.test.ts | 0 .../proposals/{ => global}/extractors.test.ts | 0 .../{ => global}/function-demethodize.test.ts | 0 .../proposals/{ => global}/is-error.test.ts | 0 .../{ => global}/iterator-chunking.test.ts | 0 .../proposals/global/iterator-joint.test.ts | 16 +++ .../{ => global}/iterator-range.test.ts | 0 .../global/iterator-sequencing.test.ts | 24 +++++ .../json-parse-with-source.test.ts | 0 .../proposals/{ => global}/map-upsert.test.ts | 0 .../proposals/{ => global}/math-sum.test.ts | 0 .../{ => global}/number-clamp.test.ts | 0 .../{ => global}/string-cooked.test.ts | 0 .../{ => global}/string-dedent.test.ts | 0 .../{ => global}/symbol-predicates.test.ts | 0 .../proposals/global/tsconfig.json | 4 + .../proposals/iterator-joint.test.ts | 22 ----- .../proposals/iterator-sequencing.test.ts | 25 ----- .../pure/async-iterator-helper.test.ts | 87 ++++++++++++++++ .../proposals/pure/collection-of-from.test.ts | 73 ++++++++++++++ .../proposals/pure/decorator-metadata.test.ts | 16 +++ .../pure/explicit-resource-management.test.ts | 98 +++++++++++++++++++ .../pure/function-demethodize.test.ts | 7 ++ .../proposals/pure/is-error.test.ts | 12 +++ .../proposals/pure/iterator-chunking.test.ts | 26 +++++ .../proposals/pure/iterator-joint.test.ts | 17 ++++ .../proposals/pure/iterator-range.test.ts | 18 ++++ .../pure/iterator-sequencing.test.ts | 24 +++++ .../pure/json-parse-with-source.test.ts | 28 ++++++ .../proposals/pure/map-upsert.test.ts | 20 ++++ .../proposals/pure/math-sum.test.ts | 12 +++ .../proposals/pure/number-clamp.test.ts | 9 ++ .../proposals/pure/string-cooked.test.ts | 10 ++ .../proposals/pure/string-dedent.test.ts | 16 +++ .../proposals/pure/symbol-predicates.test.ts | 19 ++++ .../proposals/pure/tsconfig.json | 4 + tests/type-definitions/runner.mjs | 3 +- tests/type-definitions/tsconfig.json | 3 +- 49 files changed, 553 insertions(+), 60 deletions(-) rename tests/type-definitions/proposals/{ => global}/array-buffer-base64.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/array-filtering.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/array-from-async.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/array-is-template-object.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/array-unique.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/async-iterator-helper.test.ts (96%) rename tests/type-definitions/proposals/{ => global}/collection-of-from.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/data-view-get-set-uint8-clamped.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/decorator-metadata.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/explicit-resource-management.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/extractors.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/function-demethodize.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/is-error.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/iterator-chunking.test.ts (100%) create mode 100644 tests/type-definitions/proposals/global/iterator-joint.test.ts rename tests/type-definitions/proposals/{ => global}/iterator-range.test.ts (100%) create mode 100644 tests/type-definitions/proposals/global/iterator-sequencing.test.ts rename tests/type-definitions/proposals/{ => global}/json-parse-with-source.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/map-upsert.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/math-sum.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/number-clamp.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/string-cooked.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/string-dedent.test.ts (100%) rename tests/type-definitions/proposals/{ => global}/symbol-predicates.test.ts (100%) create mode 100644 tests/type-definitions/proposals/global/tsconfig.json delete mode 100644 tests/type-definitions/proposals/iterator-joint.test.ts delete mode 100644 tests/type-definitions/proposals/iterator-sequencing.test.ts create mode 100644 tests/type-definitions/proposals/pure/async-iterator-helper.test.ts create mode 100644 tests/type-definitions/proposals/pure/collection-of-from.test.ts create mode 100644 tests/type-definitions/proposals/pure/decorator-metadata.test.ts create mode 100644 tests/type-definitions/proposals/pure/explicit-resource-management.test.ts create mode 100644 tests/type-definitions/proposals/pure/function-demethodize.test.ts create mode 100644 tests/type-definitions/proposals/pure/is-error.test.ts create mode 100644 tests/type-definitions/proposals/pure/iterator-chunking.test.ts create mode 100644 tests/type-definitions/proposals/pure/iterator-joint.test.ts create mode 100644 tests/type-definitions/proposals/pure/iterator-range.test.ts create mode 100644 tests/type-definitions/proposals/pure/iterator-sequencing.test.ts create mode 100644 tests/type-definitions/proposals/pure/json-parse-with-source.test.ts create mode 100644 tests/type-definitions/proposals/pure/map-upsert.test.ts create mode 100644 tests/type-definitions/proposals/pure/math-sum.test.ts create mode 100644 tests/type-definitions/proposals/pure/number-clamp.test.ts create mode 100644 tests/type-definitions/proposals/pure/string-cooked.test.ts create mode 100644 tests/type-definitions/proposals/pure/string-dedent.test.ts create mode 100644 tests/type-definitions/proposals/pure/symbol-predicates.test.ts create mode 100644 tests/type-definitions/proposals/pure/tsconfig.json diff --git a/packages/core-js/types/proposals/iterator-joint.d.ts b/packages/core-js/types/proposals/iterator-joint.d.ts index 98f18695e3d4..3e9185e65f6f 100644 --- a/packages/core-js/types/proposals/iterator-joint.d.ts +++ b/packages/core-js/types/proposals/iterator-joint.d.ts @@ -9,9 +9,11 @@ type ZipOptions = { padding?: object; }; -interface Iterator { - zip(iterables: Iterable, options?: ZipOptions): CoreJsIteratorObject<[T, U]>; +interface IteratorConstructor { + zip(iterables: Iterable, options?: ZipOptions): CoreJsIteratorObject<[T, U]>; - zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJsIteratorObject<[number, T, U]>; - zipKeyed(record: Record>, options?: ZipOptions): CoreJsIteratorObject<[PropertyKey, T, U]>; + zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJsIteratorObject<[number, T, U]>; + zipKeyed(record: Record>, options?: ZipOptions): CoreJsIteratorObject<[PropertyKey, T, U]>; } + +declare var Iterator: IteratorConstructor; diff --git a/packages/core-js/types/proposals/iterator-sequencing.d.ts b/packages/core-js/types/proposals/iterator-sequencing.d.ts index 1e2254a8b9c3..a4ac8cc2533a 100644 --- a/packages/core-js/types/proposals/iterator-sequencing.d.ts +++ b/packages/core-js/types/proposals/iterator-sequencing.d.ts @@ -1,5 +1,7 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-sequencing -interface Iterator { - concat(...iterators: Iterable[]): CoreJsIteratorObject; +interface IteratorConstructor { + concat(...iterators: Iterable[]): CoreJsIteratorObject; } + +declare var Iterator: IteratorConstructor; diff --git a/tests/type-definitions/proposals/array-buffer-base64.test.ts b/tests/type-definitions/proposals/global/array-buffer-base64.test.ts similarity index 100% rename from tests/type-definitions/proposals/array-buffer-base64.test.ts rename to tests/type-definitions/proposals/global/array-buffer-base64.test.ts diff --git a/tests/type-definitions/proposals/array-filtering.test.ts b/tests/type-definitions/proposals/global/array-filtering.test.ts similarity index 100% rename from tests/type-definitions/proposals/array-filtering.test.ts rename to tests/type-definitions/proposals/global/array-filtering.test.ts diff --git a/tests/type-definitions/proposals/array-from-async.test.ts b/tests/type-definitions/proposals/global/array-from-async.test.ts similarity index 100% rename from tests/type-definitions/proposals/array-from-async.test.ts rename to tests/type-definitions/proposals/global/array-from-async.test.ts diff --git a/tests/type-definitions/proposals/array-is-template-object.test.ts b/tests/type-definitions/proposals/global/array-is-template-object.test.ts similarity index 100% rename from tests/type-definitions/proposals/array-is-template-object.test.ts rename to tests/type-definitions/proposals/global/array-is-template-object.test.ts diff --git a/tests/type-definitions/proposals/array-unique.test.ts b/tests/type-definitions/proposals/global/array-unique.test.ts similarity index 100% rename from tests/type-definitions/proposals/array-unique.test.ts rename to tests/type-definitions/proposals/global/array-unique.test.ts diff --git a/tests/type-definitions/proposals/async-iterator-helper.test.ts b/tests/type-definitions/proposals/global/async-iterator-helper.test.ts similarity index 96% rename from tests/type-definitions/proposals/async-iterator-helper.test.ts rename to tests/type-definitions/proposals/global/async-iterator-helper.test.ts index 01aa003c4603..fb40600019ca 100644 --- a/tests/type-definitions/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/proposals/global/async-iterator-helper.test.ts @@ -28,10 +28,6 @@ AsyncIterator.from({}); // @ts-expect-error AsyncIterator.from(); // @ts-expect-error -AsyncIterator.from(null); -// @ts-expect-error -AsyncIterator.from(undefined); -// @ts-expect-error AsyncIterator.from({ next: () => 1 }); const raits: AsyncIterator = is.toAsync(); diff --git a/tests/type-definitions/proposals/collection-of-from.test.ts b/tests/type-definitions/proposals/global/collection-of-from.test.ts similarity index 100% rename from tests/type-definitions/proposals/collection-of-from.test.ts rename to tests/type-definitions/proposals/global/collection-of-from.test.ts diff --git a/tests/type-definitions/proposals/data-view-get-set-uint8-clamped.test.ts b/tests/type-definitions/proposals/global/data-view-get-set-uint8-clamped.test.ts similarity index 100% rename from tests/type-definitions/proposals/data-view-get-set-uint8-clamped.test.ts rename to tests/type-definitions/proposals/global/data-view-get-set-uint8-clamped.test.ts diff --git a/tests/type-definitions/proposals/decorator-metadata.test.ts b/tests/type-definitions/proposals/global/decorator-metadata.test.ts similarity index 100% rename from tests/type-definitions/proposals/decorator-metadata.test.ts rename to tests/type-definitions/proposals/global/decorator-metadata.test.ts diff --git a/tests/type-definitions/proposals/explicit-resource-management.test.ts b/tests/type-definitions/proposals/global/explicit-resource-management.test.ts similarity index 100% rename from tests/type-definitions/proposals/explicit-resource-management.test.ts rename to tests/type-definitions/proposals/global/explicit-resource-management.test.ts diff --git a/tests/type-definitions/proposals/extractors.test.ts b/tests/type-definitions/proposals/global/extractors.test.ts similarity index 100% rename from tests/type-definitions/proposals/extractors.test.ts rename to tests/type-definitions/proposals/global/extractors.test.ts diff --git a/tests/type-definitions/proposals/function-demethodize.test.ts b/tests/type-definitions/proposals/global/function-demethodize.test.ts similarity index 100% rename from tests/type-definitions/proposals/function-demethodize.test.ts rename to tests/type-definitions/proposals/global/function-demethodize.test.ts diff --git a/tests/type-definitions/proposals/is-error.test.ts b/tests/type-definitions/proposals/global/is-error.test.ts similarity index 100% rename from tests/type-definitions/proposals/is-error.test.ts rename to tests/type-definitions/proposals/global/is-error.test.ts diff --git a/tests/type-definitions/proposals/iterator-chunking.test.ts b/tests/type-definitions/proposals/global/iterator-chunking.test.ts similarity index 100% rename from tests/type-definitions/proposals/iterator-chunking.test.ts rename to tests/type-definitions/proposals/global/iterator-chunking.test.ts diff --git a/tests/type-definitions/proposals/global/iterator-joint.test.ts b/tests/type-definitions/proposals/global/iterator-joint.test.ts new file mode 100644 index 000000000000..3701cbd40dcc --- /dev/null +++ b/tests/type-definitions/proposals/global/iterator-joint.test.ts @@ -0,0 +1,16 @@ +import 'core-js/full'; + +Iterator.zip([[1, 2, 3], [4, 5, 6]]); +Iterator.zip([['a', 'b', 'c'], ['d', 'e', 'f']]); +Iterator.zip([[1, 2, 3], [4, 5, 6]], { mode: "shortest" }); +Iterator.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); +Iterator.zipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: "shortest" }); + +// @ts-expect-error +Iterator.zip(true); +// @ts-expect-error +Iterator.zip([[1, 2, 3], [4, 5, 6]], { mode: "incorrect" }); +// @ts-expect-error +Iterator.zipKeyed(42); +// @ts-expect-error +Iterator.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }, { foo: "bar" }); diff --git a/tests/type-definitions/proposals/iterator-range.test.ts b/tests/type-definitions/proposals/global/iterator-range.test.ts similarity index 100% rename from tests/type-definitions/proposals/iterator-range.test.ts rename to tests/type-definitions/proposals/global/iterator-range.test.ts diff --git a/tests/type-definitions/proposals/global/iterator-sequencing.test.ts b/tests/type-definitions/proposals/global/iterator-sequencing.test.ts new file mode 100644 index 000000000000..f50e0d9a6a72 --- /dev/null +++ b/tests/type-definitions/proposals/global/iterator-sequencing.test.ts @@ -0,0 +1,24 @@ +import 'core-js/full'; + +declare const its1: Iterable; +declare const arrs: string[]; +declare const arrn: number[]; +declare const arrb: boolean[]; +declare const itb1: Iterable; + +const ri1: Iterator = Iterator.concat(its1); +const ri2: Iterator = Iterator.concat(arrs); +const ri3: Iterator = Iterator.concat(arrn); +const ri4: Iterator = Iterator.concat(arrb, itb1); +const ri5: Iterator = Iterator.concat(); + +// @ts-expect-error +Iterator.concat(1); +// @ts-expect-error +Iterator.concat(true); +// @ts-expect-error +Iterator.concat({}); +// @ts-expect-error +Iterator.concat(null); +// @ts-expect-error +Iterator.concat(undefined); diff --git a/tests/type-definitions/proposals/json-parse-with-source.test.ts b/tests/type-definitions/proposals/global/json-parse-with-source.test.ts similarity index 100% rename from tests/type-definitions/proposals/json-parse-with-source.test.ts rename to tests/type-definitions/proposals/global/json-parse-with-source.test.ts diff --git a/tests/type-definitions/proposals/map-upsert.test.ts b/tests/type-definitions/proposals/global/map-upsert.test.ts similarity index 100% rename from tests/type-definitions/proposals/map-upsert.test.ts rename to tests/type-definitions/proposals/global/map-upsert.test.ts diff --git a/tests/type-definitions/proposals/math-sum.test.ts b/tests/type-definitions/proposals/global/math-sum.test.ts similarity index 100% rename from tests/type-definitions/proposals/math-sum.test.ts rename to tests/type-definitions/proposals/global/math-sum.test.ts diff --git a/tests/type-definitions/proposals/number-clamp.test.ts b/tests/type-definitions/proposals/global/number-clamp.test.ts similarity index 100% rename from tests/type-definitions/proposals/number-clamp.test.ts rename to tests/type-definitions/proposals/global/number-clamp.test.ts diff --git a/tests/type-definitions/proposals/string-cooked.test.ts b/tests/type-definitions/proposals/global/string-cooked.test.ts similarity index 100% rename from tests/type-definitions/proposals/string-cooked.test.ts rename to tests/type-definitions/proposals/global/string-cooked.test.ts diff --git a/tests/type-definitions/proposals/string-dedent.test.ts b/tests/type-definitions/proposals/global/string-dedent.test.ts similarity index 100% rename from tests/type-definitions/proposals/string-dedent.test.ts rename to tests/type-definitions/proposals/global/string-dedent.test.ts diff --git a/tests/type-definitions/proposals/symbol-predicates.test.ts b/tests/type-definitions/proposals/global/symbol-predicates.test.ts similarity index 100% rename from tests/type-definitions/proposals/symbol-predicates.test.ts rename to tests/type-definitions/proposals/global/symbol-predicates.test.ts diff --git a/tests/type-definitions/proposals/global/tsconfig.json b/tests/type-definitions/proposals/global/tsconfig.json new file mode 100644 index 000000000000..1fcfc7ee75bf --- /dev/null +++ b/tests/type-definitions/proposals/global/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./*.ts"] +} diff --git a/tests/type-definitions/proposals/iterator-joint.test.ts b/tests/type-definitions/proposals/iterator-joint.test.ts deleted file mode 100644 index 423d36cf6a31..000000000000 --- a/tests/type-definitions/proposals/iterator-joint.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import 'core-js/full'; - -declare function getNumberIterator(): Iterator; -declare function getStringIterator(): Iterator; - -const numIter = getNumberIterator(); -const strIter = getStringIterator(); - -numIter.zip([[1, 2, 3], [4, 5, 6]]); -strIter.zip([['a', 'b', 'c'], ['d', 'e', 'f']]); -numIter.zip([[1, 2, 3], [4, 5, 6]], { mode: "shortest" }); -numIter.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); -numIter.zipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: "shortest" }); - -// @ts-expect-error -numIter.zip(true); -// @ts-expect-error -numIter.zip([[1, 2, 3], [4, 5, 6]], { mode: "incorrect" }); -// @ts-expect-error -numIter.zipKeyed(42); -// @ts-expect-error -numIter.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }, { foo: "bar" }); diff --git a/tests/type-definitions/proposals/iterator-sequencing.test.ts b/tests/type-definitions/proposals/iterator-sequencing.test.ts deleted file mode 100644 index 65ee2ddd5f67..000000000000 --- a/tests/type-definitions/proposals/iterator-sequencing.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -import 'core-js/full'; - -declare const itn1: Iterator; -declare const its1: Iterable; -declare const arrs: string[]; -declare const arrn: number[]; -declare const arrb: boolean[]; -declare const itb1: Iterable; - -const ri1: Iterator = itn1.concat(its1); -const ri2: Iterator = itn1.concat(arrs); -const ri3: Iterator = itn1.concat(arrn); -const ri4: Iterator = itn1.concat(arrb, itb1); -const ri5: Iterator = itn1.concat(); - -// @ts-expect-error -itn.concat(1); -// @ts-expect-error -itn.concat(true); -// @ts-expect-error -itn.concat({}); -// @ts-expect-error -itn.concat(null); -// @ts-expect-error -itn.concat(undefined); diff --git a/tests/type-definitions/proposals/pure/async-iterator-helper.test.ts b/tests/type-definitions/proposals/pure/async-iterator-helper.test.ts new file mode 100644 index 000000000000..326e002dc655 --- /dev/null +++ b/tests/type-definitions/proposals/pure/async-iterator-helper.test.ts @@ -0,0 +1,87 @@ +import drop from '@core-js/pure/full/async-iterator/drop'; +import every from '@core-js/pure/full/async-iterator/every'; +import filter from '@core-js/pure/full/async-iterator/filter'; +import find from '@core-js/pure/full/async-iterator/find'; +import flatMap from '@core-js/pure/full/async-iterator/flat-map'; +import forEach from '@core-js/pure/full/async-iterator/for-each'; +import from from '@core-js/pure/full/async-iterator/from'; +import map from '@core-js/pure/full/async-iterator/map'; +import reduce from '@core-js/pure/full/async-iterator/reduce'; +import some from '@core-js/pure/full/async-iterator/some'; +import take from '@core-js/pure/full/async-iterator/take'; +import toArray from '@core-js/pure/full/async-iterator/to-array'; +import toAsync from '@core-js/pure/full/iterator/to-async'; + +from([1, 2, 3]); +from(new Set([1, 2, 3])); +from((async function* () { yield 1; yield 2; })()); +from((function* () { yield 3; })()); +from('abc'); + +declare const ain: AsyncIteratorObject; +declare const aio: AsyncIteratorObject<{ x: number }>; +declare const ais: AsyncIteratorObject; +declare const ilb: Iterable; +declare const is: Iterator; +declare const itn: Iterator; +declare const ailb: AsyncIterable; +async function* ag(): AsyncIterable { yield 'foo'; } + +from(ain); +from(ag()); +from(ilb); +from(ailb); +from(aio); + +// @ts-expect-error +from(123); +// @ts-expect-error +from({}); +// @ts-expect-error +from(); +// @ts-expect-error +from({ next: () => 1 }); + +const raits: AsyncIterator = toAsync(is); +const raitn: AsyncIterator = toAsync(itn); + +const r1: AsyncIterator = drop(ain, 3); +const r2: Promise = every(ain, (v: number, i: number) => v > 0); +const r3: AsyncIterator = filter(ain, (v: number, i: number) => v > 0); +const r4: Promise = find(ain, (v: number, i: number) => v > 0); +const r5: AsyncIterator = flatMap(ain, (v: number, i: number) => `${v}`); +const r6: Promise = forEach(ain, (v: number, i: number) => { }); +const r7: AsyncIterator = map(ain, (v: number, i: number) => v * 2); +const r8: Promise = reduce(ain, (acc: number, v: number, i: number) => acc + v, 0); +const r9: Promise = some(ain, (v: number, i: number) => v > 0); +const r10: AsyncIterator = take(ain, 10); +const r11: Promise = toArray(ain); + +// @ts-expect-error +drop(ain); +// @ts-expect-error +every(ain); +// @ts-expect-error +filter(ain); +// @ts-expect-error +find(ain); +// @ts-expect-error +flatMap(ain); +// @ts-expect-error +forEach(ain); +// @ts-expect-error +map(ain); +// @ts-expect-error +reduce(ain); +// @ts-expect-error +some(ain); +// @ts-expect-error +take(ain); +// @ts-expect-error +toArray(ain, 1); + +const s0: Promise = toArray(ais); +const f0: Promise = find(ais, (v: string, i: number) => v.length === 1); + +// @ts-expect-error +map(ais, (v: string, i: number) => v.length === 1, 'extra'); diff --git a/tests/type-definitions/proposals/pure/collection-of-from.test.ts b/tests/type-definitions/proposals/pure/collection-of-from.test.ts new file mode 100644 index 000000000000..61f9bc00a8c6 --- /dev/null +++ b/tests/type-definitions/proposals/pure/collection-of-from.test.ts @@ -0,0 +1,73 @@ +import mapFrom from '@core-js/pure/full/map/from'; +import mapOf from '@core-js/pure/full/map/of'; +import setFrom from '@core-js/pure/full/set/from'; +import setOf from '@core-js/pure/full/set/of'; +import weakMapFrom from '@core-js/pure/full/weak-map/from'; +import weakMapOf from '@core-js/pure/full/weak-map/of'; +import weakSetFrom from '@core-js/pure/full/weak-set/from'; +import weakSetOf from '@core-js/pure/full/weak-set/of'; + +const rm: Map = mapFrom([[1, 'a'], [2, 'b']] as [number, string][]); +const rm2: Map = mapFrom([[1, 10], [2, 20]] as [number, number][], (v: number, k: number) => v + k); +mapFrom([[1, 10], [2, 20]] as [number, number][], function (this: { n: number }, v: number) { return v + this.n; }, { n: 2 }); +// @ts-expect-error +mapFrom([['a', 1], ['b', 2]], (v: string, k: number) => v); +// @ts-expect-error +mapFrom([1, 2]); +// @ts-expect-error +mapFrom(); + +mapOf(['a', 1], ['b', 2]); +const rm4: Map = mapOf(['a', 1], ['b', 2]); +// @ts-expect-error +mapOf([1, 2, 3]); +// @ts-expect-error +mapOf(1, 2); + +const rs1: Set = setFrom([1, 2, 3]); +const rs2: Set = setFrom([1, 2, 3], x => x.toString()); +const rs3: Set<[string, number]> = setFrom([['a', 1], ['b', 2]]); +setFrom(['a', 'b'], function (this: { s: string }, value: string) { return value + this.s; }, { s: '-' }); +// @ts-expect-error +setFrom([1, 2, 3], (v: string) => v); +// @ts-expect-error +setFrom(); + +const rso1: Set = setOf(1, 2, 3); +const rso2: Set = setOf('a', 'b', 'c'); +// @ts-expect-error +setOf({ 'foo': 'bar' }, 2); + +const rwm1: WeakMap<{ a: number }, string> = weakMapFrom([[{ a: 1 }, 'x']] as [{ a: number }, string][]); +const rwm2: WeakMap = weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], (v, k) => v.toString()); +weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], function (this: { s: string }, v: number) { return this.s + v; }, { s: '-' }); +// @ts-expect-error +weakMapFrom([[1, 2], [2, 3]]); +// @ts-expect-error +weakMapFrom([[{}, 1], [{}, 2]], (v: string, k: string) => v); +// @ts-expect-error +weakMapFrom([1, 2]); +// @ts-expect-error +weakMapFrom(); + +const rwmo1: WeakMap = weakMapOf([{}, 2]); +// @ts-expect-error +weakMapOf([1, 2]); +// @ts-expect-error +weakMapOf({}); + +const rws1: WeakSet = weakSetFrom([{}]); +const rws2: WeakSet = weakSetFrom([{}, {}], x => x); +weakSetFrom([{}], function (this: { s: string }, obj: object) { return obj; }, { s: '-' }); +// @ts-expect-error +weakSetFrom([1, 2]); +// @ts-expect-error +weakSetFrom([{}], (v: number) => v); +// @ts-expect-error +weakSetFrom(); +// @ts-expect-error +weakSetFrom([{}], x => 'not-an-object'); + +const rwso1: WeakSet = weakSetOf({}); +// @ts-expect-error +weakSetOf(1); diff --git a/tests/type-definitions/proposals/pure/decorator-metadata.test.ts b/tests/type-definitions/proposals/pure/decorator-metadata.test.ts new file mode 100644 index 000000000000..8b12f522c44a --- /dev/null +++ b/tests/type-definitions/proposals/pure/decorator-metadata.test.ts @@ -0,0 +1,16 @@ +import metadata from '@core-js/pure/full/symbol/metadata'; + +const rsmd1: symbol = metadata; +const rsmd2: typeof metadata = metadata; + +type T = { + [metadata]?: object; +}; + +const obj: T = {}; +obj[metadata] = { foo: 1 }; + +const maybeMeta: object | undefined = obj[metadata]; + +// @ts-expect-error +obj[metadata] = 123; diff --git a/tests/type-definitions/proposals/pure/explicit-resource-management.test.ts b/tests/type-definitions/proposals/pure/explicit-resource-management.test.ts new file mode 100644 index 000000000000..e7af8185ca64 --- /dev/null +++ b/tests/type-definitions/proposals/pure/explicit-resource-management.test.ts @@ -0,0 +1,98 @@ +import symbolDispose from '@core-js/pure/full/symbol/dispose'; +import symbolAsyncDispose from '@core-js/pure/full/symbol/async-dispose'; +import suppressedError from '@core-js/pure/full/suppressed-error/constructor'; +import disposableStack from '@core-js/pure/full/disposable-stack/constructor'; +import asyncDisposableStack from '@core-js/pure/full/async-disposable-stack/constructor'; + +const d: symbol = symbolDispose; +const ad: symbol = symbolAsyncDispose; + +// @ts-expect-error +const wrong: number = symbolDispose; + +const objD: Disposable = { + [symbolDispose]() { /* empty */ } +}; +objD[symbolDispose](); + +const objAD: AsyncDisposable = { + [symbolAsyncDispose]() { return Promise.resolve(); } +} +objAD[symbolAsyncDispose](); + +const err1 = new suppressedError('err', 'suppressed', 'msg'); +err1.error; +err1.suppressed; +const m1: string = err1.message; +const _: Error = err1; + +const err2 = suppressedError(123, 456); +err2.error; +err2.suppressed; +err2.message; + +// @ts-expect-error +new suppressedError(); +// @ts-expect-error +new suppressedError(1, 2, 3, 4); + +const protoDS: DisposableStack = disposableStack.prototype; +const objDS: DisposableStack = new disposableStack(); +const disposed: boolean = objDS.disposed; +objDS.dispose(); +const ruse1: Disposable = objDS.use(objD); +const ruse2: null = objDS.use(null); +const ruse3: undefined = objDS.use(undefined); +const radopt1: string = objDS.adopt('foo', (value: string) => { /* empty */ }); +objDS.defer(() => { /* empty */ }); +const rmove1: DisposableStack = objDS.move(); +objDS[symbolDispose](); +const rts1: string = objDS[Symbol.toStringTag]; + +// @ts-expect-error +objDS.dispose(1); +// @ts-expect-error +objDS.use('foo'); +// @ts-expect-error +objDS.defer('bar'); +// @ts-expect-error +objDS.move(1); +// @ts-expect-error +objDS[Symbol.toStringTag] = 'foo'; + +const protoADS: AsyncDisposableStack = asyncDisposableStack.prototype; +const objADS: AsyncDisposableStack = new asyncDisposableStack(); +const disposedASD: boolean = objDS.disposed; +const rda: Promise = objADS.disposeAsync(); +const ruseASD1: AsyncDisposable = objADS.use(objAD); +const ruseASD2: Disposable = objADS.use(objD); +const ruseASD3: null = objADS.use(null); +const ruseASD4: undefined = objADS.use(undefined); +const radoptASD1: string = objADS.adopt('foo', (value: string) => { /* empty */ }); +const radoptASD2: string = objADS.adopt('foo', async (value: string) => { /* empty */ }); +const radoptASD3: string = objADS.adopt('foo', (value: string) => Promise.resolve()); +const radoptASD4: string = objADS.adopt('foo', async (value: string) => Promise.resolve()); +objADS.defer(() => { /* empty */ }); +objADS.defer(async () => { /* empty */ }); +objADS.defer(() => Promise.resolve()); +objADS.defer(async () => Promise.resolve()); +const rmoveASD1: AsyncDisposableStack = objADS.move(); +objADS[symbolAsyncDispose](); +const rtsASD1: string = objADS[Symbol.toStringTag]; + +// @ts-expect-error +objADS.disposeAsync(1).then(); +// @ts-expect-error +objADS.use('foo').then(); +// @ts-expect-error +objADS.defer('bar'); +// @ts-expect-error +objADS.move(1); +// @ts-expect-error +objADS[Symbol.toStringTag] = 'foo'; + +declare const iter: IteratorObject; +iter[symbolDispose](); + +declare const asyncIter: AsyncIteratorObject; +asyncIter[symbolAsyncDispose](); diff --git a/tests/type-definitions/proposals/pure/function-demethodize.test.ts b/tests/type-definitions/proposals/pure/function-demethodize.test.ts new file mode 100644 index 000000000000..82ceadb9350b --- /dev/null +++ b/tests/type-definitions/proposals/pure/function-demethodize.test.ts @@ -0,0 +1,7 @@ +import demethodize from '@core-js/pure/full/function/demethodize'; + +function sumTo(this: { base: number }, a: number, b: number): number { + return this.base + a + b; +} + +demethodize(sumTo); diff --git a/tests/type-definitions/proposals/pure/is-error.test.ts b/tests/type-definitions/proposals/pure/is-error.test.ts new file mode 100644 index 000000000000..866e7fa85531 --- /dev/null +++ b/tests/type-definitions/proposals/pure/is-error.test.ts @@ -0,0 +1,12 @@ +import isError from '@core-js/pure/full/error/is-error'; + +const e = new Error(); +const ne = { foo: 1 }; + +const re1: boolean = isError(e); +isError(ne); +isError(undefined); +isError('str'); + +// @ts-expect-error +isError(); diff --git a/tests/type-definitions/proposals/pure/iterator-chunking.test.ts b/tests/type-definitions/proposals/pure/iterator-chunking.test.ts new file mode 100644 index 000000000000..d13d87a92fda --- /dev/null +++ b/tests/type-definitions/proposals/pure/iterator-chunking.test.ts @@ -0,0 +1,26 @@ +import chunks from '@core-js/pure/full/iterator/chunks'; +import windows from '@core-js/pure/full/iterator/windows'; + +declare function getNumberIterator(): Iterator; + +const numbersIter = getNumberIterator(); + +const chunksObj: IteratorObject = chunks(numbersIter, 2); +const windowsObj: IteratorObject = windows(numbersIter, 4); + +const chunkNext = chunksObj.next(); +const windowsNext = windowsObj.next(); + +// @ts-expect-error +chunks(numbersIter); +// @ts-expect-error +chunks(numbersIter, '2'); +// @ts-expect-error +chunks(numbersIter, 2, 3); + +// @ts-expect-error +windows(numbersIter); +// @ts-expect-error +windows(numbersIter, {}); +// @ts-expect-error +windows(numbersIter, 4, 1); diff --git a/tests/type-definitions/proposals/pure/iterator-joint.test.ts b/tests/type-definitions/proposals/pure/iterator-joint.test.ts new file mode 100644 index 000000000000..25a0cdf65d70 --- /dev/null +++ b/tests/type-definitions/proposals/pure/iterator-joint.test.ts @@ -0,0 +1,17 @@ +import zip from '@core-js/pure/full/iterator/zip'; +import zipKeyed from '@core-js/pure/full/iterator/zip-keyed'; + +zip([[1, 2, 3], [4, 5, 6]]); +zip([['a', 'b', 'c'], ['d', 'e', 'f']]); +zip([[1, 2, 3], [4, 5, 6]], { mode: "shortest" }); +zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); +zipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: "shortest" }); + +// @ts-expect-error +zip(true); +// @ts-expect-error +zip([[1, 2, 3], [4, 5, 6]], { mode: "incorrect" }); +// @ts-expect-error +zipKeyed(42); +// @ts-expect-error +zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }, { foo: "bar" }); diff --git a/tests/type-definitions/proposals/pure/iterator-range.test.ts b/tests/type-definitions/proposals/pure/iterator-range.test.ts new file mode 100644 index 000000000000..a4464bb0fbba --- /dev/null +++ b/tests/type-definitions/proposals/pure/iterator-range.test.ts @@ -0,0 +1,18 @@ +import range from '@core-js/pure/full/iterator/range'; + +const rir1: Iterator = range(1, 10); +range(1, 10, 1); +range(1, 10, { step: 1 }); +range(1, 10, { inclusive: true }); +const rir2: Iterator< bigint> = range(BigInt(0), BigInt(10), { step: BigInt(2), inclusive: true }); + +// @ts-expect-error +range(0, 10, 'not-a-number'); +// @ts-expect-error +range(0, 10, { step: BigInt(1) }); +// @ts-expect-error +range(0, 10, { inclusive: 3 }); +// @ts-expect-error +range(0, 10, { step: 'smth' }); +// @ts-expect-error +range(0, 10, { foo: 'bar' }); diff --git a/tests/type-definitions/proposals/pure/iterator-sequencing.test.ts b/tests/type-definitions/proposals/pure/iterator-sequencing.test.ts new file mode 100644 index 000000000000..d50ebfb38a88 --- /dev/null +++ b/tests/type-definitions/proposals/pure/iterator-sequencing.test.ts @@ -0,0 +1,24 @@ +import concat from '@core-js/pure/full/iterator/concat'; + +declare const its1: Iterable; +declare const arrs: string[]; +declare const arrn: number[]; +declare const arrb: boolean[]; +declare const itb1: Iterable; + +const ri1: Iterator = concat(its1); +const ri2: Iterator = concat(arrs); +const ri3: Iterator = concat(arrn); +const ri4: Iterator = concat(arrb, itb1); +const ri5: Iterator = concat(); + +// @ts-expect-error +concat(1); +// @ts-expect-error +concat(true); +// @ts-expect-error +concat({}); +// @ts-expect-error +concat(null); +// @ts-expect-error +concat(undefined); diff --git a/tests/type-definitions/proposals/pure/json-parse-with-source.test.ts b/tests/type-definitions/proposals/pure/json-parse-with-source.test.ts new file mode 100644 index 000000000000..996c56e519bd --- /dev/null +++ b/tests/type-definitions/proposals/pure/json-parse-with-source.test.ts @@ -0,0 +1,28 @@ +import rawJSON from '@core-js/pure/full/json/raw-json'; +import isRawJSON from '@core-js/pure/full/json/is-raw-json'; +import parse from '@core-js/pure/full/json/parse'; + +const r: CoreJSRawJSON = rawJSON('{"a":123}'); + +const isr1: boolean = isRawJSON(r); +const isr2: boolean = isRawJSON({}); +const isr3: boolean = isRawJSON('abc'); +const isr4: boolean = isRawJSON(undefined); + +declare const smth: unknown; + +if (isRawJSON(smth)) { + smth.rawJSON; + const s: string = smth.rawJSON; + // @ts-expect-error + smth.noProp; +} + +// @ts-expect-error +rawJSON(123); +// @ts-expect-error +rawJSON(); + +parse('{"tooBigForNumber":9007199254740993}', (key: string, value: any, context: CoreJSReviverContext) => {}); +// @ts-expect-error +parse('{"tooBigForNumber":9007199254740993}', (key: string, value: any, context: []) => {}); diff --git a/tests/type-definitions/proposals/pure/map-upsert.test.ts b/tests/type-definitions/proposals/pure/map-upsert.test.ts new file mode 100644 index 000000000000..d7af7a866d9b --- /dev/null +++ b/tests/type-definitions/proposals/pure/map-upsert.test.ts @@ -0,0 +1,20 @@ +import mapGetOrInsert from '@core-js/pure/full/map/get-or-insert'; +import mapGetOrInsertComputed from '@core-js/pure/full/map/get-or-insert-computed'; +import weakMapGetOrInsert from '@core-js/pure/full/weak-map/get-or-insert'; +import weakMapGetOrInsertComputed from '@core-js/pure/full/weak-map/get-or-insert-computed'; + +declare const map: Map; + +const a: number = mapGetOrInsert(map, 'x', 42); +const b: number = mapGetOrInsertComputed(map, 'y', k => k.length); + +// @ts-expect-error +mapGetOrInsert(map, 'x'); + +declare const wmap: WeakMap<{ id: number }, boolean>; + +const wb: boolean = weakMapGetOrInsert(wmap, { id: 1 }, true); +weakMapGetOrInsertComputed(wmap, { id: 2 }, obj => obj.id === 2); + +// @ts-expect-error +weakMapGetOrInsert(wmap, { id: 1 }); diff --git a/tests/type-definitions/proposals/pure/math-sum.test.ts b/tests/type-definitions/proposals/pure/math-sum.test.ts new file mode 100644 index 000000000000..527fd3c9c78e --- /dev/null +++ b/tests/type-definitions/proposals/pure/math-sum.test.ts @@ -0,0 +1,12 @@ +import mathSumPrecise from '@core-js/pure/full/math/sum-precise'; + +function acceptsNumber(x: number) {} + +acceptsNumber(mathSumPrecise(0.1, 0.2)); +acceptsNumber(mathSumPrecise(1, 2)); + +// @ts-expect-error +mathSumPrecise('10'); + +// @ts-expect-error +mathSumPrecise([1, 2]); diff --git a/tests/type-definitions/proposals/pure/number-clamp.test.ts b/tests/type-definitions/proposals/pure/number-clamp.test.ts new file mode 100644 index 000000000000..744145e1a362 --- /dev/null +++ b/tests/type-definitions/proposals/pure/number-clamp.test.ts @@ -0,0 +1,9 @@ +import numberClamp from '@core-js/pure/full/number/clamp'; + +declare const num: number; +const clamped: number = numberClamp(num, 0, 100); + +// @ts-expect-error +numberClamp(num); +// @ts-expect-error +numberClamp(num, '1', '2'); diff --git a/tests/type-definitions/proposals/pure/string-cooked.test.ts b/tests/type-definitions/proposals/pure/string-cooked.test.ts new file mode 100644 index 000000000000..24cb8230c938 --- /dev/null +++ b/tests/type-definitions/proposals/pure/string-cooked.test.ts @@ -0,0 +1,10 @@ +import cooked from '@core-js/pure/full/string/cooked'; + +const rcooked1: string = cooked('foo', 1, 2, 3); +cooked(['foo', 'bar'], 1, 2); +cooked([]); + +// @ts-expect-error +cooked([null]); +// @ts-expect-error +cooked([undefined]); diff --git a/tests/type-definitions/proposals/pure/string-dedent.test.ts b/tests/type-definitions/proposals/pure/string-dedent.test.ts new file mode 100644 index 000000000000..6cafb975506c --- /dev/null +++ b/tests/type-definitions/proposals/pure/string-dedent.test.ts @@ -0,0 +1,16 @@ +import dedent from '@core-js/pure/full/string/dedent'; + +const rdedent1: string = dedent`foo\nbar`; +const rdedent2: string = dedent`line1 + line2 + line3`; + +const tpl = Object.assign(['foo', 'bar'], { raw: ['foo', 'bar'] }) as TemplateStringsArray; +dedent(tpl, 1, 2); + +// @ts-expect-error +dedent(['foo', 'bar'], 1, 2); +// @ts-expect-error +dedent('foo', 1, 2); +// @ts-expect-error +dedent(); diff --git a/tests/type-definitions/proposals/pure/symbol-predicates.test.ts b/tests/type-definitions/proposals/pure/symbol-predicates.test.ts new file mode 100644 index 000000000000..18342e17c341 --- /dev/null +++ b/tests/type-definitions/proposals/pure/symbol-predicates.test.ts @@ -0,0 +1,19 @@ +import isRegisteredSymbol from '@core-js/pure/full/symbol/is-registered-symbol'; +import isWellKnownSymbol from '@core-js/pure/full/symbol/is-well-known-symbol'; + +const rsymbol1: boolean = isRegisteredSymbol(Symbol.for('foo')); +const rsymbol2: boolean = isRegisteredSymbol(undefined); +const rsymbol3: boolean = isRegisteredSymbol(Symbol('bar')); + +const rsymbol4: boolean = isWellKnownSymbol(Symbol.iterator); +const rsymbol5: boolean = isWellKnownSymbol({}); +const rsymbol6: boolean = isWellKnownSymbol(Symbol('baz')); + +declare const u: unknown; +isRegisteredSymbol(u); +isWellKnownSymbol(u); + +// @ts-expect-error +isRegisteredSymbol(); +// @ts-expect-error +isWellKnownSymbol(); diff --git a/tests/type-definitions/proposals/pure/tsconfig.json b/tests/type-definitions/proposals/pure/tsconfig.json new file mode 100644 index 000000000000..1fcfc7ee75bf --- /dev/null +++ b/tests/type-definitions/proposals/pure/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./*.ts"] +} diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 280f0863e94b..c49596080745 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -1 +1,2 @@ -await $`tsc`; +await $`tsc -p proposals/global/tsconfig.json`; +await $`tsc -p proposals/pure/tsconfig.json`; diff --git a/tests/type-definitions/tsconfig.json b/tests/type-definitions/tsconfig.json index a8d048da6c3b..2601842f27bf 100644 --- a/tests/type-definitions/tsconfig.json +++ b/tests/type-definitions/tsconfig.json @@ -11,7 +11,6 @@ "./node_modules/@types" ], "include": [ - "*.ts", - "proposals/*.ts" + "*.ts" ] } From be8d6929ceeecb074cec61c1de322852353680aa Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 15 Oct 2025 00:41:42 +0700 Subject: [PATCH 036/315] Add licenses --- .../proposals/accessible-object-hasownproperty.d.ts | 5 ++++- .../core-js/types/proposals/array-find-from-last.d.ts | 3 +++ packages/core-js/types/proposals/array-flat-map.d.ts | 3 +++ .../core-js/types/proposals/array-from-async.d.ts | 3 +++ packages/core-js/types/proposals/array-grouping.d.ts | 5 ++++- packages/core-js/types/proposals/array-includes.d.ts | 3 +++ packages/core-js/types/proposals/async-iteration.d.ts | 3 +++ .../core-js/types/proposals/change-array-by-copy.d.ts | 11 +++++++---- .../types/proposals/explicit-resource-management.d.ts | 3 +++ 9 files changed, 33 insertions(+), 6 deletions(-) diff --git a/packages/core-js/types/proposals/accessible-object-hasownproperty.d.ts b/packages/core-js/types/proposals/accessible-object-hasownproperty.d.ts index 192513c61f2c..a4e51205a188 100644 --- a/packages/core-js/types/proposals/accessible-object-hasownproperty.d.ts +++ b/packages/core-js/types/proposals/accessible-object-hasownproperty.d.ts @@ -1,6 +1,9 @@ // proposal stage: 4 // https://github.com/tc39/proposal-accessible-object-hasownproperty + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2022.object.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface ObjectConstructor { - // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2022.object.d.ts hasOwn(o: object, v: PropertyKey): boolean; } diff --git a/packages/core-js/types/proposals/array-find-from-last.d.ts b/packages/core-js/types/proposals/array-find-from-last.d.ts index c89141b53801..9277d71b306b 100644 --- a/packages/core-js/types/proposals/array-find-from-last.d.ts +++ b/packages/core-js/types/proposals/array-find-from-last.d.ts @@ -1,6 +1,9 @@ // proposal stage: 4 // https://github.com/tc39/proposal-array-find-from-last + +// For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface Array { findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; diff --git a/packages/core-js/types/proposals/array-flat-map.d.ts b/packages/core-js/types/proposals/array-flat-map.d.ts index 270e759a426f..86442a23252b 100644 --- a/packages/core-js/types/proposals/array-flat-map.d.ts +++ b/packages/core-js/types/proposals/array-flat-map.d.ts @@ -1,6 +1,9 @@ // proposal stage: 4 // https://github.com/tc39/proposal-flatMap + +// For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface Array { flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): U[]; diff --git a/packages/core-js/types/proposals/array-from-async.d.ts b/packages/core-js/types/proposals/array-from-async.d.ts index 98097c3c5f81..37d2895c5723 100644 --- a/packages/core-js/types/proposals/array-from-async.d.ts +++ b/packages/core-js/types/proposals/array-from-async.d.ts @@ -1,6 +1,9 @@ // proposal stage: 3 // https://github.com/tc39/proposal-array-from-async + +// For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/esnext.array.d.ts#L6 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface ArrayConstructor { fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; diff --git a/packages/core-js/types/proposals/array-grouping.d.ts b/packages/core-js/types/proposals/array-grouping.d.ts index eb63fc247326..54df526927e1 100644 --- a/packages/core-js/types/proposals/array-grouping.d.ts +++ b/packages/core-js/types/proposals/array-grouping.d.ts @@ -1,11 +1,14 @@ // proposal stage: 4 // https://github.com/tc39/proposal-array-grouping + +// For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.object.d.ts#L7 +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.collection.d.ts#L7 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface ObjectConstructor { groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Partial>; } -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.collection.d.ts#L7 interface MapConstructor { groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Map; } diff --git a/packages/core-js/types/proposals/array-includes.d.ts b/packages/core-js/types/proposals/array-includes.d.ts index 7752b0975d5b..25addb6e67a7 100644 --- a/packages/core-js/types/proposals/array-includes.d.ts +++ b/packages/core-js/types/proposals/array-includes.d.ts @@ -1,6 +1,9 @@ // proposal stage: 4 // https://github.com/tc39/proposal-Array.prototype.includes + +// For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2016.array.include.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface Array { includes(searchElement: T, fromIndex?: number): boolean; } diff --git a/packages/core-js/types/proposals/async-iteration.d.ts b/packages/core-js/types/proposals/async-iteration.d.ts index 4b0b640a7659..15f89953861f 100644 --- a/packages/core-js/types/proposals/async-iteration.d.ts +++ b/packages/core-js/types/proposals/async-iteration.d.ts @@ -1,6 +1,9 @@ // proposal stage: 4 // https://github.com/tc39/proposal-async-iteration + +// For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2018.asynciterable.d.ts#L4 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface SymbolConstructor { readonly asyncIterator: unique symbol; } diff --git a/packages/core-js/types/proposals/change-array-by-copy.d.ts b/packages/core-js/types/proposals/change-array-by-copy.d.ts index bac72b7ff955..c50667ceac21 100644 --- a/packages/core-js/types/proposals/change-array-by-copy.d.ts +++ b/packages/core-js/types/proposals/change-array-by-copy.d.ts @@ -1,17 +1,20 @@ // proposal stage: 4 // https://github.com/tc39/proposal-change-array-by-copy + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L28 +// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L39 +// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L48 +// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L67 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface Array { - // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L28 toReversed(): T[]; - // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L39 toSorted(compareFn?: (a: T, b: T) => number): T[]; - // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L48 toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; toSpliced(start: number, deleteCount?: number): T[]; - // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L67 with(index: number, value: T): T[]; } diff --git a/packages/core-js/types/proposals/explicit-resource-management.d.ts b/packages/core-js/types/proposals/explicit-resource-management.d.ts index 313f13ab8ce3..74f2d922d835 100644 --- a/packages/core-js/types/proposals/explicit-resource-management.d.ts +++ b/packages/core-js/types/proposals/explicit-resource-management.d.ts @@ -1,6 +1,9 @@ // proposal stage: 3 // https://github.com/tc39/proposal-explicit-resource-management + +// For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/0a1aa6d6ebdfa16b82f4a6aaf282089b1d484e05/src/lib/esnext.disposable.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface SymbolConstructor { readonly dispose: unique symbol; From bbd8df76f86d7010058f6409940323124d8ad4b2 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 15 Oct 2025 00:42:10 +0700 Subject: [PATCH 037/315] Run all type definition tests --- tests/type-definitions/runner.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index c49596080745..c6b1c8643a69 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -1,2 +1,3 @@ +await $`tsc`; await $`tsc -p proposals/global/tsconfig.json`; await $`tsc -p proposals/pure/tsconfig.json`; From 4a90b39f5046dea6d9c16144233f721822f8701e Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 15 Oct 2025 01:15:59 +0700 Subject: [PATCH 038/315] Add error cases to build & compat tests --- tests/type-definitions/builder.ts | 15 +++++++++++ tests/type-definitions/compat.ts | 41 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/tests/type-definitions/builder.ts b/tests/type-definitions/builder.ts index ba7b95ff38a2..179565275b62 100644 --- a/tests/type-definitions/builder.ts +++ b/tests/type-definitions/builder.ts @@ -66,3 +66,18 @@ await builder({ comment: { size: false, modules: true }, }, }); + +// @ts-expect-error +builder({ format: 'amd' }); +// @ts-expect-error +builder({ filename: true }); +// @ts-expect-error +builder({ summary: 'all' }); +// @ts-expect-error +builder({ summary: { console: 'show' } }); +// @ts-expect-error +builder({ summary: { comment: { invalidKey: true } } }); +// @ts-expect-error +builder({ targets: 123 }); +// @ts-expect-error +builder({ invalidOption: true }); diff --git a/tests/type-definitions/compat.ts b/tests/type-definitions/compat.ts index a485bacf2d1a..3e7b11058d56 100644 --- a/tests/type-definitions/compat.ts +++ b/tests/type-definitions/compat.ts @@ -9,9 +9,23 @@ compat.getEntriesListForTargetVersion('3.0'); getModulesListForTargetVersion('3.0'); compat.getModulesListForTargetVersion('3.0'); +// @ts-expect-error +getEntriesListForTargetVersion(123); +// @ts-expect-error +compat.getEntriesListForTargetVersion(123); +// @ts-expect-error +getModulesListForTargetVersion({ version: true }); +// @ts-expect-error +compat.getModulesListForTargetVersion({ version: true }); + compat.data['es.array.push'].android compat.data['es.array.push'].firefox +// @ts-expect-error +compat.entries['es.array.map'][0] = 'not-a-module'; +// @ts-expect-error +compat.data['es.array.map']['notATarget']; + if (typeof compat.modules[0] !== 'string') { console.error('Invalid'); } @@ -40,6 +54,15 @@ compat({ targets: { chrome: '26', firefox: 4, esmodules: true, node: 'current', compat({ version: '3.0' }); compat({ inverse: true }); +// @ts-expect-error +compat({ modules: 123 }); +// @ts-expect-error +compat({ inverse: 'incorrect' }); +// @ts-expect-error +compat({ exclude: 123 }) +// @ts-expect-error +compat({ targets: 123 }) + compat.compat(); compat.compat({}); compat.compat({ modules: 'core-js/actual' }); @@ -60,6 +83,15 @@ compat.compat({ targets: { chrome: '26', firefox: 4, esmodules: true, node: 'cur compat.compat({ version: '3.0' }); compat.compat({ inverse: true }); +// @ts-expect-error +compat.compat({ modules: 123 }); +// @ts-expect-error +compat.compat({ inverse: 'incorrect' }); +// @ts-expect-error +compat({ exclude: 123 }) +// @ts-expect-error +compat({ targets: 123 }) + compat2(); compat2({}); compat2({ modules: 'core-js/actual' }); @@ -79,3 +111,12 @@ compat2({ targets: { browsers: { chrome: '26', firefox: 4 } } }); compat2({ targets: { chrome: '26', firefox: 4, esmodules: true, node: 'current', browsers: ['> 1%'] } }); compat2({ version: '3.0' }); compat2({ inverse: true }); + +// @ts-expect-error +compat2({ modules: 123 }); +// @ts-expect-error +compat2({ inverse: 'incorrect' }); +// @ts-expect-error +compat2({ exclude: 123 }) +// @ts-expect-error +compat2({ targets: 123 }) From 29e39f35b0e30e88868eecff51e6764c75cc55d2 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 15 Oct 2025 01:22:44 +0700 Subject: [PATCH 039/315] Use just one link to source code --- packages/core-js/types/proposals/change-array-by-copy.d.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/core-js/types/proposals/change-array-by-copy.d.ts b/packages/core-js/types/proposals/change-array-by-copy.d.ts index c50667ceac21..bac970bb58ab 100644 --- a/packages/core-js/types/proposals/change-array-by-copy.d.ts +++ b/packages/core-js/types/proposals/change-array-by-copy.d.ts @@ -2,10 +2,7 @@ // https://github.com/tc39/proposal-change-array-by-copy // For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L28 -// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L39 -// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L48 -// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts#L67 +// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface Array { toReversed(): T[]; From d35bb76629706b2a91cbfe2688d2096be48b4608 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 15 Oct 2025 01:33:39 +0700 Subject: [PATCH 040/315] Add license --- packages/core-js/types/proposals/array-buffer-base64.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core-js/types/proposals/array-buffer-base64.d.ts b/packages/core-js/types/proposals/array-buffer-base64.d.ts index f4c6f75f2a7f..5e8e26075ef3 100644 --- a/packages/core-js/types/proposals/array-buffer-base64.d.ts +++ b/packages/core-js/types/proposals/array-buffer-base64.d.ts @@ -1,5 +1,9 @@ // proposal stage: 3 // https://github.com/tc39/proposal-arraybuffer-base64 + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.typedarrays.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt type alphabet = 'base64' | 'base64url'; type lastChunkHandling = 'loose' | 'strict' | 'stop-before-partial'; type fromBase64Options = { From 941050c62bc2c51902c26979f5f2c6c90402dcbe Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 16 Oct 2025 01:40:23 +0700 Subject: [PATCH 041/315] Fix types for proposals and add type tests with various targets --- .../proposals/async-iterator-helpers.d.ts | 18 +++++++++++------- .../explicit-resource-management.d.ts | 4 ++-- .../types/proposals/iterator-chunking.d.ts | 4 ++-- .../types/proposals/iterator-range.d.ts | 4 ++-- .../global/async-iterator-helper.test.ts | 6 +++--- .../explicit-resource-management.test.ts | 2 -- .../proposals/global/iterator-chunking.test.ts | 4 ++-- .../proposals/global/tsconfig.es2023.json | 7 +++++++ .../proposals/global/tsconfig.es6.json | 7 +++++++ .../proposals/global/tsconfig.esnext.json | 7 +++++++ .../proposals/global/tsconfig.json | 4 ---- .../pure/explicit-resource-management.test.ts | 2 -- .../proposals/pure/iterator-chunking.test.ts | 4 ++-- .../proposals/pure/tsconfig.es2023.json | 7 +++++++ .../proposals/pure/tsconfig.es6.json | 7 +++++++ .../proposals/pure/tsconfig.esnext.json | 7 +++++++ .../proposals/pure/tsconfig.json | 4 ---- tests/type-definitions/runner.mjs | 14 ++++++++++++-- 18 files changed, 78 insertions(+), 34 deletions(-) create mode 100644 tests/type-definitions/proposals/global/tsconfig.es2023.json create mode 100644 tests/type-definitions/proposals/global/tsconfig.es6.json create mode 100644 tests/type-definitions/proposals/global/tsconfig.esnext.json delete mode 100644 tests/type-definitions/proposals/global/tsconfig.json create mode 100644 tests/type-definitions/proposals/pure/tsconfig.es2023.json create mode 100644 tests/type-definitions/proposals/pure/tsconfig.es6.json create mode 100644 tests/type-definitions/proposals/pure/tsconfig.esnext.json delete mode 100644 tests/type-definitions/proposals/pure/tsconfig.json diff --git a/packages/core-js/types/proposals/async-iterator-helpers.d.ts b/packages/core-js/types/proposals/async-iterator-helpers.d.ts index b768b006475d..11aa5601765d 100644 --- a/packages/core-js/types/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js/types/proposals/async-iterator-helpers.d.ts @@ -1,35 +1,39 @@ // proposal stage: 2 // https://github.com/tc39/proposal-async-iterator-helpers +type CoreJsAsyncIteratorObject = typeof globalThis extends { AsyncIteratorObject: infer O } + ? O + : AsyncIterator; + interface AsyncIteratorConstructor { - from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; + from(iterable: AsyncIterable | Iterable | CoreJsAsyncIteratorObject): CoreJsAsyncIteratorObject; } declare var AsyncIterator: AsyncIteratorConstructor; interface AsyncIterator { - drop(limit: number): AsyncIteratorObject; + drop(limit: number): CoreJsAsyncIteratorObject; every(predicate: (value: T, index: number) => boolean): Promise; - filter(predicate: (value: T, index: number) => boolean): AsyncIteratorObject; + filter(predicate: (value: T, index: number) => boolean): CoreJsAsyncIteratorObject; find(predicate: (value: T, index: number) => boolean): Promise; - flatMap(mapper: (value: T, index: number) => any): AsyncIteratorObject; + flatMap(mapper: (value: T, index: number) => any): CoreJsAsyncIteratorObject; forEach(callbackFn: (value: T, index: number) => void): Promise; - map(mapper: (value: T, index: number) => any): AsyncIteratorObject; + map(mapper: (value: T, index: number) => any): CoreJsAsyncIteratorObject; reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; some(predicate: (value: T, index: number) => boolean): Promise; - take(limit: number): AsyncIteratorObject; + take(limit: number): CoreJsAsyncIteratorObject; toArray(): Promise; } interface Iterator { - toAsync(): AsyncIteratorObject; + toAsync(): CoreJsAsyncIteratorObject; } diff --git a/packages/core-js/types/proposals/explicit-resource-management.d.ts b/packages/core-js/types/proposals/explicit-resource-management.d.ts index 74f2d922d835..187e8e66a088 100644 --- a/packages/core-js/types/proposals/explicit-resource-management.d.ts +++ b/packages/core-js/types/proposals/explicit-resource-management.d.ts @@ -79,6 +79,6 @@ interface AsyncDisposableStackConstructor { } declare var AsyncDisposableStack: AsyncDisposableStackConstructor; -interface IteratorObject extends Disposable {} +interface IteratorObject extends Disposable {} -interface AsyncIteratorObject extends AsyncDisposable {} +interface AsyncIteratorObject extends AsyncDisposable {} diff --git a/packages/core-js/types/proposals/iterator-chunking.d.ts b/packages/core-js/types/proposals/iterator-chunking.d.ts index b042628b6efe..bc6c31e2f31e 100644 --- a/packages/core-js/types/proposals/iterator-chunking.d.ts +++ b/packages/core-js/types/proposals/iterator-chunking.d.ts @@ -1,6 +1,6 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-chunking interface Iterator { - chunks(chunkSize: number): IteratorObject; - windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): IteratorObject; + chunks(chunkSize: number): CoreJsIteratorObject; + windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJsIteratorObject; } diff --git a/packages/core-js/types/proposals/iterator-range.d.ts b/packages/core-js/types/proposals/iterator-range.d.ts index 3a5e1a9755e9..1ba423abe09b 100644 --- a/packages/core-js/types/proposals/iterator-range.d.ts +++ b/packages/core-js/types/proposals/iterator-range.d.ts @@ -11,9 +11,9 @@ type RangeOptionsBigInt = { }; interface IteratorConstructor { - range(start: number, end: number, options?: number | RangeOptionsNumber): IteratorObject; + range(start: number, end: number, options?: number | RangeOptionsNumber): CoreJsIteratorObject; - range(start: bigint, end: bigint | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: bigint | RangeOptionsBigInt): IteratorObject; + range(start: bigint, end: bigint | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: bigint | RangeOptionsBigInt): CoreJsIteratorObject; } declare var Iterator: IteratorConstructor; diff --git a/tests/type-definitions/proposals/global/async-iterator-helper.test.ts b/tests/type-definitions/proposals/global/async-iterator-helper.test.ts index fb40600019ca..ee638f8066c6 100644 --- a/tests/type-definitions/proposals/global/async-iterator-helper.test.ts +++ b/tests/type-definitions/proposals/global/async-iterator-helper.test.ts @@ -6,9 +6,9 @@ AsyncIterator.from((async function* () { yield 1; yield 2; })()); AsyncIterator.from((function* () { yield 3; })()); AsyncIterator.from('abc'); -declare const ain: AsyncIteratorObject; -declare const aio: AsyncIteratorObject<{ x: number }>; -declare const ais: AsyncIteratorObject; +declare const ain: AsyncIterator; +declare const aio: AsyncIterator<{ x: number }>; +declare const ais: AsyncIterator; declare const ilb: Iterable; declare const is: Iterator; declare const itn: Iterator; diff --git a/tests/type-definitions/proposals/global/explicit-resource-management.test.ts b/tests/type-definitions/proposals/global/explicit-resource-management.test.ts index 8ba78348bf4f..b0d4a58e75d4 100644 --- a/tests/type-definitions/proposals/global/explicit-resource-management.test.ts +++ b/tests/type-definitions/proposals/global/explicit-resource-management.test.ts @@ -39,8 +39,6 @@ err2.message; const proto: SuppressedError = SuppressedError.prototype; -// @ts-expect-error -new SuppressedError(); // @ts-expect-error new SuppressedError(1, 2, 3, 4); diff --git a/tests/type-definitions/proposals/global/iterator-chunking.test.ts b/tests/type-definitions/proposals/global/iterator-chunking.test.ts index b22ac1aa036d..533ad35aa7ea 100644 --- a/tests/type-definitions/proposals/global/iterator-chunking.test.ts +++ b/tests/type-definitions/proposals/global/iterator-chunking.test.ts @@ -4,8 +4,8 @@ declare function getNumberIterator(): Iterator; const numbersIter = getNumberIterator(); -const chunks: IteratorObject = numbersIter.chunks(2); -const windows: IteratorObject = numbersIter.windows(4); +const chunks: Iterator = numbersIter.chunks(2); +const windows: Iterator = numbersIter.windows(4); const chunkNext = chunks.next(); const windowsNext = windows.next(); diff --git a/tests/type-definitions/proposals/global/tsconfig.es2023.json b/tests/type-definitions/proposals/global/tsconfig.es2023.json new file mode 100644 index 000000000000..37b2484b4ee4 --- /dev/null +++ b/tests/type-definitions/proposals/global/tsconfig.es2023.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./*.ts"], + "compilerOptions": { + "target": "es2023" + } +} diff --git a/tests/type-definitions/proposals/global/tsconfig.es6.json b/tests/type-definitions/proposals/global/tsconfig.es6.json new file mode 100644 index 000000000000..ae985035ec9c --- /dev/null +++ b/tests/type-definitions/proposals/global/tsconfig.es6.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./*.ts"], + "compilerOptions": { + "target": "es6" + } +} diff --git a/tests/type-definitions/proposals/global/tsconfig.esnext.json b/tests/type-definitions/proposals/global/tsconfig.esnext.json new file mode 100644 index 000000000000..e5838f861aa9 --- /dev/null +++ b/tests/type-definitions/proposals/global/tsconfig.esnext.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./*.ts"], + "compilerOptions": { + "target": "esnext" + } +} diff --git a/tests/type-definitions/proposals/global/tsconfig.json b/tests/type-definitions/proposals/global/tsconfig.json deleted file mode 100644 index 1fcfc7ee75bf..000000000000 --- a/tests/type-definitions/proposals/global/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./*.ts"] -} diff --git a/tests/type-definitions/proposals/pure/explicit-resource-management.test.ts b/tests/type-definitions/proposals/pure/explicit-resource-management.test.ts index e7af8185ca64..09360157ba7a 100644 --- a/tests/type-definitions/proposals/pure/explicit-resource-management.test.ts +++ b/tests/type-definitions/proposals/pure/explicit-resource-management.test.ts @@ -31,8 +31,6 @@ err2.error; err2.suppressed; err2.message; -// @ts-expect-error -new suppressedError(); // @ts-expect-error new suppressedError(1, 2, 3, 4); diff --git a/tests/type-definitions/proposals/pure/iterator-chunking.test.ts b/tests/type-definitions/proposals/pure/iterator-chunking.test.ts index d13d87a92fda..0cc1017e3761 100644 --- a/tests/type-definitions/proposals/pure/iterator-chunking.test.ts +++ b/tests/type-definitions/proposals/pure/iterator-chunking.test.ts @@ -5,8 +5,8 @@ declare function getNumberIterator(): Iterator; const numbersIter = getNumberIterator(); -const chunksObj: IteratorObject = chunks(numbersIter, 2); -const windowsObj: IteratorObject = windows(numbersIter, 4); +const chunksObj: Iterator = chunks(numbersIter, 2); +const windowsObj: Iterator = windows(numbersIter, 4); const chunkNext = chunksObj.next(); const windowsNext = windowsObj.next(); diff --git a/tests/type-definitions/proposals/pure/tsconfig.es2023.json b/tests/type-definitions/proposals/pure/tsconfig.es2023.json new file mode 100644 index 000000000000..37b2484b4ee4 --- /dev/null +++ b/tests/type-definitions/proposals/pure/tsconfig.es2023.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./*.ts"], + "compilerOptions": { + "target": "es2023" + } +} diff --git a/tests/type-definitions/proposals/pure/tsconfig.es6.json b/tests/type-definitions/proposals/pure/tsconfig.es6.json new file mode 100644 index 000000000000..ae985035ec9c --- /dev/null +++ b/tests/type-definitions/proposals/pure/tsconfig.es6.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./*.ts"], + "compilerOptions": { + "target": "es6" + } +} diff --git a/tests/type-definitions/proposals/pure/tsconfig.esnext.json b/tests/type-definitions/proposals/pure/tsconfig.esnext.json new file mode 100644 index 000000000000..e5838f861aa9 --- /dev/null +++ b/tests/type-definitions/proposals/pure/tsconfig.esnext.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./*.ts"], + "compilerOptions": { + "target": "esnext" + } +} diff --git a/tests/type-definitions/proposals/pure/tsconfig.json b/tests/type-definitions/proposals/pure/tsconfig.json deleted file mode 100644 index 1fcfc7ee75bf..000000000000 --- a/tests/type-definitions/proposals/pure/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./*.ts"] -} diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index c6b1c8643a69..ce26e0ff22e2 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -1,3 +1,13 @@ await $`tsc`; -await $`tsc -p proposals/global/tsconfig.json`; -await $`tsc -p proposals/pure/tsconfig.json`; + +// await $`npx -p typescript@5.5 tsc -p proposals/global/tsconfig.esnext.json`; +// // await $`npx -p typescript@4.6 tsc -p proposals/global/tsconfig.es6.json`; + +await $`tsc -p proposals/global/tsconfig.esnext.json`; +await $`tsc -p proposals/global/tsconfig.es2023.json`; +await $`tsc -p proposals/global/tsconfig.es6.json`; + +await $`tsc -p proposals/pure/tsconfig.esnext.json`; +await $`tsc -p proposals/pure/tsconfig.es2023.json`; +await $`tsc -p proposals/pure/tsconfig.es6.json`; + From 52a4867c7cc4261e1d7fa9886e1ff85803c140e0 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 16 Oct 2025 13:45:07 +0700 Subject: [PATCH 042/315] core-js object types refactoring --- .../proposals/async-iterator-helpers.d.ts | 47 ++++++++++--------- .../core-js-types/core-js-types.d.ts | 11 +++++ .../types/proposals/decorator-metadata.d.ts | 19 ++++---- .../types/proposals/iterator-chunking.d.ts | 14 ++++-- .../types/proposals/iterator-joint.d.ts | 28 ++++++----- .../types/proposals/iterator-range.d.ts | 31 +++++++----- .../types/proposals/iterator-sequencing.d.ts | 13 +++-- tests/type-definitions/runner.mjs | 3 -- 8 files changed, 103 insertions(+), 63 deletions(-) create mode 100644 packages/core-js/types/proposals/core-js-types/core-js-types.d.ts diff --git a/packages/core-js/types/proposals/async-iterator-helpers.d.ts b/packages/core-js/types/proposals/async-iterator-helpers.d.ts index 11aa5601765d..88612bb229e7 100644 --- a/packages/core-js/types/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js/types/proposals/async-iterator-helpers.d.ts @@ -1,39 +1,42 @@ // proposal stage: 2 // https://github.com/tc39/proposal-async-iterator-helpers -type CoreJsAsyncIteratorObject = typeof globalThis extends { AsyncIteratorObject: infer O } - ? O - : AsyncIterator; -interface AsyncIteratorConstructor { - from(iterable: AsyncIterable | Iterable | CoreJsAsyncIteratorObject): CoreJsAsyncIteratorObject; -} +import { CoreJsAsyncIteratorObject } from './core-js-types/core-js-types'; -declare var AsyncIterator: AsyncIteratorConstructor; +declare global { + interface AsyncIteratorConstructor { + from(iterable: AsyncIterable | Iterable | CoreJsAsyncIteratorObject): CoreJsAsyncIteratorObject; + } -interface AsyncIterator { - drop(limit: number): CoreJsAsyncIteratorObject; + var AsyncIterator: AsyncIteratorConstructor; - every(predicate: (value: T, index: number) => boolean): Promise; + interface AsyncIterator { + drop(limit: number): CoreJsAsyncIteratorObject; - filter(predicate: (value: T, index: number) => boolean): CoreJsAsyncIteratorObject; + every(predicate: (value: T, index: number) => boolean): Promise; - find(predicate: (value: T, index: number) => boolean): Promise; + filter(predicate: (value: T, index: number) => boolean): CoreJsAsyncIteratorObject; - flatMap(mapper: (value: T, index: number) => any): CoreJsAsyncIteratorObject; + find(predicate: (value: T, index: number) => boolean): Promise; - forEach(callbackFn: (value: T, index: number) => void): Promise; + flatMap(mapper: (value: T, index: number) => any): CoreJsAsyncIteratorObject; - map(mapper: (value: T, index: number) => any): CoreJsAsyncIteratorObject; + forEach(callbackFn: (value: T, index: number) => void): Promise; - reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; + map(mapper: (value: T, index: number) => any): CoreJsAsyncIteratorObject; - some(predicate: (value: T, index: number) => boolean): Promise; + reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; - take(limit: number): CoreJsAsyncIteratorObject; + some(predicate: (value: T, index: number) => boolean): Promise; - toArray(): Promise; -} + take(limit: number): CoreJsAsyncIteratorObject; -interface Iterator { - toAsync(): CoreJsAsyncIteratorObject; + toArray(): Promise; + } + + interface Iterator { + toAsync(): CoreJsAsyncIteratorObject; + } } + +export {}; diff --git a/packages/core-js/types/proposals/core-js-types/core-js-types.d.ts b/packages/core-js/types/proposals/core-js-types/core-js-types.d.ts new file mode 100644 index 000000000000..0297e12f1b5e --- /dev/null +++ b/packages/core-js/types/proposals/core-js-types/core-js-types.d.ts @@ -0,0 +1,11 @@ +export type CoreJsAsyncIteratorObject = typeof globalThis extends { AsyncIteratorObject: infer O } + ? O + : AsyncIterator; + +export type CoreJsDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer T } + ? T + : Record & object; + +export type CoreJsIteratorObject = typeof globalThis extends { IteratorObject: infer O } + ? O + : Iterator; diff --git a/packages/core-js/types/proposals/decorator-metadata.d.ts b/packages/core-js/types/proposals/decorator-metadata.d.ts index 532d58638822..02c6d0b8496f 100644 --- a/packages/core-js/types/proposals/decorator-metadata.d.ts +++ b/packages/core-js/types/proposals/decorator-metadata.d.ts @@ -1,13 +1,16 @@ // proposal stage: 3 // https://github.com/tc39/proposal-decorator-metadata -interface SymbolConstructor { - readonly metadata: unique symbol; -} -type DecoratorMetadataCoreJS = typeof globalThis extends { DecoratorMetadataObject: infer T } - ? T - : Record & object; +import { CoreJsDecoratorMetadataObject } from './core-js-types/core-js-types.js'; + +declare global { + interface SymbolConstructor { + readonly metadata: unique symbol; + } -interface Function { - [Symbol.metadata]: DecoratorMetadataCoreJS | null; + interface Function { + [Symbol.metadata]: CoreJsDecoratorMetadataObject | null; + } } + +export {}; diff --git a/packages/core-js/types/proposals/iterator-chunking.d.ts b/packages/core-js/types/proposals/iterator-chunking.d.ts index bc6c31e2f31e..8baac7c0334c 100644 --- a/packages/core-js/types/proposals/iterator-chunking.d.ts +++ b/packages/core-js/types/proposals/iterator-chunking.d.ts @@ -1,6 +1,14 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-chunking -interface Iterator { - chunks(chunkSize: number): CoreJsIteratorObject; - windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJsIteratorObject; + +import { CoreJsIteratorObject } from './core-js-types/core-js-types'; + +declare global { + interface Iterator { + chunks(chunkSize: number): CoreJsIteratorObject; + + windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJsIteratorObject; + } } + +export {}; diff --git a/packages/core-js/types/proposals/iterator-joint.d.ts b/packages/core-js/types/proposals/iterator-joint.d.ts index 3e9185e65f6f..a36c4fa0c836 100644 --- a/packages/core-js/types/proposals/iterator-joint.d.ts +++ b/packages/core-js/types/proposals/iterator-joint.d.ts @@ -1,19 +1,23 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-joint-iteration -type CoreJsIteratorObject = typeof globalThis extends { IteratorObject: infer O } - ? O - : Iterator; -type ZipOptions = { - mode?: "shortest" | "longest" | "strict"; - padding?: object; -}; +import { CoreJsIteratorObject } from './core-js-types/core-js-types'; -interface IteratorConstructor { - zip(iterables: Iterable, options?: ZipOptions): CoreJsIteratorObject<[T, U]>; +declare global { + type ZipOptions = { + mode?: "shortest" | "longest" | "strict"; + padding?: object; + }; - zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJsIteratorObject<[number, T, U]>; - zipKeyed(record: Record>, options?: ZipOptions): CoreJsIteratorObject<[PropertyKey, T, U]>; + interface IteratorConstructor { + zip(iterables: Iterable, options?: ZipOptions): CoreJsIteratorObject<[T, U]>; + + zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJsIteratorObject<[number, T, U]>; + + zipKeyed(record: Record>, options?: ZipOptions): CoreJsIteratorObject<[PropertyKey, T, U]>; + } + + var Iterator: IteratorConstructor; } -declare var Iterator: IteratorConstructor; +export {}; diff --git a/packages/core-js/types/proposals/iterator-range.d.ts b/packages/core-js/types/proposals/iterator-range.d.ts index 1ba423abe09b..b64899b4d700 100644 --- a/packages/core-js/types/proposals/iterator-range.d.ts +++ b/packages/core-js/types/proposals/iterator-range.d.ts @@ -1,19 +1,26 @@ // proposal stage: 2 // https://github.com/tc39/proposal-Number.range -type RangeOptionsNumber = { - step?: number; - inclusive?: boolean; -}; -type RangeOptionsBigInt = { - step?: bigint; - inclusive?: boolean; -}; +import { CoreJsIteratorObject } from './core-js-types/core-js-types'; -interface IteratorConstructor { - range(start: number, end: number, options?: number | RangeOptionsNumber): CoreJsIteratorObject; +declare global { + type RangeOptionsNumber = { + step?: number; + inclusive?: boolean; + }; - range(start: bigint, end: bigint | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: bigint | RangeOptionsBigInt): CoreJsIteratorObject; + type RangeOptionsBigInt = { + step?: bigint; + inclusive?: boolean; + }; + + interface IteratorConstructor { + range(start: number, end: number, options?: number | RangeOptionsNumber): CoreJsIteratorObject; + + range(start: bigint, end: bigint | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: bigint | RangeOptionsBigInt): CoreJsIteratorObject; + } + + var Iterator: IteratorConstructor; } -declare var Iterator: IteratorConstructor; +export {}; diff --git a/packages/core-js/types/proposals/iterator-sequencing.d.ts b/packages/core-js/types/proposals/iterator-sequencing.d.ts index a4ac8cc2533a..72cc2dc66c16 100644 --- a/packages/core-js/types/proposals/iterator-sequencing.d.ts +++ b/packages/core-js/types/proposals/iterator-sequencing.d.ts @@ -1,7 +1,14 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-sequencing -interface IteratorConstructor { - concat(...iterators: Iterable[]): CoreJsIteratorObject; + +import { CoreJsIteratorObject } from './core-js-types/core-js-types'; + +declare global { + interface IteratorConstructor { + concat(...iterators: Iterable[]): CoreJsIteratorObject; + } + + var Iterator: IteratorConstructor; } -declare var Iterator: IteratorConstructor; +export {}; diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index ce26e0ff22e2..2ef4b1dd6e68 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -1,8 +1,5 @@ await $`tsc`; -// await $`npx -p typescript@5.5 tsc -p proposals/global/tsconfig.esnext.json`; -// // await $`npx -p typescript@4.6 tsc -p proposals/global/tsconfig.es6.json`; - await $`tsc -p proposals/global/tsconfig.esnext.json`; await $`tsc -p proposals/global/tsconfig.es2023.json`; await $`tsc -p proposals/global/tsconfig.es6.json`; From 02a59d98d59456672dc5d802365caddd0435eded Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 16 Oct 2025 14:29:29 +0700 Subject: [PATCH 043/315] Await dictionary proposal types --- .../modules/esnext.promise.all-keyed.js | 1 + .../types/proposals/await-dictionary.d.ts | 8 ++++++++ .../proposals/global/await-dictionary.test.ts | 19 +++++++++++++++++++ .../proposals/pure/await-dictionary.test.ts | 19 +++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 packages/core-js/types/proposals/await-dictionary.d.ts create mode 100644 tests/type-definitions/proposals/global/await-dictionary.test.ts create mode 100644 tests/type-definitions/proposals/pure/await-dictionary.test.ts diff --git a/packages/core-js/modules/esnext.promise.all-keyed.js b/packages/core-js/modules/esnext.promise.all-keyed.js index bf4973bf10b0..ae942742a3a0 100644 --- a/packages/core-js/modules/esnext.promise.all-keyed.js +++ b/packages/core-js/modules/esnext.promise.all-keyed.js @@ -1,3 +1,4 @@ +// types: proposals/await-dictionary 'use strict'; var $ = require('../internals/export'); var aCallable = require('../internals/a-callable'); diff --git a/packages/core-js/types/proposals/await-dictionary.d.ts b/packages/core-js/types/proposals/await-dictionary.d.ts new file mode 100644 index 000000000000..f3a472e9d75e --- /dev/null +++ b/packages/core-js/types/proposals/await-dictionary.d.ts @@ -0,0 +1,8 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-await-dictionary + +type Dict = { [k: string | symbol]: V }; + +interface PromiseConstructor { + allKeyed>>(promises: D): Promise <{ [k in keyof D]: Awaited }> +} diff --git a/tests/type-definitions/proposals/global/await-dictionary.test.ts b/tests/type-definitions/proposals/global/await-dictionary.test.ts new file mode 100644 index 000000000000..5c1355c03e80 --- /dev/null +++ b/tests/type-definitions/proposals/global/await-dictionary.test.ts @@ -0,0 +1,19 @@ +import 'core-js/full'; + +const res: Promise<{ a: number, b: string, c: boolean }> = Promise.allKeyed({ + a: Promise.resolve(1), + b: Promise.resolve('string'), + c: Promise.resolve(true), +}); + +const sym = Symbol('sym'); +const res2: Promise<{ [sym]: number }> = Promise.allKeyed({ + [sym]: Promise.resolve(1) +}); + +// @ts-expect-error +Promise.allKeyed(); +// @ts-expect-error +Promise.allKeyed({ a: 1, b: Promise.resolve(2) }); +// @ts-expect-error +Promise.allKeyed([ Promise.resolve(1), Promise.resolve(2) ]); diff --git a/tests/type-definitions/proposals/pure/await-dictionary.test.ts b/tests/type-definitions/proposals/pure/await-dictionary.test.ts new file mode 100644 index 000000000000..d5a35724470b --- /dev/null +++ b/tests/type-definitions/proposals/pure/await-dictionary.test.ts @@ -0,0 +1,19 @@ +import allKeyed from '@core-js/pure/full/promise/all-keyed'; + +const res: Promise<{ a: number, b: string, c: boolean }> = allKeyed({ + a: Promise.resolve(1), + b: Promise.resolve('string'), + c: Promise.resolve(true), +}); + +const sym = Symbol('sym'); +const res2: Promise<{ [sym]: number }> = allKeyed({ + [sym]: Promise.resolve(1) +}); + +// @ts-expect-error +allKeyed(); +// @ts-expect-error +allKeyed({ a: 1, b: Promise.resolve(2) }); +// @ts-expect-error +allKeyed([ Promise.resolve(1), Promise.resolve(2) ]); From 266da6f87e901e995601664df92e17544fff6982 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 18 Oct 2025 22:56:52 +0700 Subject: [PATCH 044/315] Add proposal types for stages 3-4 --- .../modules/es.aggregate-error.cause.js | 1 + .../modules/es.data-view.get-float16.js | 1 + .../modules/es.data-view.set-float16.js | 1 + packages/core-js/modules/es.error.cause.js | 1 + packages/core-js/modules/es.iterator.drop.js | 1 + packages/core-js/modules/es.iterator.every.js | 1 + .../core-js/modules/es.iterator.filter.js | 1 + packages/core-js/modules/es.iterator.find.js | 1 + .../core-js/modules/es.iterator.flat-map.js | 1 + .../core-js/modules/es.iterator.for-each.js | 1 + packages/core-js/modules/es.iterator.from.js | 1 + packages/core-js/modules/es.iterator.map.js | 1 + .../core-js/modules/es.iterator.reduce.js | 1 + packages/core-js/modules/es.iterator.some.js | 1 + packages/core-js/modules/es.iterator.take.js | 1 + .../core-js/modules/es.iterator.to-array.js | 1 + packages/core-js/modules/es.math.f16round.js | 1 + .../core-js-types/core-js-types.d.ts | 17 +++-- .../data-view-get-set-uint8-clamped.d.ts | 4 +- .../core-js/types/proposals/error-cause.d.ts | 64 +++++++++++++++++++ packages/core-js/types/proposals/float16.d.ts | 18 ++++++ .../types/proposals/iterator-helpers.d.ts | 40 ++++++++++++ .../core-js/types/proposals/map-upsert.d.ts | 3 +- .../proposals/global/error-cause.test.ts | 31 +++++++++ .../proposals/global/float16.test.ts | 18 ++++++ .../proposals/global/iterator-helpers.test.ts | 6 ++ .../proposals/pure/float16.test.ts | 6 ++ tests/type-definitions/runner.mjs | 2 + 28 files changed, 219 insertions(+), 7 deletions(-) create mode 100644 packages/core-js/types/proposals/error-cause.d.ts create mode 100644 packages/core-js/types/proposals/float16.d.ts create mode 100644 packages/core-js/types/proposals/iterator-helpers.d.ts create mode 100644 tests/type-definitions/proposals/global/error-cause.test.ts create mode 100644 tests/type-definitions/proposals/global/float16.test.ts create mode 100644 tests/type-definitions/proposals/global/iterator-helpers.test.ts create mode 100644 tests/type-definitions/proposals/pure/float16.test.ts diff --git a/packages/core-js/modules/es.aggregate-error.cause.js b/packages/core-js/modules/es.aggregate-error.cause.js index 5e031dc8363b..2bb587f3bde2 100644 --- a/packages/core-js/modules/es.aggregate-error.cause.js +++ b/packages/core-js/modules/es.aggregate-error.cause.js @@ -1,3 +1,4 @@ +// types: proposals/error-cause 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/es.data-view.get-float16.js b/packages/core-js/modules/es.data-view.get-float16.js index 0c61792ceca3..36ae951cc411 100644 --- a/packages/core-js/modules/es.data-view.get-float16.js +++ b/packages/core-js/modules/es.data-view.get-float16.js @@ -1,3 +1,4 @@ +// types: proposals/float16 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/es.data-view.set-float16.js b/packages/core-js/modules/es.data-view.set-float16.js index 1cab3a9644d0..f73985758a57 100644 --- a/packages/core-js/modules/es.data-view.set-float16.js +++ b/packages/core-js/modules/es.data-view.set-float16.js @@ -1,3 +1,4 @@ +// types: proposals/float16 'use strict'; var $ = require('../internals/export'); var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); diff --git a/packages/core-js/modules/es.error.cause.js b/packages/core-js/modules/es.error.cause.js index 26a0215eedab..33a6ab2afcf8 100644 --- a/packages/core-js/modules/es.error.cause.js +++ b/packages/core-js/modules/es.error.cause.js @@ -1,3 +1,4 @@ +// types: proposals/error-cause 'use strict'; /* eslint-disable no-unused-vars -- required for functions `.length` */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.iterator.drop.js b/packages/core-js/modules/es.iterator.drop.js index 6568175a87a4..8b2e94e33820 100644 --- a/packages/core-js/modules/es.iterator.drop.js +++ b/packages/core-js/modules/es.iterator.drop.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.every.js b/packages/core-js/modules/es.iterator.every.js index 1c477ba01c35..af354d168ab9 100644 --- a/packages/core-js/modules/es.iterator.every.js +++ b/packages/core-js/modules/es.iterator.every.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.filter.js b/packages/core-js/modules/es.iterator.filter.js index a23a6ebf78ad..a5b6af0fdc6d 100644 --- a/packages/core-js/modules/es.iterator.filter.js +++ b/packages/core-js/modules/es.iterator.filter.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.find.js b/packages/core-js/modules/es.iterator.find.js index 02643692f1d4..679cc78f231f 100644 --- a/packages/core-js/modules/es.iterator.find.js +++ b/packages/core-js/modules/es.iterator.find.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.flat-map.js b/packages/core-js/modules/es.iterator.flat-map.js index ab8c5d1049ab..991d4fa04c8d 100644 --- a/packages/core-js/modules/es.iterator.flat-map.js +++ b/packages/core-js/modules/es.iterator.flat-map.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.for-each.js b/packages/core-js/modules/es.iterator.for-each.js index 670aaef4902c..ab2fd1d66697 100644 --- a/packages/core-js/modules/es.iterator.for-each.js +++ b/packages/core-js/modules/es.iterator.for-each.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.from.js b/packages/core-js/modules/es.iterator.from.js index a74ae14ce6db..e174ce298643 100644 --- a/packages/core-js/modules/es.iterator.from.js +++ b/packages/core-js/modules/es.iterator.from.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.map.js b/packages/core-js/modules/es.iterator.map.js index 8fa96df286bd..09f8c00caf0c 100644 --- a/packages/core-js/modules/es.iterator.map.js +++ b/packages/core-js/modules/es.iterator.map.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.reduce.js b/packages/core-js/modules/es.iterator.reduce.js index b0078e78352d..c406e405fff9 100644 --- a/packages/core-js/modules/es.iterator.reduce.js +++ b/packages/core-js/modules/es.iterator.reduce.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var iterate = require('../internals/iterate'); diff --git a/packages/core-js/modules/es.iterator.some.js b/packages/core-js/modules/es.iterator.some.js index a4eda9971d1a..d9d2d9818c96 100644 --- a/packages/core-js/modules/es.iterator.some.js +++ b/packages/core-js/modules/es.iterator.some.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.take.js b/packages/core-js/modules/es.iterator.take.js index 26e8daf96e40..d53804538bbf 100644 --- a/packages/core-js/modules/es.iterator.take.js +++ b/packages/core-js/modules/es.iterator.take.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.to-array.js b/packages/core-js/modules/es.iterator.to-array.js index bc74487c2e76..85900fe6b1c4 100644 --- a/packages/core-js/modules/es.iterator.to-array.js +++ b/packages/core-js/modules/es.iterator.to-array.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var anObject = require('../internals/an-object'); diff --git a/packages/core-js/modules/es.math.f16round.js b/packages/core-js/modules/es.math.f16round.js index 6dad8db170e2..81dd13a80c2c 100644 --- a/packages/core-js/modules/es.math.f16round.js +++ b/packages/core-js/modules/es.math.f16round.js @@ -1,3 +1,4 @@ +// types: proposals/float16 'use strict'; var $ = require('../internals/export'); var sign = require('../internals/math-sign'); diff --git a/packages/core-js/types/proposals/core-js-types/core-js-types.d.ts b/packages/core-js/types/proposals/core-js-types/core-js-types.d.ts index 0297e12f1b5e..7f413b43f31d 100644 --- a/packages/core-js/types/proposals/core-js-types/core-js-types.d.ts +++ b/packages/core-js/types/proposals/core-js-types/core-js-types.d.ts @@ -2,10 +2,19 @@ export type CoreJsAsyncIteratorObject = typeof globalThis extends { AsyncIter ? O : AsyncIterator; -export type CoreJsDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer T } - ? T +export type CoreJsDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } + ? O : Record & object; -export type CoreJsIteratorObject = typeof globalThis extends { IteratorObject: infer O } +declare global { + interface IteratorObject extends Iterator {} +} +export type CoreJsIteratorObject = IteratorObject; + +export type CoreJsAggregateError = typeof globalThis extends { AggregateError: infer O } ? O - : Iterator; + : { new(errors: Iterable, message?: string): Error & { errors: any[] } }; + +export type CoreJsErrorOptions = { + cause?: unknown; +} diff --git a/packages/core-js/types/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js/types/proposals/data-view-get-set-uint8-clamped.d.ts index 6def9aad49cf..36e13b639be4 100644 --- a/packages/core-js/types/proposals/data-view-get-set-uint8-clamped.d.ts +++ b/packages/core-js/types/proposals/data-view-get-set-uint8-clamped.d.ts @@ -1,6 +1,6 @@ // proposal stage: 1 -// https://github.com/tc39/proposal-setmap-offrom -interface DataView { +// https://github.com/tc39/proposal-dataview-get-set-uint8clamped +interface DataView { getUint8Clamped(byteOffset: number): number; setUint8Clamped(byteOffset: number, value: number): void; } diff --git a/packages/core-js/types/proposals/error-cause.d.ts b/packages/core-js/types/proposals/error-cause.d.ts new file mode 100644 index 000000000000..a5544b3601a1 --- /dev/null +++ b/packages/core-js/types/proposals/error-cause.d.ts @@ -0,0 +1,64 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-error-cause + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/es2022.error.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +import { CoreJsAggregateError, CoreJsErrorOptions } from './core-js-types/core-js-types.js'; + +declare global { + interface Error { + cause?: unknown; // ts <= 4.7 Error | undefined + } + + interface ErrorConstructor { + new(message?: string, options?: CoreJsErrorOptions): Error; + + (message?: string, options?: CoreJsErrorOptions): Error; + } + + interface EvalErrorConstructor { + new(message?: string, options?: CoreJsErrorOptions): EvalError; + + (message?: string, options?: CoreJsErrorOptions): EvalError; + } + + interface RangeErrorConstructor { + new(message?: string, options?: CoreJsErrorOptions): RangeError; + + (message?: string, options?: CoreJsErrorOptions): RangeError; + } + + interface ReferenceErrorConstructor { + new(message?: string, options?: CoreJsErrorOptions): ReferenceError; + + (message?: string, options?: CoreJsErrorOptions): ReferenceError; + } + + interface SyntaxErrorConstructor { + new(message?: string, options?: CoreJsErrorOptions): SyntaxError; + + (message?: string, options?: CoreJsErrorOptions): SyntaxError; + } + + interface TypeErrorConstructor { + new(message?: string, options?: CoreJsErrorOptions): TypeError; + + (message?: string, options?: CoreJsErrorOptions): TypeError; + } + + interface URIErrorConstructor { + new(message?: string, options?: CoreJsErrorOptions): URIError; + + (message?: string, options?: CoreJsErrorOptions): URIError; + } + + interface AggregateErrorConstructor { + new(errors: Iterable, message?: string, options?: CoreJsErrorOptions): CoreJsAggregateError; + + (errors: Iterable, message?: string, options?: CoreJsErrorOptions): CoreJsAggregateError; + } +} + +export {}; diff --git a/packages/core-js/types/proposals/float16.d.ts b/packages/core-js/types/proposals/float16.d.ts new file mode 100644 index 000000000000..e88e76bb865d --- /dev/null +++ b/packages/core-js/types/proposals/float16.d.ts @@ -0,0 +1,18 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-float16array + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.float16.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface Math { + f16round(x: number): number; +} + +interface DataView { + getFloat16(byteOffset: number, littleEndian?: boolean): number; + + setFloat16(byteOffset: number, value: number, littleEndian?: boolean): void; +} + + diff --git a/packages/core-js/types/proposals/iterator-helpers.d.ts b/packages/core-js/types/proposals/iterator-helpers.d.ts new file mode 100644 index 000000000000..7c33e2235ef1 --- /dev/null +++ b/packages/core-js/types/proposals/iterator-helpers.d.ts @@ -0,0 +1,40 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-iterator-helpers + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +import { CoreJsIteratorObject } from './core-js-types/core-js-types'; + +declare global { + interface Iterator { + map(callbackfn: (value: T, index: number) => U): CoreJsIteratorObject; + + filter(predicate: (value: T, index: number) => value is S): CoreJsIteratorObject; + filter(predicate: (value: T, index: number) => unknown): CoreJsIteratorObject; + + take(limit: number): CoreJsIteratorObject; + + drop(count: number): CoreJsIteratorObject; + + flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJsIteratorObject; + + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; + + toArray(): T[]; + + forEach(callbackfn: (value: T, index: number) => void): void; + + some(predicate: (value: T, index: number) => unknown): boolean; + + every(predicate: (value: T, index: number) => unknown): boolean; + + find(predicate: (value: T, index: number) => value is S): S | undefined; + find(predicate: (value: T, index: number) => unknown): T | undefined; + } +} + +export {}; diff --git a/packages/core-js/types/proposals/map-upsert.d.ts b/packages/core-js/types/proposals/map-upsert.d.ts index d3a0229a010e..a1e0843e750f 100644 --- a/packages/core-js/types/proposals/map-upsert.d.ts +++ b/packages/core-js/types/proposals/map-upsert.d.ts @@ -1,11 +1,12 @@ // proposal stage: 2 // https://github.com/tc39/proposal-upsert + interface Map { getOrInsert(key: K, value: V): V; getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } -interface WeakMap { +interface WeakMap { getOrInsert(key: K, value: V): V; getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } diff --git a/tests/type-definitions/proposals/global/error-cause.test.ts b/tests/type-definitions/proposals/global/error-cause.test.ts new file mode 100644 index 000000000000..099e6283e8da --- /dev/null +++ b/tests/type-definitions/proposals/global/error-cause.test.ts @@ -0,0 +1,31 @@ +import 'core-js/full'; + +const prevError = new Error('Prev error'); + +const resE1: Error = new Error('Error with cause', { cause: prevError }); +const resE2: Error = new Error('Error with cause', { cause: null }); +const resE3: Error = new Error('Error with cause', { cause: 'prev reason' }); + +const resEE1: EvalError = new EvalError('Error with cause', { cause: prevError }); +const resEE2: EvalError = new EvalError('Error with cause', { cause: null }); +const resEE3: EvalError = new EvalError('Error with cause', { cause: 'prev reason' }); + +const resRE1: RangeError = new RangeError('Error with cause', { cause: prevError }); +const resRE2: RangeError = new RangeError('Error with cause', { cause: null }); +const resRE3: RangeError = new RangeError('Error with cause', { cause: 'prev reason' }); + +const resReE1: ReferenceError = new ReferenceError('Error with cause', { cause: prevError }); +const resReE2: ReferenceError = new ReferenceError('Error with cause', { cause: null }); +const resReE3: ReferenceError = new ReferenceError('Error with cause', { cause: 'prev reason' }); + +const resSE1: SyntaxError = new SyntaxError('Error with cause', { cause: prevError }); +const resSE2: SyntaxError = new SyntaxError('Error with cause', { cause: null }); +const resSE3: SyntaxError = new SyntaxError('Error with cause', { cause: 'prev reason' }); + +const resTE1: TypeError = new TypeError('Error with cause', { cause: prevError }); +const resTE2: TypeError = new TypeError('Error with cause', { cause: null }); +const resTE3: TypeError = new TypeError('Error with cause', { cause: 'prev reason' }); + +const resUE1: URIError = new URIError('Error with cause', { cause: prevError }); +const resUE2: URIError = new URIError('Error with cause', { cause: null }); +const resUE3: URIError = new URIError('Error with cause', { cause: 'prev reason' }); diff --git a/tests/type-definitions/proposals/global/float16.test.ts b/tests/type-definitions/proposals/global/float16.test.ts new file mode 100644 index 000000000000..810fc9e2c788 --- /dev/null +++ b/tests/type-definitions/proposals/global/float16.test.ts @@ -0,0 +1,18 @@ +import 'core-js/full'; + +const res: number = Math.f16round(1); + +// @ts-expect-error +Math.f16round('123'); + +const view = new DataView(new ArrayBuffer(4)); +view.setFloat16(0, 1.5); +const res2: number = view.getFloat16(0); +// @ts-expect-error +view.setFloat16(0, '123'); +// @ts-expect-error +view.getFloat16('123'); +// @ts-expect-error +view.getFloat16(0, '123'); +// @ts-expect-error +view.setFloat16(0, 1.5, '123'); diff --git a/tests/type-definitions/proposals/global/iterator-helpers.test.ts b/tests/type-definitions/proposals/global/iterator-helpers.test.ts new file mode 100644 index 000000000000..a09d57d85543 --- /dev/null +++ b/tests/type-definitions/proposals/global/iterator-helpers.test.ts @@ -0,0 +1,6 @@ +import 'core-js/full'; +// +declare function getNumberIterator(): Iterator; + +const iter = getNumberIterator(); +const res: Iterator = iter.map(n => n + 1); diff --git a/tests/type-definitions/proposals/pure/float16.test.ts b/tests/type-definitions/proposals/pure/float16.test.ts new file mode 100644 index 000000000000..4d5c1fe0ecfa --- /dev/null +++ b/tests/type-definitions/proposals/pure/float16.test.ts @@ -0,0 +1,6 @@ +import f16round from '@core-js/pure/full/math/f16round'; + +const res: number = f16round(1); + +// @ts-expect-error +f16round('123'); diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 2ef4b1dd6e68..e555854248c2 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -1,5 +1,7 @@ await $`tsc`; +// await $`npx -p typescript@5.5 tsc -p proposals/global/tsconfig.esnext.json`; + await $`tsc -p proposals/global/tsconfig.esnext.json`; await $`tsc -p proposals/global/tsconfig.es2023.json`; await $`tsc -p proposals/global/tsconfig.es6.json`; From 879b5159c787ba3e2e36ff3941f6b2a5fdbde5e6 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 22 Oct 2025 20:54:02 +0700 Subject: [PATCH 045/315] Add proposal types for stages 3-4 & fix old tests & types --- ...s.array-buffer.transfer-to-fixed-length.js | 1 + .../modules/es.array-buffer.transfer.js | 1 + .../modules/es.array.find-last-index.js | 1 + .../core-js/modules/es.array.find-last.js | 1 + packages/core-js/modules/es.array.flat-map.js | 1 + packages/core-js/modules/es.array.flat.js | 1 + packages/core-js/modules/es.array.includes.js | 1 + .../core-js/modules/es.array.to-reversed.js | 1 + .../core-js/modules/es.array.to-sorted.js | 1 + .../core-js/modules/es.array.to-spliced.js | 1 + packages/core-js/modules/es.array.with.js | 1 + packages/core-js/modules/es.map.group-by.js | 1 + .../core-js/modules/es.object.from-entries.js | 1 + .../core-js/modules/es.object.group-by.js | 1 + packages/core-js/modules/es.object.has-own.js | 1 + .../modules/es.symbol.async-iterator.js | 1 + .../modules/es.typed-array.to-reversed.js | 1 + .../modules/es.typed-array.to-sorted.js | 1 + .../core-js/modules/es.typed-array.with.js | 1 + .../proposals/array-buffer-transfer.d.ts | 3 +- .../core-js/types/proposals/extractors.d.ts | 2 +- .../types/proposals/iterator-helpers.d.ts | 8 +- .../types/proposals/object-from-entries.d.ts | 12 ++ tests/type-definitions/entries.import.ts | 6 +- .../accessible-object-hasownproperty.test.ts | 20 ++ .../global/array-buffer-transfer.test.ts | 28 +++ .../proposals/global/array-filtering.test.ts | 42 ++-- .../global/array-find-from-last.test.ts | 52 +++++ .../proposals/global/array-flat-map.test.ts | 40 ++++ .../proposals/global/array-grouping.test.ts | 33 ++++ .../proposals/global/array-includes.test.ts | 122 ++++++++++++ .../proposals/global/array-unique.test.ts | 160 ++++++++++++--- .../proposals/global/async-iteration.test.ts | 10 + .../global/async-iterator-helper.test.ts | 6 +- .../global/change-array-by-copy.test.ts | 186 ++++++++++++++++++ .../global/collection-of-from.test.ts | 92 +++++---- .../proposals/global/extractors.test.ts | 8 +- .../proposals/global/iterator-helpers.test.ts | 87 +++++++- .../global/iterator-sequencing.test.ts | 4 - .../global/object-from-entries.test.ts | 27 +++ .../proposals/global/string-cooked.test.ts | 4 +- .../accessible-object-hasownproperty.test.ts | 20 ++ .../proposals/pure/array-filtering.test.ts | 9 + .../pure/array-find-from-last.test.ts | 23 +++ .../proposals/pure/array-flat-map.test.ts | 42 ++++ .../proposals/pure/array-grouping.test.ts | 34 ++++ .../proposals/pure/array-includes.test.ts | 19 ++ .../pure/array-is-template-object.test.ts | 17 ++ .../proposals/pure/array-unique.test.ts | 27 +++ .../proposals/pure/async-iteration.test.ts | 11 ++ .../pure/async-iterator-helper.test.ts | 6 +- .../pure/change-array-by-copy.test.ts | 49 +++++ .../proposals/pure/extractors.test.ts | 10 + .../proposals/pure/iterator-helpers.test.ts | 108 ++++++++++ .../pure/iterator-sequencing.test.ts | 4 - .../pure/object-from-entries.test.ts | 27 +++ .../proposals/pure/string-cooked.test.ts | 4 +- 57 files changed, 1257 insertions(+), 124 deletions(-) create mode 100644 packages/core-js/types/proposals/object-from-entries.d.ts create mode 100644 tests/type-definitions/proposals/global/accessible-object-hasownproperty.test.ts create mode 100644 tests/type-definitions/proposals/global/array-buffer-transfer.test.ts create mode 100644 tests/type-definitions/proposals/global/array-find-from-last.test.ts create mode 100644 tests/type-definitions/proposals/global/array-flat-map.test.ts create mode 100644 tests/type-definitions/proposals/global/array-grouping.test.ts create mode 100644 tests/type-definitions/proposals/global/array-includes.test.ts create mode 100644 tests/type-definitions/proposals/global/async-iteration.test.ts create mode 100644 tests/type-definitions/proposals/global/change-array-by-copy.test.ts create mode 100644 tests/type-definitions/proposals/global/object-from-entries.test.ts create mode 100644 tests/type-definitions/proposals/pure/accessible-object-hasownproperty.test.ts create mode 100644 tests/type-definitions/proposals/pure/array-filtering.test.ts create mode 100644 tests/type-definitions/proposals/pure/array-find-from-last.test.ts create mode 100644 tests/type-definitions/proposals/pure/array-flat-map.test.ts create mode 100644 tests/type-definitions/proposals/pure/array-grouping.test.ts create mode 100644 tests/type-definitions/proposals/pure/array-includes.test.ts create mode 100644 tests/type-definitions/proposals/pure/array-is-template-object.test.ts create mode 100644 tests/type-definitions/proposals/pure/array-unique.test.ts create mode 100644 tests/type-definitions/proposals/pure/async-iteration.test.ts create mode 100644 tests/type-definitions/proposals/pure/change-array-by-copy.test.ts create mode 100644 tests/type-definitions/proposals/pure/extractors.test.ts create mode 100644 tests/type-definitions/proposals/pure/iterator-helpers.test.ts create mode 100644 tests/type-definitions/proposals/pure/object-from-entries.test.ts diff --git a/packages/core-js/modules/es.array-buffer.transfer-to-fixed-length.js b/packages/core-js/modules/es.array-buffer.transfer-to-fixed-length.js index aee2a08f8bda..1ab7bba7df76 100644 --- a/packages/core-js/modules/es.array-buffer.transfer-to-fixed-length.js +++ b/packages/core-js/modules/es.array-buffer.transfer-to-fixed-length.js @@ -1,3 +1,4 @@ +// types: proposals/array-buffer-transfer 'use strict'; var $ = require('../internals/export'); var $transfer = require('../internals/array-buffer-transfer'); diff --git a/packages/core-js/modules/es.array-buffer.transfer.js b/packages/core-js/modules/es.array-buffer.transfer.js index ba6102c38127..2c487426c2eb 100644 --- a/packages/core-js/modules/es.array-buffer.transfer.js +++ b/packages/core-js/modules/es.array-buffer.transfer.js @@ -1,3 +1,4 @@ +// types: proposals/array-buffer-transfer 'use strict'; var $ = require('../internals/export'); var $transfer = require('../internals/array-buffer-transfer'); diff --git a/packages/core-js/modules/es.array.find-last-index.js b/packages/core-js/modules/es.array.find-last-index.js index 5ab5abf320a3..7adf109d6be5 100644 --- a/packages/core-js/modules/es.array.find-last-index.js +++ b/packages/core-js/modules/es.array.find-last-index.js @@ -1,3 +1,4 @@ +// types: proposals/array-find-from-last 'use strict'; var $ = require('../internals/export'); var $findLastIndex = require('../internals/array-iteration-from-last').findLastIndex; diff --git a/packages/core-js/modules/es.array.find-last.js b/packages/core-js/modules/es.array.find-last.js index 2c00b6046b54..5cf9529c8aa4 100644 --- a/packages/core-js/modules/es.array.find-last.js +++ b/packages/core-js/modules/es.array.find-last.js @@ -1,3 +1,4 @@ +// types: proposals/array-find-from-last 'use strict'; var $ = require('../internals/export'); var $findLast = require('../internals/array-iteration-from-last').findLast; diff --git a/packages/core-js/modules/es.array.flat-map.js b/packages/core-js/modules/es.array.flat-map.js index dcb63533b9a1..abaade46ac35 100644 --- a/packages/core-js/modules/es.array.flat-map.js +++ b/packages/core-js/modules/es.array.flat-map.js @@ -1,3 +1,4 @@ +// types: proposals/array-flat-map 'use strict'; // @dependency: es.array.unscopables.flat-map var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.array.flat.js b/packages/core-js/modules/es.array.flat.js index 0e1db6c00009..8c245665c395 100644 --- a/packages/core-js/modules/es.array.flat.js +++ b/packages/core-js/modules/es.array.flat.js @@ -1,3 +1,4 @@ +// types: proposals/array-flat-map 'use strict'; // @dependency: es.array.unscopables.flat var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.array.includes.js b/packages/core-js/modules/es.array.includes.js index 467fba27bee9..14b1e9b9b296 100644 --- a/packages/core-js/modules/es.array.includes.js +++ b/packages/core-js/modules/es.array.includes.js @@ -1,3 +1,4 @@ +// types: proposals/array-includes 'use strict'; var $ = require('../internals/export'); var $includes = require('../internals/array-includes'); diff --git a/packages/core-js/modules/es.array.to-reversed.js b/packages/core-js/modules/es.array.to-reversed.js index dd18d0634719..882a8f85351e 100644 --- a/packages/core-js/modules/es.array.to-reversed.js +++ b/packages/core-js/modules/es.array.to-reversed.js @@ -1,3 +1,4 @@ +// types: proposals/change-array-by-copy 'use strict'; var $ = require('../internals/export'); var toObject = require('../internals/to-object'); diff --git a/packages/core-js/modules/es.array.to-sorted.js b/packages/core-js/modules/es.array.to-sorted.js index 141b005c34da..1345019c756c 100644 --- a/packages/core-js/modules/es.array.to-sorted.js +++ b/packages/core-js/modules/es.array.to-sorted.js @@ -1,3 +1,4 @@ +// types: proposals/change-array-by-copy 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/es.array.to-spliced.js b/packages/core-js/modules/es.array.to-spliced.js index 3f533a0eee22..b3ea82afd286 100644 --- a/packages/core-js/modules/es.array.to-spliced.js +++ b/packages/core-js/modules/es.array.to-spliced.js @@ -1,3 +1,4 @@ +// types: proposals/change-array-by-copy 'use strict'; var $ = require('../internals/export'); var addToUnscopables = require('../internals/add-to-unscopables'); diff --git a/packages/core-js/modules/es.array.with.js b/packages/core-js/modules/es.array.with.js index 49d64ba1dcb0..3d3241632bf0 100644 --- a/packages/core-js/modules/es.array.with.js +++ b/packages/core-js/modules/es.array.with.js @@ -1,3 +1,4 @@ +// types: proposals/change-array-by-copy 'use strict'; var $ = require('../internals/export'); var lengthOfArrayLike = require('../internals/length-of-array-like'); diff --git a/packages/core-js/modules/es.map.group-by.js b/packages/core-js/modules/es.map.group-by.js index eee31dd2aca1..a15049fe69a6 100644 --- a/packages/core-js/modules/es.map.group-by.js +++ b/packages/core-js/modules/es.map.group-by.js @@ -1,3 +1,4 @@ +// types: proposals/array-grouping 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/es.object.from-entries.js b/packages/core-js/modules/es.object.from-entries.js index 321ae7d651d7..8276f14dbed8 100644 --- a/packages/core-js/modules/es.object.from-entries.js +++ b/packages/core-js/modules/es.object.from-entries.js @@ -1,3 +1,4 @@ +// types: proposals/object-from-entries 'use strict'; var $ = require('../internals/export'); var iterate = require('../internals/iterate'); diff --git a/packages/core-js/modules/es.object.group-by.js b/packages/core-js/modules/es.object.group-by.js index 67e909329c87..d17635abc873 100644 --- a/packages/core-js/modules/es.object.group-by.js +++ b/packages/core-js/modules/es.object.group-by.js @@ -1,3 +1,4 @@ +// types: proposals/array-grouping 'use strict'; var $ = require('../internals/export'); var createProperty = require('../internals/create-property'); diff --git a/packages/core-js/modules/es.object.has-own.js b/packages/core-js/modules/es.object.has-own.js index 974e60c3b609..fd33a1889b95 100644 --- a/packages/core-js/modules/es.object.has-own.js +++ b/packages/core-js/modules/es.object.has-own.js @@ -1,3 +1,4 @@ +// types: proposals/accessible-object-hasownproperty 'use strict'; var $ = require('../internals/export'); var hasOwn = require('../internals/has-own-property'); diff --git a/packages/core-js/modules/es.symbol.async-iterator.js b/packages/core-js/modules/es.symbol.async-iterator.js index 40d1930c1aa0..d343c338e3e4 100644 --- a/packages/core-js/modules/es.symbol.async-iterator.js +++ b/packages/core-js/modules/es.symbol.async-iterator.js @@ -1,3 +1,4 @@ +// types: proposals/async-iteration 'use strict'; var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/es.typed-array.to-reversed.js b/packages/core-js/modules/es.typed-array.to-reversed.js index 7242b54579b0..7ca0511586ef 100644 --- a/packages/core-js/modules/es.typed-array.to-reversed.js +++ b/packages/core-js/modules/es.typed-array.to-reversed.js @@ -1,3 +1,4 @@ +// types: proposals/change-array-by-copy 'use strict'; var lengthOfArrayLike = require('../internals/length-of-array-like'); var exportTypedArrayMethod = require('../internals/export-typed-array-method'); diff --git a/packages/core-js/modules/es.typed-array.to-sorted.js b/packages/core-js/modules/es.typed-array.to-sorted.js index c29966fc7822..f29f61e797b8 100644 --- a/packages/core-js/modules/es.typed-array.to-sorted.js +++ b/packages/core-js/modules/es.typed-array.to-sorted.js @@ -1,3 +1,4 @@ +// types: proposals/change-array-by-copy 'use strict'; var uncurryThis = require('../internals/function-uncurry-this'); var aCallable = require('../internals/a-callable'); diff --git a/packages/core-js/modules/es.typed-array.with.js b/packages/core-js/modules/es.typed-array.with.js index 2cd87fc9e3c4..c978b22c9244 100644 --- a/packages/core-js/modules/es.typed-array.with.js +++ b/packages/core-js/modules/es.typed-array.with.js @@ -1,3 +1,4 @@ +// types: proposals/change-array-by-copy 'use strict'; var exportTypedArrayMethod = require('../internals/export-typed-array-method'); var aTypedArray = require('../internals/a-typed-array'); diff --git a/packages/core-js/types/proposals/array-buffer-transfer.d.ts b/packages/core-js/types/proposals/array-buffer-transfer.d.ts index 59979863ea69..880c74f238da 100644 --- a/packages/core-js/types/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js/types/proposals/array-buffer-transfer.d.ts @@ -1,7 +1,8 @@ // proposal stage: 4 // https://github.com/tc39/proposal-arraybuffer-transfer interface ArrayBuffer { - readonly detached: boolean; + // todo hack for modern ts + // get detached(): boolean; transfer(newByteLength?: number): ArrayBuffer; transferToFixedLength(newByteLength?: number): ArrayBuffer; diff --git a/packages/core-js/types/proposals/extractors.d.ts b/packages/core-js/types/proposals/extractors.d.ts index 63b2c5d2c2b2..f50296ec0c8c 100644 --- a/packages/core-js/types/proposals/extractors.d.ts +++ b/packages/core-js/types/proposals/extractors.d.ts @@ -1,5 +1,5 @@ // proposal stage: 1 // https://github.com/tc39/proposal-extractors interface SymbolConstructor { - readonly customExtractor: unique symbol; + readonly customMatcher: unique symbol; } diff --git a/packages/core-js/types/proposals/iterator-helpers.d.ts b/packages/core-js/types/proposals/iterator-helpers.d.ts index 7c33e2235ef1..94b74f3e9efa 100644 --- a/packages/core-js/types/proposals/iterator-helpers.d.ts +++ b/packages/core-js/types/proposals/iterator-helpers.d.ts @@ -18,7 +18,7 @@ declare global { drop(count: number): CoreJsIteratorObject; - flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJsIteratorObject; + flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJsIteratorObject; // ts < 5.6 Iterable reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; @@ -38,3 +38,9 @@ declare global { } export {}; + +export interface Methods { + map: (callback: (value: T, index: number) => U) => CoreJsIteratorObject; + flatMap: (callback: (value: T, index: number) => Iterator | Iterable) => CoreJsIteratorObject; + reduce: (callback: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; +} diff --git a/packages/core-js/types/proposals/object-from-entries.d.ts b/packages/core-js/types/proposals/object-from-entries.d.ts new file mode 100644 index 000000000000..a4b46b1d81a3 --- /dev/null +++ b/packages/core-js/types/proposals/object-from-entries.d.ts @@ -0,0 +1,12 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-object-from-entries + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d8aafb3197ebecd7faf919eaa39e77c5805cbff8/src/lib/es2019.object.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface ObjectConstructor { + fromEntries(entries: Iterable): { [k: string]: T; }; + + fromEntries(entries: Iterable): any; +} diff --git a/tests/type-definitions/entries.import.ts b/tests/type-definitions/entries.import.ts index 53bf1cb3aa96..a64bd2287dbf 100644 --- a/tests/type-definitions/entries.import.ts +++ b/tests/type-definitions/entries.import.ts @@ -29,8 +29,8 @@ arrayVirtualIterator.call([1, 2, 3], 1); // $uncurried import arrayAt from '@core-js/pure/full/array/at'; -const arrayAtResult1: number = arrayAt([1, 2, 3], -2); -const arrayAtResult2: string = arrayAt(['a', 'b'], -2); +const arrayAtResult1: number|undefined = arrayAt([1, 2, 3], -2); +const arrayAtResult2: string|undefined = arrayAt(['a', 'b'], -2); const arrayAtResult3: undefined = arrayAt([], 1); // @ts-expect-error arrayAt([1, 2], 'string'); @@ -127,5 +127,3 @@ iFlags(); // $proposal import '@core-js/pure/proposals/accessible-object-hasownproperty'; -// @ts-expect-error it has no exports -import pahp from '@core-js/pure/proposals/accessible-object-hasownproperty'; diff --git a/tests/type-definitions/proposals/global/accessible-object-hasownproperty.test.ts b/tests/type-definitions/proposals/global/accessible-object-hasownproperty.test.ts new file mode 100644 index 000000000000..b01a6f0c1a06 --- /dev/null +++ b/tests/type-definitions/proposals/global/accessible-object-hasownproperty.test.ts @@ -0,0 +1,20 @@ +import 'core-js/full'; + +Object.hasOwn({a: 1}, 'a'); +Object.hasOwn([], 0); +Object.hasOwn(new Date(), 'toISOString'); +Object.hasOwn(Object.create(null), Symbol.iterator); +Object.hasOwn(function(){}, 'call'); +Object.hasOwn(Object.prototype, 'toString'); + +// @ts-expect-error +Object.hasOwn(1, 'a'); + +// @ts-expect-error +Object.hasOwn({a: 1}, {}); + +// @ts-expect-error +Object.hasOwn({a: 1}); + +// @ts-expect-error +Object.hasOwn(); diff --git a/tests/type-definitions/proposals/global/array-buffer-transfer.test.ts b/tests/type-definitions/proposals/global/array-buffer-transfer.test.ts new file mode 100644 index 000000000000..1545e883d570 --- /dev/null +++ b/tests/type-definitions/proposals/global/array-buffer-transfer.test.ts @@ -0,0 +1,28 @@ +import 'core-js/full'; + +const ab = new ArrayBuffer(16); +// todo uncomment when fixed +// const abDetached: boolean = ab.detached; +const abTransfer: ArrayBuffer = ab.transfer(); +const abTransfer2: ArrayBuffer = ab.transfer(32); +const abTransferFixed: ArrayBuffer = ab.transferToFixedLength(); +const abTransferFixed2: ArrayBuffer = ab.transferToFixedLength(64); + +// Некорректные вызовы + +// @ts-expect-error +ab.detached(1); +// @ts-expect-error +ab.detached = true; +// @ts-expect-error +ab.transfer('32'); +// @ts-expect-error +ab.transfer(true); +// @ts-expect-error +ab.transfer(16, 32); +// @ts-expect-error +ab.transferToFixedLength('100'); +// @ts-expect-error +ab.transferToFixedLength(false); +// @ts-expect-error +ab.transferToFixedLength(32, 64); diff --git a/tests/type-definitions/proposals/global/array-filtering.test.ts b/tests/type-definitions/proposals/global/array-filtering.test.ts index 161f77d66a14..397e10704e9e 100644 --- a/tests/type-definitions/proposals/global/array-filtering.test.ts +++ b/tests/type-definitions/proposals/global/array-filtering.test.ts @@ -1,29 +1,23 @@ import 'core-js/full'; -function testFilterReject(arr: TArr & { filterReject: any }, _: TValue) { - const res: typeof arr = arr.filterReject((x: TValue) => false); - - arr.filterReject(function(value: TValue, index: number, target: typeof arr) { - return false; - }); - - arr.filterReject(function(this: { test: string }, value: TValue) { - return false; - }, { test: 'hello' }); -} - -testFilterReject([1, 2, 3], 1); -testFilterReject(new Int8Array([1, 2]), 1); -testFilterReject(new Uint8Array([1, 2]), 1); -testFilterReject(new Uint8ClampedArray([1, 2]), 1); -testFilterReject(new Int16Array([1, 2]), 1); -testFilterReject(new Uint16Array([1, 2]), 1); -testFilterReject(new Int32Array([1, 2]), 1); -testFilterReject(new Uint32Array([1, 2]), 1); -testFilterReject(new Float32Array([1, 2]), 1); -testFilterReject(new Float64Array([1, 2]), 1); -testFilterReject(new BigInt64Array([BigInt(1), BigInt(2)]), BigInt(1)); -testFilterReject(new BigUint64Array([BigInt(1), BigInt(2)]), BigInt(1)); +[1, 2, 3].filterReject((v, i, arr) => v > 1); +['a', 'b'].filterReject((v, i, arr) => v === 'a'); +const arr: number[] = [1, 2, 3]; +const res: number[] = arr.filterReject(function(v) { return v < 2; }, { foo: true }); + + +(new Int8Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); +(new Uint8Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); +(new Uint8ClampedArray([1, 2, 3])).filterReject((v, i, arr) => v > 1); +(new Int16Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); +(new Uint16Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); +(new Int32Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); +(new Uint32Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); +(new Float32Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); +(new Float64Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); + +(new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((v, i, arr) => v > BigInt(1)); +(new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((v, i, arr) => v > BigInt(1)); // @ts-expect-error [1, 2, 3].filterReject((x: string) => false); diff --git a/tests/type-definitions/proposals/global/array-find-from-last.test.ts b/tests/type-definitions/proposals/global/array-find-from-last.test.ts new file mode 100644 index 000000000000..8757648c21b7 --- /dev/null +++ b/tests/type-definitions/proposals/global/array-find-from-last.test.ts @@ -0,0 +1,52 @@ +import 'core-js/full'; + +const res: number | undefined = [1, 2, 3].findLast(v => v > 1); +[1, 2, 3].findLast((v): v is 2 => v === 2); +['a', 'b', 'c'].findLast(v => v === 'b'); +['a', 'b', 'c'].findLast((v): v is 'b' => v === 'b'); +[1, 2, 3].findLastIndex(v => v === 2); +const nums: number[] = [1, 2, 3]; +const res2: number | undefined = nums.findLast((v, i, arr) => v > 1 && arr.length > 0, {}); +nums.findLastIndex((v, i, arr) => v > 0, {}); +const m = ["a", 2, 3] as (string | number)[]; +m.findLast((v): v is string => typeof v === "string"); +(new Int8Array([1, 2, 3])).findLast(v => v > 0); +(new Int8Array([1, 2, 3])).findLast((v, i, arr) => v == i && arr instanceof Int8Array); +(new Int8Array([1, 2, 3])).findLastIndex(v => v > 0); +(new Int8Array([1, 2, 3])).findLast((v): v is 2 => v === 2); +(new Uint8Array([1, 2, 3])).findLast(v => v > 0); +(new Uint8Array([1, 2, 3])).findLastIndex(v => v < 0); +(new Float64Array([1, 2, 3])).findLast(v => v > 1.1); +(new Float64Array([1, 2, 3])).findLastIndex(v => v > 100); +(new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLast(v => v > BigInt(1)); +(new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLast((v): v is bigint => v === BigInt(2)); +(new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLastIndex(v => v > BigInt(0)); +(new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).findLast(v => v > BigInt(1)); +(new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).findLastIndex(v => v > BigInt(0)); + +// @ts-expect-error +[1, 2, 3].findLast(); + +// @ts-expect-error +[1, 2, 3].findLast('not function'); + +// @ts-expect-error +(new Int8Array([1, 2, 3])).findLast(); + +// @ts-expect-error +(new Int8Array([1, 2, 3])).findLast('not function'); + +// @ts-expect-error +(new Int8Array([1, 2, 3])).findLast((v: string) => false); + +// @ts-expect-error +(new BigInt64Array([BigInt(1)])).findLast((v: number) => false); + +// @ts-expect-error +[1, 2, 3].findLastIndex(); + +// @ts-expect-error +(new Float64Array([1, 2, 3])).findLastIndex(); + +// @ts-expect-error +(new Uint8Array([1, 2, 3])).findLastIndex('not function'); diff --git a/tests/type-definitions/proposals/global/array-flat-map.test.ts b/tests/type-definitions/proposals/global/array-flat-map.test.ts new file mode 100644 index 000000000000..8ae7007f3a6d --- /dev/null +++ b/tests/type-definitions/proposals/global/array-flat-map.test.ts @@ -0,0 +1,40 @@ +import 'core-js/full'; + +const flatMapped: number[] = [1, 2, 3].flatMap(x => [x, x * 2]); +const flatMapped2: string[] = ['a', 'b', 'c'].flatMap(x => [x, x.toUpperCase()]); +[1, 2, 3].flatMap(x => x > 1 ? [x, x] : []); +[1, 2, 3].flatMap(function (x) { return [this, x]; }, 123); +[1, 2, 3].flatMap((x, i, arr) => arr); + +const flatted: number[] = [[1], [2], [3]].flat(); +const flatted2: (string[] | string)[] = ['a', ['b', ['c']]].flat(); +[[1], [2], [3]].flat(2); +[1, [2, [3, [4]]]].flat(2); +[1, 2, 3].flat(); +[1, 2, 3].flat(0); + +const arr = [[1, 2], [3, 4], [5, 6]]; +arr.flat(); +arr.flat(1); +arr.flat(2); + +const arr2: (number | number[])[] = [1, [2, 3], 4]; +arr2.flat(); + +const arr3: (string | string[])[] = ['a', ['b', 'c'], 'd']; +arr3.flat(); + +([[[[1]]]] as number[][][][]).flat(3); + +// @ts-expect-error +[1, 2, 3].flatMap(); +// @ts-expect-error +[1, 2, 3].flatMap(123); +// @ts-expect-error +[1, 2, 3].flatMap('not function'); +// @ts-expect-error +([1, 2, 3] as any[]).flat('not a number'); +// @ts-expect-error +[1, 2, 3].flatMap(x => x, 1, 2); +// @ts-expect-error +[1, 2, 3].flat(1, 2); diff --git a/tests/type-definitions/proposals/global/array-grouping.test.ts b/tests/type-definitions/proposals/global/array-grouping.test.ts new file mode 100644 index 000000000000..22380f95d21a --- /dev/null +++ b/tests/type-definitions/proposals/global/array-grouping.test.ts @@ -0,0 +1,33 @@ +import 'core-js/full'; + +const arr = [1, 2, 3, 4, 5]; +const objGroup: Partial> = Object.groupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); +const mapGroup: Map<'even' | 'odd', number[]> = Map.groupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); +const objGroup2: Partial> = Object.groupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); +const mapGroup2: Map = Map.groupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); + +Object.groupBy('test', c => c); +Object.groupBy(new Set([1, 2, 3]), item => item > 2 ? 'big' : 'small'); +Object.groupBy([], _ => 'x'); + +Map.groupBy('hello', c => c.charCodeAt(0)); +Map.groupBy(new Set(['a', 'b', 'c']), (x, i) => i); + +// @ts-expect-error +Object.groupBy(); +// @ts-expect-error +Object.groupBy([1,2,3]); +// @ts-expect-error +Object.groupBy([1,2,3], 123); +// @ts-expect-error +Object.groupBy(123, x => x); +// @ts-expect-error +Object.groupBy([1,2,3], (a, b, c) => a); +// @ts-expect-error +Map.groupBy(); +// @ts-expect-error +Map.groupBy([1,2,3]); +// @ts-expect-error +Map.groupBy(123, x => x); +// @ts-expect-error +Map.groupBy([1,2,3], (a, b, c) => a); diff --git a/tests/type-definitions/proposals/global/array-includes.test.ts b/tests/type-definitions/proposals/global/array-includes.test.ts new file mode 100644 index 000000000000..90dfbae0bc2a --- /dev/null +++ b/tests/type-definitions/proposals/global/array-includes.test.ts @@ -0,0 +1,122 @@ +import 'core-js/full'; + +const arr: number[] = [1, 2, 3]; +const arrRes: boolean = arr.includes(2); +const arrRes2: boolean = arr.includes(2, 1); + +const strArr: string[] = ['a', 'b', 'c']; +const strArrRes: boolean = strArr.includes('b'); +const strArrRes2: boolean = strArr.includes('b', 1); + +const i8 = new Int8Array([1, 2, 3]); +const i8Res: boolean = i8.includes(2); +const i8Res2: boolean = i8.includes(2, 1); + +const u8 = new Uint8Array([1, 2, 3]); +const u8Res: boolean = u8.includes(2); +const u8Res2: boolean = u8.includes(2, 1); + +const u8c = new Uint8ClampedArray([1, 2, 3]); +const u8cRes: boolean = u8c.includes(2); +const u8cRes2: boolean = u8c.includes(2, 1); + +const i16 = new Int16Array([1, 2, 3]); +const i16Res: boolean = i16.includes(2); +const i16Res2: boolean = i16.includes(2, 1); + +const u16 = new Uint16Array([1, 2, 3]); +const u16Res: boolean = u16.includes(2); +const u16Res2: boolean = u16.includes(2, 1); + +const i32 = new Int32Array([1, 2, 3]); +const i32Res: boolean = i32.includes(2); +const i32Res2: boolean = i32.includes(2, 1); + +const u32 = new Uint32Array([1, 2, 3]); +const u32Res: boolean = u32.includes(2); +const u32Res2: boolean = u32.includes(2, 1); + +const f32 = new Float32Array([1.5, 2.5, 3.5]); +const f32Res: boolean = f32.includes(2.5); +const f32Res2: boolean = f32.includes(2.5, 1); + +const f64 = new Float64Array([1.5, 2.5, 3.5]); +const f64Res: boolean = f64.includes(2.5); +const f64Res2: boolean = f64.includes(2.5, 1); + +const bi64 = new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)]); +const bi64Res: boolean = bi64.includes(BigInt(2)); +const bi64Res2: boolean = bi64.includes(BigInt(2), 1); + +const bu64 = new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)]); +const bu64Res: boolean = bu64.includes(BigInt(2)); +const bu64Res2: boolean = bu64.includes(BigInt(2), 1); + +// @ts-expect-error +arr.includes(); +// @ts-expect-error +arr.includes(1, '2'); + +// @ts-expect-error +strArr.includes(2); +// @ts-expect-error +strArr.includes('b', true); + +// @ts-expect-error +i8.includes('2'); +// @ts-expect-error +i8.includes(2, '1'); + +// @ts-expect-error +u8.includes('2'); +// @ts-expect-error +u8.includes(2, true); + +// @ts-expect-error +u8c.includes('2'); +// @ts-expect-error +u8c.includes(2, {}); + +// @ts-expect-error +i16.includes('2'); +// @ts-expect-error +i16.includes(2, []); + +// @ts-expect-error +u16.includes('2'); +// @ts-expect-error +u16.includes(2, ''); + +// @ts-expect-error +i32.includes('2'); +// @ts-expect-error +i32.includes(2, undefined, 42); + +// @ts-expect-error +u32.includes('2'); +// @ts-expect-error +u32.includes(2, 1, 2); + +// @ts-expect-error +f32.includes('2.5'); +// @ts-expect-error +f32.includes(2.5, '1'); + +// @ts-expect-error +f64.includes('2.5'); +// @ts-expect-error +f64.includes(2.5, []); + +// @ts-expect-error +bi64.includes(2); +// @ts-expect-error +bi64.includes(2n, '1'); +// @ts-expect-error +bi64.includes('2n'); + +// @ts-expect-error +bu64.includes(2); +// @ts-expect-error +bu64.includes(2n, []); +// @ts-expect-error +bu64.includes('2n'); diff --git a/tests/type-definitions/proposals/global/array-unique.test.ts b/tests/type-definitions/proposals/global/array-unique.test.ts index 7c3afc53aee4..9c380fafa6d2 100644 --- a/tests/type-definitions/proposals/global/array-unique.test.ts +++ b/tests/type-definitions/proposals/global/array-unique.test.ts @@ -1,27 +1,137 @@ import 'core-js/full'; -function testTypedArrayUniqueBy( - arr: { uniqueBy(resolver?: PropertyKey | ((value: T) => any)): any }, - key: PropertyKey -) { - arr.uniqueBy(); - arr.uniqueBy(key); - arr.uniqueBy((x: T) => x); - // @ts-expect-error - arr.uniqueBy({}); - // @ts-expect-error - arr.uniqueBy((x: T) => x['notExist']); -} - -testTypedArrayUniqueBy([{ id: '1', bar: '1' }, { id: '2', bar: '2' }, { id: '3', bar: '2' }], 'bar'); -testTypedArrayUniqueBy(new Int8Array([1, 2, 3]), 1); -testTypedArrayUniqueBy(new Uint8Array([1, 2, 3]), 1); -testTypedArrayUniqueBy(new Uint8ClampedArray([1, 2, 3]), 1); -testTypedArrayUniqueBy(new Int16Array([1, 2, 3]), 1); -testTypedArrayUniqueBy(new Uint16Array([1, 2, 3]), 1); -testTypedArrayUniqueBy(new Int32Array([1, 2, 3]), 1); -testTypedArrayUniqueBy(new Uint32Array([1, 2, 3]), 1); -testTypedArrayUniqueBy(new Float32Array([1.0, 2.2, 3.0]), 1); -testTypedArrayUniqueBy(new Float64Array([1.0, 2.2, 3.0]), 1); -testTypedArrayUniqueBy(new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)]), 1); -testTypedArrayUniqueBy(new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)]), 1); +type Obj = { a: number; b: string }; +const arr: Obj[] = [{ a: 1, b: 'x' }, { a: 2, b: 'y' }]; +const arrRes: Obj[] = arr.uniqueBy(); +const arrRes2: Obj[] = arr.uniqueBy('a'); +const arrRes3: Obj[] = arr.uniqueBy(obj => obj.b); + +const numArr: number[] = [1, 2, 1, 3]; +const numArrRes: number[] = numArr.uniqueBy(); +const numArrRes2: number[] = numArr.uniqueBy(x => x % 2); + +const i8 = new Int8Array([1, 2, 2, 3]); +const i8Res: Int8Array = i8.uniqueBy(); +const i8Res2: Int8Array = i8.uniqueBy('length'); +const i8Res3: Int8Array = i8.uniqueBy(x => x % 2); + +const u8 = new Uint8Array([1, 2, 2, 3]); +const u8Res: Uint8Array = u8.uniqueBy(); +const u8Res2: Uint8Array = u8.uniqueBy('buffer'); +const u8Res3: Uint8Array = u8.uniqueBy(x => x * 2); + +const u8c = new Uint8ClampedArray([1, 1, 2, 3]); +const u8cRes: Uint8ClampedArray = u8c.uniqueBy(); +const u8cRes2: Uint8ClampedArray = u8c.uniqueBy('byteOffset'); +const u8cRes3: Uint8ClampedArray = u8c.uniqueBy(x => x); + +const i16 = new Int16Array([1, 1, 2, 3]); +const i16Res: Int16Array = i16.uniqueBy(); +const i16Res2: Int16Array = i16.uniqueBy('BYTES_PER_ELEMENT'); +const i16Res3: Int16Array = i16.uniqueBy(x => x); + +const u16 = new Uint16Array([1, 2, 2, 3]); +const u16Res: Uint16Array = u16.uniqueBy(); +const u16Res2: Uint16Array = u16.uniqueBy('buffer'); +const u16Res3: Uint16Array = u16.uniqueBy(x => x + 1); + +const i32 = new Int32Array([1, 2, 2, 3]); +const i32Res: Int32Array = i32.uniqueBy(); +const i32Res2: Int32Array = i32.uniqueBy('byteLength'); +const i32Res3: Int32Array = i32.uniqueBy(x => x); + +const u32 = new Uint32Array([1, 1, 2, 3]); +const u32Res: Uint32Array = u32.uniqueBy(); +const u32Res2: Uint32Array = u32.uniqueBy('length'); +const u32Res3: Uint32Array = u32.uniqueBy(x => x % 2); + +const f32 = new Float32Array([1.5, 2.5, 1.5, 3.5]); +const f32Res: Float32Array = f32.uniqueBy(); +const f32Res2: Float32Array = f32.uniqueBy('constructor'); +const f32Res3: Float32Array = f32.uniqueBy(x => Math.floor(x)); + +const f64 = new Float64Array([1.5, 2.5, 1.5, 3.5]); +const f64Res: Float64Array = f64.uniqueBy(); +const f64Res2: Float64Array = f64.uniqueBy('length'); +const f64Res3: Float64Array = f64.uniqueBy(x => x.toFixed(1)); + +const bi64 = new BigInt64Array([BigInt(1), BigInt(2), BigInt(1), BigInt(3)]); +const bi64Res: BigInt64Array = bi64.uniqueBy(); +const bi64Res2: BigInt64Array = bi64.uniqueBy('length'); +const bi64Res3: BigInt64Array = bi64.uniqueBy(x => (x as bigint) % BigInt(2)); + +const bu64 = new BigUint64Array([BigInt(1), BigInt(2), BigInt(1), BigInt(3)]); +const bu64Res: BigUint64Array = bu64.uniqueBy(); +const bu64Res2: BigUint64Array = bu64.uniqueBy('length'); +const bu64Res3: BigUint64Array = bu64.uniqueBy(x => (x as bigint) * BigInt(3)); + +// @ts-expect-error +arr.uniqueBy(123); +// @ts-expect-error +arr.uniqueBy(true); +// @ts-expect-error +arr.uniqueBy({}); +// @ts-expect-error +arr.uniqueBy(['a']); + +// @ts-expect-error +numArr.uniqueBy(1); +// @ts-expect-error +numArr.uniqueBy({}); +// @ts-expect-error +numArr.uniqueBy(true); + +// @ts-expect-error +i8.uniqueBy([]); +// @ts-expect-error +i8.uniqueBy({}); + +// @ts-expect-error +u8.uniqueBy([]); +// @ts-expect-error +u8.uniqueBy(false); + +// @ts-expect-error +u8c.uniqueBy([]); +// @ts-expect-error +u8c.uniqueBy(undefined, 1); + +// @ts-expect-error +i16.uniqueBy([]); +// @ts-expect-error +i16.uniqueBy(function(x: string) { return x; }); + +// @ts-expect-error +u16.uniqueBy([]); +// @ts-expect-error +u16.uniqueBy(false); + +// @ts-expect-error +i32.uniqueBy([]); +// @ts-expect-error +i32.uniqueBy({}); + +// @ts-expect-error +u32.uniqueBy([]); +// @ts-expect-error +u32.uniqueBy(false); + +// @ts-expect-error +f32.uniqueBy([]); +// @ts-expect-error +f32.uniqueBy({}); + +// @ts-expect-error +f64.uniqueBy([]); +// @ts-expect-error +f64.uniqueBy(false); + +// @ts-expect-error +bi64.uniqueBy([]); +// @ts-expect-error +bi64.uniqueBy({}); + +// @ts-expect-error +bu64.uniqueBy([]); +// @ts-expect-error +bu64.uniqueBy({}); diff --git a/tests/type-definitions/proposals/global/async-iteration.test.ts b/tests/type-definitions/proposals/global/async-iteration.test.ts new file mode 100644 index 000000000000..1f96b012de28 --- /dev/null +++ b/tests/type-definitions/proposals/global/async-iteration.test.ts @@ -0,0 +1,10 @@ +import 'core-js/full'; + +const aiter: symbol = Symbol.asyncIterator; +const sym: symbol = Symbol.asyncIterator; +const s: typeof Symbol.asyncIterator = Symbol.asyncIterator; + +// @ts-expect-error +const bad1: string = Symbol.asyncIterator; +// @ts-expect-error +Symbol['asyncIterator'] = Symbol("other"); diff --git a/tests/type-definitions/proposals/global/async-iterator-helper.test.ts b/tests/type-definitions/proposals/global/async-iterator-helper.test.ts index ee638f8066c6..4936798114c7 100644 --- a/tests/type-definitions/proposals/global/async-iterator-helper.test.ts +++ b/tests/type-definitions/proposals/global/async-iterator-helper.test.ts @@ -1,10 +1,10 @@ import 'core-js/full'; -AsyncIterator.from([1, 2, 3]); -AsyncIterator.from(new Set([1, 2, 3])); +const res: AsyncIterator = AsyncIterator.from([1, 2, 3]); +const res2: AsyncIterator = AsyncIterator.from(new Set([1, 2, 3])); AsyncIterator.from((async function* () { yield 1; yield 2; })()); AsyncIterator.from((function* () { yield 3; })()); -AsyncIterator.from('abc'); +const res3: AsyncIterator = AsyncIterator.from('abc'); declare const ain: AsyncIterator; declare const aio: AsyncIterator<{ x: number }>; diff --git a/tests/type-definitions/proposals/global/change-array-by-copy.test.ts b/tests/type-definitions/proposals/global/change-array-by-copy.test.ts new file mode 100644 index 000000000000..5f60d1759ff5 --- /dev/null +++ b/tests/type-definitions/proposals/global/change-array-by-copy.test.ts @@ -0,0 +1,186 @@ +import 'core-js/full'; + +const arr: number[] = [1, 2, 3]; +const arrRev: number[] = arr.toReversed(); +const arrSorted: number[] = arr.toSorted(); +const arrSorted2: number[] = arr.toSorted((a, b) => b - a); +const arrSpliced: number[] = arr.toSpliced(1, 1, 4, 5); +const arrSpliced2: number[] = arr.toSpliced(1); +const arrSpliced3: number[] = arr.toSpliced(1, 2); +const arrWith: number[] = arr.with(1, 42); + +const sarr: string[] = ['a', 'b', 'c']; +const sarrRev: string[] = sarr.toReversed(); +const sarrSorted: string[] = sarr.toSorted(); +const sarrWith: string[] = sarr.with(0, 'z'); +const sarrSpliced: string[] = sarr.toSpliced(0, 1, 'x'); + +const i8 = new Int8Array([1, 2, 3]); +const i8Rev: Int8Array = i8.toReversed(); +const i8Sorted: Int8Array = i8.toSorted(); +const i8Sorted2: Int8Array = i8.toSorted((a, b) => b - a); +const i8With: Int8Array = i8.with(0, 10); + +const u8 = new Uint8Array([1,2,3]); +const u8Rev: Uint8Array = u8.toReversed(); +const u8Sorted: Uint8Array = u8.toSorted(); +const u8Sorted2: Uint8Array = u8.toSorted((a, b) => a - b); +const u8With: Uint8Array = u8.with(1, 42); + +const u8c = new Uint8ClampedArray([1,2,3]); +const u8cRev: Uint8ClampedArray = u8c.toReversed(); +const u8cSorted: Uint8ClampedArray = u8c.toSorted(); +const u8cSorted2: Uint8ClampedArray = u8c.toSorted((a, b) => b - a); +const u8cWith: Uint8ClampedArray = u8c.with(1, 99); + +const i16 = new Int16Array([1,2,3]); +const i16Rev: Int16Array = i16.toReversed(); +const i16Sorted: Int16Array = i16.toSorted(); +const i16With: Int16Array = i16.with(1, 2); + +const u16 = new Uint16Array([1,2,3]); +const u16Rev: Uint16Array = u16.toReversed(); +const u16Sorted: Uint16Array = u16.toSorted(); +const u16With: Uint16Array = u16.with(1, 2); + +const i32 = new Int32Array([1,2,3]); +const i32Rev: Int32Array = i32.toReversed(); +const i32Sorted: Int32Array = i32.toSorted(); +const i32With: Int32Array = i32.with(1, 2); + +const u32 = new Uint32Array([1,2,3]); +const u32Rev: Uint32Array = u32.toReversed(); +const u32Sorted: Uint32Array = u32.toSorted(); +const u32With: Uint32Array = u32.with(1, 2); + +const f32 = new Float32Array([1.1, 2.2, 3.3]); +const f32Rev: Float32Array = f32.toReversed(); +const f32Sorted: Float32Array = f32.toSorted(); +const f32With: Float32Array = f32.with(1, 8.8); + +const f64 = new Float64Array([1.1, 2.2, 3.3]); +const f64Rev: Float64Array = f64.toReversed(); +const f64Sorted: Float64Array = f64.toSorted(); +const f64With: Float64Array = f64.with(0, 2.2); + +const bi64 = new (BigInt64Array as { new(arr: ArrayLike): BigInt64Array })([BigInt(1), BigInt(2), BigInt(3)]); +const bi64Rev: BigInt64Array = bi64.toReversed(); +const bi64Sorted: BigInt64Array = bi64.toSorted(); +const bi64Sorted2: BigInt64Array = bi64.toSorted((a, b) => (a > b ? 1 : -1)); +const bi64With: BigInt64Array = bi64.with(2, BigInt(100)); + +const bu64 = new (BigUint64Array as { new(arr: ArrayLike): BigUint64Array })([BigInt(1), BigInt(2), BigInt(3)]); +const bu64Rev: BigUint64Array = bu64.toReversed(); +const bu64Sorted: BigUint64Array = bu64.toSorted(); +const bu64Sorted2: BigUint64Array = bu64.toSorted((a, b) => (a > b ? 1 : -1)); +const bu64With: BigUint64Array = bu64.with(0, BigInt(50)); + +// @ts-expect-error +arr.toReversed(1); +// @ts-expect-error +arr.toSorted('string'); +// @ts-expect-error +arr.toSorted((a: number, b: string) => 0); +// @ts-expect-error +arr.toSpliced(); +// @ts-expect-error +arr.toSpliced('1', 1); +// @ts-expect-error +arr.toSpliced(1, '1'); +// @ts-expect-error +arr.with(); +// @ts-expect-error +arr.with(1); +// @ts-expect-error +arr.with('1', 2); + +const barr: boolean[] = [true, false]; +// @ts-expect-error +barr.toSorted((a: number, b: number) => 0); +// @ts-expect-error +barr.with(0, 1); + +const arrStr: string[] = ['a', 'b']; +// @ts-expect-error +arrStr.with(0, 1); + +// @ts-expect-error +i8.toReversed(1); +// @ts-expect-error +i8.toSorted(''); +// @ts-expect-error +i8.toSorted((a: string, b: string) => 0); +// @ts-expect-error +i8.with(); +// @ts-expect-error +i8.with('1', 1); +// @ts-expect-error +i8.with(0, '1'); + + +// @ts-expect-error +u8.toReversed(1); +// @ts-expect-error +u8.toSorted('str'); +// @ts-expect-error +u8.with(0, 'v'); + + +// @ts-expect-error +u8c.toSorted('str'); +// @ts-expect-error +u8c.with(0, '1'); + +// @ts-expect-error +i16.toReversed('1'); +// @ts-expect-error +i16.toSorted((a: string, b: string) => 0); +// @ts-expect-error +i16.with(0, 'a'); + +// @ts-expect-error +u16.toReversed(null); +// @ts-expect-error +u16.toSorted('a'); +// @ts-expect-error +u16.with(0, 'a'); + +// @ts-expect-error +i32.toSorted([]); +// @ts-expect-error +i32.with('test', 1); +// @ts-expect-error +i32.with(1, 'foo'); + +// @ts-expect-error +u32.with('0', 0); +// @ts-expect-error +u32.with(1, 'foo'); + +// @ts-expect-error +f32.toReversed('abc'); +// @ts-expect-error +f32.with(0, 'a'); + +// @ts-expect-error +f64.toSorted(1,2); +// @ts-expect-error +f64.with('a', 1); + +// @ts-expect-error +bi64.toReversed(1); +// @ts-expect-error +bi64.toSorted('f'); +// @ts-expect-error +bi64.toSorted((a: number, b: number) => 0); +// @ts-expect-error +bi64.with(1, 1); +// @ts-expect-error +bi64.with('a', BigInt(1)); + +// @ts-expect-error +bu64.toSorted({}); +// @ts-expect-error +bu64.with(0, 1); +// @ts-expect-error +bu64.with('abc', BigInt(1)); diff --git a/tests/type-definitions/proposals/global/collection-of-from.test.ts b/tests/type-definitions/proposals/global/collection-of-from.test.ts index a88f3d6d9d20..e5ac9f57c86c 100644 --- a/tests/type-definitions/proposals/global/collection-of-from.test.ts +++ b/tests/type-definitions/proposals/global/collection-of-from.test.ts @@ -1,66 +1,74 @@ import 'core-js/full'; -const rm: Map = Map.from([[1, 'a'], [2, 'b']]); -const rm2: Map = Map.from([[1, 10], [2, 20]], (v: number, k: number) => v + k); -Map.from([[1, 10], [2, 20]], function (this: { n: number }, v: number) { return v + this.n; }, { n: 2 }); +const arrEntries: Array<[string, number]> = [['a', 1], ['b', 2]]; +const mapFrom: Map = Map.from(arrEntries, v => String(v)); +const mapFrom2: Map = Map.from(arrEntries, v => v > 1); +const mapFrom3: Map = Map.from(arrEntries); +const mapOf: Map = Map.of(['a', 1], ['b', 2]); + +const setFrom: Set = Set.from(['a', 'b', 'c']); +const setFrom2: Set = Set.from([1, 2, 3], (v) => v * 2); +const setFrom3: Set = Set.from(['a', 'b', 'c'], String); +const setOf: Set = Set.of(1, 2, 3); + +const ws1 = {}; +const ws2 = {}; +const wsArr = [ws1, ws2]; +const weakSetFrom: WeakSet<{a?: number}> = WeakSet.from(wsArr); +const weakSetFrom2: WeakSet = WeakSet.from(wsArr, x => x); +const weakSetOf: WeakSet = WeakSet.of(ws1, ws2); + +const wmArr: Array<[object, string]> = [[ws1, 'a'], [ws2, 'b']]; +const weakMapFrom: WeakMap = WeakMap.from(wmArr); +const weakMapFrom2: WeakMap = WeakMap.from(wmArr, v => Number(v.length)); +const weakMapOf: WeakMap = WeakMap.of([ws1, 'a'], [ws2, 'b']); + +// @ts-expect-error +Map.from(); // @ts-expect-error -Map.from([['a', 1], ['b', 2]], (v: string, k: number) => v); +Map.from(123); // @ts-expect-error -Map.from([1, 2]); +Map.from([1, 2, 3]); // @ts-expect-error -Map.from(); - -Map.of(['a', 1], ['b', 2]); -const rm4: Map = Map.of(['a', 1], ['b', 2]); +Map.from(arrEntries, (a, b, c) => a); // @ts-expect-error -Map.of([1, 2, 3]); +Map.of(1, 2, 3); // @ts-expect-error -Map.of(1, 2); +Map.of(['a', 1], [2, 3, 4]); -const rs1: Set = Set.from([1, 2, 3]); -const rs2: Set = Set.from([1, 2, 3], x => x.toString()); -const rs3: Set<[string, number]> = Set.from([['a', 1], ['b', 2]]); -Set.from(['a', 'b'], function (this: { s: string }, value: string) { return value + this.s; }, { s: '-' }); -// @ts-expect-error -Set.from([1, 2, 3], (v: string) => v); // @ts-expect-error Set.from(); - -const rso1: Set = Set.of(1, 2, 3); -const rso2: Set = Set.of('a', 'b', 'c'); // @ts-expect-error -Set.of({ 'foo': 'bar' }, 2); +Set.from(123); +// @ts-expect-error +Set.from(['a', 'b'], 42); +// @ts-expect-error +Set.from(['a'], (value, index, extra) => value); +// @ts-expect-error +Set.of(1, 2, {}); -const rwm1: WeakMap<{ a: number }, string> = WeakMap.from([[{ a: 1 }, 'x']]); -const rwm2: WeakMap = WeakMap.from([[{}, 1], [{}, 2]], (v, k) => v.toString()); -WeakMap.from([[{}, 1], [{}, 2]], function (this: { s: string }, v: number) { return this.s + v; }, { s: '-' }); // @ts-expect-error -WeakMap.from([[1, 2], [2, 3]]); +WeakSet.from([1, 2]); // @ts-expect-error -WeakMap.from([[{}, 1], [{}, 2]], (v: string, k: string) => v); +WeakSet.from('notiterable'); // @ts-expect-error -WeakMap.from([1, 2]); +WeakSet.from(wsArr, 42); // @ts-expect-error -WeakMap.from(); - -const rwmo1: WeakMap = WeakMap.of([{}, 2]); +WeakSet.of(1, 2); // @ts-expect-error -WeakMap.of([1, 2]); +WeakSet.of('a'); // @ts-expect-error -WeakMap.of({}); +WeakSet.of({}, 42); -const rws1: WeakSet = WeakSet.from([{}]); -const rws2: WeakSet = WeakSet.from([{}, {}], x => x); -WeakSet.from([{}], function (this: { s: string }, obj: object) { return obj; }, { s: '-' }); // @ts-expect-error -WeakSet.from([1, 2]); +WeakMap.from([[1, 'a'], [2, 'b']]); // @ts-expect-error -WeakSet.from([{}], (v: number) => v); +WeakMap.from([['a', 1]]); // @ts-expect-error -WeakSet.from(); +WeakMap.from(wmArr, (v, k, x) => v); // @ts-expect-error -WeakSet.from([{}], x => 'not-an-object'); - -const rwso1: WeakSet = WeakSet.of({}); +WeakMap.of([{}, 'a'], [{}, 'b', 3]); +// @ts-expect-error +WeakMap.of([1, 2]); // @ts-expect-error -WeakSet.of(1); +WeakMap.of(['a', 'b']); diff --git a/tests/type-definitions/proposals/global/extractors.test.ts b/tests/type-definitions/proposals/global/extractors.test.ts index 8959fabf131b..13ee20e150fe 100644 --- a/tests/type-definitions/proposals/global/extractors.test.ts +++ b/tests/type-definitions/proposals/global/extractors.test.ts @@ -1,9 +1,9 @@ import 'core-js/full'; -const rscs1: symbol = Symbol.customExtractor; -const rscs2: typeof Symbol.customExtractor = Symbol.customExtractor; +const rscs1: symbol = Symbol.customMatcher; +const rscs2: typeof Symbol.customMatcher = Symbol.customMatcher; // @ts-expect-error -Symbol['customExtractor'] = Symbol("other"); +Symbol['customMatcher'] = Symbol("other"); // @ts-expect-error -const n: number = Symbol.customExtractor; +const n: number = Symbol.customMatcher; diff --git a/tests/type-definitions/proposals/global/iterator-helpers.test.ts b/tests/type-definitions/proposals/global/iterator-helpers.test.ts index a09d57d85543..ad4f2c52ed1b 100644 --- a/tests/type-definitions/proposals/global/iterator-helpers.test.ts +++ b/tests/type-definitions/proposals/global/iterator-helpers.test.ts @@ -1,6 +1,85 @@ import 'core-js/full'; -// -declare function getNumberIterator(): Iterator; -const iter = getNumberIterator(); -const res: Iterator = iter.map(n => n + 1); +declare const it: Iterator; +declare const itStr: Iterator; +declare const itNumStr: Iterator; + +const mappedStr: Iterator = it.map((v, i) => String(v)); +const mappedNum: Iterator = it.map(n => n + 1); + +// @ts-expect-error +it.map(); +// @ts-expect-error +it.map((v, i, extra) => v + i + extra); + +const onlyEven: Iterator = it.filter(v => v % 2 === 0); +const filtered: Iterator = it.filter((v): v is number => typeof v === 'number'); + +// @ts-expect-error +it.filter(); +// @ts-expect-error +it.filter((v, i, extra) => true); + +const taken: Iterator = it.take(5); + +// @ts-expect-error +it.take(); +// @ts-expect-error +it.take('5'); + +const dropped: Iterator = it.drop(3); + +// @ts-expect-error +it.drop('3'); + +const flatMapped: Iterator = it.flatMap((v, i) => itStr); +const flatMapped2: Iterator = it.flatMap((v, i) => ({ + [Symbol.iterator]: function* () { + yield String(v); + } +})); + +// @ts-expect-error +it.flatMap(); + +const sum1: number = it.reduce((a, b, c) => a + b + c); +const sum2: number = it.reduce((a, b, c) => a + b + c, 0); +const strReduce: string = it.reduce( + (acc: string, val) => acc + val, + '' +); + +// @ts-expect-error +it.reduce(); +// @ts-expect-error +it.reduce((a, b, c, d) => a); + +const arr: number[] = it.toArray(); + +it.forEach((value, idx) => { + const x: number = value; + const y: number = idx; +}); + +// @ts-expect-error +it.forEach(); + +const hasPositive: boolean = it.some((v, i) => v > 0); + +// @ts-expect-error +it.some(); +// @ts-expect-error +it.some((v, i, extra) => true); + +const allPositive: boolean = it.every((v, i) => v > 0); + +// @ts-expect-error +it.every(); +// @ts-expect-error +it.every((v, i, extra) => true); + +const found1: number | undefined = it.find((v, i) => v > 5); +const findString: string | undefined = itNumStr.find((v): v is string => typeof v === 'string'); + +// @ts-expect-error +it.find(); diff --git a/tests/type-definitions/proposals/global/iterator-sequencing.test.ts b/tests/type-definitions/proposals/global/iterator-sequencing.test.ts index f50e0d9a6a72..21a342cca779 100644 --- a/tests/type-definitions/proposals/global/iterator-sequencing.test.ts +++ b/tests/type-definitions/proposals/global/iterator-sequencing.test.ts @@ -18,7 +18,3 @@ Iterator.concat(1); Iterator.concat(true); // @ts-expect-error Iterator.concat({}); -// @ts-expect-error -Iterator.concat(null); -// @ts-expect-error -Iterator.concat(undefined); diff --git a/tests/type-definitions/proposals/global/object-from-entries.test.ts b/tests/type-definitions/proposals/global/object-from-entries.test.ts new file mode 100644 index 000000000000..3a2c20009b15 --- /dev/null +++ b/tests/type-definitions/proposals/global/object-from-entries.test.ts @@ -0,0 +1,27 @@ +import 'core-js/full'; + +declare const objEntries: Iterable; +declare const mixedEntries: Iterable; +declare const wrongEntries1: Iterable; +declare const wrongEntries2: number; +declare const notIterable: {}; + +const r1: { [k: string]: number } = Object.fromEntries(objEntries); +const r2: any = Object.fromEntries(mixedEntries); +const r3: any = Object.fromEntries([['a', 1], ['b', 2]]); +const r4: object = Object.fromEntries(new Map([ ['x', 1], ['y', 2] ])); + +// @ts-expect-error +Object.fromEntries(); + +// @ts-expect-error +Object.fromEntries(123); + +// @ts-expect-error +Object.fromEntries(wrongEntries1); + +// @ts-expect-error +Object.fromEntries(wrongEntries2); + +// @ts-expect-error +Object.fromEntries(notIterable); diff --git a/tests/type-definitions/proposals/global/string-cooked.test.ts b/tests/type-definitions/proposals/global/string-cooked.test.ts index 2f440f249886..d2884ba55d55 100644 --- a/tests/type-definitions/proposals/global/string-cooked.test.ts +++ b/tests/type-definitions/proposals/global/string-cooked.test.ts @@ -5,6 +5,6 @@ String.cooked(['foo', 'bar'], 1, 2); String.cooked([]); // @ts-expect-error -String.cooked([null]); +String.cooked(1); // @ts-expect-error -String.cooked([undefined]); +String.cooked(false); diff --git a/tests/type-definitions/proposals/pure/accessible-object-hasownproperty.test.ts b/tests/type-definitions/proposals/pure/accessible-object-hasownproperty.test.ts new file mode 100644 index 000000000000..5ba3431548ad --- /dev/null +++ b/tests/type-definitions/proposals/pure/accessible-object-hasownproperty.test.ts @@ -0,0 +1,20 @@ +import objectHasOwn from '@core-js/pure/full/object/has-own'; + +objectHasOwn({a: 1}, 'a'); +objectHasOwn([], 0); +objectHasOwn(new Date(), 'toISOString'); +objectHasOwn(Object.create(null), Symbol.iterator); +objectHasOwn(function(){}, 'call'); +objectHasOwn(Object.prototype, 'toString'); + +// @ts-expect-error +objectHasOwn(1, 'a'); + +// @ts-expect-error +objectHasOwn({a: 1}, {}); + +// @ts-expect-error +objectHasOwn({a: 1}); + +// @ts-expect-error +objectHasOwn(); diff --git a/tests/type-definitions/proposals/pure/array-filtering.test.ts b/tests/type-definitions/proposals/pure/array-filtering.test.ts new file mode 100644 index 000000000000..bb66099f102e --- /dev/null +++ b/tests/type-definitions/proposals/pure/array-filtering.test.ts @@ -0,0 +1,9 @@ +import arrayFilterReject from '@core-js/pure/full/array/filter-reject'; + +arrayFilterReject([1, 2, 3], (v, i, arr) => v > 1); +arrayFilterReject(['a', 'b'], (v, i, arr) => v === 'a'); +const arr: number[] = [1, 2, 3]; +const res: number[] = arrayFilterReject(arr, function(v) { return v < 2; }, { foo: true }); + +// @ts-expect-error +[1, 2, 3].arrayFilterReject((x: string) => false); diff --git a/tests/type-definitions/proposals/pure/array-find-from-last.test.ts b/tests/type-definitions/proposals/pure/array-find-from-last.test.ts new file mode 100644 index 000000000000..0780b370a0ff --- /dev/null +++ b/tests/type-definitions/proposals/pure/array-find-from-last.test.ts @@ -0,0 +1,23 @@ +import arrayFindLast from '@core-js/pure/full/array/find-last'; +import arrayFindLastIndex from '@core-js/pure/full/array/find-last-index'; + +const res: number | undefined = arrayFindLast([1, 2, 3], v => v > 1); +arrayFindLast([1, 2, 3], (v): v is 2 => v === 2); +arrayFindLast(['a', 'b', 'c'], v => v === 'b'); +arrayFindLast(['a', 'b', 'c'], (v): v is 'b' => v === 'b'); +arrayFindLastIndex([1, 2, 3], v => v === 2); +const nums: number[] = [1, 2, 3]; +const res2: number | undefined = arrayFindLast(nums, (v, i, arr) => v > 1 && arr.length > 0, {}); +arrayFindLastIndex(nums, (v, i, arr) => v > 0, {}); +const m = ["a", 2, 3] as (string | number)[]; +arrayFindLast(m, (v): v is string => typeof v === "string"); + +// @ts-expect-error +arrayFindLast([1, 2, 3]); +// @ts-expect-error +arrayFindLast([1, 2, 3], 'not function'); + +// @ts-expect-error +arrayFindLastIndex([1, 2, 3]); +// @ts-expect-error +arrayFindLastIndex([1, 2, 3], 'not function'); diff --git a/tests/type-definitions/proposals/pure/array-flat-map.test.ts b/tests/type-definitions/proposals/pure/array-flat-map.test.ts new file mode 100644 index 000000000000..e8a36c5a283d --- /dev/null +++ b/tests/type-definitions/proposals/pure/array-flat-map.test.ts @@ -0,0 +1,42 @@ +import arrayFlatMap from '@core-js/pure/full/array/flat-map'; +import arrayFlat from '@core-js/pure/full/array/flat'; + +// todo check return type after fix +arrayFlatMap([1, 2, 3], x => [x, x * 2]); +arrayFlatMap(['a', 'b', 'c'], x => [x, x.toUpperCase()]); +arrayFlatMap([1, 2, 3], x => x > 1 ? [x, x] : []); +arrayFlatMap([1, 2, 3], function (x) { return [this, x]; }, 123); +arrayFlatMap([1, 2, 3], (x, i, arr) => arr); + +arrayFlat([[1], [2], [3]]); +arrayFlat([[1], [2], [3]], 2); +arrayFlat([1, [2, [3, [4]]]], 2); +arrayFlat(['a', ['b', ['c']]]); +arrayFlat([1, 2, 3]); +arrayFlat([1, 2, 3], 0); + +const arr = [[1, 2], [3, 4], [5, 6]]; +arrayFlat(arr); +arrayFlat(arr, 1); +arrayFlat(arr, 2); + +const arr2: (number | number[])[] = [1, [2, 3], 4]; +arrayFlat(arr2); + +const arr3: (string | string[])[] = ['a', ['b', 'c'], 'd']; +arrayFlat(arr3); + +arrayFlat([[[[1]]]] as number[][][][], 3); + +// @ts-expect-error +arrayFlatMap([1, 2, 3]); +// @ts-expect-error +arrayFlatMap([1, 2, 3], 123); +// @ts-expect-error +arrayFlatMap([1, 2, 3], 'not function'); +// @ts-expect-error +arrayFlat([1, 2, 3] as any[], 'not a number'); +// @ts-expect-error +arrayFlatMap([1, 2, 3], x => x, 1, 2); +// @ts-expect-error +arrayFlat([1, 2, 3], 1, 2); diff --git a/tests/type-definitions/proposals/pure/array-grouping.test.ts b/tests/type-definitions/proposals/pure/array-grouping.test.ts new file mode 100644 index 000000000000..4ccb5b12e3d7 --- /dev/null +++ b/tests/type-definitions/proposals/pure/array-grouping.test.ts @@ -0,0 +1,34 @@ +import objectGroupBy from '@core-js/pure/full/object/group-by'; +import mapGroupBy from '@core-js/pure/full/map/group-by'; + +const arr = [1, 2, 3, 4, 5]; +const objGroup: Partial> = objectGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); +const mapGroup: Map<'even' | 'odd', number[]> = mapGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); +const objGroup2: Partial> = objectGroupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); +const mapGroup2: Map = mapGroupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); + +objectGroupBy('test', c => c); +objectGroupBy(new Set([1, 2, 3]), item => item > 2 ? 'big' : 'small'); +objectGroupBy([], _ => 'x'); + +mapGroupBy('hello', c => c.charCodeAt(0)); +mapGroupBy(new Set(['a', 'b', 'c']), (x, i) => i); + +// @ts-expect-error +objectGroupBy(); +// @ts-expect-error +objectGroupBy([1,2,3]); +// @ts-expect-error +objectGroupBy([1,2,3], 123); +// @ts-expect-error +objectGroupBy(123, x => x); +// @ts-expect-error +objectGroupBy([1,2,3], (a, b, c) => a); +// @ts-expect-error +mapGroupBy(); +// @ts-expect-error +mapGroupBy([1,2,3]); +// @ts-expect-error +mapGroupBy(123, x => x); +// @ts-expect-error +mapGroupBy([1,2,3], (a, b, c) => a); diff --git a/tests/type-definitions/proposals/pure/array-includes.test.ts b/tests/type-definitions/proposals/pure/array-includes.test.ts new file mode 100644 index 000000000000..107134de0407 --- /dev/null +++ b/tests/type-definitions/proposals/pure/array-includes.test.ts @@ -0,0 +1,19 @@ +import arrayIncludes from '@core-js/pure/full/array/includes'; + +const arr: number[] = [1, 2, 3]; +const arrRes: boolean = arrayIncludes(arr, 2); +const arrRes2: boolean = arrayIncludes(arr, 2, 1); + +const strArr: string[] = ['a', 'b', 'c']; +const strArrRes: boolean = arrayIncludes(strArr, 'b'); +const strArrRes2: boolean = arrayIncludes(strArr, 'b', 1); + +// @ts-expect-error +arrayIncludes(); +// @ts-expect-error +arrayIncludes(1, '2'); + +// @ts-expect-error +arrayIncludes(2); +// @ts-expect-error +arrayIncludes('b', true); diff --git a/tests/type-definitions/proposals/pure/array-is-template-object.test.ts b/tests/type-definitions/proposals/pure/array-is-template-object.test.ts new file mode 100644 index 000000000000..d28159bc665d --- /dev/null +++ b/tests/type-definitions/proposals/pure/array-is-template-object.test.ts @@ -0,0 +1,17 @@ +import arrayIsTemplateObject from '@core-js/pure/full/array/is-template-object'; +import objectFreeze from '@core-js/pure/full/object/freeze'; +import sym from '@core-js/pure/full/symbol'; + +const t: boolean = arrayIsTemplateObject([]); +arrayIsTemplateObject({}); +arrayIsTemplateObject(['a', 'b']); +arrayIsTemplateObject(objectFreeze(['foo', 'bar'])); +arrayIsTemplateObject(123); +arrayIsTemplateObject('str'); +arrayIsTemplateObject(sym()); + +declare const x: unknown; +if (arrayIsTemplateObject(x)) { + x.raw; + const _: readonly string[] = x.raw; +} diff --git a/tests/type-definitions/proposals/pure/array-unique.test.ts b/tests/type-definitions/proposals/pure/array-unique.test.ts new file mode 100644 index 000000000000..3981bb477115 --- /dev/null +++ b/tests/type-definitions/proposals/pure/array-unique.test.ts @@ -0,0 +1,27 @@ +import arrayUniqueBy from '@core-js/pure/full/array/unique-by'; + +type Obj = { a: number; b: string }; +const arr: Obj[] = [{ a: 1, b: 'x' }, { a: 2, b: 'y' }]; +const arrRes: Obj[] = arrayUniqueBy(arr); +const arrRes2: Obj[] = arrayUniqueBy(arr, 'a'); +const arrRes3: Obj[] = arrayUniqueBy(arr, obj => obj.b); + +const numArr: number[] = [1, 2, 1, 3]; +const numArrRes: number[] = arrayUniqueBy(numArr); +const numArrRes2: number[] = arrayUniqueBy(numArr, x => x % 2); + +// @ts-expect-error +arrayUniqueBy(123); +// @ts-expect-error +arrayUniqueBy(true); +// @ts-expect-error +arrayUniqueBy({}); +// @ts-expect-error +arrayUniqueBy(''); + +// @ts-expect-error +numarrayUniqueBy(1); +// @ts-expect-error +numarrayUniqueBy({}); +// @ts-expect-error +numarrayUniqueBy(true); diff --git a/tests/type-definitions/proposals/pure/async-iteration.test.ts b/tests/type-definitions/proposals/pure/async-iteration.test.ts new file mode 100644 index 000000000000..386494a1348b --- /dev/null +++ b/tests/type-definitions/proposals/pure/async-iteration.test.ts @@ -0,0 +1,11 @@ +import symbolAsyncIterator from '@core-js/pure/full/symbol/async-iterator'; +import $symbol from '@core-js/pure/full/symbol'; + +const aiter: symbol = symbolAsyncIterator; +const sym: symbol = symbolAsyncIterator; +const s: typeof symbolAsyncIterator = symbolAsyncIterator; + +// @ts-expect-error +const bad1: string = symbolAsyncIterator; +// @ts-expect-error +$symbol['asyncIterator'] = $symbol("other"); diff --git a/tests/type-definitions/proposals/pure/async-iterator-helper.test.ts b/tests/type-definitions/proposals/pure/async-iterator-helper.test.ts index 326e002dc655..bccede6d25bc 100644 --- a/tests/type-definitions/proposals/pure/async-iterator-helper.test.ts +++ b/tests/type-definitions/proposals/pure/async-iterator-helper.test.ts @@ -12,11 +12,11 @@ import take from '@core-js/pure/full/async-iterator/take'; import toArray from '@core-js/pure/full/async-iterator/to-array'; import toAsync from '@core-js/pure/full/iterator/to-async'; -from([1, 2, 3]); -from(new Set([1, 2, 3])); +const res: AsyncIterator = from([1, 2, 3]); +const res2: AsyncIterator = from(new Set([1, 2, 3])); from((async function* () { yield 1; yield 2; })()); from((function* () { yield 3; })()); -from('abc'); +const res3: AsyncIterator = from('abc'); declare const ain: AsyncIteratorObject; declare const aio: AsyncIteratorObject<{ x: number }>; diff --git a/tests/type-definitions/proposals/pure/change-array-by-copy.test.ts b/tests/type-definitions/proposals/pure/change-array-by-copy.test.ts new file mode 100644 index 000000000000..914ead1f572b --- /dev/null +++ b/tests/type-definitions/proposals/pure/change-array-by-copy.test.ts @@ -0,0 +1,49 @@ +import arrayToReversed from '@core-js/pure/full/array/to-reversed'; +import arrayToSorted from '@core-js/pure/full/array/to-sorted'; +import arrayToSpliced from '@core-js/pure/full/array/to-spliced'; +import arrayWith from '@core-js/pure/full/array/with'; + +const arr: number[] = [1, 2, 3]; +const arrRev: number[] = arrayToReversed(arr); +const arrSorted: number[] = arrayToSorted(arr); +const arrSorted2: number[] = arrayToSorted(arr, (a, b) => b - a); +// todo add items after fix uncurried version +const arrSpliced: number[] = arrayToSpliced(arr, 1, 1); +const arrSpliced2: number[] = arrayToSpliced(arr, 1); +const arrSpliced3: number[] = arrayToSpliced(arr, 1, 2); +const arrWith: number[] = arrayWith(arr, 1, 42); + +const sarr: string[] = ['a', 'b', 'c']; +const sarrRev: string[] = arrayToReversed(sarr); +const sarrSorted: string[] = arrayToSorted(sarr); +const sarrWith: string[] = arrayWith(sarr, 0, 'z'); +const sarrSpliced: string[] = arrayToSpliced(sarr ,0, 1); + +// @ts-expect-error +arrayToReversed(arr, 1); +// @ts-expect-error +arrayToSorted(arr, 'string'); +// @ts-expect-error +arrayToSorted(arr, (a: number, b: string) => 0); +// @ts-expect-error +arrayToSpliced(arr); +// @ts-expect-error +arrayToSpliced(arr, '1', 1); +// @ts-expect-error +arrayToSpliced(arr, 1, '1'); +// @ts-expect-error +arrayWith(arr); +// @ts-expect-error +arrayWith(arr, 1); +// @ts-expect-error +arrayWith(arr, '1', 2); + +const barr: boolean[] = [true, false]; +// @ts-expect-error +arrayToSorted(barr, (a: number, b: number) => 0); +// @ts-expect-error +arrayWith(barr, 0, 1); + +const arrStr: string[] = ['a', 'b']; +// @ts-expect-error +arrayWith(arrStr, 0, 1); diff --git a/tests/type-definitions/proposals/pure/extractors.test.ts b/tests/type-definitions/proposals/pure/extractors.test.ts new file mode 100644 index 000000000000..d47541f2b1b2 --- /dev/null +++ b/tests/type-definitions/proposals/pure/extractors.test.ts @@ -0,0 +1,10 @@ +import symbolCustomMatcher from '@core-js/pure/full/symbol/custom-matcher'; +import $symbol from '@core-js/pure/full/symbol'; + +const rscs1: symbol = symbolCustomMatcher; +const rscs2: typeof symbolCustomMatcher = symbolCustomMatcher; + +// @ts-expect-error +$symbol['customMatcher'] = $symbol("other"); +// @ts-expect-error +const n: number = symbolCustomMatcher; diff --git a/tests/type-definitions/proposals/pure/iterator-helpers.test.ts b/tests/type-definitions/proposals/pure/iterator-helpers.test.ts new file mode 100644 index 000000000000..9b50f8f929c5 --- /dev/null +++ b/tests/type-definitions/proposals/pure/iterator-helpers.test.ts @@ -0,0 +1,108 @@ +import iteratorMap from '@core-js/pure/full/iterator/map'; +import iteratorFilter from '@core-js/pure/full/iterator/filter'; +import iteratorTake from '@core-js/pure/full/iterator/take'; +import iteratorDrop from '@core-js/pure/full/iterator/drop'; +import iteratorFlatMap from '@core-js/pure/full/iterator/flat-map'; +import iteratorReduce from '@core-js/pure/full/iterator/reduce'; +import iteratorToArray from '@core-js/pure/full/iterator/to-array'; +import iteratorForEach from '@core-js/pure/full/iterator/for-each'; +import iteratorSome from '@core-js/pure/full/iterator/some'; +import iteratorEvery from '@core-js/pure/full/iterator/every'; +import iteratorFind from '@core-js/pure/full/iterator/find'; + +declare const it: Iterator; +declare const itStr: Iterator; +declare const itNumStr: Iterator; + +// todo uncomment when uncurried methods would be fixed +// const res: Iterator = iteratorMap(it, (v, i) => String(v)); +// const mappedNum: Iterator = iteratorMap(it, n => n + 1); +iteratorMap(it, (v, i) => String(v)); +iteratorMap(it, n => n + 1); + +// @ts-expect-error +iteratorMap(); +// @ts-expect-error +iteratorMap((v, i, extra) => v + i + extra); + +const onlyEven: Iterator = iteratorFilter(it, v => v % 2 === 0); +const filtered: Iterator = iteratorFilter(it, (v): v is number => typeof v === 'number'); + +// @ts-expect-error +iteratorFilter(); +// @ts-expect-error +iteratorFilter((v, i, extra) => true); + +const taken: Iterator = iteratorTake(it, 5); + +// @ts-expect-error +iteratorTake(); +// @ts-expect-error +iteratorTake('5'); + +const dropped: Iterator = iteratorDrop(it, 3); + +// @ts-expect-error +iteratorDrop('3'); + +// todo uncomment when uncurried methods would be fixed +// const flatMapped: Iterator = iteratorFlatMap(it, (v, i) => itStr); +// const flatMapped2: Iterator = iteratorFlatMap(it, (v, i) => ({ +// [Symbol.iterator]: function* () { +// yield String(v); +// } +// })); +iteratorFlatMap(it, (v, i) => itStr); +iteratorFlatMap(it, (v, i) => ({ + [Symbol.iterator]: function* () { + yield String(v); + } +})); + +// @ts-expect-error +iteratorFlatMap(); + +// todo fix +// const sum1: number = iteratorReduce(it, (a, b, c) => a + b + c, 0); +// const sum2: number = iteratorReduce(it, (a, b, c) => a + b + c, 0); +// const strReduce: string = iteratorReduce( +// it, +// (acc: string, val) => acc + val, +// '' +// ); + +// @ts-expect-error +iteratorReduce(); +// @ts-expect-error +iteratorReduce(it, (a, b, c, d) => a); + +const arr: number[] = iteratorToArray(it); + +iteratorForEach(it, (value, idx) => { + const x: number = value; + const y: number = idx; +}); + +// @ts-expect-error +iteratorForEach(it); + +const hasPositive: boolean = iteratorSome(it, (v, i) => v > 0); + +// @ts-expect-error +iteratorSome(it); +// @ts-expect-error +iteratorSome(it, (v, i, extra) => true); + +const allPositive: boolean = iteratorEvery(it, (v, i) => v > 0); + +// @ts-expect-error +iteratorEvery(it); +// @ts-expect-error +iteratorEvery(it, (v, i, extra) => true); + +const found1: number | undefined = iteratorFind(it, (v, i) => v > 5); +// const findString: string | undefined = iteratorFind(itNumStr, (v): v is string => typeof v === 'string'); +iteratorFind(itNumStr, (v): v is string => typeof v === 'string'); + +// @ts-expect-error +iteratorFind(it); diff --git a/tests/type-definitions/proposals/pure/iterator-sequencing.test.ts b/tests/type-definitions/proposals/pure/iterator-sequencing.test.ts index d50ebfb38a88..45adf848eccc 100644 --- a/tests/type-definitions/proposals/pure/iterator-sequencing.test.ts +++ b/tests/type-definitions/proposals/pure/iterator-sequencing.test.ts @@ -18,7 +18,3 @@ concat(1); concat(true); // @ts-expect-error concat({}); -// @ts-expect-error -concat(null); -// @ts-expect-error -concat(undefined); diff --git a/tests/type-definitions/proposals/pure/object-from-entries.test.ts b/tests/type-definitions/proposals/pure/object-from-entries.test.ts new file mode 100644 index 000000000000..ca8d30a934bc --- /dev/null +++ b/tests/type-definitions/proposals/pure/object-from-entries.test.ts @@ -0,0 +1,27 @@ +import objectFromEntries from '@core-js/pure/full/object/from-entries'; + +declare const objEntries: Iterable; +declare const mixedEntries: Iterable; +declare const wrongEntries1: Iterable; +declare const wrongEntries2: number; +declare const notIterable: {}; + +const r1: { [k: string]: number } = objectFromEntries(objEntries); +const r2: any = objectFromEntries(mixedEntries); +const r3: any = objectFromEntries([['a', 1], ['b', 2]]); +const r4: object = objectFromEntries(new Map([ ['x', 1], ['y', 2] ])); + +// @ts-expect-error +objectFromEntries(); + +// @ts-expect-error +objectFromEntries(123); + +// @ts-expect-error +objectFromEntries(wrongEntries1); + +// @ts-expect-error +objectFromEntries(wrongEntries2); + +// @ts-expect-error +objectFromEntries(notIterable); diff --git a/tests/type-definitions/proposals/pure/string-cooked.test.ts b/tests/type-definitions/proposals/pure/string-cooked.test.ts index 24cb8230c938..64ad5f105f4e 100644 --- a/tests/type-definitions/proposals/pure/string-cooked.test.ts +++ b/tests/type-definitions/proposals/pure/string-cooked.test.ts @@ -5,6 +5,6 @@ cooked(['foo', 'bar'], 1, 2); cooked([]); // @ts-expect-error -cooked([null]); +cooked(1); // @ts-expect-error -cooked([undefined]); +cooked(false); From 8b846d34e4acc8b174f19e822b69432d3f5ff5f5 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 22 Oct 2025 23:09:55 +0700 Subject: [PATCH 046/315] Add proposal types for stages 3-4 --- packages/core-js/modules/es.object.entries.js | 1 + .../es.object.get-own-property-descriptors.js | 1 + packages/core-js/modules/es.object.values.js | 1 + .../core-js/modules/es.promise.all-settled.js | 1 + packages/core-js/modules/es.promise.any.js | 1 + .../core-js/modules/es.promise.finally.js | 1 + packages/core-js/modules/es.promise.try.js | 1 + .../modules/es.promise.with-resolvers.js | 1 + .../object-get-own-property-descriptors.d.ts | 12 ++++++ .../proposals/object-values-entries.d.ts | 14 +++++++ .../types/proposals/promise-all-settled.d.ts | 12 ++++++ .../core-js/types/proposals/promise-any.d.ts | 12 ++++++ .../types/proposals/promise-finally.d.ts | 10 +++++ .../core-js/types/proposals/promise-try.d.ts | 11 +++++ .../proposals/promise-with-resolvers.d.ts | 18 ++++++++ ...bject-get-own-property-descriptors.test.ts | 18 ++++++++ .../global/object-values-entries.test.ts | 30 +++++++++++++ .../global/promise-all-settled.test.ts | 41 ++++++++++++++++++ .../proposals/global/promise-any.test.ts | 34 +++++++++++++++ .../proposals/global/promise-finally.test.ts | 37 ++++++++++++++++ .../proposals/global/promise-try.test.ts | 35 ++++++++++++++++ .../global/promise-with-resolvers.test.ts | 34 +++++++++++++++ ...bject-get-own-property-descriptors.test.ts | 18 ++++++++ .../pure/object-values-entries.test.ts | 31 ++++++++++++++ .../pure/promise-all-settled.test.ts | 42 +++++++++++++++++++ .../proposals/pure/promise-any.test.ts | 35 ++++++++++++++++ .../proposals/pure/promise-finally.test.ts | 38 +++++++++++++++++ .../proposals/pure/promise-try.test.ts | 36 ++++++++++++++++ .../pure/promise-with-resolvers.test.ts | 35 ++++++++++++++++ 29 files changed, 561 insertions(+) create mode 100644 packages/core-js/types/proposals/object-get-own-property-descriptors.d.ts create mode 100644 packages/core-js/types/proposals/object-values-entries.d.ts create mode 100644 packages/core-js/types/proposals/promise-all-settled.d.ts create mode 100644 packages/core-js/types/proposals/promise-any.d.ts create mode 100644 packages/core-js/types/proposals/promise-finally.d.ts create mode 100644 packages/core-js/types/proposals/promise-try.d.ts create mode 100644 packages/core-js/types/proposals/promise-with-resolvers.d.ts create mode 100644 tests/type-definitions/proposals/global/object-get-own-property-descriptors.test.ts create mode 100644 tests/type-definitions/proposals/global/object-values-entries.test.ts create mode 100644 tests/type-definitions/proposals/global/promise-all-settled.test.ts create mode 100644 tests/type-definitions/proposals/global/promise-any.test.ts create mode 100644 tests/type-definitions/proposals/global/promise-finally.test.ts create mode 100644 tests/type-definitions/proposals/global/promise-try.test.ts create mode 100644 tests/type-definitions/proposals/global/promise-with-resolvers.test.ts create mode 100644 tests/type-definitions/proposals/pure/object-get-own-property-descriptors.test.ts create mode 100644 tests/type-definitions/proposals/pure/object-values-entries.test.ts create mode 100644 tests/type-definitions/proposals/pure/promise-all-settled.test.ts create mode 100644 tests/type-definitions/proposals/pure/promise-any.test.ts create mode 100644 tests/type-definitions/proposals/pure/promise-finally.test.ts create mode 100644 tests/type-definitions/proposals/pure/promise-try.test.ts create mode 100644 tests/type-definitions/proposals/pure/promise-with-resolvers.test.ts diff --git a/packages/core-js/modules/es.object.entries.js b/packages/core-js/modules/es.object.entries.js index 4735d9251987..b0d3954e984c 100644 --- a/packages/core-js/modules/es.object.entries.js +++ b/packages/core-js/modules/es.object.entries.js @@ -1,3 +1,4 @@ +// types: proposals/object-values-entries 'use strict'; var $ = require('../internals/export'); var $entries = require('../internals/object-to-array').entries; diff --git a/packages/core-js/modules/es.object.get-own-property-descriptors.js b/packages/core-js/modules/es.object.get-own-property-descriptors.js index ed7781a3cbae..0b006a7eadb3 100644 --- a/packages/core-js/modules/es.object.get-own-property-descriptors.js +++ b/packages/core-js/modules/es.object.get-own-property-descriptors.js @@ -1,3 +1,4 @@ +// types: proposals/object-get-own-property-descriptors 'use strict'; var $ = require('../internals/export'); var ownKeys = require('../internals/own-keys'); diff --git a/packages/core-js/modules/es.object.values.js b/packages/core-js/modules/es.object.values.js index 349595ddfe2a..948d4d504cb7 100644 --- a/packages/core-js/modules/es.object.values.js +++ b/packages/core-js/modules/es.object.values.js @@ -1,3 +1,4 @@ +// types: proposals/object-values-entries 'use strict'; var $ = require('../internals/export'); var $values = require('../internals/object-to-array').values; diff --git a/packages/core-js/modules/es.promise.all-settled.js b/packages/core-js/modules/es.promise.all-settled.js index c43a66f73112..f467d0d45354 100644 --- a/packages/core-js/modules/es.promise.all-settled.js +++ b/packages/core-js/modules/es.promise.all-settled.js @@ -1,3 +1,4 @@ +// types: proposals/promise-all-settled 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.promise.any.js b/packages/core-js/modules/es.promise.any.js index 5d38fc78ff1b..12eff381134d 100644 --- a/packages/core-js/modules/es.promise.any.js +++ b/packages/core-js/modules/es.promise.any.js @@ -1,3 +1,4 @@ +// types: proposals/promise-any 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.promise.finally.js b/packages/core-js/modules/es.promise.finally.js index 7bf599239df2..2d275545d0e7 100644 --- a/packages/core-js/modules/es.promise.finally.js +++ b/packages/core-js/modules/es.promise.finally.js @@ -1,3 +1,4 @@ +// types: proposals/promise-finally 'use strict'; var $ = require('../internals/export'); var IS_PURE = require('../internals/is-pure'); diff --git a/packages/core-js/modules/es.promise.try.js b/packages/core-js/modules/es.promise.try.js index 91fc13f50ad4..db9734a391c9 100644 --- a/packages/core-js/modules/es.promise.try.js +++ b/packages/core-js/modules/es.promise.try.js @@ -1,3 +1,4 @@ +// types: proposals/promise-try 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/es.promise.with-resolvers.js b/packages/core-js/modules/es.promise.with-resolvers.js index 2d33773cbf49..da81a79bd8b9 100644 --- a/packages/core-js/modules/es.promise.with-resolvers.js +++ b/packages/core-js/modules/es.promise.with-resolvers.js @@ -1,3 +1,4 @@ +// types: proposals/promise-with-resolvers 'use strict'; var $ = require('../internals/export'); var newPromiseCapabilityModule = require('../internals/new-promise-capability'); diff --git a/packages/core-js/types/proposals/object-get-own-property-descriptors.d.ts b/packages/core-js/types/proposals/object-get-own-property-descriptors.d.ts new file mode 100644 index 000000000000..03381a3b031f --- /dev/null +++ b/packages/core-js/types/proposals/object-get-own-property-descriptors.d.ts @@ -0,0 +1,12 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-object-getownpropertydescriptors + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2017.object.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface ObjectConstructor { + getOwnPropertyDescriptors(o: T): { [P in keyof T]: TypedPropertyDescriptor; } & { + [x: string]: PropertyDescriptor; + }; +} diff --git a/packages/core-js/types/proposals/object-values-entries.d.ts b/packages/core-js/types/proposals/object-values-entries.d.ts new file mode 100644 index 000000000000..d2f4e35d18c2 --- /dev/null +++ b/packages/core-js/types/proposals/object-values-entries.d.ts @@ -0,0 +1,14 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-object-values-entries + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2017.object.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface ObjectConstructor { + values(o: { [s: string]: T; } | ArrayLike): T[]; + values(o: {}): any[]; + + entries(o: { [s: string]: T; } | ArrayLike): [string, T][]; + entries(o: {}): [string, any][]; +} diff --git a/packages/core-js/types/proposals/promise-all-settled.d.ts b/packages/core-js/types/proposals/promise-all-settled.d.ts new file mode 100644 index 000000000000..788bbd819c10 --- /dev/null +++ b/packages/core-js/types/proposals/promise-all-settled.d.ts @@ -0,0 +1,12 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-promise-allSettled + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2017.object.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface PromiseConstructor { + allSettled(values: T): Promise<{ -readonly [P in keyof T]: PromiseSettledResult>; }>; + + allSettled(values: Iterable>): Promise>[]>; +} diff --git a/packages/core-js/types/proposals/promise-any.d.ts b/packages/core-js/types/proposals/promise-any.d.ts new file mode 100644 index 000000000000..9071311b39eb --- /dev/null +++ b/packages/core-js/types/proposals/promise-any.d.ts @@ -0,0 +1,12 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-promise-any + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2021.promise.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface PromiseConstructor { + any(values: T): Promise>; + + any(values: Iterable>): Promise>; +} diff --git a/packages/core-js/types/proposals/promise-finally.d.ts b/packages/core-js/types/proposals/promise-finally.d.ts new file mode 100644 index 000000000000..1936b256f060 --- /dev/null +++ b/packages/core-js/types/proposals/promise-finally.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-promise-finally + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2018.promise.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface Promise { + finally(onfinally?: (() => void) | undefined | null): Promise; +} diff --git a/packages/core-js/types/proposals/promise-try.d.ts b/packages/core-js/types/proposals/promise-try.d.ts new file mode 100644 index 000000000000..75ff6358f34f --- /dev/null +++ b/packages/core-js/types/proposals/promise-try.d.ts @@ -0,0 +1,11 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-promise-try + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/esnext.promise.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface PromiseConstructor { + try(callbackFn: (...args: U) => T | PromiseLike, ...args: U): Promise>; +} + diff --git a/packages/core-js/types/proposals/promise-with-resolvers.d.ts b/packages/core-js/types/proposals/promise-with-resolvers.d.ts new file mode 100644 index 000000000000..7d0acfc8e23e --- /dev/null +++ b/packages/core-js/types/proposals/promise-with-resolvers.d.ts @@ -0,0 +1,18 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-promise-with-resolvers + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2024.promise.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface PromiseWithResolvers { + promise: Promise; + resolve: (value: T | PromiseLike) => void; + reject: (reason?: any) => void; +} + +interface PromiseConstructor { + withResolvers(): PromiseWithResolvers; +} + + diff --git a/tests/type-definitions/proposals/global/object-get-own-property-descriptors.test.ts b/tests/type-definitions/proposals/global/object-get-own-property-descriptors.test.ts new file mode 100644 index 000000000000..b938ffbdf181 --- /dev/null +++ b/tests/type-definitions/proposals/global/object-get-own-property-descriptors.test.ts @@ -0,0 +1,18 @@ +import 'core-js/full'; + +const obj = { a: 1, b: 'x', c: true }; +const objDescs: { a: TypedPropertyDescriptor; b: TypedPropertyDescriptor; c: TypedPropertyDescriptor } & + { [x: string]: PropertyDescriptor } = Object.getOwnPropertyDescriptors(obj); + +class Foo { + bar = 42; + baz() {} +} +const foo = new Foo(); +const fooDescs: { bar: TypedPropertyDescriptor; baz: TypedPropertyDescriptor<() => void> } & + { [x: string]: PropertyDescriptor } = Object.getOwnPropertyDescriptors(foo); + +const descsAny = Object.getOwnPropertyDescriptors({ x: 1, y: 2 }); + +// @ts-expect-error +Object.getOwnPropertyDescriptors(); diff --git a/tests/type-definitions/proposals/global/object-values-entries.test.ts b/tests/type-definitions/proposals/global/object-values-entries.test.ts new file mode 100644 index 000000000000..ce789d73924d --- /dev/null +++ b/tests/type-definitions/proposals/global/object-values-entries.test.ts @@ -0,0 +1,30 @@ +import 'core-js/full'; + +const obj = { a: 1, b: 2 }; +const arr = [1, 2, 3]; +const strArr = ['a', 'b', 'c']; +const arrLike: ArrayLike = { 0: 10, 1: 20, length: 2 }; +const emptyObj = {}; + +const values1: number[] = Object.values(obj); +const values2: number[] = Object.values(arr); +const values3: string[] = Object.values(strArr); +const values4: number[] = Object.values(arrLike); +const values5: any[] = Object.values(emptyObj); + +const entries1: [string, number][] = Object.entries(obj); +const entries2: [string, number][] = Object.entries(arr); +const entries3: [string, string][] = Object.entries(strArr); +const entries4: [string, number][] = Object.entries(arrLike); +const entries5: [string, any][] = Object.entries(emptyObj); + +const valuesAnyArr: any[] = Object.values({ foo: 123, bar: "baz" }); +const entriesAnyArr: [string, any][] = Object.entries({ foo: 123, bar: "baz" }); + +// Некорректные вызовы + +// @ts-expect-error +Object.values(); + +// @ts-expect-error +Object.entries(); diff --git a/tests/type-definitions/proposals/global/promise-all-settled.test.ts b/tests/type-definitions/proposals/global/promise-all-settled.test.ts new file mode 100644 index 000000000000..9d6624efb42d --- /dev/null +++ b/tests/type-definitions/proposals/global/promise-all-settled.test.ts @@ -0,0 +1,41 @@ +import 'core-js/full'; + +const promises = [Promise.resolve(1), Promise.resolve("foo"), 3] as const; +const arr = [Promise.resolve(1), Promise.resolve(2)]; +const strArr = ["a", "b", "c"]; +const promiseLike = { then: (cb: (val: number) => void) => cb(42) }; + +const settled1: Promise<[ + PromiseSettledResult, + PromiseSettledResult, + PromiseSettledResult +]> = Promise.allSettled(promises); + +const settled2: Promise[]> = Promise.allSettled([Promise.resolve(10), Promise.resolve(20), 30]); +const settled3: Promise[]> = Promise.allSettled(strArr); +const settled4: Promise[]> = Promise.allSettled(new Set([1, 2, 3])); +const settled5: Promise[]> = Promise.allSettled([promiseLike]); + +const emptyTuple: [] = []; +const settled6: Promise<[]> = Promise.allSettled(emptyTuple); + +const mixedTuple = [42, Promise.resolve("bar")] as const; +const settled7: Promise<[ + PromiseSettledResult, + PromiseSettledResult +]> = Promise.allSettled(mixedTuple); + +// @ts-expect-error +Promise.allSettled(); + +// @ts-expect-error +Promise.allSettled(5); + +// @ts-expect-error +Promise.allSettled({ foo: 123 }); + +// @ts-expect-error +Promise.allSettled([1, 2], 123); + +// @ts-expect-error +Promise.allSettled([Promise.resolve(1)], "extra"); diff --git a/tests/type-definitions/proposals/global/promise-any.test.ts b/tests/type-definitions/proposals/global/promise-any.test.ts new file mode 100644 index 000000000000..aa174df5ac4d --- /dev/null +++ b/tests/type-definitions/proposals/global/promise-any.test.ts @@ -0,0 +1,34 @@ +import 'core-js/full'; + +const arr = [Promise.resolve(1), Promise.resolve("foo"), 3] as const; +const justNumbers = [1, 2, 3]; +const setOfStrings = new Set(["a", "b", "c"]); +const promiseLike = { then: (cb: (val: number) => void) => cb(123) }; +const emptyTuple: [] = []; +const mixed = [true, Promise.resolve("z")] as const; + +const any1: Promise = Promise.any(arr); +const any2: Promise = Promise.any(["x", "y", Promise.resolve(5)]); +const any3: Promise = Promise.any(emptyTuple); +const any4: Promise = Promise.any(mixed); + +const any5: Promise = Promise.any(justNumbers); +const any6: Promise = Promise.any(setOfStrings); +const any7: Promise = Promise.any([promiseLike]); +const any8: Promise = Promise.any(new Set([1])); +const any9: Promise = Promise.any([Promise.resolve()]); + +// @ts-expect-error +Promise.any(); + +// @ts-expect-error +Promise.any(123); + +// @ts-expect-error +Promise.any({ foo: 42 }); + +// @ts-expect-error +Promise.any([1, 2], 3); + +// @ts-expect-error +Promise.any(justNumbers, "extra"); diff --git a/tests/type-definitions/proposals/global/promise-finally.test.ts b/tests/type-definitions/proposals/global/promise-finally.test.ts new file mode 100644 index 000000000000..6accc9916486 --- /dev/null +++ b/tests/type-definitions/proposals/global/promise-finally.test.ts @@ -0,0 +1,37 @@ +import 'core-js/full'; + +const p1 = Promise.resolve(42); +const pf1: Promise = p1.finally(); +const pf2: Promise = p1.finally(undefined); +const pf3: Promise = p1.finally(null); +const pf4: Promise = p1.finally(() => {}); +const pf5: Promise = p1.finally(function () {}); + +const p2 = Promise.reject("err"); +const pf6: Promise = p2.finally(); +const pf7: Promise = p2.finally(() => {}); + +// Можно вызывать на generic +declare function returnsPromise(): Promise; +const genericF: Promise = returnsPromise().finally(() => {}); + +// @ts-expect-error +p1.finally(123); + +// @ts-expect-error +p1.finally("foo"); + +// @ts-expect-error +p1.finally({}); + +// @ts-expect-error +p1.finally([]); + +// @ts-expect-error +p1.finally(() => {}, "extra"); + +// @ts-expect-error +p1.finally(true); + +// @ts-expect-error +p1.finally(Symbol("x")); diff --git a/tests/type-definitions/proposals/global/promise-try.test.ts b/tests/type-definitions/proposals/global/promise-try.test.ts new file mode 100644 index 000000000000..1268220ec85d --- /dev/null +++ b/tests/type-definitions/proposals/global/promise-try.test.ts @@ -0,0 +1,35 @@ +import 'core-js/full'; + +const pt1: Promise = Promise.try(() => 42); +const pt2: Promise = Promise.try(() => Promise.resolve("hi")); +const pt3: Promise = Promise.try((a: number, b: number) => a + b, 1, 2); +const pt4: Promise = Promise.try((x: string) => x + "!!", "test"); +const pt5: Promise = Promise.try(() => {}); +const pt6: Promise = Promise.try((b: boolean) => b, false); + +const pt7: Promise = Promise.try((a: number, b: string, c: boolean) => c ? a : Number(b), 10, "100", true); +const pt8: Promise = Promise.try((a: string) => Promise.resolve(a), "bar"); + +declare function returnsPromise(): Promise; +const pt9: Promise = Promise.try(() => returnsPromise()); + +// @ts-expect-error +Promise.try(); + +// @ts-expect-error +Promise.try(42); + +// @ts-expect-error +Promise.try("callback"); + +// @ts-expect-error +Promise.try({}); + +// @ts-expect-error +Promise.try([]); + +// @ts-expect-error +Promise.try(() => 1, 2, "a", Symbol("x")); + +// @ts-expect-error +Promise.try((a: boolean) => a, 123); diff --git a/tests/type-definitions/proposals/global/promise-with-resolvers.test.ts b/tests/type-definitions/proposals/global/promise-with-resolvers.test.ts new file mode 100644 index 000000000000..a22face5a074 --- /dev/null +++ b/tests/type-definitions/proposals/global/promise-with-resolvers.test.ts @@ -0,0 +1,34 @@ +import 'core-js/full'; + +const pr = Promise.withResolvers(); +const pr2 = Promise.withResolvers(); +const pr3 = Promise.withResolvers(); + +const p1: Promise = pr.promise; +const p2: Promise = pr2.promise; +const p3: Promise = pr3.promise; + +pr.resolve(42); +pr.resolve(Promise.resolve(43)); +pr.reject(); +pr.reject('some error'); + +pr2.resolve('test'); +pr2.resolve(Promise.resolve('hi')); +pr2.reject(new Error('fail')); +pr3.resolve(undefined); +pr3.reject(); + +const value: number | PromiseLike = 99; +pr.resolve(value); + +declare function agrees(): PromiseWithResolvers; +const gr: PromiseWithResolvers = agrees(); +gr.resolve(true); +gr.reject(); + +// @ts-expect-error +Promise.withResolvers(123); + +// @ts-expect-error +Promise.withResolvers(123); diff --git a/tests/type-definitions/proposals/pure/object-get-own-property-descriptors.test.ts b/tests/type-definitions/proposals/pure/object-get-own-property-descriptors.test.ts new file mode 100644 index 000000000000..a728290039dc --- /dev/null +++ b/tests/type-definitions/proposals/pure/object-get-own-property-descriptors.test.ts @@ -0,0 +1,18 @@ +import objectGetOwnPropertyDescriptors from '@core-js/pure/full/object/get-own-property-descriptors'; + +const obj = { a: 1, b: 'x', c: true }; +const objDescs: { a: TypedPropertyDescriptor; b: TypedPropertyDescriptor; c: TypedPropertyDescriptor } & + { [x: string]: PropertyDescriptor } = objectGetOwnPropertyDescriptors(obj); + +class Foo { + bar = 42; + baz() {} +} +const foo = new Foo(); +const fooDescs: { bar: TypedPropertyDescriptor; baz: TypedPropertyDescriptor<() => void> } & + { [x: string]: PropertyDescriptor } = objectGetOwnPropertyDescriptors(foo); + +const descsAny = objectGetOwnPropertyDescriptors({ x: 1, y: 2 }); + +// @ts-expect-error +objectGetOwnPropertyDescriptors(); diff --git a/tests/type-definitions/proposals/pure/object-values-entries.test.ts b/tests/type-definitions/proposals/pure/object-values-entries.test.ts new file mode 100644 index 000000000000..b0104c593572 --- /dev/null +++ b/tests/type-definitions/proposals/pure/object-values-entries.test.ts @@ -0,0 +1,31 @@ +import objectValues from '@core-js/pure/full/object/values'; +import objectEntries from '@core-js/pure/full/object/entries'; + +const obj = { a: 1, b: 2 }; +const arr = [1, 2, 3]; +const strArr = ['a', 'b', 'c']; +const arrLike: ArrayLike = { 0: 10, 1: 20, length: 2 }; +const emptyObj = {}; + +const values1: number[] = objectValues(obj); +const values2: number[] = objectValues(arr); +const values3: string[] = objectValues(strArr); +const values4: number[] = objectValues(arrLike); +const values5: any[] = objectValues(emptyObj); + +const entries1: [string, number][] = objectEntries(obj); +const entries2: [string, number][] = objectEntries(arr); +const entries3: [string, string][] = objectEntries(strArr); +const entries4: [string, number][] = objectEntries(arrLike); +const entries5: [string, any][] = objectEntries(emptyObj); + +const valuesAnyArr: any[] = objectValues({ foo: 123, bar: "baz" }); +const entriesAnyArr: [string, any][] = objectEntries({ foo: 123, bar: "baz" }); + +// Некорректные вызовы + +// @ts-expect-error +objectValues(); + +// @ts-expect-error +objectEntries(); diff --git a/tests/type-definitions/proposals/pure/promise-all-settled.test.ts b/tests/type-definitions/proposals/pure/promise-all-settled.test.ts new file mode 100644 index 000000000000..3a6e2f683771 --- /dev/null +++ b/tests/type-definitions/proposals/pure/promise-all-settled.test.ts @@ -0,0 +1,42 @@ +import promiseAllSettled from '@core-js/pure/full/promise/all-settled'; +import promiseResolve from '@core-js/pure/full/promise/resolve'; + +const promises = [promiseResolve(1), promiseResolve("foo"), 3] as const; +const arr = [promiseResolve(1), promiseResolve(2)]; +const strArr = ["a", "b", "c"]; +const promiseLike = { then: (cb: (val: number) => void) => cb(42) }; + +const settled1: Promise<[ + PromiseSettledResult, + PromiseSettledResult, + PromiseSettledResult +]> = promiseAllSettled(promises); + +const settled2: Promise[]> = promiseAllSettled([promiseResolve(10), promiseResolve(20), 30]); +const settled3: Promise[]> = promiseAllSettled(strArr); +const settled4: Promise[]> = promiseAllSettled(new Set([1, 2, 3])); +const settled5: Promise[]> = promiseAllSettled([promiseLike]); + +const emptyTuple: [] = []; +const settled6: Promise<[]> = promiseAllSettled(emptyTuple); + +const mixedTuple = [42, promiseResolve("bar")] as const; +const settled7: Promise<[ + PromiseSettledResult, + PromiseSettledResult +]> = promiseAllSettled(mixedTuple); + +// @ts-expect-error +promiseAllSettled(); + +// @ts-expect-error +promiseAllSettled(5); + +// @ts-expect-error +promiseAllSettled({ foo: 123 }); + +// @ts-expect-error +promiseAllSettled([1, 2], 123); + +// @ts-expect-error +promiseAllSettled([promiseResolve(1)], "extra"); diff --git a/tests/type-definitions/proposals/pure/promise-any.test.ts b/tests/type-definitions/proposals/pure/promise-any.test.ts new file mode 100644 index 000000000000..cf089a60c736 --- /dev/null +++ b/tests/type-definitions/proposals/pure/promise-any.test.ts @@ -0,0 +1,35 @@ +import promiseAny from '@core-js/pure/full/promise/any'; +import promiseResolve from '@core-js/pure/full/promise/resolve'; + +const arr = [promiseResolve(1), promiseResolve("foo"), 3] as const; +const justNumbers = [1, 2, 3]; +const setOfStrings = new Set(["a", "b", "c"]); +const promiseLike = { then: (cb: (val: number) => void) => cb(123) }; +const emptyTuple: [] = []; +const mixed = [true, promiseResolve("z")] as const; + +const any1: Promise = promiseAny(arr); +const any2: Promise = promiseAny(["x", "y", promiseResolve(5)]); +const any3: Promise = promiseAny(emptyTuple); +const any4: Promise = promiseAny(mixed); + +const any5: Promise = promiseAny(justNumbers); +const any6: Promise = promiseAny(setOfStrings); +const any7: Promise = promiseAny([promiseLike]); +const any8: Promise = promiseAny(new Set([1])); +const any9: Promise = promiseAny([promiseResolve()]); + +// @ts-expect-error +promiseAny(); + +// @ts-expect-error +promiseAny(123); + +// @ts-expect-error +promiseAny({ foo: 42 }); + +// @ts-expect-error +promiseAny([1, 2], 3); + +// @ts-expect-error +promiseAny(justNumbers, "extra"); diff --git a/tests/type-definitions/proposals/pure/promise-finally.test.ts b/tests/type-definitions/proposals/pure/promise-finally.test.ts new file mode 100644 index 000000000000..9e47a640f544 --- /dev/null +++ b/tests/type-definitions/proposals/pure/promise-finally.test.ts @@ -0,0 +1,38 @@ +import promiseFinally from '@core-js/pure/full/promise/finally'; +import promiseResolve from '@core-js/pure/full/promise/resolve'; + +const p1 = promiseResolve(42); +const pf1: Promise = promiseFinally(p1); +const pf2: Promise = promiseFinally(p1, undefined); +const pf3: Promise = promiseFinally(p1, null); +const pf4: Promise = promiseFinally(p1, () => {}); +const pf5: Promise = promiseFinally(p1, function () {}); + +const p2 = Promise.reject("err"); +const pf6: Promise = promiseFinally(p2); +const pf7: Promise = promiseFinally(p2, () => {}); + +// Можно вызывать на generic +declare function returnsPromise(): Promise; +const genericF: Promise = returnsPromise().finally(() => {}); + +// @ts-expect-error +promiseFinally(p1, 123); + +// @ts-expect-error +promiseFinally(p1, "foo"); + +// @ts-expect-error +promiseFinally(p1, {}); + +// @ts-expect-error +promiseFinally(p1, []); + +// @ts-expect-error +promiseFinally(p1, () => {}, "extra"); + +// @ts-expect-error +promiseFinally(p1, true); + +// @ts-expect-error +promiseFinally(p1, Symbol("x")); diff --git a/tests/type-definitions/proposals/pure/promise-try.test.ts b/tests/type-definitions/proposals/pure/promise-try.test.ts new file mode 100644 index 000000000000..a2c17d6777b3 --- /dev/null +++ b/tests/type-definitions/proposals/pure/promise-try.test.ts @@ -0,0 +1,36 @@ +import promiseTry from '@core-js/pure/full/promise/try'; +import promiseResolve from '@core-js/pure/full/promise/resolve'; + +const pt1: Promise = promiseTry(() => 42); +const pt2: Promise = promiseTry(() => promiseResolve("hi")); +const pt3: Promise = promiseTry((a: number, b: number) => a + b, 1, 2); +const pt4: Promise = promiseTry((x: string) => x + "!!", "test"); +const pt5: Promise = promiseTry(() => {}); +const pt6: Promise = promiseTry((b: boolean) => b, false); + +const pt7: Promise = promiseTry((a: number, b: string, c: boolean) => c ? a : Number(b), 10, "100", true); +const pt8: Promise = promiseTry((a: string) => promiseResolve(a), "bar"); + +declare function returnsPromise(): Promise; +const pt9: Promise = promiseTry(() => returnsPromise()); + +// @ts-expect-error +promiseTry(); + +// @ts-expect-error +promiseTry(42); + +// @ts-expect-error +promiseTry("callback"); + +// @ts-expect-error +promiseTry({}); + +// @ts-expect-error +promiseTry([]); + +// @ts-expect-error +promiseTry(() => 1, 2, "a", Symbol("x")); + +// @ts-expect-error +promiseTry((a: boolean) => a, 123); diff --git a/tests/type-definitions/proposals/pure/promise-with-resolvers.test.ts b/tests/type-definitions/proposals/pure/promise-with-resolvers.test.ts new file mode 100644 index 000000000000..ce836a13308d --- /dev/null +++ b/tests/type-definitions/proposals/pure/promise-with-resolvers.test.ts @@ -0,0 +1,35 @@ +import promiseWithResolvers from '@core-js/pure/full/promise/with-resolvers'; +import promiseResolve from '@core-js/pure/full/promise/resolve'; + +const pr = promiseWithResolvers(); +const pr2 = promiseWithResolvers(); +const pr3 = promiseWithResolvers(); + +const p1: Promise = pr.promise; +const p2: Promise = pr2.promise; +const p3: Promise = pr3.promise; + +pr.resolve(42); +pr.resolve(promiseResolve(43)); +pr.reject(); +pr.reject('some error'); + +pr2.resolve('test'); +pr2.resolve(promiseResolve('hi')); +pr2.reject(new Error('fail')); +pr3.resolve(undefined); +pr3.reject(); + +const value: number | PromiseLike = 99; +pr.resolve(value); + +declare function agrees(): PromiseWithResolvers; +const gr: PromiseWithResolvers = agrees(); +gr.resolve(true); +gr.reject(); + +// @ts-expect-error +promiseWithResolvers(123); + +// @ts-expect-error +promiseWithResolvers(123); From 5eda142f768329dcd0592d09d24cf6e56d9e29b4 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 23 Oct 2025 23:05:19 +0700 Subject: [PATCH 047/315] Add proposal types for stages 3-4 --- packages/core-js/modules/es.array.at.js | 1 + .../core-js/modules/es.regexp.constructor.js | 2 + packages/core-js/modules/es.regexp.dot-all.js | 1 + packages/core-js/modules/es.regexp.escape.js | 1 + packages/core-js/modules/es.regexp.exec.js | 2 + packages/core-js/modules/es.regexp.flags.js | 2 + .../core-js/modules/es.set.constructor.js | 1 + packages/core-js/modules/es.set.difference.js | 1 + .../core-js/modules/es.set.intersection.js | 1 + .../modules/es.set.is-disjoint-from.js | 1 + .../core-js/modules/es.set.is-subset-of.js | 1 + .../core-js/modules/es.set.is-superset-of.js | 1 + .../modules/es.set.symmetric-difference.js | 1 + packages/core-js/modules/es.set.union.js | 1 + packages/core-js/modules/es.string.at.js | 1 + .../modules/es.string.is-well-formed.js | 1 + .../core-js/modules/es.string.match-all.js | 1 + packages/core-js/modules/es.string.pad-end.js | 1 + .../core-js/modules/es.string.pad-start.js | 1 + .../core-js/modules/es.string.replace-all.js | 1 + .../modules/es.string.to-well-formed.js | 1 + .../core-js/modules/es.string.trim-end.js | 1 + .../core-js/modules/es.string.trim-left.js | 1 + .../core-js/modules/es.string.trim-right.js | 1 + .../core-js/modules/es.string.trim-start.js | 1 + .../core-js/modules/es.symbol.description.js | 1 + packages/core-js/modules/es.typed-array.at.js | 1 + .../types/proposals/regexp-dotall-flag.d.ts | 10 ++ .../types/proposals/regexp-escaping.d.ts | 8 ++ .../types/proposals/regexp-named-groups.d.ts | 17 +++ .../proposals/relative-indexing-method.d.ts | 63 ++++++++++ .../core-js/types/proposals/set-methods.d.ts | 46 +++++++ .../proposals/string-left-right-trim.d.ts | 16 +++ .../types/proposals/string-match-all.d.ts | 10 ++ .../types/proposals/string-padding.d.ts | 12 ++ .../types/proposals/string-replace-all.d.ts | 12 ++ .../types/proposals/symbol-description.d.ts | 10 ++ .../well-formed-unicode-strings.d.ts | 12 ++ .../global/regexp-dotall-flag.test.ts | 15 +++ .../proposals/global/regexp-escaping.test.ts | 25 ++++ .../global/regexp-named-groups.test.ts | 45 +++++++ .../global/relative-indexing-method.test.ts | 115 ++++++++++++++++++ .../proposals/global/set-methods.test.ts | 98 +++++++++++++++ .../global/string-left-right-trim.test.ts | 22 ++++ .../proposals/global/string-match-all.test.ts | 26 ++++ .../proposals/global/string-padding.test.ts | 28 +++++ .../global/string-replace-all.test.ts | 34 ++++++ .../global/symbol-description.test.ts | 19 +++ .../well-formed-unicode-strings.test.ts | 23 ++++ .../proposals/pure/regexp-escaping.test.ts | 25 ++++ .../pure/relative-indexing-method.test.ts | 28 +++++ .../proposals/pure/set-methods.test.ts | 82 +++++++++++++ .../pure/string-left-right-trim.test.ts | 25 ++++ .../proposals/pure/string-match-all.test.ts | 26 ++++ .../proposals/pure/string-padding.test.ts | 30 +++++ .../proposals/pure/string-replace-all.test.ts | 35 ++++++ .../pure/well-formed-unicode-strings.test.ts | 24 ++++ 57 files changed, 971 insertions(+) create mode 100644 packages/core-js/types/proposals/regexp-dotall-flag.d.ts create mode 100644 packages/core-js/types/proposals/regexp-escaping.d.ts create mode 100644 packages/core-js/types/proposals/regexp-named-groups.d.ts create mode 100644 packages/core-js/types/proposals/relative-indexing-method.d.ts create mode 100644 packages/core-js/types/proposals/set-methods.d.ts create mode 100644 packages/core-js/types/proposals/string-left-right-trim.d.ts create mode 100644 packages/core-js/types/proposals/string-match-all.d.ts create mode 100644 packages/core-js/types/proposals/string-padding.d.ts create mode 100644 packages/core-js/types/proposals/string-replace-all.d.ts create mode 100644 packages/core-js/types/proposals/symbol-description.d.ts create mode 100644 packages/core-js/types/proposals/well-formed-unicode-strings.d.ts create mode 100644 tests/type-definitions/proposals/global/regexp-dotall-flag.test.ts create mode 100644 tests/type-definitions/proposals/global/regexp-escaping.test.ts create mode 100644 tests/type-definitions/proposals/global/regexp-named-groups.test.ts create mode 100644 tests/type-definitions/proposals/global/relative-indexing-method.test.ts create mode 100644 tests/type-definitions/proposals/global/set-methods.test.ts create mode 100644 tests/type-definitions/proposals/global/string-left-right-trim.test.ts create mode 100644 tests/type-definitions/proposals/global/string-match-all.test.ts create mode 100644 tests/type-definitions/proposals/global/string-padding.test.ts create mode 100644 tests/type-definitions/proposals/global/string-replace-all.test.ts create mode 100644 tests/type-definitions/proposals/global/symbol-description.test.ts create mode 100644 tests/type-definitions/proposals/global/well-formed-unicode-strings.test.ts create mode 100644 tests/type-definitions/proposals/pure/regexp-escaping.test.ts create mode 100644 tests/type-definitions/proposals/pure/relative-indexing-method.test.ts create mode 100644 tests/type-definitions/proposals/pure/set-methods.test.ts create mode 100644 tests/type-definitions/proposals/pure/string-left-right-trim.test.ts create mode 100644 tests/type-definitions/proposals/pure/string-match-all.test.ts create mode 100644 tests/type-definitions/proposals/pure/string-padding.test.ts create mode 100644 tests/type-definitions/proposals/pure/string-replace-all.test.ts create mode 100644 tests/type-definitions/proposals/pure/well-formed-unicode-strings.test.ts diff --git a/packages/core-js/modules/es.array.at.js b/packages/core-js/modules/es.array.at.js index c1973582df5f..bc47f078eb21 100644 --- a/packages/core-js/modules/es.array.at.js +++ b/packages/core-js/modules/es.array.at.js @@ -1,3 +1,4 @@ +// types: proposals/relative-indexing-method 'use strict'; var $ = require('../internals/export'); var toObject = require('../internals/to-object'); diff --git a/packages/core-js/modules/es.regexp.constructor.js b/packages/core-js/modules/es.regexp.constructor.js index d86aab5c15db..467f3474cca1 100644 --- a/packages/core-js/modules/es.regexp.constructor.js +++ b/packages/core-js/modules/es.regexp.constructor.js @@ -1,3 +1,5 @@ +// types: proposals/regexp-dotall-flag +// types: proposals/regexp-named-groups 'use strict'; // @dependency: es.regexp.exec var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/es.regexp.dot-all.js b/packages/core-js/modules/es.regexp.dot-all.js index b6d8895cc6a7..979c6dc1a198 100644 --- a/packages/core-js/modules/es.regexp.dot-all.js +++ b/packages/core-js/modules/es.regexp.dot-all.js @@ -1,3 +1,4 @@ +// types: proposals/regexp-dotall-flag 'use strict'; var UNSUPPORTED_DOT_ALL = require('../internals/regexp-unsupported-dot-all'); var classof = require('../internals/classof-raw'); diff --git a/packages/core-js/modules/es.regexp.escape.js b/packages/core-js/modules/es.regexp.escape.js index 38caa454cfc5..094bb3f22065 100644 --- a/packages/core-js/modules/es.regexp.escape.js +++ b/packages/core-js/modules/es.regexp.escape.js @@ -1,3 +1,4 @@ +// types: proposals/regexp-escaping 'use strict'; var $ = require('../internals/export'); var getBuiltInPrototypeMethod = require('../internals/get-built-in-prototype-method'); diff --git a/packages/core-js/modules/es.regexp.exec.js b/packages/core-js/modules/es.regexp.exec.js index b2396e5816b6..b5830f45a4dc 100644 --- a/packages/core-js/modules/es.regexp.exec.js +++ b/packages/core-js/modules/es.regexp.exec.js @@ -1,3 +1,5 @@ +// types: proposals/regexp-dotall-flag +// types: proposals/regexp-named-groups 'use strict'; var $ = require('../internals/export'); var exec = require('../internals/regexp-exec'); diff --git a/packages/core-js/modules/es.regexp.flags.js b/packages/core-js/modules/es.regexp.flags.js index 2d4f6264e0f3..075cd418e5b4 100644 --- a/packages/core-js/modules/es.regexp.flags.js +++ b/packages/core-js/modules/es.regexp.flags.js @@ -1,3 +1,5 @@ +// types: proposals/regexp-dotall-flag +// types: proposals/regexp-named-groups 'use strict'; var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); var regExpFlagsDetection = require('../internals/regexp-flags-detection'); diff --git a/packages/core-js/modules/es.set.constructor.js b/packages/core-js/modules/es.set.constructor.js index a35ebe1e90fb..a63f265a995d 100644 --- a/packages/core-js/modules/es.set.constructor.js +++ b/packages/core-js/modules/es.set.constructor.js @@ -1,3 +1,4 @@ +// types: proposals/set-methods 'use strict'; var collection = require('../internals/collection'); var collectionStrong = require('../internals/collection-strong'); diff --git a/packages/core-js/modules/es.set.difference.js b/packages/core-js/modules/es.set.difference.js index a5e889e9a813..c605f3253755 100644 --- a/packages/core-js/modules/es.set.difference.js +++ b/packages/core-js/modules/es.set.difference.js @@ -1,3 +1,4 @@ +// types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var aSet = require('../internals/a-set'); diff --git a/packages/core-js/modules/es.set.intersection.js b/packages/core-js/modules/es.set.intersection.js index 2fd74d5bbb30..aaf095dfd241 100644 --- a/packages/core-js/modules/es.set.intersection.js +++ b/packages/core-js/modules/es.set.intersection.js @@ -1,3 +1,4 @@ +// types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var fails = require('../internals/fails'); diff --git a/packages/core-js/modules/es.set.is-disjoint-from.js b/packages/core-js/modules/es.set.is-disjoint-from.js index 685dbe14c88a..f9b7c6476458 100644 --- a/packages/core-js/modules/es.set.is-disjoint-from.js +++ b/packages/core-js/modules/es.set.is-disjoint-from.js @@ -1,3 +1,4 @@ +// types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var aSet = require('../internals/a-set'); diff --git a/packages/core-js/modules/es.set.is-subset-of.js b/packages/core-js/modules/es.set.is-subset-of.js index 9cfa54bf6611..bf9b7bdfceec 100644 --- a/packages/core-js/modules/es.set.is-subset-of.js +++ b/packages/core-js/modules/es.set.is-subset-of.js @@ -1,3 +1,4 @@ +// types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var aSet = require('../internals/a-set'); diff --git a/packages/core-js/modules/es.set.is-superset-of.js b/packages/core-js/modules/es.set.is-superset-of.js index c66056b7648a..bd17a20a1455 100644 --- a/packages/core-js/modules/es.set.is-superset-of.js +++ b/packages/core-js/modules/es.set.is-superset-of.js @@ -1,3 +1,4 @@ +// types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var aSet = require('../internals/a-set'); diff --git a/packages/core-js/modules/es.set.symmetric-difference.js b/packages/core-js/modules/es.set.symmetric-difference.js index 75ea7a2b5784..8c624605f219 100644 --- a/packages/core-js/modules/es.set.symmetric-difference.js +++ b/packages/core-js/modules/es.set.symmetric-difference.js @@ -1,3 +1,4 @@ +// types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var aSet = require('../internals/a-set'); diff --git a/packages/core-js/modules/es.set.union.js b/packages/core-js/modules/es.set.union.js index e0e1b3412647..3d82d836f7c0 100644 --- a/packages/core-js/modules/es.set.union.js +++ b/packages/core-js/modules/es.set.union.js @@ -1,3 +1,4 @@ +// types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var aSet = require('../internals/a-set'); diff --git a/packages/core-js/modules/es.string.at.js b/packages/core-js/modules/es.string.at.js index 41377abc15fb..87fff75cb477 100644 --- a/packages/core-js/modules/es.string.at.js +++ b/packages/core-js/modules/es.string.at.js @@ -1,3 +1,4 @@ +// types: proposals/relative-indexing-method 'use strict'; var $ = require('../internals/export'); var requireObjectCoercible = require('../internals/require-object-coercible'); diff --git a/packages/core-js/modules/es.string.is-well-formed.js b/packages/core-js/modules/es.string.is-well-formed.js index f4cb056c692d..df6ca9bada04 100644 --- a/packages/core-js/modules/es.string.is-well-formed.js +++ b/packages/core-js/modules/es.string.is-well-formed.js @@ -1,3 +1,4 @@ +// types: proposals/well-formed-unicode-strings 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/es.string.match-all.js b/packages/core-js/modules/es.string.match-all.js index a499cdf4ced9..85d063b05b90 100644 --- a/packages/core-js/modules/es.string.match-all.js +++ b/packages/core-js/modules/es.string.match-all.js @@ -1,3 +1,4 @@ +// types: proposals/string-match-all 'use strict'; /* eslint-disable es/no-string-prototype-matchall -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.string.pad-end.js b/packages/core-js/modules/es.string.pad-end.js index c671bae66897..b075527317c2 100644 --- a/packages/core-js/modules/es.string.pad-end.js +++ b/packages/core-js/modules/es.string.pad-end.js @@ -1,3 +1,4 @@ +// types: proposals/string-padding 'use strict'; var $ = require('../internals/export'); var $padEnd = require('../internals/string-pad').end; diff --git a/packages/core-js/modules/es.string.pad-start.js b/packages/core-js/modules/es.string.pad-start.js index b4bc677c4e45..ad8903560889 100644 --- a/packages/core-js/modules/es.string.pad-start.js +++ b/packages/core-js/modules/es.string.pad-start.js @@ -1,3 +1,4 @@ +// types: proposals/string-padding 'use strict'; var $ = require('../internals/export'); var $padStart = require('../internals/string-pad').start; diff --git a/packages/core-js/modules/es.string.replace-all.js b/packages/core-js/modules/es.string.replace-all.js index 60931f31b0a2..b31ef52f6807 100644 --- a/packages/core-js/modules/es.string.replace-all.js +++ b/packages/core-js/modules/es.string.replace-all.js @@ -1,3 +1,4 @@ +// types: proposals/string-replace-all 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.string.to-well-formed.js b/packages/core-js/modules/es.string.to-well-formed.js index e16005cecdd4..142342ac85b0 100644 --- a/packages/core-js/modules/es.string.to-well-formed.js +++ b/packages/core-js/modules/es.string.to-well-formed.js @@ -1,3 +1,4 @@ +// types: proposals/well-formed-unicode-strings 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.string.trim-end.js b/packages/core-js/modules/es.string.trim-end.js index 215978f998bd..f841cc6ad380 100644 --- a/packages/core-js/modules/es.string.trim-end.js +++ b/packages/core-js/modules/es.string.trim-end.js @@ -1,3 +1,4 @@ +// types: proposals/string-left-right-trim 'use strict'; var $ = require('../internals/export'); var trimEnd = require('../internals/string-trim-end'); diff --git a/packages/core-js/modules/es.string.trim-left.js b/packages/core-js/modules/es.string.trim-left.js index d40b2951262d..eec34be6510f 100644 --- a/packages/core-js/modules/es.string.trim-left.js +++ b/packages/core-js/modules/es.string.trim-left.js @@ -1,3 +1,4 @@ +// types: proposals/string-left-right-trim 'use strict'; var $ = require('../internals/export'); var trimStart = require('../internals/string-trim-start'); diff --git a/packages/core-js/modules/es.string.trim-right.js b/packages/core-js/modules/es.string.trim-right.js index 50232778d204..ef8ba1ddb7f5 100644 --- a/packages/core-js/modules/es.string.trim-right.js +++ b/packages/core-js/modules/es.string.trim-right.js @@ -1,3 +1,4 @@ +// types: proposals/string-left-right-trim 'use strict'; var $ = require('../internals/export'); var trimEnd = require('../internals/string-trim-end'); diff --git a/packages/core-js/modules/es.string.trim-start.js b/packages/core-js/modules/es.string.trim-start.js index 2fcd9f4ad0aa..095b8a01062b 100644 --- a/packages/core-js/modules/es.string.trim-start.js +++ b/packages/core-js/modules/es.string.trim-start.js @@ -1,3 +1,4 @@ +// types: proposals/string-left-right-trim 'use strict'; var $ = require('../internals/export'); var trimStart = require('../internals/string-trim-start'); diff --git a/packages/core-js/modules/es.symbol.description.js b/packages/core-js/modules/es.symbol.description.js index b3c8072ba237..ae39801858b9 100644 --- a/packages/core-js/modules/es.symbol.description.js +++ b/packages/core-js/modules/es.symbol.description.js @@ -1,3 +1,4 @@ +// types: proposals/symbol-description // `Symbol.prototype.description` getter // https://tc39.es/ecma262/#sec-symbol.prototype.description 'use strict'; diff --git a/packages/core-js/modules/es.typed-array.at.js b/packages/core-js/modules/es.typed-array.at.js index 70a5cecb048f..27027944ad6f 100644 --- a/packages/core-js/modules/es.typed-array.at.js +++ b/packages/core-js/modules/es.typed-array.at.js @@ -1,3 +1,4 @@ +// types: proposals/relative-indexing-method 'use strict'; var exportTypedArrayMethod = require('../internals/export-typed-array-method'); var aTypedArray = require('../internals/a-typed-array'); diff --git a/packages/core-js/types/proposals/regexp-dotall-flag.d.ts b/packages/core-js/types/proposals/regexp-dotall-flag.d.ts new file mode 100644 index 000000000000..931f2cedf514 --- /dev/null +++ b/packages/core-js/types/proposals/regexp-dotall-flag.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-regexp-dotall-flag + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2018.regexp.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface RegExp { + readonly dotAll: boolean; +} diff --git a/packages/core-js/types/proposals/regexp-escaping.d.ts b/packages/core-js/types/proposals/regexp-escaping.d.ts new file mode 100644 index 000000000000..e3526cfa3e88 --- /dev/null +++ b/packages/core-js/types/proposals/regexp-escaping.d.ts @@ -0,0 +1,8 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-regex-escaping + +interface RegExpConstructor { + escape(string: string): string; +} + +declare var RegExp: RegExpConstructor; diff --git a/packages/core-js/types/proposals/regexp-named-groups.d.ts b/packages/core-js/types/proposals/regexp-named-groups.d.ts new file mode 100644 index 000000000000..d262ed4fc084 --- /dev/null +++ b/packages/core-js/types/proposals/regexp-named-groups.d.ts @@ -0,0 +1,17 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-regexp-named-groups + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2018.regexp.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface RegExpExecArray extends Array { + groups?: { + [key: string]: string; + }; +} +interface RegExpMatchArray extends Array { + groups?: { + [key: string]: string; + }; +} diff --git a/packages/core-js/types/proposals/relative-indexing-method.d.ts b/packages/core-js/types/proposals/relative-indexing-method.d.ts new file mode 100644 index 000000000000..b07d4cbe0e93 --- /dev/null +++ b/packages/core-js/types/proposals/relative-indexing-method.d.ts @@ -0,0 +1,63 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-relative-indexing-method + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.array.d.ts +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface String { + at(index: number): string | undefined; +} + +interface Array { + at(index: number): T | undefined; +} + +interface ReadonlyArray { + at(index: number): T | undefined; +} + +interface Int8Array { + at(index: number): number | undefined; +} + +interface Uint8Array { + at(index: number): number | undefined; +} + +interface Uint8ClampedArray { + at(index: number): number | undefined; +} + +interface Int16Array { + at(index: number): number | undefined; +} + +interface Uint16Array { + at(index: number): number | undefined; +} + +interface Int32Array { + at(index: number): number | undefined; +} + +interface Uint32Array { + at(index: number): number | undefined; +} + +interface Float32Array { + at(index: number): number | undefined; +} + +interface Float64Array { + at(index: number): number | undefined; +} + +interface BigInt64Array { + at(index: number): bigint | undefined; +} + +interface BigUint64Array { + at(index: number): bigint | undefined; +} diff --git a/packages/core-js/types/proposals/set-methods.d.ts b/packages/core-js/types/proposals/set-methods.d.ts new file mode 100644 index 000000000000..eee1e46701ad --- /dev/null +++ b/packages/core-js/types/proposals/set-methods.d.ts @@ -0,0 +1,46 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-set-methods + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface ReadonlySetLike { + keys(): Iterator; + + has(value: T): boolean; + + readonly size: number; +} + +interface Set { + union(other: ReadonlySetLike): Set; + + intersection(other: ReadonlySetLike): Set; + + difference(other: ReadonlySetLike): Set; + + symmetricDifference(other: ReadonlySetLike): Set; + + isSubsetOf(other: ReadonlySetLike): boolean; + + isSupersetOf(other: ReadonlySetLike): boolean; + + isDisjointFrom(other: ReadonlySetLike): boolean; +} + +interface ReadonlySet { + union(other: ReadonlySetLike): Set; + + intersection(other: ReadonlySetLike): Set; + + difference(other: ReadonlySetLike): Set; + + symmetricDifference(other: ReadonlySetLike): Set; + + isSubsetOf(other: ReadonlySetLike): boolean; + + isSupersetOf(other: ReadonlySetLike): boolean; + + isDisjointFrom(other: ReadonlySetLike): boolean; +} diff --git a/packages/core-js/types/proposals/string-left-right-trim.d.ts b/packages/core-js/types/proposals/string-left-right-trim.d.ts new file mode 100644 index 000000000000..cbd4ce89a795 --- /dev/null +++ b/packages/core-js/types/proposals/string-left-right-trim.d.ts @@ -0,0 +1,16 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-string-left-right-trim + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface String { + trimEnd(): string; + + trimStart(): string; + + trimLeft(): string; + + trimRight(): string; +} diff --git a/packages/core-js/types/proposals/string-match-all.d.ts b/packages/core-js/types/proposals/string-match-all.d.ts new file mode 100644 index 000000000000..84178483473f --- /dev/null +++ b/packages/core-js/types/proposals/string-match-all.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-string-matchall + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface String { + matchAll(regexp: RegExp): RegExpStringIterator; +} diff --git a/packages/core-js/types/proposals/string-padding.d.ts b/packages/core-js/types/proposals/string-padding.d.ts new file mode 100644 index 000000000000..c4e9a68da923 --- /dev/null +++ b/packages/core-js/types/proposals/string-padding.d.ts @@ -0,0 +1,12 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-string-pad-start-end + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface String { + padStart(maxLength: number, fillString?: string): string; + + padEnd(maxLength: number, fillString?: string): string; +} diff --git a/packages/core-js/types/proposals/string-replace-all.d.ts b/packages/core-js/types/proposals/string-replace-all.d.ts new file mode 100644 index 000000000000..a76a6be7d60e --- /dev/null +++ b/packages/core-js/types/proposals/string-replace-all.d.ts @@ -0,0 +1,12 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-string-replaceall + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface String { + replaceAll(searchValue: string | RegExp, replaceValue: string): string; + + replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; +} diff --git a/packages/core-js/types/proposals/symbol-description.d.ts b/packages/core-js/types/proposals/symbol-description.d.ts new file mode 100644 index 000000000000..6d0927220518 --- /dev/null +++ b/packages/core-js/types/proposals/symbol-description.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-Symbol-description + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.symbol.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface Symbol { + readonly description: string | undefined; +} diff --git a/packages/core-js/types/proposals/well-formed-unicode-strings.d.ts b/packages/core-js/types/proposals/well-formed-unicode-strings.d.ts new file mode 100644 index 000000000000..3f4c2caf5e4d --- /dev/null +++ b/packages/core-js/types/proposals/well-formed-unicode-strings.d.ts @@ -0,0 +1,12 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-is-usv-string + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2024.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface String { + isWellFormed(): boolean; + + toWellFormed(): string; +} diff --git a/tests/type-definitions/proposals/global/regexp-dotall-flag.test.ts b/tests/type-definitions/proposals/global/regexp-dotall-flag.test.ts new file mode 100644 index 000000000000..286c56a36090 --- /dev/null +++ b/tests/type-definitions/proposals/global/regexp-dotall-flag.test.ts @@ -0,0 +1,15 @@ +import 'core-js/full'; + +const r1 = new RegExp('foo.bar', 's'); +const dotAll: boolean = r1.dotAll; + +// @ts-expect-error +r1.dotAll(); +// @ts-expect-error +r1['dotAll'] = false; +// @ts-expect-error +RegExp.prototype['dotAll'] = true; +// @ts-expect-error +RegExp.prototype.dotAll(); +// @ts-expect-error +const err: string = r1.dotAll; diff --git a/tests/type-definitions/proposals/global/regexp-escaping.test.ts b/tests/type-definitions/proposals/global/regexp-escaping.test.ts new file mode 100644 index 000000000000..8247f2e80a58 --- /dev/null +++ b/tests/type-definitions/proposals/global/regexp-escaping.test.ts @@ -0,0 +1,25 @@ +import 'core-js/full'; + +const escaped1: string = RegExp.escape('foo.*+?^${}()|[]\\'); +const escaped2: string = RegExp.escape(''); +const s: string = 'abc'; +const escaped3: string = RegExp.escape(s); + +// Некорректные вызовы + +// @ts-expect-error +RegExp.escape(); +// @ts-expect-error +RegExp.escape(123); +// @ts-expect-error +RegExp.escape(); +// @ts-expect-error +RegExp.escape({}); +// @ts-expect-error +RegExp.escape(/abc/); +// @ts-expect-error +RegExp.escape([]); +// @ts-expect-error +const wrong: number = RegExp.escape('boo'); +// @ts-expect-error +RegExp.escape('foo', 'bar'); diff --git a/tests/type-definitions/proposals/global/regexp-named-groups.test.ts b/tests/type-definitions/proposals/global/regexp-named-groups.test.ts new file mode 100644 index 000000000000..ae52ed44cd18 --- /dev/null +++ b/tests/type-definitions/proposals/global/regexp-named-groups.test.ts @@ -0,0 +1,45 @@ +import 'core-js/full'; + +declare const execArr: RegExpExecArray; +declare const matchArr: RegExpMatchArray; + +const execGroups: { [key: string]: string } | undefined = execArr.groups; +const matchGroups: { [key: string]: string } | undefined = matchArr.groups; + +if (execGroups) { + const foo: string | undefined = execGroups.foo; + const bar: string | undefined = execGroups["bar"]; +} + +if (matchGroups) { + const baz: string | undefined = matchGroups.baz; + const qr: string | undefined = matchGroups["qr"]; +} + +// Динамический ключ: +if (execGroups) { + const key = "dynamic"; + const dyn: string | undefined = execGroups[key]; +} + +const first: string = execArr[0]; +const mfirst: string = matchArr[0]; + +// @ts-expect-error +execArr.groups = { foo: 123 }; +// @ts-expect-error +execArr.groups = "bad"; +// @ts-expect-error +matchArr.groups = { baz: 123 }; +// @ts-expect-error +matchArr.groups = 42; +// @ts-expect-error +execGroups.foo = 1; +// @ts-expect-error +const n: number = execGroups && execGroups.foo; +// @ts-expect-error +const b: boolean = execArr.groups && execArr.groups.bar; +// @ts-expect-error +const numFirst: number = execArr[0]; +// @ts-expect-error +const arrTest: string[] = execArr.groups; diff --git a/tests/type-definitions/proposals/global/relative-indexing-method.test.ts b/tests/type-definitions/proposals/global/relative-indexing-method.test.ts new file mode 100644 index 000000000000..39020fafdaf0 --- /dev/null +++ b/tests/type-definitions/proposals/global/relative-indexing-method.test.ts @@ -0,0 +1,115 @@ +import 'core-js/full'; + +const str = 'hello'; +const s1: string | undefined = str.at(0); +const s2: string | undefined = str.at(-1); + +const arr: number[] = [10, 20, 30]; +const a1: number | undefined = arr.at(1); +const a2: number | undefined = arr.at(-2); + +const roArr: ReadonlyArray = ['a', 'b', 'c']; +const r1: string | undefined = roArr.at(1); +const r2: string | undefined = roArr.at(-3); + +const i8 = new Int8Array([5, 6, 7]); +const i8_1: number | undefined = i8.at(2); +const i8_2: number | undefined = i8.at(-1); + +const u8 = new Uint8Array([8, 9, 10]); +const u8_1: number | undefined = u8.at(0); + +const u8c = new Uint8ClampedArray([15, 16, 17]); +const u8c_1: number | undefined = u8c.at(2); + +const i16 = new Int16Array([100, 200, 300]); +const i16_1: number | undefined = i16.at(1); + +const u16 = new Uint16Array([400, 500, 600]); +const u16_1: number | undefined = u16.at(-1); + +const i32 = new Int32Array([1, 2, 3]); +const i32_1: number | undefined = i32.at(0); + +const u32 = new Uint32Array([7, 8, 9]); +const u32_1: number | undefined = u32.at(2); + +const f32 = new Float32Array([1.5, 2.5, 3.5]); +const f32_1: number | undefined = f32.at(-1); + +const f64 = new Float64Array([11.1, 22.2, 33.3]); +const f64_1: number | undefined = f64.at(0); + +const bi64 = new (BigInt64Array as { new(arr: ArrayLike): BigInt64Array })([BigInt(1), BigInt(2), BigInt(3)]); +const bi64_1: bigint | undefined = bi64.at(2); + +const bu64 = new (BigUint64Array as { new(arr: ArrayLike): BigUint64Array })([BigInt(10), BigInt(20)]); +const bu64_1: bigint | undefined = bu64.at(-1); + +// @ts-expect-error +str.at(); +// @ts-expect-error +str.at('1'); +// @ts-expect-error +str.at(1, 2); + +// @ts-expect-error +arr.at(); +// @ts-expect-error +arr.at('1'); +// @ts-expect-error +arr.at({}); +// @ts-expect-error +arr.at(); +// @ts-expect-error +arr.at(1, 1); + +// @ts-expect-error +roArr.at(); +// @ts-expect-error +roArr.at('2'); + +// @ts-expect-error +i8.at(); +// @ts-expect-error +i8.at('0'); +// @ts-expect-error +i8.at(1, 2); + +// @ts-expect-error +u8.at('0'); +// @ts-expect-error +u8.at(); + +// @ts-expect-error +u8c.at(); +// @ts-expect-error +u8c.at({}); +// @ts-expect-error +u8c.at(''); + +// @ts-expect-error +i16.at(); +// @ts-expect-error +i16.at([]); + +// @ts-expect-error +u16.at(() => 42); + +// @ts-expect-error +i32.at(false); + +// @ts-expect-error +u32.at(Symbol()); + +// @ts-expect-error +f32.at('a'); + +// @ts-expect-error +f64.at([]); + +// @ts-expect-error +bi64.at('a'); + +// @ts-expect-error +bu64.at({}); diff --git a/tests/type-definitions/proposals/global/set-methods.test.ts b/tests/type-definitions/proposals/global/set-methods.test.ts new file mode 100644 index 000000000000..5b1f3313706d --- /dev/null +++ b/tests/type-definitions/proposals/global/set-methods.test.ts @@ -0,0 +1,98 @@ +import 'core-js/full'; + +const setA = new Set([1, 2, 3]); +const setB = new Set(['a', 'b', 'c']); + +const setLike: ReadonlySetLike = { + keys() { return [1, 2, 3][Symbol.iterator](); }, + has(val: number): boolean { return val === 2; }, + size: 3 +}; + +const setLikeStr: ReadonlySetLike = { + keys() { return ['a', 'b'][Symbol.iterator](); }, + has(val: string): boolean { return val === 'a'; }, + size: 2 +}; + +const arrSet: ReadonlySet = new Set([4, 5, 6]); + +const unionAB: Set = setA.union(setB); +const unionAN: Set = setA.union(setLike); + +const interAB: Set = setA.intersection(setB); +const interAN: Set = setA.intersection(setLike); + +const diffAB: Set = setA.difference(setB); +const diffAN: Set = setA.difference(setLike); + +const symdiffAB: Set = setA.symmetricDifference(setB); +const symdiffAL: Set = setA.symmetricDifference(setLike); + +const sub: boolean = setA.isSubsetOf(setLikeStr); +const superSet: boolean = setA.isSupersetOf(setLikeStr); +const isDisjoint: boolean = setA.isDisjointFrom(setLike); + +const unionR: Set = arrSet.union(setLike); +const intersectionR: Set = arrSet.intersection(setLike); +const diffR: Set = arrSet.difference(setLike); +const symdiffR: Set = arrSet.symmetricDifference(setLike); + +const subR: boolean = arrSet.isSubsetOf(setLikeStr); +const supR: boolean = arrSet.isSupersetOf(setLikeStr); +const disjR: boolean = arrSet.isDisjointFrom(setLike); + +const numStrUnion: Set = setA.union(setLikeStr); +const numStrInter: Set = setA.intersection(setLikeStr); +const numStrSym: Set = setA.symmetricDifference(setLikeStr); + +// @ts-expect-error +setA.union(); +// @ts-expect-error +setA.union(123); +// @ts-expect-error +setA.union({}); + +// @ts-expect-error +setA.intersection(); +// @ts-expect-error +setA.intersection('a'); +// @ts-expect-error +setA.intersection({ foo: 'bar' }); + +// @ts-expect-error +setA.difference(); +// @ts-expect-error +setA.difference([]); + +// @ts-expect-error +setA.symmetricDifference(); +// @ts-expect-error +setA.symmetricDifference(1); + +// @ts-expect-error +setA.isSubsetOf(); +// @ts-expect-error +setA.isSubsetOf([]); + +// @ts-expect-error +setA.isSupersetOf(); +// @ts-expect-error +setA.isDisjointFrom(); + +// @ts-expect-error +arrSet.union(); +// @ts-expect-error +arrSet.union('a'); + +// @ts-expect-error +arrSet.intersection({}); + +// @ts-expect-error +arrSet.difference({}); + +// @ts-expect-error +arrSet.symmetricDifference({}); + +// @ts-expect-error +arrSet.isSubsetOf(1); diff --git a/tests/type-definitions/proposals/global/string-left-right-trim.test.ts b/tests/type-definitions/proposals/global/string-left-right-trim.test.ts new file mode 100644 index 000000000000..0da6d7ed51a7 --- /dev/null +++ b/tests/type-definitions/proposals/global/string-left-right-trim.test.ts @@ -0,0 +1,22 @@ +import 'core-js/full'; + +const s = 'abc'; +const t1: string = s.trimEnd(); +const t2: string = s.trimStart(); +const t3: string = s.trimLeft(); +const t4: string = s.trimRight(); + +// @ts-expect-error +s.trimEnd(123); + +// @ts-expect-error +s.trimStart('a'); + +// @ts-expect-error +s.trimLeft([]); + +// @ts-expect-error +s.trimRight({}); + +// @ts-expect-error +const n: number = s.trimEnd(); diff --git a/tests/type-definitions/proposals/global/string-match-all.test.ts b/tests/type-definitions/proposals/global/string-match-all.test.ts new file mode 100644 index 000000000000..662b73e3cc1d --- /dev/null +++ b/tests/type-definitions/proposals/global/string-match-all.test.ts @@ -0,0 +1,26 @@ +import 'core-js/full'; + +const s = 'abcabc'; +const re = /abc/g; +const matchIter: RegExpStringIterator = s.matchAll(re); + +const result = s.matchAll(re); +const assertType: RegExpStringIterator = result; + +// @ts-expect-error +s.matchAll(); + +// @ts-expect-error +s.matchAll('abc'); + +// @ts-expect-error +const n: number = s.matchAll(re); + +// @ts-expect-error +s.matchAll({}); + +// @ts-expect-error +s.matchAll(123); + +// @ts-expect-error +s.matchAll(/abc/g, /def/g); diff --git a/tests/type-definitions/proposals/global/string-padding.test.ts b/tests/type-definitions/proposals/global/string-padding.test.ts new file mode 100644 index 000000000000..42e5c44aeea5 --- /dev/null +++ b/tests/type-definitions/proposals/global/string-padding.test.ts @@ -0,0 +1,28 @@ +import 'core-js/full'; + +const s = 'foo'; +const p1: string = s.padStart(5); +const p2: string = s.padStart(10, '0'); +const p3: string = s.padEnd(8); +const p4: string = s.padEnd(4, '-'); + +// @ts-expect-error +s.padStart(); +// @ts-expect-error +s.padEnd(); +// @ts-expect-error +s.padStart('10'); +// @ts-expect-error +s.padEnd(true); +// @ts-expect-error +s.padStart(5, 1); +// @ts-expect-error +s.padEnd(3, {}); +// @ts-expect-error +s.padStart(2, [], 'extra'); +// @ts-expect-error +s.padEnd(7, '', undefined); +// @ts-expect-error +const n: number = s.padStart(5); +// @ts-expect-error +const n2: number = s.padEnd(3, '-'); diff --git a/tests/type-definitions/proposals/global/string-replace-all.test.ts b/tests/type-definitions/proposals/global/string-replace-all.test.ts new file mode 100644 index 000000000000..c65e1000ebdc --- /dev/null +++ b/tests/type-definitions/proposals/global/string-replace-all.test.ts @@ -0,0 +1,34 @@ +import 'core-js/full'; + +const s = 'foo bar foo'; + +const r1: string = s.replaceAll('foo', 'baz'); +const r2: string = s.replaceAll(/foo/g, 'baz'); +const r3: string = s.replaceAll('bar', (substr: string) => substr); +const r4: string = s.replaceAll(/bar/g, (substr: string) => substr + 'Test'); +const r5: string = s.replaceAll('foo', function(substring: string): string { return substring + '!'; }); +const r6: string = s.replaceAll(/foo/g, (match: string, ...args: any[]) => match + args.length); + +// @ts-expect-error +s.replaceAll(); + +// @ts-expect-error +s.replaceAll('foo'); + +// @ts-expect-error +s.replaceAll('foo', 1); + +// @ts-expect-error +s.replaceAll('foo', {}); + +// @ts-expect-error +s.replaceAll(/foo/, 'bar', 'extra'); + +// @ts-expect-error +s.replaceAll(/foo/g, (match: string) => 123); + +// @ts-expect-error +s.replaceAll(/foo/g, 5); + +// @ts-expect-error +const n: number = s.replaceAll('foo', 'baz'); diff --git a/tests/type-definitions/proposals/global/symbol-description.test.ts b/tests/type-definitions/proposals/global/symbol-description.test.ts new file mode 100644 index 000000000000..94f52767ea83 --- /dev/null +++ b/tests/type-definitions/proposals/global/symbol-description.test.ts @@ -0,0 +1,19 @@ +import 'core-js/full'; + +const sym1 = Symbol('foo'); +const d1: string | undefined = sym1.description; + +const sym2 = Symbol(); +const d2: string | undefined = sym2.description; + +// @ts-expect-error +sym1['description'] = 'bar'; + +// @ts-expect-error +const n: number = sym1.description; + +// @ts-expect-error +sym2.description(); + +// @ts-expect-error +s.description = 123; diff --git a/tests/type-definitions/proposals/global/well-formed-unicode-strings.test.ts b/tests/type-definitions/proposals/global/well-formed-unicode-strings.test.ts new file mode 100644 index 000000000000..e089e4857fa2 --- /dev/null +++ b/tests/type-definitions/proposals/global/well-formed-unicode-strings.test.ts @@ -0,0 +1,23 @@ +import 'core-js/full'; + +const s = 'test'; +const b: boolean = s.isWellFormed(); +const str: string = s.toWellFormed(); + +// @ts-expect-error +s.isWellFormed(123); + +// @ts-expect-error +s.isWellFormed('foo'); + +// @ts-expect-error +s.toWellFormed([]); + +// @ts-expect-error +s.toWellFormed(true); + +// @ts-expect-error +const n: number = s.toWellFormed(); + +// @ts-expect-error +const s2: string = s.isWellFormed(); diff --git a/tests/type-definitions/proposals/pure/regexp-escaping.test.ts b/tests/type-definitions/proposals/pure/regexp-escaping.test.ts new file mode 100644 index 000000000000..2e9091b11b71 --- /dev/null +++ b/tests/type-definitions/proposals/pure/regexp-escaping.test.ts @@ -0,0 +1,25 @@ +import regexpEscape from '@core-js/pure/full/regexp/escape'; + +const escaped1: string = regexpEscape('foo.*+?^${}()|[]\\'); +const escaped2: string = regexpEscape(''); +const s: string = 'abc'; +const escaped3: string = regexpEscape(s); + +// Некорректные вызовы + +// @ts-expect-error +regexpEscape(); +// @ts-expect-error +regexpEscape(123); +// @ts-expect-error +regexpEscape(); +// @ts-expect-error +regexpEscape({}); +// @ts-expect-error +regexpEscape(/abc/); +// @ts-expect-error +regexpEscape([]); +// @ts-expect-error +const wrong: number = regexpEscape('boo'); +// @ts-expect-error +regexpEscape('foo', 'bar'); diff --git a/tests/type-definitions/proposals/pure/relative-indexing-method.test.ts b/tests/type-definitions/proposals/pure/relative-indexing-method.test.ts new file mode 100644 index 000000000000..07592f654b62 --- /dev/null +++ b/tests/type-definitions/proposals/pure/relative-indexing-method.test.ts @@ -0,0 +1,28 @@ +import stringAt from '@core-js/pure/full/string/at'; +import arrayAt from '@core-js/pure/full/array/at'; + +const str = 'hello'; +const s1: string | undefined = stringAt(str, 0); +const s2: string | undefined = stringAt(str, -1); + +const arr: number[] = [10, 20, 30]; +const a1: number | undefined = arrayAt(arr, 1); +const a2: number | undefined = arrayAt(arr, -2); + +// @ts-expect-error +stringAt(str); +// @ts-expect-error +stringAt(str, '1'); +// @ts-expect-error +stringAt(str, 1, 2); + +// @ts-expect-error +arrayAt(arr); +// @ts-expect-error +arrayAt(arr, '1'); +// @ts-expect-error +arrayAt(arr, {}); +// @ts-expect-error +arrayAt(arr); +// @ts-expect-error +arrayAt(arr, 1, 1); diff --git a/tests/type-definitions/proposals/pure/set-methods.test.ts b/tests/type-definitions/proposals/pure/set-methods.test.ts new file mode 100644 index 000000000000..4aae8ea4f397 --- /dev/null +++ b/tests/type-definitions/proposals/pure/set-methods.test.ts @@ -0,0 +1,82 @@ +import setUnion from '@core-js/pure/full/set/union'; +import setIntersection from '@core-js/pure/full/set/intersection'; +import setDifference from '@core-js/pure/full/set/difference'; +import setSymmetricDifference from '@core-js/pure/full/set/symmetric-difference'; +import setIsSubsetOf from '@core-js/pure/full/set/is-subset-of'; +import setIsSupersetOf from '@core-js/pure/full/set/is-superset-of'; +import setIsDisjointFrom from '@core-js/pure/full/set/is-disjoint-from'; + +const setA = new Set([1, 2, 3]); +const setB = new Set(['a', 'b', 'c']); + +const setLike: ReadonlySetLike = { + keys() { return [1, 2, 3][Symbol.iterator](); }, + has(val: number): boolean { return val === 2; }, + size: 3 +}; + +const setLikeStr: ReadonlySetLike = { + keys() { return ['a', 'b'][Symbol.iterator](); }, + has(val: string): boolean { return val === 'a'; }, + size: 2 +}; + +// todo check return types after uncurried methods fix +// const unionAB: Set = setUnion(setA, setB); +// const unionAN: Set = setUnion(setA, setLike); + +setUnion(setA, setB); +setUnion(setA, setLike); +setUnion(setA, setLikeStr); + +const interAB: Set = setIntersection(setA, setB); +const interAN: Set = setIntersection(setA, setLike); +setIntersection(setA, setLikeStr); + +const diffAB: Set = setDifference(setA, setB); +const diffAN: Set = setDifference(setA, setLike); +setDifference(setA, setLikeStr); + +// todo check return types after uncurried methods fix +// const symdiffAB: Set = setSymmetricDifference(setA, setB); +// const symdiffAL: Set = setSymmetricDifference(setA, setLike); +setSymmetricDifference(setA, setB); +setSymmetricDifference(setA, setLike); + +const sub: boolean = setIsSubsetOf(setA, setLikeStr); +const superSet: boolean = setIsSupersetOf(setA, setLikeStr); +const isDisjoint: boolean = setIsDisjointFrom(setA, setLike); + +// @ts-expect-error +setUnion(setA); +// @ts-expect-error +setUnion(setA, 123); +// @ts-expect-error +setUnion(setA, {}); + +// @ts-expect-error +setIntersection(setA); +// @ts-expect-error +setIntersection(setA, 'a'); +// @ts-expect-error +setIntersection(setA, { foo: 'bar' }); + +// @ts-expect-error +setDifference(setA); +// @ts-expect-error +setDifference(setA, []); + +// @ts-expect-error +setSymmetricDifference(setA); +// @ts-expect-error +setSymmetricDifference(setA, 1); + +// @ts-expect-error +setIsSubsetOf(setA); +// @ts-expect-error +setIsSubsetOf(setA, []); + +// @ts-expect-error +setIsSupersetOf(setA); +// @ts-expect-error +setIsDisjointFrom(setA); diff --git a/tests/type-definitions/proposals/pure/string-left-right-trim.test.ts b/tests/type-definitions/proposals/pure/string-left-right-trim.test.ts new file mode 100644 index 000000000000..ac6c29a748ce --- /dev/null +++ b/tests/type-definitions/proposals/pure/string-left-right-trim.test.ts @@ -0,0 +1,25 @@ +import stringTrimLeft from '@core-js/pure/full/string/trim-left'; +import stringTrimStart from '@core-js/pure/full/string/trim-start'; +import stringTrimRight from '@core-js/pure/full/string/trim-right'; +import stringTrimEnd from '@core-js/pure/full/string/trim-end'; + +const s = 'abc'; +const t1: string = stringTrimLeft(s); +const t2: string = stringTrimStart(s); +const t3: string = stringTrimRight(s); +const t4: string = stringTrimEnd(s); + +// @ts-expect-error +stringTrimLeft(s, 123); + +// @ts-expect-error +stringTrimStart(s, 'a'); + +// @ts-expect-error +stringTrimRight(s, []); + +// @ts-expect-error +stringTrimEnd(s, {}); + +// @ts-expect-error +const n: number = stringTrimLeft(s); diff --git a/tests/type-definitions/proposals/pure/string-match-all.test.ts b/tests/type-definitions/proposals/pure/string-match-all.test.ts new file mode 100644 index 000000000000..cf699e29bb1e --- /dev/null +++ b/tests/type-definitions/proposals/pure/string-match-all.test.ts @@ -0,0 +1,26 @@ +import stringMatchAll from '@core-js/pure/full/string/match-all'; + +const s = 'abcabc'; +const re = /abc/g; +const matchIter: RegExpStringIterator = stringMatchAll(s, re); + +const result = stringMatchAll(s, re); +const assertType: RegExpStringIterator = result; + +// @ts-expect-error +stringMatchAll(s); + +// @ts-expect-error +stringMatchAll(s, 'abc'); + +// @ts-expect-error +const n: number = stringMatchAll(re); + +// @ts-expect-error +stringMatchAll(s, {}); + +// @ts-expect-error +stringMatchAll(s, 123); + +// @ts-expect-error +stringMatchAll(s, /abc/g, /def/g); diff --git a/tests/type-definitions/proposals/pure/string-padding.test.ts b/tests/type-definitions/proposals/pure/string-padding.test.ts new file mode 100644 index 000000000000..d78e278b68e6 --- /dev/null +++ b/tests/type-definitions/proposals/pure/string-padding.test.ts @@ -0,0 +1,30 @@ +import stringPadStart from '@core-js/pure/full/string/pad-start'; +import stringPadEnd from '@core-js/pure/full/string/pad-end'; + +const s = 'foo'; +const str: string = ''; +const p1: string = stringPadStart(s, 5); +const p2: string = stringPadStart(s, 10, '0'); +const p3: string = stringPadEnd(s, 8); +const p4: string = stringPadEnd(s, 4, '-'); + +// @ts-expect-error +stringPadStart(s, ); +// @ts-expect-error +stringPadEnd(s, ); +// @ts-expect-error +stringPadStart(s, '10'); +// @ts-expect-error +stringPadEnd(s, true); +// @ts-expect-error +stringPadStart(s, 5, 1); +// @ts-expect-error +stringPadEnd(s, 3, {}); +// @ts-expect-error +stringPadStart(s, 2, [], 'extra'); +// @ts-expect-error +stringPadEnd(s, 7, '', undefined); +// @ts-expect-error +const n: number = stringPadStart(s, 5); +// @ts-expect-error +const n2: number = stringPadEnd(s, 3, '-'); diff --git a/tests/type-definitions/proposals/pure/string-replace-all.test.ts b/tests/type-definitions/proposals/pure/string-replace-all.test.ts new file mode 100644 index 000000000000..edd00d436366 --- /dev/null +++ b/tests/type-definitions/proposals/pure/string-replace-all.test.ts @@ -0,0 +1,35 @@ +import stringReplaceAll from '@core-js/pure/full/string/replace-all'; + +const s = 'foo bar foo'; + +// todo fix after uncurried methods fix +// const r1: string = stringReplaceAll(s, 'foo', 'baz'); +// const r2: string = stringReplaceAll(s, /foo/g, 'baz'); +const r3: string = stringReplaceAll(s, 'bar', (substr: string) => substr); +const r4: string = stringReplaceAll(s, /bar/g, (substr: string) => substr + 'Test'); +const r5: string = stringReplaceAll(s, 'foo', function(substring: string): string { return substring + '!'; }); +const r6: string = stringReplaceAll(s, /foo/g, (match: string, ...args: any[]) => match + args.length); + +// @ts-expect-error +stringReplaceAll(s); + +// @ts-expect-error +stringReplaceAll(s, 'foo'); + +// @ts-expect-error +stringReplaceAll(s, 'foo', 1); + +// @ts-expect-error +stringReplaceAll(s, 'foo', {}); + +// @ts-expect-error +stringReplaceAll(s, /foo/, 'bar', 'extra'); + +// @ts-expect-error +stringReplaceAll(s, /foo/g, (match: string) => 123); + +// @ts-expect-error +stringReplaceAll(s, /foo/g, 5); + +// @ts-expect-error +const n: number = stringReplaceAll(s, 'foo', 'baz'); diff --git a/tests/type-definitions/proposals/pure/well-formed-unicode-strings.test.ts b/tests/type-definitions/proposals/pure/well-formed-unicode-strings.test.ts new file mode 100644 index 000000000000..5abd21abe632 --- /dev/null +++ b/tests/type-definitions/proposals/pure/well-formed-unicode-strings.test.ts @@ -0,0 +1,24 @@ +import stringIsWellFormed from '@core-js/pure/full/string/is-well-formed'; +import stringToWellFormed from '@core-js/pure/full/string/to-well-formed'; + +const s = 'test'; +const b: boolean = stringIsWellFormed(s); +const str: string = stringToWellFormed(s); + +// @ts-expect-error +stringIsWellFormed(s, 123); + +// @ts-expect-error +stringIsWellFormed(s, 'foo'); + +// @ts-expect-error +stringToWellFormed(s, []); + +// @ts-expect-error +stringToWellFormed(s, true); + +// @ts-expect-error +const n: number = stringToWellFormed(s); + +// @ts-expect-error +const s2: string = stringIsWellFormed(s); From 8cb181347284874ddb1066120009ac27b04297e5 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 24 Oct 2025 18:49:34 +0700 Subject: [PATCH 048/315] Add proposal types for stages 3-4 --- packages/core-js/types/proposals/pattern-matching.d.ts | 6 ++++++ .../proposals/global/async-iteration.test.ts | 2 -- .../proposals/global/pattern-matching.test.ts | 8 ++++++++ .../proposals/pure/async-iteration.test.ts | 6 ++---- .../proposals/pure/pattern-matching.test.ts | 8 ++++++++ 5 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 packages/core-js/types/proposals/pattern-matching.d.ts create mode 100644 tests/type-definitions/proposals/global/pattern-matching.test.ts create mode 100644 tests/type-definitions/proposals/pure/pattern-matching.test.ts diff --git a/packages/core-js/types/proposals/pattern-matching.d.ts b/packages/core-js/types/proposals/pattern-matching.d.ts new file mode 100644 index 000000000000..874f263f2930 --- /dev/null +++ b/packages/core-js/types/proposals/pattern-matching.d.ts @@ -0,0 +1,6 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-pattern-matching + +interface SymbolConstructor { + readonly customMatcher: unique symbol; +} diff --git a/tests/type-definitions/proposals/global/async-iteration.test.ts b/tests/type-definitions/proposals/global/async-iteration.test.ts index 1f96b012de28..b2989ab42dd2 100644 --- a/tests/type-definitions/proposals/global/async-iteration.test.ts +++ b/tests/type-definitions/proposals/global/async-iteration.test.ts @@ -1,8 +1,6 @@ import 'core-js/full'; -const aiter: symbol = Symbol.asyncIterator; const sym: symbol = Symbol.asyncIterator; -const s: typeof Symbol.asyncIterator = Symbol.asyncIterator; // @ts-expect-error const bad1: string = Symbol.asyncIterator; diff --git a/tests/type-definitions/proposals/global/pattern-matching.test.ts b/tests/type-definitions/proposals/global/pattern-matching.test.ts new file mode 100644 index 000000000000..7d7f8de721aa --- /dev/null +++ b/tests/type-definitions/proposals/global/pattern-matching.test.ts @@ -0,0 +1,8 @@ +import 'core-js/full'; + +const sym: symbol = Symbol.customMatcher; + +// @ts-expect-error +const bad1: string = Symbol.customMatcher; +// @ts-expect-error +Symbol['customMatcher'] = Symbol("other"); diff --git a/tests/type-definitions/proposals/pure/async-iteration.test.ts b/tests/type-definitions/proposals/pure/async-iteration.test.ts index 386494a1348b..b33c8d23377d 100644 --- a/tests/type-definitions/proposals/pure/async-iteration.test.ts +++ b/tests/type-definitions/proposals/pure/async-iteration.test.ts @@ -1,11 +1,9 @@ import symbolAsyncIterator from '@core-js/pure/full/symbol/async-iterator'; import $symbol from '@core-js/pure/full/symbol'; -const aiter: symbol = symbolAsyncIterator; -const sym: symbol = symbolAsyncIterator; -const s: typeof symbolAsyncIterator = symbolAsyncIterator; +const sym: symbol = $symbol.asyncIterator; // @ts-expect-error -const bad1: string = symbolAsyncIterator; +const bad1: string = $symbol.asyncIterator; // @ts-expect-error $symbol['asyncIterator'] = $symbol("other"); diff --git a/tests/type-definitions/proposals/pure/pattern-matching.test.ts b/tests/type-definitions/proposals/pure/pattern-matching.test.ts new file mode 100644 index 000000000000..415dedd16502 --- /dev/null +++ b/tests/type-definitions/proposals/pure/pattern-matching.test.ts @@ -0,0 +1,8 @@ +import $symbol from '@core-js/pure/full/symbol'; + +const sym: symbol = $symbol.customMatcher; + +// @ts-expect-error +const bad1: string = $symbol.customMatcher; +// @ts-expect-error +$symbol['customMatcher'] = $symbol("other"); From 18bd7a42d02809c87e909624e6e4081a22d8e738 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 24 Oct 2025 21:05:31 +0700 Subject: [PATCH 049/315] Add custom types --- .../types/proposals/array-flat-map.d.ts | 13 +- .../types/proposals/change-array-by-copy.d.ts | 130 ++++++++++-------- .../types/proposals/iterator-helpers.d.ts | 8 +- .../core-js/types/proposals/set-methods.d.ts | 51 ++++--- .../types/proposals/string-replace-all.d.ts | 12 +- scripts/build-entries/entries-definitions.mjs | 33 +++-- .../proposals/pure/array-flat-map.test.ts | 5 +- .../pure/change-array-by-copy.test.ts | 3 +- .../proposals/pure/iterator-helpers.test.ts | 33 ++--- .../proposals/pure/set-methods.test.ts | 21 +-- .../proposals/pure/string-replace-all.test.ts | 5 +- 11 files changed, 168 insertions(+), 146 deletions(-) diff --git a/packages/core-js/types/proposals/array-flat-map.d.ts b/packages/core-js/types/proposals/array-flat-map.d.ts index 86442a23252b..accacb8b5c35 100644 --- a/packages/core-js/types/proposals/array-flat-map.d.ts +++ b/packages/core-js/types/proposals/array-flat-map.d.ts @@ -4,8 +4,15 @@ // For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface Array { - flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): U[]; - flat(this: A, depth?: D): FlatArray[]; +declare global { + interface Array { + flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): U[]; + + flat(this: A, depth?: D): FlatArray[]; + } } + +export {}; + +export type CoreJsArrayFlatMap = (callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This) => U[]; diff --git a/packages/core-js/types/proposals/change-array-by-copy.d.ts b/packages/core-js/types/proposals/change-array-by-copy.d.ts index bac970bb58ab..fe20e41bbe28 100644 --- a/packages/core-js/types/proposals/change-array-by-copy.d.ts +++ b/packages/core-js/types/proposals/change-array-by-copy.d.ts @@ -4,101 +4,109 @@ // For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface Array { - toReversed(): T[]; - toSorted(compareFn?: (a: T, b: T) => number): T[]; +declare global { + interface Array { + toReversed(): T[]; - toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; - toSpliced(start: number, deleteCount?: number): T[]; + toSorted(compareFn?: (a: T, b: T) => number): T[]; - with(index: number, value: T): T[]; -} + toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; -interface Int8Array { - toReversed(): Int8Array; + toSpliced(start: number, deleteCount?: number): T[]; - toSorted(compareFn?: (a: number, b: number) => number): Int8Array; + with(index: number, value: T): T[]; + } - with(index: number, value: number): Int8Array; -} + interface Int8Array { + toReversed(): Int8Array; -interface Uint8Array { - toReversed(): Uint8Array; + toSorted(compareFn?: (a: number, b: number) => number): Int8Array; - toSorted(compareFn?: (a: number, b: number) => number): Uint8Array; + with(index: number, value: number): Int8Array; + } - with(index: number, value: number): Uint8Array; -} + interface Uint8Array { + toReversed(): Uint8Array; -interface Uint8ClampedArray { - toReversed(): Uint8ClampedArray; + toSorted(compareFn?: (a: number, b: number) => number): Uint8Array; - toSorted(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + with(index: number, value: number): Uint8Array; + } - with(index: number, value: number): Uint8ClampedArray; -} + interface Uint8ClampedArray { + toReversed(): Uint8ClampedArray; -interface Int16Array { - toReversed(): Int16Array; + toSorted(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; - toSorted(compareFn?: (a: number, b: number) => number): Int16Array; + with(index: number, value: number): Uint8ClampedArray; + } - with(index: number, value: number): Int16Array; -} + interface Int16Array { + toReversed(): Int16Array; -interface Uint16Array { - toReversed(): Uint16Array; + toSorted(compareFn?: (a: number, b: number) => number): Int16Array; - toSorted(compareFn?: (a: number, b: number) => number): Uint16Array; + with(index: number, value: number): Int16Array; + } - with(index: number, value: number): Uint16Array; -} + interface Uint16Array { + toReversed(): Uint16Array; -interface Int32Array { - toReversed(): Int32Array; + toSorted(compareFn?: (a: number, b: number) => number): Uint16Array; - toSorted(compareFn?: (a: number, b: number) => number): Int32Array; + with(index: number, value: number): Uint16Array; + } - with(index: number, value: number): Int32Array; -} + interface Int32Array { + toReversed(): Int32Array; -interface Uint32Array { - toReversed(): Uint32Array; + toSorted(compareFn?: (a: number, b: number) => number): Int32Array; - toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; + with(index: number, value: number): Int32Array; + } - with(index: number, value: number): Uint32Array; -} + interface Uint32Array { + toReversed(): Uint32Array; -interface Float32Array { - toReversed(): Float32Array; + toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; - toSorted(compareFn?: (a: number, b: number) => number): Float32Array; + with(index: number, value: number): Uint32Array; + } - with(index: number, value: number): Float32Array; -} + interface Float32Array { + toReversed(): Float32Array; -interface Float64Array { - toReversed(): Float64Array; + toSorted(compareFn?: (a: number, b: number) => number): Float32Array; - toSorted(compareFn?: (a: number, b: number) => number): Float64Array; + with(index: number, value: number): Float32Array; + } - with(index: number, value: number): Float64Array; -} + interface Float64Array { + toReversed(): Float64Array; -interface BigInt64Array { - toReversed(): BigInt64Array; + toSorted(compareFn?: (a: number, b: number) => number): Float64Array; - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; + with(index: number, value: number): Float64Array; + } - with(index: number, value: bigint): BigInt64Array; -} + interface BigInt64Array { + toReversed(): BigInt64Array; + + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; -interface BigUint64Array { - toReversed(): BigUint64Array; + with(index: number, value: bigint): BigInt64Array; + } - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; + interface BigUint64Array { + toReversed(): BigUint64Array; - with(index: number, value: bigint): BigUint64Array; + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; + + with(index: number, value: bigint): BigUint64Array; + } } + +export {}; + +export type CoreJsArrayToSpliced = ((start: number, deleteCount: number, ...items: T[]) => T[]) | ((start: number, deleteCount?: number)=> T[]); diff --git a/packages/core-js/types/proposals/iterator-helpers.d.ts b/packages/core-js/types/proposals/iterator-helpers.d.ts index 94b74f3e9efa..88091e7de4d5 100644 --- a/packages/core-js/types/proposals/iterator-helpers.d.ts +++ b/packages/core-js/types/proposals/iterator-helpers.d.ts @@ -39,8 +39,6 @@ declare global { export {}; -export interface Methods { - map: (callback: (value: T, index: number) => U) => CoreJsIteratorObject; - flatMap: (callback: (value: T, index: number) => Iterator | Iterable) => CoreJsIteratorObject; - reduce: (callback: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; -} +export type CoreJsIteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => CoreJsIteratorObject; +export type CoreJsIteratorMap = (callback: (value: T, index: number) => U) => CoreJsIteratorObject; +export type CoreJsIteratorReduce = (callback: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; diff --git a/packages/core-js/types/proposals/set-methods.d.ts b/packages/core-js/types/proposals/set-methods.d.ts index eee1e46701ad..5e35487159fb 100644 --- a/packages/core-js/types/proposals/set-methods.d.ts +++ b/packages/core-js/types/proposals/set-methods.d.ts @@ -5,42 +5,49 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface ReadonlySetLike { - keys(): Iterator; +declare global { + interface ReadonlySetLike { + keys(): Iterator; - has(value: T): boolean; + has(value: T): boolean; - readonly size: number; -} + readonly size: number; + } -interface Set { - union(other: ReadonlySetLike): Set; + interface Set { + union(other: ReadonlySetLike): Set; - intersection(other: ReadonlySetLike): Set; + intersection(other: ReadonlySetLike): Set; - difference(other: ReadonlySetLike): Set; + difference(other: ReadonlySetLike): Set; - symmetricDifference(other: ReadonlySetLike): Set; + symmetricDifference(other: ReadonlySetLike): Set; - isSubsetOf(other: ReadonlySetLike): boolean; + isSubsetOf(other: ReadonlySetLike): boolean; - isSupersetOf(other: ReadonlySetLike): boolean; + isSupersetOf(other: ReadonlySetLike): boolean; - isDisjointFrom(other: ReadonlySetLike): boolean; -} + isDisjointFrom(other: ReadonlySetLike): boolean; + } -interface ReadonlySet { - union(other: ReadonlySetLike): Set; + interface ReadonlySet { + union(other: ReadonlySetLike): Set; - intersection(other: ReadonlySetLike): Set; + intersection(other: ReadonlySetLike): Set; - difference(other: ReadonlySetLike): Set; + difference(other: ReadonlySetLike): Set; - symmetricDifference(other: ReadonlySetLike): Set; + symmetricDifference(other: ReadonlySetLike): Set; - isSubsetOf(other: ReadonlySetLike): boolean; + isSubsetOf(other: ReadonlySetLike): boolean; - isSupersetOf(other: ReadonlySetLike): boolean; + isSupersetOf(other: ReadonlySetLike): boolean; - isDisjointFrom(other: ReadonlySetLike): boolean; + isDisjointFrom(other: ReadonlySetLike): boolean; + } } + +export {}; + +export type CoreJsSetUnion = (other: ReadonlySetLike) => Set; +export type CoreJsSetSymmetricDifference = (other: ReadonlySetLike) => Set; diff --git a/packages/core-js/types/proposals/string-replace-all.d.ts b/packages/core-js/types/proposals/string-replace-all.d.ts index a76a6be7d60e..188f53a1e508 100644 --- a/packages/core-js/types/proposals/string-replace-all.d.ts +++ b/packages/core-js/types/proposals/string-replace-all.d.ts @@ -5,8 +5,14 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface String { - replaceAll(searchValue: string | RegExp, replaceValue: string): string; +declare global { + interface String { + replaceAll(searchValue: string | RegExp, replaceValue: string): string; - replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; + replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; + } } + +export {}; + +export type CoreJsStringReplaceAll = ((searchValue: string | RegExp, replaceValue: string) => string) | ((searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string) => string); diff --git a/scripts/build-entries/entries-definitions.mjs b/scripts/build-entries/entries-definitions.mjs index 6ad1bcaa72c9..6ad865df4519 100644 --- a/scripts/build-entries/entries-definitions.mjs +++ b/scripts/build-entries/entries-definitions.mjs @@ -1,6 +1,7 @@ import { $uncurried, $uncurriedIterator, + $uncurriedWithCustomType, $prototype, $prototypeIterator, $static, @@ -319,9 +320,11 @@ export const features = { }, 'array/flat-map': { modules: ['es.array.flat-map'], - template: $uncurried, + template: $uncurriedWithCustomType, namespace: 'Array', name: 'flatMap', + customType: 'proposals/array-flat-map', + genericsCount: 3, }, 'array/prototype/flat-map': { modules: ['es.array.flat-map'], @@ -547,9 +550,11 @@ export const features = { }, 'array/to-spliced': { modules: ['es.array.to-spliced'], - template: $uncurried, + template: $uncurriedWithCustomType, namespace: 'Array', name: 'toSpliced', + customType: 'proposals/change-array-by-copy', + genericsCount: 1, }, 'array/prototype/to-spliced': { modules: ['es.array.to-spliced'], @@ -1286,9 +1291,11 @@ export const features = { }, 'iterator/flat-map': { modules: ['es.iterator.flat-map'], - template: $uncurried, + template: $uncurriedWithCustomType, namespace: 'Iterator', name: 'flatMap', + customType: 'proposals/iterator-helpers', + genericsCount: 2, }, 'iterator/prototype/flat-map': { modules: ['es.iterator.flat-map'], @@ -1322,9 +1329,11 @@ export const features = { }, 'iterator/map': { modules: ['es.iterator.map'], - template: $uncurried, + template: $uncurriedWithCustomType, namespace: 'Iterator', name: 'map', + customType: 'proposals/iterator-helpers', + genericsCount: 2, }, 'iterator/prototype/map': { modules: ['es.iterator.map'], @@ -1334,9 +1343,11 @@ export const features = { }, 'iterator/reduce': { modules: ['es.iterator.reduce'], - template: $uncurried, + template: $uncurriedWithCustomType, namespace: 'Iterator', name: 'reduce', + customType: 'proposals/iterator-helpers', + genericsCount: 2, }, 'iterator/prototype/reduce': { modules: ['es.iterator.reduce'], @@ -2243,9 +2254,11 @@ export const features = { }, 'set/symmetric-difference': { modules: ['es.set.symmetric-difference'], - template: $uncurried, + template: $uncurriedWithCustomType, namespace: 'Set', name: 'symmetricDifference', + customType: 'proposals/set-methods', + genericsCount: 2, }, 'set/prototype/symmetric-difference': { modules: ['es.set.symmetric-difference'], @@ -2255,9 +2268,11 @@ export const features = { }, 'set/union': { modules: ['es.set.union'], - template: $uncurried, + template: $uncurriedWithCustomType, namespace: 'Set', name: 'union', + customType: 'proposals/set-methods', + genericsCount: 2, }, 'set/prototype/union': { modules: ['es.set.union'], @@ -2536,9 +2551,11 @@ export const features = { }, 'string/replace-all': { modules: ['es.string.replace-all'], - template: $uncurried, + template: $uncurriedWithCustomType, namespace: 'String', name: 'replaceAll', + customType: 'proposals/string-replace-all', + genericsCount: 2, }, 'string/prototype/replace-all': { modules: ['es.string.replace-all'], diff --git a/tests/type-definitions/proposals/pure/array-flat-map.test.ts b/tests/type-definitions/proposals/pure/array-flat-map.test.ts index e8a36c5a283d..8cf36ad56e9f 100644 --- a/tests/type-definitions/proposals/pure/array-flat-map.test.ts +++ b/tests/type-definitions/proposals/pure/array-flat-map.test.ts @@ -1,9 +1,8 @@ import arrayFlatMap from '@core-js/pure/full/array/flat-map'; import arrayFlat from '@core-js/pure/full/array/flat'; -// todo check return type after fix -arrayFlatMap([1, 2, 3], x => [x, x * 2]); -arrayFlatMap(['a', 'b', 'c'], x => [x, x.toUpperCase()]); +const flatMapped: number[] = arrayFlatMap([1, 2, 3], x => [x, x * 2]); +const flatMapped2: string[] = arrayFlatMap(['a', 'b', 'c'], x => [x, x.toUpperCase()]); arrayFlatMap([1, 2, 3], x => x > 1 ? [x, x] : []); arrayFlatMap([1, 2, 3], function (x) { return [this, x]; }, 123); arrayFlatMap([1, 2, 3], (x, i, arr) => arr); diff --git a/tests/type-definitions/proposals/pure/change-array-by-copy.test.ts b/tests/type-definitions/proposals/pure/change-array-by-copy.test.ts index 914ead1f572b..6e2051155916 100644 --- a/tests/type-definitions/proposals/pure/change-array-by-copy.test.ts +++ b/tests/type-definitions/proposals/pure/change-array-by-copy.test.ts @@ -7,8 +7,7 @@ const arr: number[] = [1, 2, 3]; const arrRev: number[] = arrayToReversed(arr); const arrSorted: number[] = arrayToSorted(arr); const arrSorted2: number[] = arrayToSorted(arr, (a, b) => b - a); -// todo add items after fix uncurried version -const arrSpliced: number[] = arrayToSpliced(arr, 1, 1); +const arrSpliced: number[] = arrayToSpliced(arr, 1, 1, 4, 5); const arrSpliced2: number[] = arrayToSpliced(arr, 1); const arrSpliced3: number[] = arrayToSpliced(arr, 1, 2); const arrWith: number[] = arrayWith(arr, 1, 42); diff --git a/tests/type-definitions/proposals/pure/iterator-helpers.test.ts b/tests/type-definitions/proposals/pure/iterator-helpers.test.ts index 9b50f8f929c5..7e821030d207 100644 --- a/tests/type-definitions/proposals/pure/iterator-helpers.test.ts +++ b/tests/type-definitions/proposals/pure/iterator-helpers.test.ts @@ -14,11 +14,8 @@ declare const it: Iterator; declare const itStr: Iterator; declare const itNumStr: Iterator; -// todo uncomment when uncurried methods would be fixed -// const res: Iterator = iteratorMap(it, (v, i) => String(v)); -// const mappedNum: Iterator = iteratorMap(it, n => n + 1); -iteratorMap(it, (v, i) => String(v)); -iteratorMap(it, n => n + 1); +const res: Iterator = iteratorMap(it, (v, i) => String(v)); +const mappedNum: Iterator = iteratorMap(it, n => n + 1); // @ts-expect-error iteratorMap(); @@ -45,15 +42,8 @@ const dropped: Iterator = iteratorDrop(it, 3); // @ts-expect-error iteratorDrop('3'); -// todo uncomment when uncurried methods would be fixed -// const flatMapped: Iterator = iteratorFlatMap(it, (v, i) => itStr); -// const flatMapped2: Iterator = iteratorFlatMap(it, (v, i) => ({ -// [Symbol.iterator]: function* () { -// yield String(v); -// } -// })); -iteratorFlatMap(it, (v, i) => itStr); -iteratorFlatMap(it, (v, i) => ({ +const flatMapped: Iterator = iteratorFlatMap(it, (v, i) => itStr); +const flatMapped2: Iterator = iteratorFlatMap(it, (v, i) => ({ [Symbol.iterator]: function* () { yield String(v); } @@ -62,14 +52,13 @@ iteratorFlatMap(it, (v, i) => ({ // @ts-expect-error iteratorFlatMap(); -// todo fix -// const sum1: number = iteratorReduce(it, (a, b, c) => a + b + c, 0); -// const sum2: number = iteratorReduce(it, (a, b, c) => a + b + c, 0); -// const strReduce: string = iteratorReduce( -// it, -// (acc: string, val) => acc + val, -// '' -// ); +const sum1: number = iteratorReduce(it, (a, b, c) => a + b + c, 0); +const sum2: number = iteratorReduce(it, (a, b, c) => a + b + c, 0); +const strReduce: string = iteratorReduce( + it, + (acc: string, val) => acc + val, + '' +); // @ts-expect-error iteratorReduce(); diff --git a/tests/type-definitions/proposals/pure/set-methods.test.ts b/tests/type-definitions/proposals/pure/set-methods.test.ts index 4aae8ea4f397..fee65f87549a 100644 --- a/tests/type-definitions/proposals/pure/set-methods.test.ts +++ b/tests/type-definitions/proposals/pure/set-methods.test.ts @@ -21,27 +21,20 @@ const setLikeStr: ReadonlySetLike = { size: 2 }; -// todo check return types after uncurried methods fix -// const unionAB: Set = setUnion(setA, setB); -// const unionAN: Set = setUnion(setA, setLike); - -setUnion(setA, setB); -setUnion(setA, setLike); -setUnion(setA, setLikeStr); +const unionAB: Set = setUnion(setA, setB); +const unionAL: Set = setUnion(setA, setLike); +const unionALS: Set = setUnion(setA, setLikeStr); const interAB: Set = setIntersection(setA, setB); const interAN: Set = setIntersection(setA, setLike); -setIntersection(setA, setLikeStr); +const interALS: Set = setIntersection(setA, setLikeStr); const diffAB: Set = setDifference(setA, setB); const diffAN: Set = setDifference(setA, setLike); -setDifference(setA, setLikeStr); +const diffALS: Set = setDifference(setA, setLikeStr); -// todo check return types after uncurried methods fix -// const symdiffAB: Set = setSymmetricDifference(setA, setB); -// const symdiffAL: Set = setSymmetricDifference(setA, setLike); -setSymmetricDifference(setA, setB); -setSymmetricDifference(setA, setLike); +const symdiffAB: Set = setSymmetricDifference(setA, setB); +const symdiffAL: Set = setSymmetricDifference(setA, setLike); const sub: boolean = setIsSubsetOf(setA, setLikeStr); const superSet: boolean = setIsSupersetOf(setA, setLikeStr); diff --git a/tests/type-definitions/proposals/pure/string-replace-all.test.ts b/tests/type-definitions/proposals/pure/string-replace-all.test.ts index edd00d436366..5ad8ad6ef59a 100644 --- a/tests/type-definitions/proposals/pure/string-replace-all.test.ts +++ b/tests/type-definitions/proposals/pure/string-replace-all.test.ts @@ -2,9 +2,8 @@ import stringReplaceAll from '@core-js/pure/full/string/replace-all'; const s = 'foo bar foo'; -// todo fix after uncurried methods fix -// const r1: string = stringReplaceAll(s, 'foo', 'baz'); -// const r2: string = stringReplaceAll(s, /foo/g, 'baz'); +const r1: string = stringReplaceAll(s, 'foo', 'baz'); +const r2: string = stringReplaceAll(s, /foo/g, 'baz'); const r3: string = stringReplaceAll(s, 'bar', (substr: string) => substr); const r4: string = stringReplaceAll(s, /bar/g, (substr: string) => substr + 'Test'); const r5: string = stringReplaceAll(s, 'foo', function(substring: string): string { return substring + '!'; }); From edf0ac345ee87d972aad93ae38a5c2a671ed3f2a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 24 Oct 2025 21:10:05 +0700 Subject: [PATCH 050/315] Remove unnecessary comments --- .../proposals/global/array-buffer-transfer.test.ts | 2 -- .../type-definitions/proposals/global/iterator-helpers.test.ts | 2 +- .../proposals/global/object-values-entries.test.ts | 2 -- tests/type-definitions/proposals/global/promise-finally.test.ts | 1 - tests/type-definitions/proposals/global/regexp-escaping.test.ts | 2 -- .../proposals/global/regexp-named-groups.test.ts | 1 - tests/type-definitions/proposals/pure/iterator-helpers.test.ts | 2 +- .../proposals/pure/object-values-entries.test.ts | 2 -- tests/type-definitions/proposals/pure/promise-finally.test.ts | 1 - tests/type-definitions/proposals/pure/regexp-escaping.test.ts | 2 -- 10 files changed, 2 insertions(+), 15 deletions(-) diff --git a/tests/type-definitions/proposals/global/array-buffer-transfer.test.ts b/tests/type-definitions/proposals/global/array-buffer-transfer.test.ts index 1545e883d570..7e4acf0eae5f 100644 --- a/tests/type-definitions/proposals/global/array-buffer-transfer.test.ts +++ b/tests/type-definitions/proposals/global/array-buffer-transfer.test.ts @@ -8,8 +8,6 @@ const abTransfer2: ArrayBuffer = ab.transfer(32); const abTransferFixed: ArrayBuffer = ab.transferToFixedLength(); const abTransferFixed2: ArrayBuffer = ab.transferToFixedLength(64); -// Некорректные вызовы - // @ts-expect-error ab.detached(1); // @ts-expect-error diff --git a/tests/type-definitions/proposals/global/iterator-helpers.test.ts b/tests/type-definitions/proposals/global/iterator-helpers.test.ts index ad4f2c52ed1b..b5bcb703908f 100644 --- a/tests/type-definitions/proposals/global/iterator-helpers.test.ts +++ b/tests/type-definitions/proposals/global/iterator-helpers.test.ts @@ -79,7 +79,7 @@ it.every(); it.every((v, i, extra) => true); const found1: number | undefined = it.find((v, i) => v > 5); -const findString: string | undefined = itNumStr.find((v): v is string => typeof v === 'string'); +const findString: string | number = itNumStr.find((v): v is string => typeof v === 'string'); // @ts-expect-error it.find(); diff --git a/tests/type-definitions/proposals/global/object-values-entries.test.ts b/tests/type-definitions/proposals/global/object-values-entries.test.ts index ce789d73924d..08836ce7eb8e 100644 --- a/tests/type-definitions/proposals/global/object-values-entries.test.ts +++ b/tests/type-definitions/proposals/global/object-values-entries.test.ts @@ -21,8 +21,6 @@ const entries5: [string, any][] = Object.entries(emptyObj); const valuesAnyArr: any[] = Object.values({ foo: 123, bar: "baz" }); const entriesAnyArr: [string, any][] = Object.entries({ foo: 123, bar: "baz" }); -// Некорректные вызовы - // @ts-expect-error Object.values(); diff --git a/tests/type-definitions/proposals/global/promise-finally.test.ts b/tests/type-definitions/proposals/global/promise-finally.test.ts index 6accc9916486..c0923cfa112f 100644 --- a/tests/type-definitions/proposals/global/promise-finally.test.ts +++ b/tests/type-definitions/proposals/global/promise-finally.test.ts @@ -11,7 +11,6 @@ const p2 = Promise.reject("err"); const pf6: Promise = p2.finally(); const pf7: Promise = p2.finally(() => {}); -// Можно вызывать на generic declare function returnsPromise(): Promise; const genericF: Promise = returnsPromise().finally(() => {}); diff --git a/tests/type-definitions/proposals/global/regexp-escaping.test.ts b/tests/type-definitions/proposals/global/regexp-escaping.test.ts index 8247f2e80a58..64bd78bca4dd 100644 --- a/tests/type-definitions/proposals/global/regexp-escaping.test.ts +++ b/tests/type-definitions/proposals/global/regexp-escaping.test.ts @@ -5,8 +5,6 @@ const escaped2: string = RegExp.escape(''); const s: string = 'abc'; const escaped3: string = RegExp.escape(s); -// Некорректные вызовы - // @ts-expect-error RegExp.escape(); // @ts-expect-error diff --git a/tests/type-definitions/proposals/global/regexp-named-groups.test.ts b/tests/type-definitions/proposals/global/regexp-named-groups.test.ts index ae52ed44cd18..8ae7eae0b1fa 100644 --- a/tests/type-definitions/proposals/global/regexp-named-groups.test.ts +++ b/tests/type-definitions/proposals/global/regexp-named-groups.test.ts @@ -16,7 +16,6 @@ if (matchGroups) { const qr: string | undefined = matchGroups["qr"]; } -// Динамический ключ: if (execGroups) { const key = "dynamic"; const dyn: string | undefined = execGroups[key]; diff --git a/tests/type-definitions/proposals/pure/iterator-helpers.test.ts b/tests/type-definitions/proposals/pure/iterator-helpers.test.ts index 7e821030d207..d4a705ed6c63 100644 --- a/tests/type-definitions/proposals/pure/iterator-helpers.test.ts +++ b/tests/type-definitions/proposals/pure/iterator-helpers.test.ts @@ -90,7 +90,7 @@ iteratorEvery(it); iteratorEvery(it, (v, i, extra) => true); const found1: number | undefined = iteratorFind(it, (v, i) => v > 5); -// const findString: string | undefined = iteratorFind(itNumStr, (v): v is string => typeof v === 'string'); +const findString: string | number = iteratorFind(itNumStr, (v): v is string => typeof v === 'string'); iteratorFind(itNumStr, (v): v is string => typeof v === 'string'); // @ts-expect-error diff --git a/tests/type-definitions/proposals/pure/object-values-entries.test.ts b/tests/type-definitions/proposals/pure/object-values-entries.test.ts index b0104c593572..ba56cb8aff6b 100644 --- a/tests/type-definitions/proposals/pure/object-values-entries.test.ts +++ b/tests/type-definitions/proposals/pure/object-values-entries.test.ts @@ -22,8 +22,6 @@ const entries5: [string, any][] = objectEntries(emptyObj); const valuesAnyArr: any[] = objectValues({ foo: 123, bar: "baz" }); const entriesAnyArr: [string, any][] = objectEntries({ foo: 123, bar: "baz" }); -// Некорректные вызовы - // @ts-expect-error objectValues(); diff --git a/tests/type-definitions/proposals/pure/promise-finally.test.ts b/tests/type-definitions/proposals/pure/promise-finally.test.ts index 9e47a640f544..36054651dcda 100644 --- a/tests/type-definitions/proposals/pure/promise-finally.test.ts +++ b/tests/type-definitions/proposals/pure/promise-finally.test.ts @@ -12,7 +12,6 @@ const p2 = Promise.reject("err"); const pf6: Promise = promiseFinally(p2); const pf7: Promise = promiseFinally(p2, () => {}); -// Можно вызывать на generic declare function returnsPromise(): Promise; const genericF: Promise = returnsPromise().finally(() => {}); diff --git a/tests/type-definitions/proposals/pure/regexp-escaping.test.ts b/tests/type-definitions/proposals/pure/regexp-escaping.test.ts index 2e9091b11b71..da34a159082a 100644 --- a/tests/type-definitions/proposals/pure/regexp-escaping.test.ts +++ b/tests/type-definitions/proposals/pure/regexp-escaping.test.ts @@ -5,8 +5,6 @@ const escaped2: string = regexpEscape(''); const s: string = 'abc'; const escaped3: string = regexpEscape(s); -// Некорректные вызовы - // @ts-expect-error regexpEscape(); // @ts-expect-error From dc2b54fcf2f423c28c17b28891f4d4b5a9c2f9d9 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 24 Oct 2025 21:17:47 +0700 Subject: [PATCH 051/315] Fix iterator-helpers test --- .../type-definitions/proposals/global/iterator-helpers.test.ts | 2 +- tests/type-definitions/proposals/pure/iterator-helpers.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/type-definitions/proposals/global/iterator-helpers.test.ts b/tests/type-definitions/proposals/global/iterator-helpers.test.ts index b5bcb703908f..1686ac2ab661 100644 --- a/tests/type-definitions/proposals/global/iterator-helpers.test.ts +++ b/tests/type-definitions/proposals/global/iterator-helpers.test.ts @@ -79,7 +79,7 @@ it.every(); it.every((v, i, extra) => true); const found1: number | undefined = it.find((v, i) => v > 5); -const findString: string | number = itNumStr.find((v): v is string => typeof v === 'string'); +const findString: string | number | undefined = itNumStr.find((v): v is string => typeof v === 'string'); // @ts-expect-error it.find(); diff --git a/tests/type-definitions/proposals/pure/iterator-helpers.test.ts b/tests/type-definitions/proposals/pure/iterator-helpers.test.ts index d4a705ed6c63..f49c814d4bb3 100644 --- a/tests/type-definitions/proposals/pure/iterator-helpers.test.ts +++ b/tests/type-definitions/proposals/pure/iterator-helpers.test.ts @@ -90,7 +90,7 @@ iteratorEvery(it); iteratorEvery(it, (v, i, extra) => true); const found1: number | undefined = iteratorFind(it, (v, i) => v > 5); -const findString: string | number = iteratorFind(itNumStr, (v): v is string => typeof v === 'string'); +const findString: string | number | undefined = iteratorFind(itNumStr, (v): v is string => typeof v === 'string'); iteratorFind(itNumStr, (v): v is string => typeof v === 'string'); // @ts-expect-error From 32ad63708d19b962331b6885f107a5546b2f205a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 27 Oct 2025 17:51:56 +0700 Subject: [PATCH 052/315] Fix for codespell --- tests/type-definitions/proposals/pure/set-methods.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/type-definitions/proposals/pure/set-methods.test.ts b/tests/type-definitions/proposals/pure/set-methods.test.ts index fee65f87549a..58819c79dd0a 100644 --- a/tests/type-definitions/proposals/pure/set-methods.test.ts +++ b/tests/type-definitions/proposals/pure/set-methods.test.ts @@ -27,7 +27,7 @@ const unionALS: Set = setUnion(setA, setLikeStr); const interAB: Set = setIntersection(setA, setB); const interAN: Set = setIntersection(setA, setLike); -const interALS: Set = setIntersection(setA, setLikeStr); +const intersectionALS: Set = setIntersection(setA, setLikeStr); const diffAB: Set = setDifference(setA, setB); const diffAN: Set = setDifference(setA, setLike); From cc7a6cc11a3a5cb3d9b1da729971ace2ed1c9284 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 30 Oct 2025 23:42:20 +0700 Subject: [PATCH 053/315] Create package with core-js types --- .gitignore | 2 + package.json | 3 +- packages/core-js-types/package.json | 32 ++++ .../src/56/common/aggregate-error.d.ts | 11 ++ .../src/56/common/object-extend.d.ts | 9 ++ .../src/56/common/symbol-match-all.d.ts | 3 + .../core-js-types/src/56/common/timers.d.ts | 4 + .../src/56/core-js-types/core-js-types.d.ts | 39 +++++ .../accessible-object-hasownproperty.d.ts | 0 .../56}/proposals/array-buffer-base64.d.ts | 0 .../56}/proposals/array-buffer-transfer.d.ts | 0 .../src/56}/proposals/array-filtering.d.ts | 8 +- .../56}/proposals/array-find-from-last.d.ts | 4 +- .../56/proposals/array-flat-map-custom.d.ts | 10 ++ .../src/56}/proposals/array-flat-map.d.ts | 6 +- .../src/56/proposals/array-from-async.d.ts | 16 ++ .../src/56}/proposals/array-grouping.d.ts | 0 .../src/56}/proposals/array-includes.d.ts | 4 +- .../proposals/array-is-template-object.d.ts | 0 .../src/56}/proposals/array-unique.d.ts | 8 +- .../src/56}/proposals/async-iteration.d.ts | 0 .../56}/proposals/async-iterator-helpers.d.ts | 18 +-- .../src/56/proposals/await-dictionary.d.ts | 15 ++ .../change-array-by-copy-custom.d.ts | 10 ++ .../56}/proposals/change-array-by-copy.d.ts | 18 +-- .../src/56}/proposals/collection-of-from.d.ts | 0 .../data-view-get-set-uint8-clamped.d.ts | 0 .../src/56}/proposals/decorator-metadata.d.ts | 2 +- .../src/56/proposals/error-cause.d.ts | 60 ++++++++ .../explicit-resource-management.d.ts | 0 .../src/56}/proposals/extractors.d.ts | 0 .../src/56}/proposals/float16.d.ts | 0 .../56}/proposals/function-demethodize.d.ts | 0 .../src/56}/proposals/is-error.d.ts | 0 .../src/56}/proposals/iterator-chunking.d.ts | 2 +- .../56/proposals/iterator-helpers-custom.d.ts | 12 ++ .../src/56}/proposals/iterator-helpers.d.ts | 12 +- .../src/56}/proposals/iterator-joint.d.ts | 2 +- .../src/56/proposals/iterator-range.d.ts | 17 +++ .../56}/proposals/iterator-sequencing.d.ts | 2 +- .../56}/proposals/json-parse-with-source.d.ts | 0 .../src/56}/proposals/map-upsert.d.ts | 0 .../src/56}/proposals/math-sum.d.ts | 0 .../src/56}/proposals/number-clamp.d.ts | 0 .../56}/proposals/object-from-entries.d.ts | 0 .../object-get-own-property-descriptors.d.ts | 0 .../56}/proposals/object-values-entries.d.ts | 0 .../src/56}/proposals/pattern-matching.d.ts | 0 .../src/56/proposals/promise-all-settled.d.ts | 18 +++ .../src/56}/proposals/promise-any.d.ts | 0 .../src/56}/proposals/promise-finally.d.ts | 0 .../src/56}/proposals/promise-try.d.ts | 0 .../56}/proposals/promise-with-resolvers.d.ts | 0 .../src/56}/proposals/regexp-dotall-flag.d.ts | 0 .../src/56}/proposals/regexp-escaping.d.ts | 0 .../56}/proposals/regexp-named-groups.d.ts | 0 .../proposals/relative-indexing-method.d.ts | 0 .../src/56/proposals/set-methods-custom.d.ts | 19 +++ .../src/56}/proposals/set-methods.d.ts | 6 +- .../src/56}/proposals/string-cooked.d.ts | 0 .../src/56}/proposals/string-dedent.d.ts | 0 .../56}/proposals/string-left-right-trim.d.ts | 0 .../src/56}/proposals/string-match-all.d.ts | 12 +- .../src/56}/proposals/string-padding.d.ts | 0 .../proposals/string-replace-all-custom.d.ts | 10 ++ .../src/56}/proposals/string-replace-all.d.ts | 2 - .../src/56}/proposals/symbol-description.d.ts | 0 .../src/56}/proposals/symbol-predicates.d.ts | 0 .../well-formed-unicode-strings.d.ts | 0 .../modules/es.object.define-getter.js | 1 + .../modules/es.object.define-setter.js | 1 + .../modules/es.object.lookup-getter.js | 1 + .../modules/es.object.lookup-setter.js | 1 + .../esnext.promise.all-settled-keyed.js | 1 + .../core-js/modules/web.clear-immediate.js | 1 + packages/core-js/modules/web.set-immediate.js | 1 + .../types/proposals/array-from-async.d.ts | 11 -- .../types/proposals/await-dictionary.d.ts | 8 - .../core-js-types/core-js-types.d.ts | 20 --- .../core-js/types/proposals/error-cause.d.ts | 64 -------- .../types/proposals/iterator-range.d.ts | 26 ---- .../types/proposals/promise-all-settled.d.ts | 12 -- scripts/build-entries/entries-definitions.mjs | 16 +- scripts/build-entries/index.mjs | 5 +- scripts/build-types/config.mjs | 7 + scripts/build-types/index.mjs | 139 ++++++++++++++++++ scripts/build-types/package-lock.json | 10 ++ scripts/build-types/package.json | 3 + tests/type-definitions/entries.import.ts | 22 +-- tests/type-definitions/package-lock.json | 15 ++ tests/type-definitions/package.json | 1 + .../accessible-object-hasownproperty.test.ts | 1 + .../global/array-buffer-base64.test.ts | 1 + .../global/array-buffer-transfer.test.ts | 1 + .../proposals/global/array-filtering.test.ts | 20 ++- .../global/array-find-from-last.test.ts | 16 +- .../proposals/global/array-flat-map.test.ts | 1 + .../proposals/global/array-from-async.test.ts | 1 + .../proposals/global/array-grouping.test.ts | 1 + .../proposals/global/array-includes.test.ts | 33 +++-- .../global/array-is-template-object.test.ts | 1 + .../proposals/global/array-unique.test.ts | 38 ++--- .../proposals/global/async-iteration.test.ts | 1 + .../global/async-iterator-helper.test.ts | 7 +- .../proposals/global/await-dictionary.test.ts | 1 + .../global/change-array-by-copy.test.ts | 44 +++--- .../global/collection-of-from.test.ts | 1 + .../data-view-get-set-uint8-clamped.test.ts | 1 + .../global/decorator-metadata.test.ts | 1 + .../proposals/global/error-cause.test.ts | 1 + .../explicit-resource-management.test.ts | 1 + .../proposals/global/extractors.test.ts | 1 + .../proposals/global/float16.test.ts | 1 + .../global/function-demethodize.test.ts | 1 + .../proposals/global/is-error.test.ts | 1 + .../global/iterator-chunking.test.ts | 1 + .../proposals/global/iterator-helpers.test.ts | 1 + .../proposals/global/iterator-joint.test.ts | 1 + .../proposals/global/iterator-range.test.ts | 4 +- .../global/iterator-sequencing.test.ts | 1 + .../global/json-parse-with-source.test.ts | 1 + .../proposals/global/map-upsert.test.ts | 1 + .../proposals/global/math-sum.test.ts | 1 + .../proposals/global/number-clamp.test.ts | 1 + .../global/object-from-entries.test.ts | 1 + ...bject-get-own-property-descriptors.test.ts | 1 + .../global/object-values-entries.test.ts | 1 + .../proposals/global/pattern-matching.test.ts | 1 + .../global/promise-all-settled.test.ts | 20 +-- .../proposals/global/promise-any.test.ts | 1 + .../proposals/global/promise-finally.test.ts | 1 + .../proposals/global/promise-try.test.ts | 1 + .../global/promise-with-resolvers.test.ts | 1 + .../global/regexp-dotall-flag.test.ts | 1 + .../proposals/global/regexp-escaping.test.ts | 1 + .../global/regexp-named-groups.test.ts | 1 + .../global/relative-indexing-method.test.ts | 22 +-- .../proposals/global/set-methods.test.ts | 1 + .../proposals/global/string-cooked.test.ts | 1 + .../proposals/global/string-dedent.test.ts | 1 + .../global/string-left-right-trim.test.ts | 1 + .../proposals/global/string-match-all.test.ts | 4 +- .../proposals/global/string-padding.test.ts | 1 + .../global/string-replace-all.test.ts | 1 + .../global/symbol-description.test.ts | 1 + .../global/symbol-predicates.test.ts | 1 + .../well-formed-unicode-strings.test.ts | 1 + .../pure/array-is-template-object.test.ts | 2 +- .../proposals/pure/async-iteration.test.ts | 3 +- .../pure/async-iterator-helper.test.ts | 3 - .../proposals/pure/extractors.test.ts | 2 +- .../proposals/pure/iterator-range.test.ts | 3 - .../proposals/pure/pattern-matching.test.ts | 2 +- .../pure/promise-all-settled.test.ts | 18 +-- tests/type-definitions/runner.mjs | 1 + tests/type-definitions/tsconfig.json | 15 +- tests/type-definitions/tsconfig.require.json | 13 ++ 157 files changed, 740 insertions(+), 338 deletions(-) create mode 100644 packages/core-js-types/package.json create mode 100644 packages/core-js-types/src/56/common/aggregate-error.d.ts create mode 100644 packages/core-js-types/src/56/common/object-extend.d.ts create mode 100644 packages/core-js-types/src/56/common/symbol-match-all.d.ts create mode 100644 packages/core-js-types/src/56/common/timers.d.ts create mode 100644 packages/core-js-types/src/56/core-js-types/core-js-types.d.ts rename packages/{core-js/types => core-js-types/src/56}/proposals/accessible-object-hasownproperty.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/array-buffer-base64.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/array-buffer-transfer.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/array-filtering.d.ts (84%) rename packages/{core-js/types => core-js-types/src/56}/proposals/array-find-from-last.d.ts (97%) create mode 100644 packages/core-js-types/src/56/proposals/array-flat-map-custom.d.ts rename packages/{core-js/types => core-js-types/src/56}/proposals/array-flat-map.d.ts (69%) create mode 100644 packages/core-js-types/src/56/proposals/array-from-async.d.ts rename packages/{core-js/types => core-js-types/src/56}/proposals/array-grouping.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/array-includes.d.ts (91%) rename packages/{core-js/types => core-js-types/src/56}/proposals/array-is-template-object.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/array-unique.d.ts (86%) rename packages/{core-js/types => core-js-types/src/56}/proposals/async-iteration.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/async-iterator-helpers.d.ts (51%) create mode 100644 packages/core-js-types/src/56/proposals/await-dictionary.d.ts create mode 100644 packages/core-js-types/src/56/proposals/change-array-by-copy-custom.d.ts rename packages/{core-js/types => core-js-types/src/56}/proposals/change-array-by-copy.d.ts (85%) rename packages/{core-js/types => core-js-types/src/56}/proposals/collection-of-from.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/data-view-get-set-uint8-clamped.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/decorator-metadata.d.ts (76%) create mode 100644 packages/core-js-types/src/56/proposals/error-cause.d.ts rename packages/{core-js/types => core-js-types/src/56}/proposals/explicit-resource-management.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/extractors.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/float16.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/function-demethodize.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/is-error.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/iterator-chunking.d.ts (81%) create mode 100644 packages/core-js-types/src/56/proposals/iterator-helpers-custom.d.ts rename packages/{core-js/types => core-js-types/src/56}/proposals/iterator-helpers.d.ts (76%) rename packages/{core-js/types => core-js-types/src/56}/proposals/iterator-joint.d.ts (89%) create mode 100644 packages/core-js-types/src/56/proposals/iterator-range.d.ts rename packages/{core-js/types => core-js-types/src/56}/proposals/iterator-sequencing.d.ts (78%) rename packages/{core-js/types => core-js-types/src/56}/proposals/json-parse-with-source.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/map-upsert.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/math-sum.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/number-clamp.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/object-from-entries.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/object-get-own-property-descriptors.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/object-values-entries.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/pattern-matching.d.ts (100%) create mode 100644 packages/core-js-types/src/56/proposals/promise-all-settled.d.ts rename packages/{core-js/types => core-js-types/src/56}/proposals/promise-any.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/promise-finally.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/promise-try.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/promise-with-resolvers.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/regexp-dotall-flag.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/regexp-escaping.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/regexp-named-groups.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/relative-indexing-method.d.ts (100%) create mode 100644 packages/core-js-types/src/56/proposals/set-methods-custom.d.ts rename packages/{core-js/types => core-js-types/src/56}/proposals/set-methods.d.ts (88%) rename packages/{core-js/types => core-js-types/src/56}/proposals/string-cooked.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/string-dedent.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/string-left-right-trim.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/string-match-all.d.ts (56%) rename packages/{core-js/types => core-js-types/src/56}/proposals/string-padding.d.ts (100%) create mode 100644 packages/core-js-types/src/56/proposals/string-replace-all-custom.d.ts rename packages/{core-js/types => core-js-types/src/56}/proposals/string-replace-all.d.ts (73%) rename packages/{core-js/types => core-js-types/src/56}/proposals/symbol-description.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/symbol-predicates.d.ts (100%) rename packages/{core-js/types => core-js-types/src/56}/proposals/well-formed-unicode-strings.d.ts (100%) delete mode 100644 packages/core-js/types/proposals/array-from-async.d.ts delete mode 100644 packages/core-js/types/proposals/await-dictionary.d.ts delete mode 100644 packages/core-js/types/proposals/core-js-types/core-js-types.d.ts delete mode 100644 packages/core-js/types/proposals/error-cause.d.ts delete mode 100644 packages/core-js/types/proposals/iterator-range.d.ts delete mode 100644 packages/core-js/types/proposals/promise-all-settled.d.ts create mode 100644 scripts/build-types/config.mjs create mode 100644 scripts/build-types/index.mjs create mode 100644 scripts/build-types/package-lock.json create mode 100644 scripts/build-types/package.json create mode 100644 tests/type-definitions/tsconfig.require.json diff --git a/.gitignore b/.gitignore index 4d3e6e5bd869..7dc4d22f121b 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,8 @@ node_modules/ /packages/core-js-pure/configurator.js /packages/core-js-pure/package.json /packages/core-js-pure/LICENSE +/packages/core-js-types/dist/ +/packages/core-js-types/LICENSE /tests/**/bundles/ /tests/compat/*.jar /tests/compat/compat-data.js diff --git a/package.json b/package.json index 8deea3e56ba1..d79f09be86b9 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "prepare-monorepo": "node scripts/prepare-monorepo.mjs", "build-entries": "npm run zxi time scripts/build-entries/index.mjs", "build-compat": "npm run zxi scripts/build-compat/index.mjs", + "build-types": "npm run zxi time scripts/build-types/index.mjs", "build-website": "npm run zxi time website/index.mjs", "build-website-local": "npm run zxi time website/build-local.mjs", "bundle": "run-s bundle-package bundle-tests", @@ -39,7 +40,7 @@ "compat-rhino": "npm run zxi tests/compat/rhino-adapter.mjs", "debug-get-dependencies": "npm run zxi time tests/debug-get-dependencies/debug-get-dependencies.mjs", "lint": "run-s prepare lint-raw", - "lint-raw": "run-s test-eslint test-type-definitions bundle-package test-publint", + "lint-raw": "run-s build-types test-eslint test-type-definitions bundle-package test-publint", "test": "run-s prepare test-raw", "test-raw": "run-s lint-raw bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check", "test-eslint": "npm run zxi time tests/eslint/runner.mjs", diff --git a/packages/core-js-types/package.json b/packages/core-js-types/package.json new file mode 100644 index 000000000000..aad08e439a72 --- /dev/null +++ b/packages/core-js-types/package.json @@ -0,0 +1,32 @@ +{ + "name": "@core-js/types", + "version": "4.0.0-alpha.0", + "publishConfig": { + "access": "public" + }, + "type": "commonjs", + "description": "TypeScript types for core-js", + "repository": { + "type": "git", + "url": "git+https://github.com/zloirock/core-js.git", + "directory": "packages/core-js-types" + }, + "homepage": "https://core-js.io", + "bugs": { + "url": "https://github.com/zloirock/core-js/issues" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + }, + "license": "SEE LICENSE IN LICENSE.md", + "author": { + "name": "Denis Pushkarev", + "email": "zloirock@zloirock.ru", + "url": "http://zloirock.ru" + }, + "types": "dist/core-js-types.latest.d.ts", + "files": [ + "dist/core-js-types.latest.d.ts" + ] +} diff --git a/packages/core-js-types/src/56/common/aggregate-error.d.ts b/packages/core-js-types/src/56/common/aggregate-error.d.ts new file mode 100644 index 000000000000..20f0b940233e --- /dev/null +++ b/packages/core-js-types/src/56/common/aggregate-error.d.ts @@ -0,0 +1,11 @@ +interface AggregateError extends Error { + errors: any[]; +} + +interface AggregateErrorConstructor { + new (errors: Iterable, message?: string): AggregateError; + (errors: Iterable, message?: string): AggregateError; + readonly prototype: AggregateError; +} + +declare var AggregateError: AggregateErrorConstructor; diff --git a/packages/core-js-types/src/56/common/object-extend.d.ts b/packages/core-js-types/src/56/common/object-extend.d.ts new file mode 100644 index 000000000000..cf148f00e65a --- /dev/null +++ b/packages/core-js-types/src/56/common/object-extend.d.ts @@ -0,0 +1,9 @@ +interface Object { + __defineGetter__(prop: PropertyKey, getter: () => any): void; + + __defineSetter__(prop: PropertyKey, setter: (val: any) => void): void; + + __lookupGetter__(prop: PropertyKey): (() => any) | undefined; + + __lookupSetter__(prop: PropertyKey): ((val: any) => void) | undefined; +} diff --git a/packages/core-js-types/src/56/common/symbol-match-all.d.ts b/packages/core-js-types/src/56/common/symbol-match-all.d.ts new file mode 100644 index 000000000000..75cb8fc70f26 --- /dev/null +++ b/packages/core-js-types/src/56/common/symbol-match-all.d.ts @@ -0,0 +1,3 @@ +interface SymbolConstructor { + readonly matchAll: unique symbol; +} diff --git a/packages/core-js-types/src/56/common/timers.d.ts b/packages/core-js-types/src/56/common/timers.d.ts new file mode 100644 index 000000000000..fc17f67b6945 --- /dev/null +++ b/packages/core-js-types/src/56/common/timers.d.ts @@ -0,0 +1,4 @@ +type Immediate = object; + +declare function setImmediate(handler: (...args: any[]) => void, ...args: any[]): Immediate; +declare function clearImmediate(immediate: Immediate): void; diff --git a/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts new file mode 100644 index 000000000000..8e1e10822eb9 --- /dev/null +++ b/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts @@ -0,0 +1,39 @@ +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2019.array.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare global { + interface IteratorObject extends Iterator {} + + interface AsyncIteratorObject extends AsyncIterator { + [Symbol.asyncIterator](): AsyncIteratorObject; + } + + interface AsyncIterableIterator extends AsyncIterator { + [Symbol.asyncIterator](): AsyncIterableIterator; + } + + interface PromiseFulfilledResult { status: "fulfilled"; value: T; } + + interface PromiseRejectedResult { status: "rejected"; reason: any; } + + interface AsyncIterable { [Symbol.asyncIterator](): AsyncIterator; } +} + +export type CoreJsDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } + ? O + : Record & object; + +export type CoreJsIteratorObject = IteratorObject; + +export type CoreJsFlatArray = typeof globalThis extends { FlatArray: infer O } + ? O + : { + done: Arr; + recur: Arr extends ReadonlyArray ? CoreJsFlatArray + : Arr; + }[Depth extends -1 ? "done" : "recur"]; + +export type CoreJsPromiseSettledResult = typeof globalThis extends { PromiseSettledResult: infer O } + ? O + : PromiseFulfilledResult | PromiseRejectedResult; diff --git a/packages/core-js/types/proposals/accessible-object-hasownproperty.d.ts b/packages/core-js-types/src/56/proposals/accessible-object-hasownproperty.d.ts similarity index 100% rename from packages/core-js/types/proposals/accessible-object-hasownproperty.d.ts rename to packages/core-js-types/src/56/proposals/accessible-object-hasownproperty.d.ts diff --git a/packages/core-js/types/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts similarity index 100% rename from packages/core-js/types/proposals/array-buffer-base64.d.ts rename to packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts diff --git a/packages/core-js/types/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts similarity index 100% rename from packages/core-js/types/proposals/array-buffer-transfer.d.ts rename to packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts diff --git a/packages/core-js/types/proposals/array-filtering.d.ts b/packages/core-js-types/src/56/proposals/array-filtering.d.ts similarity index 84% rename from packages/core-js/types/proposals/array-filtering.d.ts rename to packages/core-js-types/src/56/proposals/array-filtering.d.ts index 1a9a8fb8aa06..f45043f3e02b 100644 --- a/packages/core-js/types/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/56/proposals/array-filtering.d.ts @@ -40,10 +40,10 @@ interface Float64Array { filterReject(callbackFn: (value: number, index: number, target: Float64Array) => boolean, thisArg?: any): Float64Array; } -interface BigInt64Array { - filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array; +interface BigInt64Array { + filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array; } -interface BigUint64Array { - filterReject(callbackFn: (value: bigint, index: number, target: BigUint64Array) => boolean, thisArg?: any): BigUint64Array; +interface BigUint64Array { + filterReject(callbackFn: (value: bigint, index: number, target: BigUint64Array) => boolean, thisArg?: any): BigUint64Array; } diff --git a/packages/core-js/types/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts similarity index 97% rename from packages/core-js/types/proposals/array-find-from-last.d.ts rename to packages/core-js-types/src/56/proposals/array-find-from-last.d.ts index 9277d71b306b..1bd27f9b76f0 100644 --- a/packages/core-js/types/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts @@ -92,7 +92,7 @@ interface Float64Array { findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface BigInt64Array { +interface BigInt64Array { findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): bigint | undefined; @@ -100,7 +100,7 @@ interface BigInt64Array { findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; } -interface BigUint64Array { +interface BigUint64Array { findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): bigint | undefined; diff --git a/packages/core-js-types/src/56/proposals/array-flat-map-custom.d.ts b/packages/core-js-types/src/56/proposals/array-flat-map-custom.d.ts new file mode 100644 index 000000000000..5fa537b80823 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/array-flat-map-custom.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-flatMap + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJs { + export type ArrayFlatMap = (callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This) => U[]; +} diff --git a/packages/core-js/types/proposals/array-flat-map.d.ts b/packages/core-js-types/src/56/proposals/array-flat-map.d.ts similarity index 69% rename from packages/core-js/types/proposals/array-flat-map.d.ts rename to packages/core-js-types/src/56/proposals/array-flat-map.d.ts index accacb8b5c35..a067bbdd72e2 100644 --- a/packages/core-js/types/proposals/array-flat-map.d.ts +++ b/packages/core-js-types/src/56/proposals/array-flat-map.d.ts @@ -5,14 +5,14 @@ // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt +import { CoreJsFlatArray } from '../core-js-types/core-js-types'; + declare global { interface Array { flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): U[]; - flat(this: A, depth?: D): FlatArray[]; + flat(this: A, depth?: D): CoreJsFlatArray[]; } } export {}; - -export type CoreJsArrayFlatMap = (callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This) => U[]; diff --git a/packages/core-js-types/src/56/proposals/array-from-async.d.ts b/packages/core-js-types/src/56/proposals/array-from-async.d.ts new file mode 100644 index 000000000000..b0f1c21cd725 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/array-from-async.d.ts @@ -0,0 +1,16 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-array-from-async + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/esnext.array.d.ts#L6 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare global { + interface ArrayConstructor { + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; + + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; + } +} + +export {}; diff --git a/packages/core-js/types/proposals/array-grouping.d.ts b/packages/core-js-types/src/56/proposals/array-grouping.d.ts similarity index 100% rename from packages/core-js/types/proposals/array-grouping.d.ts rename to packages/core-js-types/src/56/proposals/array-grouping.d.ts diff --git a/packages/core-js/types/proposals/array-includes.d.ts b/packages/core-js-types/src/56/proposals/array-includes.d.ts similarity index 91% rename from packages/core-js/types/proposals/array-includes.d.ts rename to packages/core-js-types/src/56/proposals/array-includes.d.ts index 25addb6e67a7..8bc797b6263f 100644 --- a/packages/core-js/types/proposals/array-includes.d.ts +++ b/packages/core-js-types/src/56/proposals/array-includes.d.ts @@ -44,10 +44,10 @@ interface Float64Array { includes(searchElement: number, fromIndex?: number): boolean; } -interface BigInt64Array { +interface BigInt64Array { includes(searchElement: bigint, fromIndex?: number): boolean; } -interface BigUint64Array { +interface BigUint64Array { includes(searchElement: bigint, fromIndex?: number): boolean; } diff --git a/packages/core-js/types/proposals/array-is-template-object.d.ts b/packages/core-js-types/src/56/proposals/array-is-template-object.d.ts similarity index 100% rename from packages/core-js/types/proposals/array-is-template-object.d.ts rename to packages/core-js-types/src/56/proposals/array-is-template-object.d.ts diff --git a/packages/core-js/types/proposals/array-unique.d.ts b/packages/core-js-types/src/56/proposals/array-unique.d.ts similarity index 86% rename from packages/core-js/types/proposals/array-unique.d.ts rename to packages/core-js-types/src/56/proposals/array-unique.d.ts index 12f3a5720faa..c896c29d8c85 100644 --- a/packages/core-js/types/proposals/array-unique.d.ts +++ b/packages/core-js-types/src/56/proposals/array-unique.d.ts @@ -40,10 +40,10 @@ interface Float64Array { uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float64Array; } -interface BigInt64Array { - uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigInt64Array; +interface BigInt64Array { + uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigInt64Array; } -interface BigUint64Array { - uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigUint64Array; +interface BigUint64Array { + uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigUint64Array; } diff --git a/packages/core-js/types/proposals/async-iteration.d.ts b/packages/core-js-types/src/56/proposals/async-iteration.d.ts similarity index 100% rename from packages/core-js/types/proposals/async-iteration.d.ts rename to packages/core-js-types/src/56/proposals/async-iteration.d.ts diff --git a/packages/core-js/types/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts similarity index 51% rename from packages/core-js/types/proposals/async-iterator-helpers.d.ts rename to packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts index 88612bb229e7..e14886bd6a75 100644 --- a/packages/core-js/types/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts @@ -1,41 +1,39 @@ // proposal stage: 2 // https://github.com/tc39/proposal-async-iterator-helpers -import { CoreJsAsyncIteratorObject } from './core-js-types/core-js-types'; - declare global { interface AsyncIteratorConstructor { - from(iterable: AsyncIterable | Iterable | CoreJsAsyncIteratorObject): CoreJsAsyncIteratorObject; + from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; } var AsyncIterator: AsyncIteratorConstructor; - interface AsyncIterator { - drop(limit: number): CoreJsAsyncIteratorObject; + interface AsyncIterator { + drop(limit: number): AsyncIteratorObject; every(predicate: (value: T, index: number) => boolean): Promise; - filter(predicate: (value: T, index: number) => boolean): CoreJsAsyncIteratorObject; + filter(predicate: (value: T, index: number) => boolean): AsyncIteratorObject; find(predicate: (value: T, index: number) => boolean): Promise; - flatMap(mapper: (value: T, index: number) => any): CoreJsAsyncIteratorObject; + flatMap(mapper: (value: T, index: number) => any): AsyncIteratorObject; forEach(callbackFn: (value: T, index: number) => void): Promise; - map(mapper: (value: T, index: number) => any): CoreJsAsyncIteratorObject; + map(mapper: (value: T, index: number) => any): AsyncIteratorObject; reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; some(predicate: (value: T, index: number) => boolean): Promise; - take(limit: number): CoreJsAsyncIteratorObject; + take(limit: number): AsyncIteratorObject; toArray(): Promise; } interface Iterator { - toAsync(): CoreJsAsyncIteratorObject; + toAsync(): AsyncIteratorObject; } } diff --git a/packages/core-js-types/src/56/proposals/await-dictionary.d.ts b/packages/core-js-types/src/56/proposals/await-dictionary.d.ts new file mode 100644 index 000000000000..c6c094ddb28f --- /dev/null +++ b/packages/core-js-types/src/56/proposals/await-dictionary.d.ts @@ -0,0 +1,15 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-await-dictionary +import { CoreJsPromiseSettledResult } from '../core-js-types/core-js-types'; + +type Dict = { [k: string | symbol]: V }; + +declare global { + interface PromiseConstructor { + allKeyed>>(promises: D): Promise <{ [k in keyof D]: Awaited }>; + + allSettledKeyed>>(promises: D): Promise <{ [k in keyof D]: CoreJsPromiseSettledResult> }>; + } +} + +export {}; diff --git a/packages/core-js-types/src/56/proposals/change-array-by-copy-custom.d.ts b/packages/core-js-types/src/56/proposals/change-array-by-copy-custom.d.ts new file mode 100644 index 000000000000..4f6a96004f9e --- /dev/null +++ b/packages/core-js-types/src/56/proposals/change-array-by-copy-custom.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-change-array-by-copy + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJs { + export type ArrayToSpliced = ((start: number, deleteCount: number, ...items: T[]) => T[]) | ((start: number, deleteCount?: number)=> T[]); +} diff --git a/packages/core-js/types/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts similarity index 85% rename from packages/core-js/types/proposals/change-array-by-copy.d.ts rename to packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts index fe20e41bbe28..729f1e25971f 100644 --- a/packages/core-js/types/proposals/change-array-by-copy.d.ts +++ b/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts @@ -90,23 +90,21 @@ declare global { with(index: number, value: number): Float64Array; } - interface BigInt64Array { - toReversed(): BigInt64Array; + interface BigInt64Array { + toReversed(): BigInt64Array; - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; - with(index: number, value: bigint): BigInt64Array; + with(index: number, value: bigint): BigInt64Array; } - interface BigUint64Array { - toReversed(): BigUint64Array; + interface BigUint64Array { + toReversed(): BigUint64Array; - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; - with(index: number, value: bigint): BigUint64Array; + with(index: number, value: bigint): BigUint64Array; } } export {}; - -export type CoreJsArrayToSpliced = ((start: number, deleteCount: number, ...items: T[]) => T[]) | ((start: number, deleteCount?: number)=> T[]); diff --git a/packages/core-js/types/proposals/collection-of-from.d.ts b/packages/core-js-types/src/56/proposals/collection-of-from.d.ts similarity index 100% rename from packages/core-js/types/proposals/collection-of-from.d.ts rename to packages/core-js-types/src/56/proposals/collection-of-from.d.ts diff --git a/packages/core-js/types/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts similarity index 100% rename from packages/core-js/types/proposals/data-view-get-set-uint8-clamped.d.ts rename to packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts diff --git a/packages/core-js/types/proposals/decorator-metadata.d.ts b/packages/core-js-types/src/56/proposals/decorator-metadata.d.ts similarity index 76% rename from packages/core-js/types/proposals/decorator-metadata.d.ts rename to packages/core-js-types/src/56/proposals/decorator-metadata.d.ts index 02c6d0b8496f..a1d24d0aa63d 100644 --- a/packages/core-js/types/proposals/decorator-metadata.d.ts +++ b/packages/core-js-types/src/56/proposals/decorator-metadata.d.ts @@ -1,7 +1,7 @@ // proposal stage: 3 // https://github.com/tc39/proposal-decorator-metadata -import { CoreJsDecoratorMetadataObject } from './core-js-types/core-js-types.js'; +import { CoreJsDecoratorMetadataObject } from '../core-js-types/core-js-types.js'; declare global { interface SymbolConstructor { diff --git a/packages/core-js-types/src/56/proposals/error-cause.d.ts b/packages/core-js-types/src/56/proposals/error-cause.d.ts new file mode 100644 index 000000000000..01bdbe8ef1d8 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/error-cause.d.ts @@ -0,0 +1,60 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-error-cause + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/es2022.error.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare global { + interface ErrorOptions { + cause?: unknown; + } + + interface Error { + cause?: unknown; // ts <= 4.7 Error | undefined + } + + interface ErrorConstructor { + new(message?: string, options?: ErrorOptions): Error; + + (message?: string, options?: ErrorOptions): Error; + } + + interface EvalErrorConstructor { + new(message?: string, options?: ErrorOptions): EvalError; + + (message?: string, options?: ErrorOptions): EvalError; + } + + interface RangeErrorConstructor { + new(message?: string, options?: ErrorOptions): RangeError; + + (message?: string, options?: ErrorOptions): RangeError; + } + + interface ReferenceErrorConstructor { + new(message?: string, options?: ErrorOptions): ReferenceError; + + (message?: string, options?: ErrorOptions): ReferenceError; + } + + interface SyntaxErrorConstructor { + new(message?: string, options?: ErrorOptions): SyntaxError; + + (message?: string, options?: ErrorOptions): SyntaxError; + } + + interface TypeErrorConstructor { + new(message?: string, options?: ErrorOptions): TypeError; + + (message?: string, options?: ErrorOptions): TypeError; + } + + interface URIErrorConstructor { + new(message?: string, options?: ErrorOptions): URIError; + + (message?: string, options?: ErrorOptions): URIError; + } +} + +export {}; diff --git a/packages/core-js/types/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts similarity index 100% rename from packages/core-js/types/proposals/explicit-resource-management.d.ts rename to packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts diff --git a/packages/core-js/types/proposals/extractors.d.ts b/packages/core-js-types/src/56/proposals/extractors.d.ts similarity index 100% rename from packages/core-js/types/proposals/extractors.d.ts rename to packages/core-js-types/src/56/proposals/extractors.d.ts diff --git a/packages/core-js/types/proposals/float16.d.ts b/packages/core-js-types/src/56/proposals/float16.d.ts similarity index 100% rename from packages/core-js/types/proposals/float16.d.ts rename to packages/core-js-types/src/56/proposals/float16.d.ts diff --git a/packages/core-js/types/proposals/function-demethodize.d.ts b/packages/core-js-types/src/56/proposals/function-demethodize.d.ts similarity index 100% rename from packages/core-js/types/proposals/function-demethodize.d.ts rename to packages/core-js-types/src/56/proposals/function-demethodize.d.ts diff --git a/packages/core-js/types/proposals/is-error.d.ts b/packages/core-js-types/src/56/proposals/is-error.d.ts similarity index 100% rename from packages/core-js/types/proposals/is-error.d.ts rename to packages/core-js-types/src/56/proposals/is-error.d.ts diff --git a/packages/core-js/types/proposals/iterator-chunking.d.ts b/packages/core-js-types/src/56/proposals/iterator-chunking.d.ts similarity index 81% rename from packages/core-js/types/proposals/iterator-chunking.d.ts rename to packages/core-js-types/src/56/proposals/iterator-chunking.d.ts index 8baac7c0334c..45aeffd06693 100644 --- a/packages/core-js/types/proposals/iterator-chunking.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-chunking.d.ts @@ -1,7 +1,7 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-chunking -import { CoreJsIteratorObject } from './core-js-types/core-js-types'; +import { CoreJsIteratorObject } from '../core-js-types/core-js-types'; declare global { interface Iterator { diff --git a/packages/core-js-types/src/56/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/56/proposals/iterator-helpers-custom.d.ts new file mode 100644 index 000000000000..4e09b29194ab --- /dev/null +++ b/packages/core-js-types/src/56/proposals/iterator-helpers-custom.d.ts @@ -0,0 +1,12 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-iterator-helpers + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJs { + export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => IteratorObject; + export type IteratorMap = (callback: (value: T, index: number) => U) => IteratorObject; + export type IteratorReduce = (callback: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; +} diff --git a/packages/core-js/types/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts similarity index 76% rename from packages/core-js/types/proposals/iterator-helpers.d.ts rename to packages/core-js-types/src/56/proposals/iterator-helpers.d.ts index 88091e7de4d5..f335eb19f3c1 100644 --- a/packages/core-js/types/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts @@ -5,7 +5,7 @@ // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -import { CoreJsIteratorObject } from './core-js-types/core-js-types'; +import { CoreJsIteratorObject } from '../core-js-types/core-js-types'; declare global { interface Iterator { @@ -35,10 +35,12 @@ declare global { find(predicate: (value: T, index: number) => value is S): S | undefined; find(predicate: (value: T, index: number) => unknown): T | undefined; } + + interface IteratorConstructor { + from(value: Iterator | Iterable): IteratorObject; + } + + var Iterator: IteratorConstructor; } export {}; - -export type CoreJsIteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => CoreJsIteratorObject; -export type CoreJsIteratorMap = (callback: (value: T, index: number) => U) => CoreJsIteratorObject; -export type CoreJsIteratorReduce = (callback: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; diff --git a/packages/core-js/types/proposals/iterator-joint.d.ts b/packages/core-js-types/src/56/proposals/iterator-joint.d.ts similarity index 89% rename from packages/core-js/types/proposals/iterator-joint.d.ts rename to packages/core-js-types/src/56/proposals/iterator-joint.d.ts index a36c4fa0c836..14ca2982fe34 100644 --- a/packages/core-js/types/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-joint.d.ts @@ -1,7 +1,7 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-joint-iteration -import { CoreJsIteratorObject } from './core-js-types/core-js-types'; +import { CoreJsIteratorObject } from '../core-js-types/core-js-types'; declare global { type ZipOptions = { diff --git a/packages/core-js-types/src/56/proposals/iterator-range.d.ts b/packages/core-js-types/src/56/proposals/iterator-range.d.ts new file mode 100644 index 000000000000..1f76b5284b12 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/iterator-range.d.ts @@ -0,0 +1,17 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-Number.range + +declare global { + type IteratorRangeOptions = { + step?: T; + inclusive?: boolean; + }; + + interface IteratorConstructor { + range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): IteratorObject + } + + var Iterator: IteratorConstructor; +} + +export {}; diff --git a/packages/core-js/types/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts similarity index 78% rename from packages/core-js/types/proposals/iterator-sequencing.d.ts rename to packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts index 72cc2dc66c16..568cf12a08d9 100644 --- a/packages/core-js/types/proposals/iterator-sequencing.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts @@ -1,7 +1,7 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-sequencing -import { CoreJsIteratorObject } from './core-js-types/core-js-types'; +import { CoreJsIteratorObject } from '../core-js-types/core-js-types'; declare global { interface IteratorConstructor { diff --git a/packages/core-js/types/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts similarity index 100% rename from packages/core-js/types/proposals/json-parse-with-source.d.ts rename to packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts diff --git a/packages/core-js/types/proposals/map-upsert.d.ts b/packages/core-js-types/src/56/proposals/map-upsert.d.ts similarity index 100% rename from packages/core-js/types/proposals/map-upsert.d.ts rename to packages/core-js-types/src/56/proposals/map-upsert.d.ts diff --git a/packages/core-js/types/proposals/math-sum.d.ts b/packages/core-js-types/src/56/proposals/math-sum.d.ts similarity index 100% rename from packages/core-js/types/proposals/math-sum.d.ts rename to packages/core-js-types/src/56/proposals/math-sum.d.ts diff --git a/packages/core-js/types/proposals/number-clamp.d.ts b/packages/core-js-types/src/56/proposals/number-clamp.d.ts similarity index 100% rename from packages/core-js/types/proposals/number-clamp.d.ts rename to packages/core-js-types/src/56/proposals/number-clamp.d.ts diff --git a/packages/core-js/types/proposals/object-from-entries.d.ts b/packages/core-js-types/src/56/proposals/object-from-entries.d.ts similarity index 100% rename from packages/core-js/types/proposals/object-from-entries.d.ts rename to packages/core-js-types/src/56/proposals/object-from-entries.d.ts diff --git a/packages/core-js/types/proposals/object-get-own-property-descriptors.d.ts b/packages/core-js-types/src/56/proposals/object-get-own-property-descriptors.d.ts similarity index 100% rename from packages/core-js/types/proposals/object-get-own-property-descriptors.d.ts rename to packages/core-js-types/src/56/proposals/object-get-own-property-descriptors.d.ts diff --git a/packages/core-js/types/proposals/object-values-entries.d.ts b/packages/core-js-types/src/56/proposals/object-values-entries.d.ts similarity index 100% rename from packages/core-js/types/proposals/object-values-entries.d.ts rename to packages/core-js-types/src/56/proposals/object-values-entries.d.ts diff --git a/packages/core-js/types/proposals/pattern-matching.d.ts b/packages/core-js-types/src/56/proposals/pattern-matching.d.ts similarity index 100% rename from packages/core-js/types/proposals/pattern-matching.d.ts rename to packages/core-js-types/src/56/proposals/pattern-matching.d.ts diff --git a/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts new file mode 100644 index 000000000000..5cd75e8f5c02 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts @@ -0,0 +1,18 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-promise-allSettled + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2020.promise.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +import { CoreJsPromiseSettledResult } from '../core-js-types/core-js-types'; + +declare global { + interface PromiseConstructor { + allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJsPromiseSettledResult>; }>; + + allSettled(values: Iterable>): Promise>[]>; + } +} + +export {}; diff --git a/packages/core-js/types/proposals/promise-any.d.ts b/packages/core-js-types/src/56/proposals/promise-any.d.ts similarity index 100% rename from packages/core-js/types/proposals/promise-any.d.ts rename to packages/core-js-types/src/56/proposals/promise-any.d.ts diff --git a/packages/core-js/types/proposals/promise-finally.d.ts b/packages/core-js-types/src/56/proposals/promise-finally.d.ts similarity index 100% rename from packages/core-js/types/proposals/promise-finally.d.ts rename to packages/core-js-types/src/56/proposals/promise-finally.d.ts diff --git a/packages/core-js/types/proposals/promise-try.d.ts b/packages/core-js-types/src/56/proposals/promise-try.d.ts similarity index 100% rename from packages/core-js/types/proposals/promise-try.d.ts rename to packages/core-js-types/src/56/proposals/promise-try.d.ts diff --git a/packages/core-js/types/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts similarity index 100% rename from packages/core-js/types/proposals/promise-with-resolvers.d.ts rename to packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts diff --git a/packages/core-js/types/proposals/regexp-dotall-flag.d.ts b/packages/core-js-types/src/56/proposals/regexp-dotall-flag.d.ts similarity index 100% rename from packages/core-js/types/proposals/regexp-dotall-flag.d.ts rename to packages/core-js-types/src/56/proposals/regexp-dotall-flag.d.ts diff --git a/packages/core-js/types/proposals/regexp-escaping.d.ts b/packages/core-js-types/src/56/proposals/regexp-escaping.d.ts similarity index 100% rename from packages/core-js/types/proposals/regexp-escaping.d.ts rename to packages/core-js-types/src/56/proposals/regexp-escaping.d.ts diff --git a/packages/core-js/types/proposals/regexp-named-groups.d.ts b/packages/core-js-types/src/56/proposals/regexp-named-groups.d.ts similarity index 100% rename from packages/core-js/types/proposals/regexp-named-groups.d.ts rename to packages/core-js-types/src/56/proposals/regexp-named-groups.d.ts diff --git a/packages/core-js/types/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts similarity index 100% rename from packages/core-js/types/proposals/relative-indexing-method.d.ts rename to packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts diff --git a/packages/core-js-types/src/56/proposals/set-methods-custom.d.ts b/packages/core-js-types/src/56/proposals/set-methods-custom.d.ts new file mode 100644 index 000000000000..a684bfd69d7a --- /dev/null +++ b/packages/core-js-types/src/56/proposals/set-methods-custom.d.ts @@ -0,0 +1,19 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-set-methods + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface ReadonlySetLike { + keys(): Iterator; + + has(value: T): boolean; + + readonly size: number; +} + +declare namespace CoreJs { + export type SetUnion = (other: ReadonlySetLike) => Set; + export type SetSymmetricDifference = (other: ReadonlySetLike) => Set; +} diff --git a/packages/core-js/types/proposals/set-methods.d.ts b/packages/core-js-types/src/56/proposals/set-methods.d.ts similarity index 88% rename from packages/core-js/types/proposals/set-methods.d.ts rename to packages/core-js-types/src/56/proposals/set-methods.d.ts index 5e35487159fb..14f42bdaecfd 100644 --- a/packages/core-js/types/proposals/set-methods.d.ts +++ b/packages/core-js-types/src/56/proposals/set-methods.d.ts @@ -49,5 +49,7 @@ declare global { export {}; -export type CoreJsSetUnion = (other: ReadonlySetLike) => Set; -export type CoreJsSetSymmetricDifference = (other: ReadonlySetLike) => Set; +declare namespace CoreJs { + export type SetUnion = (other: ReadonlySetLike) => Set; + export type SetSymmetricDifference = (other: ReadonlySetLike) => Set; +} diff --git a/packages/core-js/types/proposals/string-cooked.d.ts b/packages/core-js-types/src/56/proposals/string-cooked.d.ts similarity index 100% rename from packages/core-js/types/proposals/string-cooked.d.ts rename to packages/core-js-types/src/56/proposals/string-cooked.d.ts diff --git a/packages/core-js/types/proposals/string-dedent.d.ts b/packages/core-js-types/src/56/proposals/string-dedent.d.ts similarity index 100% rename from packages/core-js/types/proposals/string-dedent.d.ts rename to packages/core-js-types/src/56/proposals/string-dedent.d.ts diff --git a/packages/core-js/types/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/56/proposals/string-left-right-trim.d.ts similarity index 100% rename from packages/core-js/types/proposals/string-left-right-trim.d.ts rename to packages/core-js-types/src/56/proposals/string-left-right-trim.d.ts diff --git a/packages/core-js/types/proposals/string-match-all.d.ts b/packages/core-js-types/src/56/proposals/string-match-all.d.ts similarity index 56% rename from packages/core-js/types/proposals/string-match-all.d.ts rename to packages/core-js-types/src/56/proposals/string-match-all.d.ts index 84178483473f..53d212f36c18 100644 --- a/packages/core-js/types/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/56/proposals/string-match-all.d.ts @@ -5,6 +5,14 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface String { - matchAll(regexp: RegExp): RegExpStringIterator; +declare global { + interface RegExpStringIterator extends IteratorObject { + [Symbol.iterator](): RegExpStringIterator; + } + + interface String { + matchAll(regexp: RegExp): RegExpStringIterator; + } } + +export {}; diff --git a/packages/core-js/types/proposals/string-padding.d.ts b/packages/core-js-types/src/56/proposals/string-padding.d.ts similarity index 100% rename from packages/core-js/types/proposals/string-padding.d.ts rename to packages/core-js-types/src/56/proposals/string-padding.d.ts diff --git a/packages/core-js-types/src/56/proposals/string-replace-all-custom.d.ts b/packages/core-js-types/src/56/proposals/string-replace-all-custom.d.ts new file mode 100644 index 000000000000..f5f85d63e101 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/string-replace-all-custom.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-string-replaceall + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJs { + export type StringReplaceAll = ((searchValue: string | RegExp, replaceValue: string) => string) | ((searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string) => string); +} diff --git a/packages/core-js/types/proposals/string-replace-all.d.ts b/packages/core-js-types/src/56/proposals/string-replace-all.d.ts similarity index 73% rename from packages/core-js/types/proposals/string-replace-all.d.ts rename to packages/core-js-types/src/56/proposals/string-replace-all.d.ts index 188f53a1e508..9fa6276b406b 100644 --- a/packages/core-js/types/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/56/proposals/string-replace-all.d.ts @@ -14,5 +14,3 @@ declare global { } export {}; - -export type CoreJsStringReplaceAll = ((searchValue: string | RegExp, replaceValue: string) => string) | ((searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string) => string); diff --git a/packages/core-js/types/proposals/symbol-description.d.ts b/packages/core-js-types/src/56/proposals/symbol-description.d.ts similarity index 100% rename from packages/core-js/types/proposals/symbol-description.d.ts rename to packages/core-js-types/src/56/proposals/symbol-description.d.ts diff --git a/packages/core-js/types/proposals/symbol-predicates.d.ts b/packages/core-js-types/src/56/proposals/symbol-predicates.d.ts similarity index 100% rename from packages/core-js/types/proposals/symbol-predicates.d.ts rename to packages/core-js-types/src/56/proposals/symbol-predicates.d.ts diff --git a/packages/core-js/types/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/56/proposals/well-formed-unicode-strings.d.ts similarity index 100% rename from packages/core-js/types/proposals/well-formed-unicode-strings.d.ts rename to packages/core-js-types/src/56/proposals/well-formed-unicode-strings.d.ts diff --git a/packages/core-js/modules/es.object.define-getter.js b/packages/core-js/modules/es.object.define-getter.js index 0700a5161711..65c8c0100123 100644 --- a/packages/core-js/modules/es.object.define-getter.js +++ b/packages/core-js/modules/es.object.define-getter.js @@ -1,3 +1,4 @@ +// types: common/object-extend 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/es.object.define-setter.js b/packages/core-js/modules/es.object.define-setter.js index 75c76d38f6bf..454c63e1e2e1 100644 --- a/packages/core-js/modules/es.object.define-setter.js +++ b/packages/core-js/modules/es.object.define-setter.js @@ -1,3 +1,4 @@ +// types: common/object-extend 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/es.object.lookup-getter.js b/packages/core-js/modules/es.object.lookup-getter.js index 5fef7f074e68..d66bf41973ff 100644 --- a/packages/core-js/modules/es.object.lookup-getter.js +++ b/packages/core-js/modules/es.object.lookup-getter.js @@ -1,3 +1,4 @@ +// types: common/object-extend 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/es.object.lookup-setter.js b/packages/core-js/modules/es.object.lookup-setter.js index e8af92fc0cf2..100a548bf212 100644 --- a/packages/core-js/modules/es.object.lookup-setter.js +++ b/packages/core-js/modules/es.object.lookup-setter.js @@ -1,3 +1,4 @@ +// types: common/object-extend 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/esnext.promise.all-settled-keyed.js b/packages/core-js/modules/esnext.promise.all-settled-keyed.js index f99a5ce007e0..10cc239348c5 100644 --- a/packages/core-js/modules/esnext.promise.all-settled-keyed.js +++ b/packages/core-js/modules/esnext.promise.all-settled-keyed.js @@ -1,3 +1,4 @@ +// types: proposals/await-dictionary 'use strict'; var $ = require('../internals/export'); var aCallable = require('../internals/a-callable'); diff --git a/packages/core-js/modules/web.clear-immediate.js b/packages/core-js/modules/web.clear-immediate.js index 2d3a0c731a3a..9b655e5509e9 100644 --- a/packages/core-js/modules/web.clear-immediate.js +++ b/packages/core-js/modules/web.clear-immediate.js @@ -1,3 +1,4 @@ +// types: common/timers 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.set-immediate.js b/packages/core-js/modules/web.set-immediate.js index 23dc9fc795fe..0b0a1725b188 100644 --- a/packages/core-js/modules/web.set-immediate.js +++ b/packages/core-js/modules/web.set-immediate.js @@ -1,3 +1,4 @@ +// types: common/timers 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/types/proposals/array-from-async.d.ts b/packages/core-js/types/proposals/array-from-async.d.ts deleted file mode 100644 index 37d2895c5723..000000000000 --- a/packages/core-js/types/proposals/array-from-async.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// proposal stage: 3 -// https://github.com/tc39/proposal-array-from-async - -// For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/esnext.array.d.ts#L6 -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface ArrayConstructor { - fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; - - fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; -} diff --git a/packages/core-js/types/proposals/await-dictionary.d.ts b/packages/core-js/types/proposals/await-dictionary.d.ts deleted file mode 100644 index f3a472e9d75e..000000000000 --- a/packages/core-js/types/proposals/await-dictionary.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// proposal stage: 1 -// https://github.com/tc39/proposal-await-dictionary - -type Dict = { [k: string | symbol]: V }; - -interface PromiseConstructor { - allKeyed>>(promises: D): Promise <{ [k in keyof D]: Awaited }> -} diff --git a/packages/core-js/types/proposals/core-js-types/core-js-types.d.ts b/packages/core-js/types/proposals/core-js-types/core-js-types.d.ts deleted file mode 100644 index 7f413b43f31d..000000000000 --- a/packages/core-js/types/proposals/core-js-types/core-js-types.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -export type CoreJsAsyncIteratorObject = typeof globalThis extends { AsyncIteratorObject: infer O } - ? O - : AsyncIterator; - -export type CoreJsDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } - ? O - : Record & object; - -declare global { - interface IteratorObject extends Iterator {} -} -export type CoreJsIteratorObject = IteratorObject; - -export type CoreJsAggregateError = typeof globalThis extends { AggregateError: infer O } - ? O - : { new(errors: Iterable, message?: string): Error & { errors: any[] } }; - -export type CoreJsErrorOptions = { - cause?: unknown; -} diff --git a/packages/core-js/types/proposals/error-cause.d.ts b/packages/core-js/types/proposals/error-cause.d.ts deleted file mode 100644 index a5544b3601a1..000000000000 --- a/packages/core-js/types/proposals/error-cause.d.ts +++ /dev/null @@ -1,64 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-error-cause - -// For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/es2022.error.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -import { CoreJsAggregateError, CoreJsErrorOptions } from './core-js-types/core-js-types.js'; - -declare global { - interface Error { - cause?: unknown; // ts <= 4.7 Error | undefined - } - - interface ErrorConstructor { - new(message?: string, options?: CoreJsErrorOptions): Error; - - (message?: string, options?: CoreJsErrorOptions): Error; - } - - interface EvalErrorConstructor { - new(message?: string, options?: CoreJsErrorOptions): EvalError; - - (message?: string, options?: CoreJsErrorOptions): EvalError; - } - - interface RangeErrorConstructor { - new(message?: string, options?: CoreJsErrorOptions): RangeError; - - (message?: string, options?: CoreJsErrorOptions): RangeError; - } - - interface ReferenceErrorConstructor { - new(message?: string, options?: CoreJsErrorOptions): ReferenceError; - - (message?: string, options?: CoreJsErrorOptions): ReferenceError; - } - - interface SyntaxErrorConstructor { - new(message?: string, options?: CoreJsErrorOptions): SyntaxError; - - (message?: string, options?: CoreJsErrorOptions): SyntaxError; - } - - interface TypeErrorConstructor { - new(message?: string, options?: CoreJsErrorOptions): TypeError; - - (message?: string, options?: CoreJsErrorOptions): TypeError; - } - - interface URIErrorConstructor { - new(message?: string, options?: CoreJsErrorOptions): URIError; - - (message?: string, options?: CoreJsErrorOptions): URIError; - } - - interface AggregateErrorConstructor { - new(errors: Iterable, message?: string, options?: CoreJsErrorOptions): CoreJsAggregateError; - - (errors: Iterable, message?: string, options?: CoreJsErrorOptions): CoreJsAggregateError; - } -} - -export {}; diff --git a/packages/core-js/types/proposals/iterator-range.d.ts b/packages/core-js/types/proposals/iterator-range.d.ts deleted file mode 100644 index b64899b4d700..000000000000 --- a/packages/core-js/types/proposals/iterator-range.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -// proposal stage: 2 -// https://github.com/tc39/proposal-Number.range - -import { CoreJsIteratorObject } from './core-js-types/core-js-types'; - -declare global { - type RangeOptionsNumber = { - step?: number; - inclusive?: boolean; - }; - - type RangeOptionsBigInt = { - step?: bigint; - inclusive?: boolean; - }; - - interface IteratorConstructor { - range(start: number, end: number, options?: number | RangeOptionsNumber): CoreJsIteratorObject; - - range(start: bigint, end: bigint | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: bigint | RangeOptionsBigInt): CoreJsIteratorObject; - } - - var Iterator: IteratorConstructor; -} - -export {}; diff --git a/packages/core-js/types/proposals/promise-all-settled.d.ts b/packages/core-js/types/proposals/promise-all-settled.d.ts deleted file mode 100644 index 788bbd819c10..000000000000 --- a/packages/core-js/types/proposals/promise-all-settled.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-promise-allSettled - -// For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2017.object.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface PromiseConstructor { - allSettled(values: T): Promise<{ -readonly [P in keyof T]: PromiseSettledResult>; }>; - - allSettled(values: Iterable>): Promise>[]>; -} diff --git a/scripts/build-entries/entries-definitions.mjs b/scripts/build-entries/entries-definitions.mjs index 6ad865df4519..70649bea5e85 100644 --- a/scripts/build-entries/entries-definitions.mjs +++ b/scripts/build-entries/entries-definitions.mjs @@ -323,7 +323,7 @@ export const features = { template: $uncurriedWithCustomType, namespace: 'Array', name: 'flatMap', - customType: 'proposals/array-flat-map', + customType: 'proposals/array-flat-map-custom', genericsCount: 3, }, 'array/prototype/flat-map': { @@ -553,7 +553,7 @@ export const features = { template: $uncurriedWithCustomType, namespace: 'Array', name: 'toSpliced', - customType: 'proposals/change-array-by-copy', + customType: 'proposals/change-array-by-copy-custom', genericsCount: 1, }, 'array/prototype/to-spliced': { @@ -1294,7 +1294,7 @@ export const features = { template: $uncurriedWithCustomType, namespace: 'Iterator', name: 'flatMap', - customType: 'proposals/iterator-helpers', + customType: 'proposals/iterator-helpers-custom', genericsCount: 2, }, 'iterator/prototype/flat-map': { @@ -1332,7 +1332,7 @@ export const features = { template: $uncurriedWithCustomType, namespace: 'Iterator', name: 'map', - customType: 'proposals/iterator-helpers', + customType: 'proposals/iterator-helpers-custom', genericsCount: 2, }, 'iterator/prototype/map': { @@ -1346,7 +1346,7 @@ export const features = { template: $uncurriedWithCustomType, namespace: 'Iterator', name: 'reduce', - customType: 'proposals/iterator-helpers', + customType: 'proposals/iterator-helpers-custom', genericsCount: 2, }, 'iterator/prototype/reduce': { @@ -2257,7 +2257,7 @@ export const features = { template: $uncurriedWithCustomType, namespace: 'Set', name: 'symmetricDifference', - customType: 'proposals/set-methods', + customType: 'proposals/set-methods-custom', genericsCount: 2, }, 'set/prototype/symmetric-difference': { @@ -2271,7 +2271,7 @@ export const features = { template: $uncurriedWithCustomType, namespace: 'Set', name: 'union', - customType: 'proposals/set-methods', + customType: 'proposals/set-methods-custom', genericsCount: 2, }, 'set/prototype/union': { @@ -2554,7 +2554,7 @@ export const features = { template: $uncurriedWithCustomType, namespace: 'String', name: 'replaceAll', - customType: 'proposals/string-replace-all', + customType: 'proposals/string-replace-all-custom', genericsCount: 2, }, 'string/prototype/replace-all': { diff --git a/scripts/build-entries/index.mjs b/scripts/build-entries/index.mjs index 9448bdd54e29..777b33c112b0 100644 --- a/scripts/build-entries/index.mjs +++ b/scripts/build-entries/index.mjs @@ -1,6 +1,6 @@ import { getModulesMetadata, sort } from './get-dependencies.mjs'; import { features, proposals } from './entries-definitions.mjs'; -import { $proposal, $path, wrapDts, wrapEntry } from './templates.mjs'; +import { $proposal, $path, wrapEntry } from './templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; const { mkdir, writeFile, readJson, writeJson } = fs; @@ -92,9 +92,6 @@ async function buildEntry(entry, options) { await mkdir(dirname(filepath), { recursive: true }); await writeFile(filepath, wrapEntry(tpl.entry)); - const typePath = `./packages/core-js/${ entry }.d.ts`; - await writeFile(typePath, wrapDts(tpl.dts, { types, level })); - built++; if (entry.endsWith('/index')) exportsFields[`./${ entry.slice(0, -6) }`] = `./${ entry }.js`; diff --git a/scripts/build-types/config.mjs b/scripts/build-types/config.mjs new file mode 100644 index 000000000000..fdaefbca84ce --- /dev/null +++ b/scripts/build-types/config.mjs @@ -0,0 +1,7 @@ +export default { + buildDir: 'packages/core-js-types/dist/', + bundleName: 'core-js-types', + latestTsVersion: 59, + packageName: '@core-js/pure/', + srcDir: 'packages/core-js-types/src/', +}; diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs new file mode 100644 index 000000000000..7decdd943b6b --- /dev/null +++ b/scripts/build-types/index.mjs @@ -0,0 +1,139 @@ +import { features, proposals } from '../build-entries/entries-definitions.mjs'; +import { $path, $proposal } from '../build-entries/templates.mjs'; +import { modules as AllModules } from '@core-js/compat/src/data.mjs'; +import { getModulesMetadata, sort } from '../build-entries/get-dependencies.mjs'; +import config from './config.mjs'; +import { path, fs } from 'zx'; + +const { copy, outputFile, pathExists, readdir, remove } = fs; + +function modulesToStage(x) { + return sort([ + ...StableModules, + ...Object.values(proposals).flatMap(({ stage, modules }) => stage >= x ? modules : []), + ]); +} + +function expandModules(modules, filter) { + if (!Array.isArray(modules)) modules = [modules]; + modules = modules.flatMap(it => it instanceof RegExp ? AllModules.filter(p => it.test(p)) : [it]); + if (filter) modules = modules.filter(it => typeof it != 'string' || filter.has(it)); + return modules; +} + +async function buildType(typeFilePath, entry, options) { + let { + entryFromNamespace, + subset = entryFromNamespace ?? 'full', + template, templateStable, templateActual, templateFull, filter, modules, enforceEntryCreation, + } = options; + + switch (subset) { + case 'es': + filter ??= ESSet; + break; + case 'stable': + filter ??= StableSet; + template = templateStable ?? template; + break; + case 'actual': + filter ??= ActualSet; + template = templateActual ?? templateStable ?? template; + break; + case 'full': + template = templateFull ?? templateActual ?? templateStable ?? template; + break; + case 'es-stage': + filter ??= ESWithProposalsSet; + } + + if (!enforceEntryCreation && !expandModules(modules[0], filter).length) return; + + const rawModules = modules; + + modules = expandModules(modules, filter); + + const level = entry.split('/').length - 1; + + const { dependencies, types } = await getModulesMetadata(modules); + modules = dependencies; + + if (filter) modules = modules.filter(it => filter.has(it)); + + const tpl = template({ ...options, modules, rawModules, level, entry, types, packageName: config.packageName }); + + await outputFile(typeFilePath, `${ tpl.dts }\n\n`, { flag: 'a' }); +} + +async function getVersions() { + const versions = []; + const entries = await readdir(config.srcDir, { withFileTypes: true }); + for (const entry of entries) { + if (entry.isDirectory()) { + versions.push(parseInt(entry.name, 10)); + } + } + return versions.sort(); +} + +async function buildTypesForTSVersion(version) { + const versions = await getVersions(); + for (const v of versions) { + if (v > version) break; + await copy(path.join(config.srcDir, v.toString()), path.join(config.buildDir, version.toString())); + } +} + +async function addImports(filePath, fromPath) { + const entries = await readdir(fromPath, { withFileTypes: true }); + for (const entry of entries) { + if (entry.isDirectory()) { + await addImports(filePath, path.join(fromPath, entry.name)); + } else { + const typePath = path.join(fromPath, entry.name).replace(config.buildDir, ''); + await outputFile(filePath, `/// \n`, { flag: 'a' }); + } + } +} + +const ESModules = AllModules.filter(it => it.startsWith('es.')); +const ESWithProposalsModules = AllModules.filter(it => it.startsWith('es')); +const StableModules = AllModules.filter(it => it.match(/^(?:es|web)\./)); +const ActualModules = modulesToStage(3); + +const ESSet = new Set(ESModules); +const ESWithProposalsSet = new Set(ESWithProposalsModules); +const StableSet = new Set(StableModules); +const ActualSet = new Set(ActualModules); + +const tsVersion = config.latestTsVersion; +const bundleName = `${ config.bundleName }.${ tsVersion === config.latestTsVersion ? 'latest' : tsVersion }.d.ts`; +const bundlePath = path.join(config.buildDir, bundleName); +const typesPath = path.join(config.buildDir, tsVersion.toString()); +if (await pathExists(bundlePath)) await remove(bundlePath); +if (await pathExists(typesPath)) await remove(typesPath); +await buildTypesForTSVersion(tsVersion); +await addImports(bundlePath, typesPath); + +for (const [entry, definition] of Object.entries(features)) { + await buildType(bundlePath, `es/${ entry }`, { ...definition, entryFromNamespace: 'es' }); + await buildType(bundlePath, `stable/${ entry }`, { ...definition, entryFromNamespace: 'stable' }); + await buildType(bundlePath, `actual/${ entry }`, { ...definition, entryFromNamespace: 'actual' }); + await buildType(bundlePath, `full/${ entry }`, { ...definition, entryFromNamespace: 'full' }); +} + +for (const [name, definition] of Object.entries(proposals)) { + await buildType(bundlePath, `proposals/${ name }`, { ...definition, template: $proposal }); +} + +await buildType(bundlePath, 'stage/3', { template: $path, modules: ActualModules, subset: 'es-stage' }); +await buildType(bundlePath, 'stage/2.7', { template: $path, modules: modulesToStage(2.7), subset: 'es-stage' }); +await buildType(bundlePath, 'stage/2', { template: $path, modules: modulesToStage(2), subset: 'es-stage' }); +await buildType(bundlePath, 'stage/1', { template: $path, modules: modulesToStage(1), subset: 'es-stage' }); +await buildType(bundlePath, 'stage/0', { template: $path, modules: AllModules, subset: 'es-stage' }); + +await buildType(bundlePath, 'es/index', { template: $path, modules: ESModules, subset: 'es' }); +await buildType(bundlePath, 'stable/index', { template: $path, modules: StableModules, subset: 'stable' }); +await buildType(bundlePath, 'actual/index', { template: $path, modules: ActualModules }); +await buildType(bundlePath, 'full/index', { template: $path, modules: AllModules }); +await buildType(bundlePath, 'index', { template: $path, modules: ActualModules }); diff --git a/scripts/build-types/package-lock.json b/scripts/build-types/package-lock.json new file mode 100644 index 000000000000..24bea456d15f --- /dev/null +++ b/scripts/build-types/package-lock.json @@ -0,0 +1,10 @@ +{ + "name": "scripts/build-types", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "scripts/build-types" + } + } +} diff --git a/scripts/build-types/package.json b/scripts/build-types/package.json new file mode 100644 index 000000000000..6e42c9e1600e --- /dev/null +++ b/scripts/build-types/package.json @@ -0,0 +1,3 @@ +{ + "name": "scripts/build-types" +} diff --git a/tests/type-definitions/entries.import.ts b/tests/type-definitions/entries.import.ts index a64bd2287dbf..e9e523076ad0 100644 --- a/tests/type-definitions/entries.import.ts +++ b/tests/type-definitions/entries.import.ts @@ -4,17 +4,17 @@ import '@core-js/pure/full/array-buffer/detached'; import detached from '@core-js/pure/full/array-buffer/detached'; // $prototype -import at from '@core-js/pure/full/array/prototype/at'; -const atResult1: number = at.call([1, 2, 3], -2); -at.apply([1, 2, 3], [-2]); -// @ts-expect-error -at.call([1, 2, 3], null); -// @ts-expect-error -at.call(123); -// @ts-expect-error -at('string'); -// @ts-expect-error -at(null); +// import at from '@core-js/pure/full/array/prototype/at'; +// const atResult1: number = at.call([1, 2, 3], -2); +// at.apply([1, 2, 3], [-2]); +// // @ts-expect-error +// at.call([1, 2, 3], null); +// // @ts-expect-error +// at.call(123); +// // @ts-expect-error +// at('string'); +// // @ts-expect-error +// at(null); // $prototypeIterator import arrayVirtualIterator from '@core-js/pure/full/array/prototype/iterator'; diff --git a/tests/type-definitions/package-lock.json b/tests/type-definitions/package-lock.json index f5989ce6d385..fbfbfd5d2474 100644 --- a/tests/type-definitions/package-lock.json +++ b/tests/type-definitions/package-lock.json @@ -6,9 +6,24 @@ "": { "name": "tests/type-definitions", "devDependencies": { + "@core-js/types": "../../packages/core-js-types/", "typescript": "^5.9.3" } }, + "../../packages/core-js-types": { + "name": "@core-js/types", + "version": "4.0.0-alpha.0", + "dev": true, + "license": "SEE LICENSE IN LICENSE.md", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, + "node_modules/@core-js/types": { + "resolved": "../../packages/core-js-types", + "link": true + }, "node_modules/typescript": { "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", diff --git a/tests/type-definitions/package.json b/tests/type-definitions/package.json index dffa3cb452e1..33e48397afbe 100644 --- a/tests/type-definitions/package.json +++ b/tests/type-definitions/package.json @@ -1,6 +1,7 @@ { "name": "tests/type-definitions", "devDependencies": { + "@core-js/types": "../../packages/core-js-types/", "typescript": "^5.9.3" } } diff --git a/tests/type-definitions/proposals/global/accessible-object-hasownproperty.test.ts b/tests/type-definitions/proposals/global/accessible-object-hasownproperty.test.ts index b01a6f0c1a06..83fe9356c184 100644 --- a/tests/type-definitions/proposals/global/accessible-object-hasownproperty.test.ts +++ b/tests/type-definitions/proposals/global/accessible-object-hasownproperty.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; Object.hasOwn({a: 1}, 'a'); Object.hasOwn([], 0); diff --git a/tests/type-definitions/proposals/global/array-buffer-base64.test.ts b/tests/type-definitions/proposals/global/array-buffer-base64.test.ts index 22d0162d6899..6f5741d2f42a 100644 --- a/tests/type-definitions/proposals/global/array-buffer-base64.test.ts +++ b/tests/type-definitions/proposals/global/array-buffer-base64.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; function acceptUint8Array(v: Uint8Array) {} function acceptProcessMetadata(v: { read: number; written: number }) {} diff --git a/tests/type-definitions/proposals/global/array-buffer-transfer.test.ts b/tests/type-definitions/proposals/global/array-buffer-transfer.test.ts index 7e4acf0eae5f..b8482003ca2f 100644 --- a/tests/type-definitions/proposals/global/array-buffer-transfer.test.ts +++ b/tests/type-definitions/proposals/global/array-buffer-transfer.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const ab = new ArrayBuffer(16); // todo uncomment when fixed diff --git a/tests/type-definitions/proposals/global/array-filtering.test.ts b/tests/type-definitions/proposals/global/array-filtering.test.ts index 397e10704e9e..5092abf1edc1 100644 --- a/tests/type-definitions/proposals/global/array-filtering.test.ts +++ b/tests/type-definitions/proposals/global/array-filtering.test.ts @@ -1,11 +1,11 @@ import 'core-js/full'; +import '@core-js/types'; [1, 2, 3].filterReject((v, i, arr) => v > 1); ['a', 'b'].filterReject((v, i, arr) => v === 'a'); const arr: number[] = [1, 2, 3]; const res: number[] = arr.filterReject(function(v) { return v < 2; }, { foo: true }); - (new Int8Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); (new Uint8Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); (new Uint8ClampedArray([1, 2, 3])).filterReject((v, i, arr) => v > 1); @@ -16,8 +16,11 @@ const res: number[] = arr.filterReject(function(v) { return v < 2; }, { foo: tru (new Float32Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); (new Float64Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); -(new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((v, i, arr) => v > BigInt(1)); -(new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((v, i, arr) => v > BigInt(1)); +// todo for es6 +// declare var BigInt: (value: number | string | bigint) => bigint; +// (new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((v, i, arr) => v > BigInt(1)); +// (new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((v, i, arr) => v > BigInt(1)); + // @ts-expect-error [1, 2, 3].filterReject((x: string) => false); @@ -49,8 +52,9 @@ const res: number[] = arr.filterReject(function(v) { return v < 2; }, { foo: tru // @ts-expect-error (new Float64Array([1, 2, 3])).filterReject((x: string) => false); -// @ts-expect-error -(new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((x: number) => false); - -// @ts-expect-error -(new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((x: number) => false); +// todo +// // @ts-expect-error +// (new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((x: number) => false); +// +// // @ts-expect-error +// (new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((x: number) => false); diff --git a/tests/type-definitions/proposals/global/array-find-from-last.test.ts b/tests/type-definitions/proposals/global/array-find-from-last.test.ts index 8757648c21b7..d5e87481e5a9 100644 --- a/tests/type-definitions/proposals/global/array-find-from-last.test.ts +++ b/tests/type-definitions/proposals/global/array-find-from-last.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const res: number | undefined = [1, 2, 3].findLast(v => v > 1); [1, 2, 3].findLast((v): v is 2 => v === 2); @@ -18,11 +19,12 @@ m.findLast((v): v is string => typeof v === "string"); (new Uint8Array([1, 2, 3])).findLastIndex(v => v < 0); (new Float64Array([1, 2, 3])).findLast(v => v > 1.1); (new Float64Array([1, 2, 3])).findLastIndex(v => v > 100); -(new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLast(v => v > BigInt(1)); -(new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLast((v): v is bigint => v === BigInt(2)); -(new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLastIndex(v => v > BigInt(0)); -(new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).findLast(v => v > BigInt(1)); -(new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).findLastIndex(v => v > BigInt(0)); +// todo for es6 +// (new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLast(v => v > BigInt(1)); +// (new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLast((v): v is bigint => v === BigInt(2)); +// (new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLastIndex(v => v > BigInt(0)); +// (new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).findLast(v => v > BigInt(1)); +// (new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).findLastIndex(v => v > BigInt(0)); // @ts-expect-error [1, 2, 3].findLast(); @@ -39,8 +41,8 @@ m.findLast((v): v is string => typeof v === "string"); // @ts-expect-error (new Int8Array([1, 2, 3])).findLast((v: string) => false); -// @ts-expect-error -(new BigInt64Array([BigInt(1)])).findLast((v: number) => false); +// // @ts-expect-error +// (new BigInt64Array([BigInt(1)])).findLast((v: number) => false); // @ts-expect-error [1, 2, 3].findLastIndex(); diff --git a/tests/type-definitions/proposals/global/array-flat-map.test.ts b/tests/type-definitions/proposals/global/array-flat-map.test.ts index 8ae7007f3a6d..f26911d88cb7 100644 --- a/tests/type-definitions/proposals/global/array-flat-map.test.ts +++ b/tests/type-definitions/proposals/global/array-flat-map.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const flatMapped: number[] = [1, 2, 3].flatMap(x => [x, x * 2]); const flatMapped2: string[] = ['a', 'b', 'c'].flatMap(x => [x, x.toUpperCase()]); diff --git a/tests/type-definitions/proposals/global/array-from-async.test.ts b/tests/type-definitions/proposals/global/array-from-async.test.ts index fa8209bf9c1d..79a79405c088 100644 --- a/tests/type-definitions/proposals/global/array-from-async.test.ts +++ b/tests/type-definitions/proposals/global/array-from-async.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; Array.fromAsync([1, 2, 3]); Array.fromAsync([Promise.resolve(1), 2, 3]); diff --git a/tests/type-definitions/proposals/global/array-grouping.test.ts b/tests/type-definitions/proposals/global/array-grouping.test.ts index 22380f95d21a..095a15355ba1 100644 --- a/tests/type-definitions/proposals/global/array-grouping.test.ts +++ b/tests/type-definitions/proposals/global/array-grouping.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const arr = [1, 2, 3, 4, 5]; const objGroup: Partial> = Object.groupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); diff --git a/tests/type-definitions/proposals/global/array-includes.test.ts b/tests/type-definitions/proposals/global/array-includes.test.ts index 90dfbae0bc2a..176975fc64c0 100644 --- a/tests/type-definitions/proposals/global/array-includes.test.ts +++ b/tests/type-definitions/proposals/global/array-includes.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const arr: number[] = [1, 2, 3]; const arrRes: boolean = arr.includes(2); @@ -44,13 +45,14 @@ const f64 = new Float64Array([1.5, 2.5, 3.5]); const f64Res: boolean = f64.includes(2.5); const f64Res2: boolean = f64.includes(2.5, 1); -const bi64 = new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)]); -const bi64Res: boolean = bi64.includes(BigInt(2)); -const bi64Res2: boolean = bi64.includes(BigInt(2), 1); - -const bu64 = new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)]); -const bu64Res: boolean = bu64.includes(BigInt(2)); -const bu64Res2: boolean = bu64.includes(BigInt(2), 1); +// todo for es6 +// const bi64 = new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)]); +// const bi64Res: boolean = bi64.includes(BigInt(2)); +// const bi64Res2: boolean = bi64.includes(BigInt(2), 1); +// +// const bu64 = new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)]); +// const bu64Res: boolean = bu64.includes(BigInt(2)); +// const bu64Res2: boolean = bu64.includes(BigInt(2), 1); // @ts-expect-error arr.includes(); @@ -109,14 +111,15 @@ f64.includes(2.5, []); // @ts-expect-error bi64.includes(2); -// @ts-expect-error -bi64.includes(2n, '1'); -// @ts-expect-error -bi64.includes('2n'); +// // @ts-expect-error +// bi64.includes(2n, '1'); +// // @ts-expect-error +// bi64.includes('2n'); // @ts-expect-error bu64.includes(2); -// @ts-expect-error -bu64.includes(2n, []); -// @ts-expect-error -bu64.includes('2n'); + +// // @ts-expect-error +// bu64.includes(2n, []); +// // @ts-expect-error +// bu64.includes('2n'); diff --git a/tests/type-definitions/proposals/global/array-is-template-object.test.ts b/tests/type-definitions/proposals/global/array-is-template-object.test.ts index bc54ef0bd82d..4af57fba7d82 100644 --- a/tests/type-definitions/proposals/global/array-is-template-object.test.ts +++ b/tests/type-definitions/proposals/global/array-is-template-object.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const t: boolean = Array.isTemplateObject([]); Array.isTemplateObject({}); diff --git a/tests/type-definitions/proposals/global/array-unique.test.ts b/tests/type-definitions/proposals/global/array-unique.test.ts index 9c380fafa6d2..f547b5654aa5 100644 --- a/tests/type-definitions/proposals/global/array-unique.test.ts +++ b/tests/type-definitions/proposals/global/array-unique.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; type Obj = { a: number; b: string }; const arr: Obj[] = [{ a: 1, b: 'x' }, { a: 2, b: 'y' }]; @@ -55,15 +56,16 @@ const f64Res: Float64Array = f64.uniqueBy(); const f64Res2: Float64Array = f64.uniqueBy('length'); const f64Res3: Float64Array = f64.uniqueBy(x => x.toFixed(1)); -const bi64 = new BigInt64Array([BigInt(1), BigInt(2), BigInt(1), BigInt(3)]); -const bi64Res: BigInt64Array = bi64.uniqueBy(); -const bi64Res2: BigInt64Array = bi64.uniqueBy('length'); -const bi64Res3: BigInt64Array = bi64.uniqueBy(x => (x as bigint) % BigInt(2)); - -const bu64 = new BigUint64Array([BigInt(1), BigInt(2), BigInt(1), BigInt(3)]); -const bu64Res: BigUint64Array = bu64.uniqueBy(); -const bu64Res2: BigUint64Array = bu64.uniqueBy('length'); -const bu64Res3: BigUint64Array = bu64.uniqueBy(x => (x as bigint) * BigInt(3)); +// todo for es6 +// const bi64 = new BigInt64Array([BigInt(1), BigInt(2), BigInt(1), BigInt(3)]); +// const bi64Res: BigInt64Array = bi64.uniqueBy(); +// const bi64Res2: BigInt64Array = bi64.uniqueBy('length'); +// const bi64Res3: BigInt64Array = bi64.uniqueBy(x => (x as bigint) % BigInt(2)); +// +// const bu64 = new BigUint64Array([BigInt(1), BigInt(2), BigInt(1), BigInt(3)]); +// const bu64Res: BigUint64Array = bu64.uniqueBy(); +// const bu64Res2: BigUint64Array = bu64.uniqueBy('length'); +// const bu64Res3: BigUint64Array = bu64.uniqueBy(x => (x as bigint) * BigInt(3)); // @ts-expect-error arr.uniqueBy(123); @@ -126,12 +128,12 @@ f64.uniqueBy([]); // @ts-expect-error f64.uniqueBy(false); -// @ts-expect-error -bi64.uniqueBy([]); -// @ts-expect-error -bi64.uniqueBy({}); - -// @ts-expect-error -bu64.uniqueBy([]); -// @ts-expect-error -bu64.uniqueBy({}); +// // @ts-expect-error +// bi64.uniqueBy([]); +// // @ts-expect-error +// bi64.uniqueBy({}); +// +// // @ts-expect-error +// bu64.uniqueBy([]); +// // @ts-expect-error +// bu64.uniqueBy({}); diff --git a/tests/type-definitions/proposals/global/async-iteration.test.ts b/tests/type-definitions/proposals/global/async-iteration.test.ts index b2989ab42dd2..67de54f6c01c 100644 --- a/tests/type-definitions/proposals/global/async-iteration.test.ts +++ b/tests/type-definitions/proposals/global/async-iteration.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const sym: symbol = Symbol.asyncIterator; diff --git a/tests/type-definitions/proposals/global/async-iterator-helper.test.ts b/tests/type-definitions/proposals/global/async-iterator-helper.test.ts index 4936798114c7..eef9cce999a0 100644 --- a/tests/type-definitions/proposals/global/async-iterator-helper.test.ts +++ b/tests/type-definitions/proposals/global/async-iterator-helper.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const res: AsyncIterator = AsyncIterator.from([1, 2, 3]); const res2: AsyncIterator = AsyncIterator.from(new Set([1, 2, 3])); @@ -6,9 +7,9 @@ AsyncIterator.from((async function* () { yield 1; yield 2; })()); AsyncIterator.from((function* () { yield 3; })()); const res3: AsyncIterator = AsyncIterator.from('abc'); -declare const ain: AsyncIterator; -declare const aio: AsyncIterator<{ x: number }>; -declare const ais: AsyncIterator; +declare const ain: AsyncIteratorObject; +declare const aio: AsyncIteratorObject<{ x: number }>; +declare const ais: AsyncIteratorObject; declare const ilb: Iterable; declare const is: Iterator; declare const itn: Iterator; diff --git a/tests/type-definitions/proposals/global/await-dictionary.test.ts b/tests/type-definitions/proposals/global/await-dictionary.test.ts index 5c1355c03e80..31747e0107aa 100644 --- a/tests/type-definitions/proposals/global/await-dictionary.test.ts +++ b/tests/type-definitions/proposals/global/await-dictionary.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const res: Promise<{ a: number, b: string, c: boolean }> = Promise.allKeyed({ a: Promise.resolve(1), diff --git a/tests/type-definitions/proposals/global/change-array-by-copy.test.ts b/tests/type-definitions/proposals/global/change-array-by-copy.test.ts index 5f60d1759ff5..a8c94b79634c 100644 --- a/tests/type-definitions/proposals/global/change-array-by-copy.test.ts +++ b/tests/type-definitions/proposals/global/change-array-by-copy.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const arr: number[] = [1, 2, 3]; const arrRev: number[] = arr.toReversed(); @@ -63,17 +64,18 @@ const f64Rev: Float64Array = f64.toReversed(); const f64Sorted: Float64Array = f64.toSorted(); const f64With: Float64Array = f64.with(0, 2.2); -const bi64 = new (BigInt64Array as { new(arr: ArrayLike): BigInt64Array })([BigInt(1), BigInt(2), BigInt(3)]); -const bi64Rev: BigInt64Array = bi64.toReversed(); -const bi64Sorted: BigInt64Array = bi64.toSorted(); -const bi64Sorted2: BigInt64Array = bi64.toSorted((a, b) => (a > b ? 1 : -1)); -const bi64With: BigInt64Array = bi64.with(2, BigInt(100)); - -const bu64 = new (BigUint64Array as { new(arr: ArrayLike): BigUint64Array })([BigInt(1), BigInt(2), BigInt(3)]); -const bu64Rev: BigUint64Array = bu64.toReversed(); -const bu64Sorted: BigUint64Array = bu64.toSorted(); -const bu64Sorted2: BigUint64Array = bu64.toSorted((a, b) => (a > b ? 1 : -1)); -const bu64With: BigUint64Array = bu64.with(0, BigInt(50)); +// todo for es6 +// const bi64 = new (BigInt64Array as { new(arr: ArrayLike): BigInt64Array })([BigInt(1), BigInt(2), BigInt(3)]); +// const bi64Rev: BigInt64Array = bi64.toReversed(); +// const bi64Sorted: BigInt64Array = bi64.toSorted(); +// const bi64Sorted2: BigInt64Array = bi64.toSorted((a, b) => (a > b ? 1 : -1)); +// const bi64With: BigInt64Array = bi64.with(2, BigInt(100)); +// +// const bu64 = new (BigUint64Array as { new(arr: ArrayLike): BigUint64Array })([BigInt(1), BigInt(2), BigInt(3)]); +// const bu64Rev: BigUint64Array = bu64.toReversed(); +// const bu64Sorted: BigUint64Array = bu64.toSorted(); +// const bu64Sorted2: BigUint64Array = bu64.toSorted((a, b) => (a > b ? 1 : -1)); +// const bu64With: BigUint64Array = bu64.with(0, BigInt(50)); // @ts-expect-error arr.toReversed(1); @@ -167,16 +169,16 @@ f64.toSorted(1,2); // @ts-expect-error f64.with('a', 1); -// @ts-expect-error -bi64.toReversed(1); -// @ts-expect-error -bi64.toSorted('f'); -// @ts-expect-error -bi64.toSorted((a: number, b: number) => 0); -// @ts-expect-error -bi64.with(1, 1); -// @ts-expect-error -bi64.with('a', BigInt(1)); +// // @ts-expect-error +// bi64.toReversed(1); +// // @ts-expect-error +// bi64.toSorted('f'); +// // @ts-expect-error +// bi64.toSorted((a: number, b: number) => 0); +// // @ts-expect-error +// bi64.with(1, 1); +// // @ts-expect-error +// bi64.with('a', BigInt(1)); // @ts-expect-error bu64.toSorted({}); diff --git a/tests/type-definitions/proposals/global/collection-of-from.test.ts b/tests/type-definitions/proposals/global/collection-of-from.test.ts index e5ac9f57c86c..0873339ec620 100644 --- a/tests/type-definitions/proposals/global/collection-of-from.test.ts +++ b/tests/type-definitions/proposals/global/collection-of-from.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const arrEntries: Array<[string, number]> = [['a', 1], ['b', 2]]; const mapFrom: Map = Map.from(arrEntries, v => String(v)); diff --git a/tests/type-definitions/proposals/global/data-view-get-set-uint8-clamped.test.ts b/tests/type-definitions/proposals/global/data-view-get-set-uint8-clamped.test.ts index da6e0703bfaa..16ee58b80c98 100644 --- a/tests/type-definitions/proposals/global/data-view-get-set-uint8-clamped.test.ts +++ b/tests/type-definitions/proposals/global/data-view-get-set-uint8-clamped.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; declare const dv: DataView; diff --git a/tests/type-definitions/proposals/global/decorator-metadata.test.ts b/tests/type-definitions/proposals/global/decorator-metadata.test.ts index 4abbf2decd7d..8ccdc984a580 100644 --- a/tests/type-definitions/proposals/global/decorator-metadata.test.ts +++ b/tests/type-definitions/proposals/global/decorator-metadata.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const rsmd1: symbol = Symbol.metadata; const rsmd2: typeof Symbol.metadata = Symbol.metadata; diff --git a/tests/type-definitions/proposals/global/error-cause.test.ts b/tests/type-definitions/proposals/global/error-cause.test.ts index 099e6283e8da..37049a35f62b 100644 --- a/tests/type-definitions/proposals/global/error-cause.test.ts +++ b/tests/type-definitions/proposals/global/error-cause.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const prevError = new Error('Prev error'); diff --git a/tests/type-definitions/proposals/global/explicit-resource-management.test.ts b/tests/type-definitions/proposals/global/explicit-resource-management.test.ts index b0d4a58e75d4..f2c99f328671 100644 --- a/tests/type-definitions/proposals/global/explicit-resource-management.test.ts +++ b/tests/type-definitions/proposals/global/explicit-resource-management.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const d: symbol = Symbol.dispose; const ad: symbol = Symbol.asyncDispose; diff --git a/tests/type-definitions/proposals/global/extractors.test.ts b/tests/type-definitions/proposals/global/extractors.test.ts index 13ee20e150fe..826ff039b864 100644 --- a/tests/type-definitions/proposals/global/extractors.test.ts +++ b/tests/type-definitions/proposals/global/extractors.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const rscs1: symbol = Symbol.customMatcher; const rscs2: typeof Symbol.customMatcher = Symbol.customMatcher; diff --git a/tests/type-definitions/proposals/global/float16.test.ts b/tests/type-definitions/proposals/global/float16.test.ts index 810fc9e2c788..62097d9f483d 100644 --- a/tests/type-definitions/proposals/global/float16.test.ts +++ b/tests/type-definitions/proposals/global/float16.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const res: number = Math.f16round(1); diff --git a/tests/type-definitions/proposals/global/function-demethodize.test.ts b/tests/type-definitions/proposals/global/function-demethodize.test.ts index be44d65caf70..2fce02473635 100644 --- a/tests/type-definitions/proposals/global/function-demethodize.test.ts +++ b/tests/type-definitions/proposals/global/function-demethodize.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; function sumTo(this: { base: number }, a: number, b: number): number { return this.base + a + b; diff --git a/tests/type-definitions/proposals/global/is-error.test.ts b/tests/type-definitions/proposals/global/is-error.test.ts index fde89158e17f..63aff9ef9b29 100644 --- a/tests/type-definitions/proposals/global/is-error.test.ts +++ b/tests/type-definitions/proposals/global/is-error.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const e = new Error(); const ne = { foo: 1 }; diff --git a/tests/type-definitions/proposals/global/iterator-chunking.test.ts b/tests/type-definitions/proposals/global/iterator-chunking.test.ts index 533ad35aa7ea..4c185307381e 100644 --- a/tests/type-definitions/proposals/global/iterator-chunking.test.ts +++ b/tests/type-definitions/proposals/global/iterator-chunking.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; declare function getNumberIterator(): Iterator; diff --git a/tests/type-definitions/proposals/global/iterator-helpers.test.ts b/tests/type-definitions/proposals/global/iterator-helpers.test.ts index 1686ac2ab661..51cdafd16d15 100644 --- a/tests/type-definitions/proposals/global/iterator-helpers.test.ts +++ b/tests/type-definitions/proposals/global/iterator-helpers.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; declare const it: Iterator; declare const itStr: Iterator; diff --git a/tests/type-definitions/proposals/global/iterator-joint.test.ts b/tests/type-definitions/proposals/global/iterator-joint.test.ts index 3701cbd40dcc..a714a7b52add 100644 --- a/tests/type-definitions/proposals/global/iterator-joint.test.ts +++ b/tests/type-definitions/proposals/global/iterator-joint.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; Iterator.zip([[1, 2, 3], [4, 5, 6]]); Iterator.zip([['a', 'b', 'c'], ['d', 'e', 'f']]); diff --git a/tests/type-definitions/proposals/global/iterator-range.test.ts b/tests/type-definitions/proposals/global/iterator-range.test.ts index b7d89bcaba4a..eb3421a5a1d8 100644 --- a/tests/type-definitions/proposals/global/iterator-range.test.ts +++ b/tests/type-definitions/proposals/global/iterator-range.test.ts @@ -1,10 +1,12 @@ import 'core-js/full'; +import '@core-js/types'; const rir1: Iterator = Iterator.range(1, 10); Iterator.range(1, 10, 1); Iterator.range(1, 10, { step: 1 }); Iterator.range(1, 10, { inclusive: true }); -const rir2: Iterator< bigint> = Iterator.range(BigInt(0), BigInt(10), { step: BigInt(2), inclusive: true }); +// todo for es6 +// const rir2: Iterator< bigint> = Iterator.range(BigInt(0), BigInt(10), { step: BigInt(2), inclusive: true }); // @ts-expect-error Iterator.range(0, 10, 'not-a-number'); diff --git a/tests/type-definitions/proposals/global/iterator-sequencing.test.ts b/tests/type-definitions/proposals/global/iterator-sequencing.test.ts index 21a342cca779..7615f724438e 100644 --- a/tests/type-definitions/proposals/global/iterator-sequencing.test.ts +++ b/tests/type-definitions/proposals/global/iterator-sequencing.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; declare const its1: Iterable; declare const arrs: string[]; diff --git a/tests/type-definitions/proposals/global/json-parse-with-source.test.ts b/tests/type-definitions/proposals/global/json-parse-with-source.test.ts index d8c9a4944fd8..47b31e0d32a5 100644 --- a/tests/type-definitions/proposals/global/json-parse-with-source.test.ts +++ b/tests/type-definitions/proposals/global/json-parse-with-source.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const r: CoreJSRawJSON = JSON.rawJSON('{"a":123}'); diff --git a/tests/type-definitions/proposals/global/map-upsert.test.ts b/tests/type-definitions/proposals/global/map-upsert.test.ts index 67e80f422712..f2dd06e4ea11 100644 --- a/tests/type-definitions/proposals/global/map-upsert.test.ts +++ b/tests/type-definitions/proposals/global/map-upsert.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; declare const map: Map; diff --git a/tests/type-definitions/proposals/global/math-sum.test.ts b/tests/type-definitions/proposals/global/math-sum.test.ts index 2b48e4628c20..07a5b5b873d2 100644 --- a/tests/type-definitions/proposals/global/math-sum.test.ts +++ b/tests/type-definitions/proposals/global/math-sum.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; function acceptsNumber(x: number) {} diff --git a/tests/type-definitions/proposals/global/number-clamp.test.ts b/tests/type-definitions/proposals/global/number-clamp.test.ts index 44617c511b3f..8c6239425cc5 100644 --- a/tests/type-definitions/proposals/global/number-clamp.test.ts +++ b/tests/type-definitions/proposals/global/number-clamp.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; declare const num: number; const clamped: number = num.clamp(0, 100); diff --git a/tests/type-definitions/proposals/global/object-from-entries.test.ts b/tests/type-definitions/proposals/global/object-from-entries.test.ts index 3a2c20009b15..346cea84cf8e 100644 --- a/tests/type-definitions/proposals/global/object-from-entries.test.ts +++ b/tests/type-definitions/proposals/global/object-from-entries.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; declare const objEntries: Iterable; declare const mixedEntries: Iterable; diff --git a/tests/type-definitions/proposals/global/object-get-own-property-descriptors.test.ts b/tests/type-definitions/proposals/global/object-get-own-property-descriptors.test.ts index b938ffbdf181..0b4a1ddc7e95 100644 --- a/tests/type-definitions/proposals/global/object-get-own-property-descriptors.test.ts +++ b/tests/type-definitions/proposals/global/object-get-own-property-descriptors.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const obj = { a: 1, b: 'x', c: true }; const objDescs: { a: TypedPropertyDescriptor; b: TypedPropertyDescriptor; c: TypedPropertyDescriptor } & diff --git a/tests/type-definitions/proposals/global/object-values-entries.test.ts b/tests/type-definitions/proposals/global/object-values-entries.test.ts index 08836ce7eb8e..e4cd08a093db 100644 --- a/tests/type-definitions/proposals/global/object-values-entries.test.ts +++ b/tests/type-definitions/proposals/global/object-values-entries.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const obj = { a: 1, b: 2 }; const arr = [1, 2, 3]; diff --git a/tests/type-definitions/proposals/global/pattern-matching.test.ts b/tests/type-definitions/proposals/global/pattern-matching.test.ts index 7d7f8de721aa..1359b17fc624 100644 --- a/tests/type-definitions/proposals/global/pattern-matching.test.ts +++ b/tests/type-definitions/proposals/global/pattern-matching.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const sym: symbol = Symbol.customMatcher; diff --git a/tests/type-definitions/proposals/global/promise-all-settled.test.ts b/tests/type-definitions/proposals/global/promise-all-settled.test.ts index 9d6624efb42d..963013a8037a 100644 --- a/tests/type-definitions/proposals/global/promise-all-settled.test.ts +++ b/tests/type-definitions/proposals/global/promise-all-settled.test.ts @@ -5,24 +5,26 @@ const arr = [Promise.resolve(1), Promise.resolve(2)]; const strArr = ["a", "b", "c"]; const promiseLike = { then: (cb: (val: number) => void) => cb(42) }; +type PromiseResult = PromiseFulfilledResult | PromiseRejectedResult; + const settled1: Promise<[ - PromiseSettledResult, - PromiseSettledResult, - PromiseSettledResult + PromiseResult, + PromiseResult, + PromiseResult ]> = Promise.allSettled(promises); -const settled2: Promise[]> = Promise.allSettled([Promise.resolve(10), Promise.resolve(20), 30]); -const settled3: Promise[]> = Promise.allSettled(strArr); -const settled4: Promise[]> = Promise.allSettled(new Set([1, 2, 3])); -const settled5: Promise[]> = Promise.allSettled([promiseLike]); +const settled2: Promise[]> = Promise.allSettled([Promise.resolve(10), Promise.resolve(20), 30]); +const settled3: Promise[]> = Promise.allSettled(strArr); +const settled4: Promise[]> = Promise.allSettled(new Set([1, 2, 3])); +const settled5: Promise[]> = Promise.allSettled([promiseLike]); const emptyTuple: [] = []; const settled6: Promise<[]> = Promise.allSettled(emptyTuple); const mixedTuple = [42, Promise.resolve("bar")] as const; const settled7: Promise<[ - PromiseSettledResult, - PromiseSettledResult + PromiseResult, + PromiseResult ]> = Promise.allSettled(mixedTuple); // @ts-expect-error diff --git a/tests/type-definitions/proposals/global/promise-any.test.ts b/tests/type-definitions/proposals/global/promise-any.test.ts index aa174df5ac4d..7229fae7f45b 100644 --- a/tests/type-definitions/proposals/global/promise-any.test.ts +++ b/tests/type-definitions/proposals/global/promise-any.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const arr = [Promise.resolve(1), Promise.resolve("foo"), 3] as const; const justNumbers = [1, 2, 3]; diff --git a/tests/type-definitions/proposals/global/promise-finally.test.ts b/tests/type-definitions/proposals/global/promise-finally.test.ts index c0923cfa112f..5af0a95d6a6e 100644 --- a/tests/type-definitions/proposals/global/promise-finally.test.ts +++ b/tests/type-definitions/proposals/global/promise-finally.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const p1 = Promise.resolve(42); const pf1: Promise = p1.finally(); diff --git a/tests/type-definitions/proposals/global/promise-try.test.ts b/tests/type-definitions/proposals/global/promise-try.test.ts index 1268220ec85d..39812e12574c 100644 --- a/tests/type-definitions/proposals/global/promise-try.test.ts +++ b/tests/type-definitions/proposals/global/promise-try.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const pt1: Promise = Promise.try(() => 42); const pt2: Promise = Promise.try(() => Promise.resolve("hi")); diff --git a/tests/type-definitions/proposals/global/promise-with-resolvers.test.ts b/tests/type-definitions/proposals/global/promise-with-resolvers.test.ts index a22face5a074..60aba896d2b2 100644 --- a/tests/type-definitions/proposals/global/promise-with-resolvers.test.ts +++ b/tests/type-definitions/proposals/global/promise-with-resolvers.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const pr = Promise.withResolvers(); const pr2 = Promise.withResolvers(); diff --git a/tests/type-definitions/proposals/global/regexp-dotall-flag.test.ts b/tests/type-definitions/proposals/global/regexp-dotall-flag.test.ts index 286c56a36090..c11df9dd200f 100644 --- a/tests/type-definitions/proposals/global/regexp-dotall-flag.test.ts +++ b/tests/type-definitions/proposals/global/regexp-dotall-flag.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const r1 = new RegExp('foo.bar', 's'); const dotAll: boolean = r1.dotAll; diff --git a/tests/type-definitions/proposals/global/regexp-escaping.test.ts b/tests/type-definitions/proposals/global/regexp-escaping.test.ts index 64bd78bca4dd..3361addbb13f 100644 --- a/tests/type-definitions/proposals/global/regexp-escaping.test.ts +++ b/tests/type-definitions/proposals/global/regexp-escaping.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const escaped1: string = RegExp.escape('foo.*+?^${}()|[]\\'); const escaped2: string = RegExp.escape(''); diff --git a/tests/type-definitions/proposals/global/regexp-named-groups.test.ts b/tests/type-definitions/proposals/global/regexp-named-groups.test.ts index 8ae7eae0b1fa..5b06452f2e22 100644 --- a/tests/type-definitions/proposals/global/regexp-named-groups.test.ts +++ b/tests/type-definitions/proposals/global/regexp-named-groups.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; declare const execArr: RegExpExecArray; declare const matchArr: RegExpMatchArray; diff --git a/tests/type-definitions/proposals/global/relative-indexing-method.test.ts b/tests/type-definitions/proposals/global/relative-indexing-method.test.ts index 39020fafdaf0..e1655396e16a 100644 --- a/tests/type-definitions/proposals/global/relative-indexing-method.test.ts +++ b/tests/type-definitions/proposals/global/relative-indexing-method.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const str = 'hello'; const s1: string | undefined = str.at(0); @@ -40,11 +41,12 @@ const f32_1: number | undefined = f32.at(-1); const f64 = new Float64Array([11.1, 22.2, 33.3]); const f64_1: number | undefined = f64.at(0); -const bi64 = new (BigInt64Array as { new(arr: ArrayLike): BigInt64Array })([BigInt(1), BigInt(2), BigInt(3)]); -const bi64_1: bigint | undefined = bi64.at(2); - -const bu64 = new (BigUint64Array as { new(arr: ArrayLike): BigUint64Array })([BigInt(10), BigInt(20)]); -const bu64_1: bigint | undefined = bu64.at(-1); +// todo for es6 +// const bi64 = new (BigInt64Array as { new(arr: ArrayLike): BigInt64Array })([BigInt(1), BigInt(2), BigInt(3)]); +// const bi64_1: bigint | undefined = bi64.at(2); +// +// const bu64 = new (BigUint64Array as { new(arr: ArrayLike): BigUint64Array })([BigInt(10), BigInt(20)]); +// const bu64_1: bigint | undefined = bu64.at(-1); // @ts-expect-error str.at(); @@ -108,8 +110,8 @@ f32.at('a'); // @ts-expect-error f64.at([]); -// @ts-expect-error -bi64.at('a'); - -// @ts-expect-error -bu64.at({}); +// // @ts-expect-error +// bi64.at('a'); +// +// // @ts-expect-error +// bu64.at({}); diff --git a/tests/type-definitions/proposals/global/set-methods.test.ts b/tests/type-definitions/proposals/global/set-methods.test.ts index 5b1f3313706d..07de09497a42 100644 --- a/tests/type-definitions/proposals/global/set-methods.test.ts +++ b/tests/type-definitions/proposals/global/set-methods.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const setA = new Set([1, 2, 3]); const setB = new Set(['a', 'b', 'c']); diff --git a/tests/type-definitions/proposals/global/string-cooked.test.ts b/tests/type-definitions/proposals/global/string-cooked.test.ts index d2884ba55d55..2a852210bdf2 100644 --- a/tests/type-definitions/proposals/global/string-cooked.test.ts +++ b/tests/type-definitions/proposals/global/string-cooked.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const rcooked1: string = String.cooked('foo', 1, 2, 3); String.cooked(['foo', 'bar'], 1, 2); diff --git a/tests/type-definitions/proposals/global/string-dedent.test.ts b/tests/type-definitions/proposals/global/string-dedent.test.ts index 19d3004c1f13..31a74ee8d1f3 100644 --- a/tests/type-definitions/proposals/global/string-dedent.test.ts +++ b/tests/type-definitions/proposals/global/string-dedent.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const rdedent1: string = String.dedent`foo\nbar`; const rdedent2: string = String.dedent`line1 diff --git a/tests/type-definitions/proposals/global/string-left-right-trim.test.ts b/tests/type-definitions/proposals/global/string-left-right-trim.test.ts index 0da6d7ed51a7..e791df02bf70 100644 --- a/tests/type-definitions/proposals/global/string-left-right-trim.test.ts +++ b/tests/type-definitions/proposals/global/string-left-right-trim.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const s = 'abc'; const t1: string = s.trimEnd(); diff --git a/tests/type-definitions/proposals/global/string-match-all.test.ts b/tests/type-definitions/proposals/global/string-match-all.test.ts index 662b73e3cc1d..97cadde985b3 100644 --- a/tests/type-definitions/proposals/global/string-match-all.test.ts +++ b/tests/type-definitions/proposals/global/string-match-all.test.ts @@ -1,12 +1,10 @@ import 'core-js/full'; +import '@core-js/types'; const s = 'abcabc'; const re = /abc/g; const matchIter: RegExpStringIterator = s.matchAll(re); -const result = s.matchAll(re); -const assertType: RegExpStringIterator = result; - // @ts-expect-error s.matchAll(); diff --git a/tests/type-definitions/proposals/global/string-padding.test.ts b/tests/type-definitions/proposals/global/string-padding.test.ts index 42e5c44aeea5..5bbbd5f8880c 100644 --- a/tests/type-definitions/proposals/global/string-padding.test.ts +++ b/tests/type-definitions/proposals/global/string-padding.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const s = 'foo'; const p1: string = s.padStart(5); diff --git a/tests/type-definitions/proposals/global/string-replace-all.test.ts b/tests/type-definitions/proposals/global/string-replace-all.test.ts index c65e1000ebdc..045f65547cd3 100644 --- a/tests/type-definitions/proposals/global/string-replace-all.test.ts +++ b/tests/type-definitions/proposals/global/string-replace-all.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const s = 'foo bar foo'; diff --git a/tests/type-definitions/proposals/global/symbol-description.test.ts b/tests/type-definitions/proposals/global/symbol-description.test.ts index 94f52767ea83..8a55612203dd 100644 --- a/tests/type-definitions/proposals/global/symbol-description.test.ts +++ b/tests/type-definitions/proposals/global/symbol-description.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const sym1 = Symbol('foo'); const d1: string | undefined = sym1.description; diff --git a/tests/type-definitions/proposals/global/symbol-predicates.test.ts b/tests/type-definitions/proposals/global/symbol-predicates.test.ts index 5cad02b9fd39..54e49d4a1f63 100644 --- a/tests/type-definitions/proposals/global/symbol-predicates.test.ts +++ b/tests/type-definitions/proposals/global/symbol-predicates.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const rsymbol1: boolean = Symbol.isRegisteredSymbol(Symbol.for('foo')); const rsymbol2: boolean = Symbol.isRegisteredSymbol(undefined); diff --git a/tests/type-definitions/proposals/global/well-formed-unicode-strings.test.ts b/tests/type-definitions/proposals/global/well-formed-unicode-strings.test.ts index e089e4857fa2..0d18568b8ed5 100644 --- a/tests/type-definitions/proposals/global/well-formed-unicode-strings.test.ts +++ b/tests/type-definitions/proposals/global/well-formed-unicode-strings.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import '@core-js/types'; const s = 'test'; const b: boolean = s.isWellFormed(); diff --git a/tests/type-definitions/proposals/pure/array-is-template-object.test.ts b/tests/type-definitions/proposals/pure/array-is-template-object.test.ts index d28159bc665d..e31c139c373b 100644 --- a/tests/type-definitions/proposals/pure/array-is-template-object.test.ts +++ b/tests/type-definitions/proposals/pure/array-is-template-object.test.ts @@ -1,6 +1,6 @@ import arrayIsTemplateObject from '@core-js/pure/full/array/is-template-object'; import objectFreeze from '@core-js/pure/full/object/freeze'; -import sym from '@core-js/pure/full/symbol'; +import sym from '@core-js/pure/full/symbol/index'; const t: boolean = arrayIsTemplateObject([]); arrayIsTemplateObject({}); diff --git a/tests/type-definitions/proposals/pure/async-iteration.test.ts b/tests/type-definitions/proposals/pure/async-iteration.test.ts index b33c8d23377d..80f00e3fd7b9 100644 --- a/tests/type-definitions/proposals/pure/async-iteration.test.ts +++ b/tests/type-definitions/proposals/pure/async-iteration.test.ts @@ -1,5 +1,4 @@ -import symbolAsyncIterator from '@core-js/pure/full/symbol/async-iterator'; -import $symbol from '@core-js/pure/full/symbol'; +import $symbol from '@core-js/pure/full/symbol/index'; const sym: symbol = $symbol.asyncIterator; diff --git a/tests/type-definitions/proposals/pure/async-iterator-helper.test.ts b/tests/type-definitions/proposals/pure/async-iterator-helper.test.ts index bccede6d25bc..8dfca77ec5e6 100644 --- a/tests/type-definitions/proposals/pure/async-iterator-helper.test.ts +++ b/tests/type-definitions/proposals/pure/async-iterator-helper.test.ts @@ -14,7 +14,6 @@ import toAsync from '@core-js/pure/full/iterator/to-async'; const res: AsyncIterator = from([1, 2, 3]); const res2: AsyncIterator = from(new Set([1, 2, 3])); -from((async function* () { yield 1; yield 2; })()); from((function* () { yield 3; })()); const res3: AsyncIterator = from('abc'); @@ -25,10 +24,8 @@ declare const ilb: Iterable; declare const is: Iterator; declare const itn: Iterator; declare const ailb: AsyncIterable; -async function* ag(): AsyncIterable { yield 'foo'; } from(ain); -from(ag()); from(ilb); from(ailb); from(aio); diff --git a/tests/type-definitions/proposals/pure/extractors.test.ts b/tests/type-definitions/proposals/pure/extractors.test.ts index d47541f2b1b2..23b64362e952 100644 --- a/tests/type-definitions/proposals/pure/extractors.test.ts +++ b/tests/type-definitions/proposals/pure/extractors.test.ts @@ -1,5 +1,5 @@ import symbolCustomMatcher from '@core-js/pure/full/symbol/custom-matcher'; -import $symbol from '@core-js/pure/full/symbol'; +import $symbol from '@core-js/pure/full/symbol/index'; const rscs1: symbol = symbolCustomMatcher; const rscs2: typeof symbolCustomMatcher = symbolCustomMatcher; diff --git a/tests/type-definitions/proposals/pure/iterator-range.test.ts b/tests/type-definitions/proposals/pure/iterator-range.test.ts index a4464bb0fbba..247713a43dfc 100644 --- a/tests/type-definitions/proposals/pure/iterator-range.test.ts +++ b/tests/type-definitions/proposals/pure/iterator-range.test.ts @@ -4,13 +4,10 @@ const rir1: Iterator = range(1, 10); range(1, 10, 1); range(1, 10, { step: 1 }); range(1, 10, { inclusive: true }); -const rir2: Iterator< bigint> = range(BigInt(0), BigInt(10), { step: BigInt(2), inclusive: true }); // @ts-expect-error range(0, 10, 'not-a-number'); // @ts-expect-error -range(0, 10, { step: BigInt(1) }); -// @ts-expect-error range(0, 10, { inclusive: 3 }); // @ts-expect-error range(0, 10, { step: 'smth' }); diff --git a/tests/type-definitions/proposals/pure/pattern-matching.test.ts b/tests/type-definitions/proposals/pure/pattern-matching.test.ts index 415dedd16502..2521f4fb8732 100644 --- a/tests/type-definitions/proposals/pure/pattern-matching.test.ts +++ b/tests/type-definitions/proposals/pure/pattern-matching.test.ts @@ -1,4 +1,4 @@ -import $symbol from '@core-js/pure/full/symbol'; +import $symbol from '@core-js/pure/full/symbol/index'; const sym: symbol = $symbol.customMatcher; diff --git a/tests/type-definitions/proposals/pure/promise-all-settled.test.ts b/tests/type-definitions/proposals/pure/promise-all-settled.test.ts index 3a6e2f683771..7690b72fa355 100644 --- a/tests/type-definitions/proposals/pure/promise-all-settled.test.ts +++ b/tests/type-definitions/proposals/pure/promise-all-settled.test.ts @@ -6,24 +6,20 @@ const arr = [promiseResolve(1), promiseResolve(2)]; const strArr = ["a", "b", "c"]; const promiseLike = { then: (cb: (val: number) => void) => cb(42) }; -const settled1: Promise<[ - PromiseSettledResult, - PromiseSettledResult, - PromiseSettledResult -]> = promiseAllSettled(promises); +type PromiseResult = PromiseFulfilledResult | PromiseRejectedResult; -const settled2: Promise[]> = promiseAllSettled([promiseResolve(10), promiseResolve(20), 30]); -const settled3: Promise[]> = promiseAllSettled(strArr); -const settled4: Promise[]> = promiseAllSettled(new Set([1, 2, 3])); -const settled5: Promise[]> = promiseAllSettled([promiseLike]); +const settled2: Promise[]> = promiseAllSettled([promiseResolve(10), promiseResolve(20), 30]); +const settled3: Promise[]> = promiseAllSettled(strArr); +const settled4: Promise[]> = promiseAllSettled(new Set([1, 2, 3])); +const settled5: Promise[]> = promiseAllSettled([promiseLike]); const emptyTuple: [] = []; const settled6: Promise<[]> = promiseAllSettled(emptyTuple); const mixedTuple = [42, promiseResolve("bar")] as const; const settled7: Promise<[ - PromiseSettledResult, - PromiseSettledResult + PromiseResult, + PromiseResult ]> = promiseAllSettled(mixedTuple); // @ts-expect-error diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index e555854248c2..3e7d0be26ba7 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -1,4 +1,5 @@ await $`tsc`; +await $`tsc -p tsconfig.require.json`; // await $`npx -p typescript@5.5 tsc -p proposals/global/tsconfig.esnext.json`; diff --git a/tests/type-definitions/tsconfig.json b/tests/type-definitions/tsconfig.json index 2601842f27bf..983fdac6373a 100644 --- a/tests/type-definitions/tsconfig.json +++ b/tests/type-definitions/tsconfig.json @@ -3,14 +3,17 @@ "strict": true, "target": "esnext", "module": "esnext", - "moduleResolution": "node", "esModuleInterop": true, - "noEmit": true + "moduleResolution": "node", + "noEmit": true, + "types": [ + "@core-js/types" + ] }, - "typeRoots": [ - "./node_modules/@types" - ], "include": [ - "*.ts" + "./*.ts" + ], + "exclude": [ + "./entries.require.ts" ] } diff --git a/tests/type-definitions/tsconfig.require.json b/tests/type-definitions/tsconfig.require.json new file mode 100644 index 000000000000..7bfad95eda4e --- /dev/null +++ b/tests/type-definitions/tsconfig.require.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "types": [ + "@core-js/types", + "@types/node" + ] + }, + "include": [ + "./entries.require.ts" + ], + "exclude": [] +} From 49f9f85de712007c126bf976a0efc618ce266010 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 5 Nov 2025 01:44:07 +0700 Subject: [PATCH 054/315] allSettledKeyed tests & some improvements --- packages/core-js-types/.gitignore | 2 ++ .../src/56/common/aggregate-error.d.ts | 11 ----------- .../56/common/{timers.d.ts => immediate.d.ts} | 2 +- .../src/56/common/symbol-match-all.d.ts | 3 --- .../src/56/proposals/promise-any.d.ts | 12 ++++++++++++ .../src/56/proposals/string-match-all.d.ts | 4 ++++ .../proposals/global/await-dictionary.test.ts | 18 ++++++++++++++++++ .../proposals/global/immediate.test.ts | 14 ++++++++++++++ .../proposals/pure/await-dictionary.test.ts | 19 +++++++++++++++++++ .../proposals/pure/immediate.test.ts | 14 ++++++++++++++ 10 files changed, 84 insertions(+), 15 deletions(-) create mode 100644 packages/core-js-types/.gitignore delete mode 100644 packages/core-js-types/src/56/common/aggregate-error.d.ts rename packages/core-js-types/src/56/common/{timers.d.ts => immediate.d.ts} (82%) delete mode 100644 packages/core-js-types/src/56/common/symbol-match-all.d.ts create mode 100644 tests/type-definitions/proposals/global/immediate.test.ts create mode 100644 tests/type-definitions/proposals/pure/immediate.test.ts diff --git a/packages/core-js-types/.gitignore b/packages/core-js-types/.gitignore new file mode 100644 index 000000000000..bea2b9109cc9 --- /dev/null +++ b/packages/core-js-types/.gitignore @@ -0,0 +1,2 @@ +/dist/ +/LICENSE diff --git a/packages/core-js-types/src/56/common/aggregate-error.d.ts b/packages/core-js-types/src/56/common/aggregate-error.d.ts deleted file mode 100644 index 20f0b940233e..000000000000 --- a/packages/core-js-types/src/56/common/aggregate-error.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -interface AggregateError extends Error { - errors: any[]; -} - -interface AggregateErrorConstructor { - new (errors: Iterable, message?: string): AggregateError; - (errors: Iterable, message?: string): AggregateError; - readonly prototype: AggregateError; -} - -declare var AggregateError: AggregateErrorConstructor; diff --git a/packages/core-js-types/src/56/common/timers.d.ts b/packages/core-js-types/src/56/common/immediate.d.ts similarity index 82% rename from packages/core-js-types/src/56/common/timers.d.ts rename to packages/core-js-types/src/56/common/immediate.d.ts index fc17f67b6945..758f870509cb 100644 --- a/packages/core-js-types/src/56/common/timers.d.ts +++ b/packages/core-js-types/src/56/common/immediate.d.ts @@ -1,4 +1,4 @@ -type Immediate = object; +type Immediate = number | object; declare function setImmediate(handler: (...args: any[]) => void, ...args: any[]): Immediate; declare function clearImmediate(immediate: Immediate): void; diff --git a/packages/core-js-types/src/56/common/symbol-match-all.d.ts b/packages/core-js-types/src/56/common/symbol-match-all.d.ts deleted file mode 100644 index 75cb8fc70f26..000000000000 --- a/packages/core-js-types/src/56/common/symbol-match-all.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -interface SymbolConstructor { - readonly matchAll: unique symbol; -} diff --git a/packages/core-js-types/src/56/proposals/promise-any.d.ts b/packages/core-js-types/src/56/proposals/promise-any.d.ts index 9071311b39eb..0470b9436996 100644 --- a/packages/core-js-types/src/56/proposals/promise-any.d.ts +++ b/packages/core-js-types/src/56/proposals/promise-any.d.ts @@ -10,3 +10,15 @@ interface PromiseConstructor { any(values: Iterable>): Promise>; } + +interface AggregateError extends Error { + errors: any[]; +} + +interface AggregateErrorConstructor { + new (errors: Iterable, message?: string): AggregateError; + (errors: Iterable, message?: string): AggregateError; + readonly prototype: AggregateError; +} + +declare var AggregateError: AggregateErrorConstructor; diff --git a/packages/core-js-types/src/56/proposals/string-match-all.d.ts b/packages/core-js-types/src/56/proposals/string-match-all.d.ts index 53d212f36c18..7ff2b331433d 100644 --- a/packages/core-js-types/src/56/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/56/proposals/string-match-all.d.ts @@ -13,6 +13,10 @@ declare global { interface String { matchAll(regexp: RegExp): RegExpStringIterator; } + + interface SymbolConstructor { + readonly matchAll: unique symbol; + } } export {}; diff --git a/tests/type-definitions/proposals/global/await-dictionary.test.ts b/tests/type-definitions/proposals/global/await-dictionary.test.ts index 31747e0107aa..66da7f658f20 100644 --- a/tests/type-definitions/proposals/global/await-dictionary.test.ts +++ b/tests/type-definitions/proposals/global/await-dictionary.test.ts @@ -18,3 +18,21 @@ Promise.allKeyed(); Promise.allKeyed({ a: 1, b: Promise.resolve(2) }); // @ts-expect-error Promise.allKeyed([ Promise.resolve(1), Promise.resolve(2) ]); + +declare type AllSettledKeyedResult = PromiseFulfilledResult | PromiseRejectedResult; +const resASK: Promise<{ a: AllSettledKeyedResult, b: AllSettledKeyedResult, c: AllSettledKeyedResult }> = Promise.allSettledKeyed({ + a: Promise.resolve(1), + b: Promise.resolve('string'), + c: Promise.resolve(true), +}); + +const resASK2: Promise<{ [sym]: AllSettledKeyedResult }> = Promise.allSettledKeyed({ + [sym]: Promise.resolve(1) +}); + +// @ts-expect-error +Promise.allSettledKeyed(); +// @ts-expect-error +Promise.allSettledKeyed({ a: 1, b: Promise.resolve(2) }); +// @ts-expect-error +Promise.allSettledKeyed([ Promise.resolve(1), Promise.resolve(2) ]); diff --git a/tests/type-definitions/proposals/global/immediate.test.ts b/tests/type-definitions/proposals/global/immediate.test.ts new file mode 100644 index 000000000000..601a567bbdf4 --- /dev/null +++ b/tests/type-definitions/proposals/global/immediate.test.ts @@ -0,0 +1,14 @@ +import 'core-js/full'; +import '@core-js/types'; + +const res: number | object = setImmediate(() => 42); +clearImmediate(res); + +// @ts-expect-error +setImmediate(); +// @ts-expect-error +setImmediate(42); +// @ts-expect-error +clearImmediate(); +// @ts-expect-error +clearImmediate('str'); diff --git a/tests/type-definitions/proposals/pure/await-dictionary.test.ts b/tests/type-definitions/proposals/pure/await-dictionary.test.ts index d5a35724470b..d0a6eda9302d 100644 --- a/tests/type-definitions/proposals/pure/await-dictionary.test.ts +++ b/tests/type-definitions/proposals/pure/await-dictionary.test.ts @@ -1,4 +1,5 @@ import allKeyed from '@core-js/pure/full/promise/all-keyed'; +import allSettledKeyed from '@core-js/pure/full/promise/all-settled-keyed'; const res: Promise<{ a: number, b: string, c: boolean }> = allKeyed({ a: Promise.resolve(1), @@ -17,3 +18,21 @@ allKeyed(); allKeyed({ a: 1, b: Promise.resolve(2) }); // @ts-expect-error allKeyed([ Promise.resolve(1), Promise.resolve(2) ]); + +declare type AllSettledKeyedResult = PromiseFulfilledResult | PromiseRejectedResult; +const resASK: Promise<{ a: AllSettledKeyedResult, b: AllSettledKeyedResult, c: AllSettledKeyedResult }> = allSettledKeyed({ + a: Promise.resolve(1), + b: Promise.resolve('string'), + c: Promise.resolve(true), +}); + +const resASK2: Promise<{ [sym]: AllSettledKeyedResult }> = allSettledKeyed({ + [sym]: Promise.resolve(1) +}); + +// @ts-expect-error +allSettledKeyed(); +// @ts-expect-error +allSettledKeyed({ a: 1, b: Promise.resolve(2) }); +// @ts-expect-error +allSettledKeyed([ Promise.resolve(1), Promise.resolve(2) ]); diff --git a/tests/type-definitions/proposals/pure/immediate.test.ts b/tests/type-definitions/proposals/pure/immediate.test.ts new file mode 100644 index 000000000000..82dd18c265d0 --- /dev/null +++ b/tests/type-definitions/proposals/pure/immediate.test.ts @@ -0,0 +1,14 @@ +import setImmediate from '@core-js/pure/full/set-immediate'; +import clearImmediate from '@core-js/pure/full/clear-immediate'; + +const res: number | object = setImmediate(() => 42); +clearImmediate(res); + +// @ts-expect-error +setImmediate(); +// @ts-expect-error +setImmediate(42); +// @ts-expect-error +clearImmediate(); +// @ts-expect-error +clearImmediate('str'); From 73e369a32352d641d31b14e8e2a1bcbe1e6736d5 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 5 Nov 2025 04:55:22 +0700 Subject: [PATCH 055/315] Types stabilization for TS 5.6+ --- .../src/56/proposals/array-filtering.d.ts | 8 +++---- .../56/proposals/array-find-from-last.d.ts | 12 ++-------- .../src/56/proposals/array-includes.d.ts | 4 ++-- .../src/56/proposals/array-unique.d.ts | 8 +++---- .../56/proposals/change-array-by-copy.d.ts | 16 +++++++------- .../proposals/relative-indexing-method.d.ts | 22 +++++++++---------- 6 files changed, 31 insertions(+), 39 deletions(-) diff --git a/packages/core-js-types/src/56/proposals/array-filtering.d.ts b/packages/core-js-types/src/56/proposals/array-filtering.d.ts index f45043f3e02b..1a9a8fb8aa06 100644 --- a/packages/core-js-types/src/56/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/56/proposals/array-filtering.d.ts @@ -40,10 +40,10 @@ interface Float64Array { filterReject(callbackFn: (value: number, index: number, target: Float64Array) => boolean, thisArg?: any): Float64Array; } -interface BigInt64Array { - filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array; +interface BigInt64Array { + filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array; } -interface BigUint64Array { - filterReject(callbackFn: (value: bigint, index: number, target: BigUint64Array) => boolean, thisArg?: any): BigUint64Array; +interface BigUint64Array { + filterReject(callbackFn: (value: bigint, index: number, target: BigUint64Array) => boolean, thisArg?: any): BigUint64Array; } diff --git a/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts index 1bd27f9b76f0..dd14d380e605 100644 --- a/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts @@ -28,14 +28,6 @@ interface Uint8Array { findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Uint8Array { - findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; - - findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; -} - interface Uint8ClampedArray { findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; @@ -92,7 +84,7 @@ interface Float64Array { findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface BigInt64Array { +interface BigInt64Array { findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): bigint | undefined; @@ -100,7 +92,7 @@ interface BigInt64Array { findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; } -interface BigUint64Array { +interface BigUint64Array { findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): bigint | undefined; diff --git a/packages/core-js-types/src/56/proposals/array-includes.d.ts b/packages/core-js-types/src/56/proposals/array-includes.d.ts index 8bc797b6263f..25addb6e67a7 100644 --- a/packages/core-js-types/src/56/proposals/array-includes.d.ts +++ b/packages/core-js-types/src/56/proposals/array-includes.d.ts @@ -44,10 +44,10 @@ interface Float64Array { includes(searchElement: number, fromIndex?: number): boolean; } -interface BigInt64Array { +interface BigInt64Array { includes(searchElement: bigint, fromIndex?: number): boolean; } -interface BigUint64Array { +interface BigUint64Array { includes(searchElement: bigint, fromIndex?: number): boolean; } diff --git a/packages/core-js-types/src/56/proposals/array-unique.d.ts b/packages/core-js-types/src/56/proposals/array-unique.d.ts index c896c29d8c85..12f3a5720faa 100644 --- a/packages/core-js-types/src/56/proposals/array-unique.d.ts +++ b/packages/core-js-types/src/56/proposals/array-unique.d.ts @@ -40,10 +40,10 @@ interface Float64Array { uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float64Array; } -interface BigInt64Array { - uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigInt64Array; +interface BigInt64Array { + uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigInt64Array; } -interface BigUint64Array { - uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigUint64Array; +interface BigUint64Array { + uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigUint64Array; } diff --git a/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts index 729f1e25971f..cc8a2d3f4e2f 100644 --- a/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts +++ b/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts @@ -90,20 +90,20 @@ declare global { with(index: number, value: number): Float64Array; } - interface BigInt64Array { - toReversed(): BigInt64Array; + interface BigInt64Array { + toReversed(): BigInt64Array; - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; - with(index: number, value: bigint): BigInt64Array; + with(index: number, value: bigint): BigInt64Array; } - interface BigUint64Array { - toReversed(): BigUint64Array; + interface BigUint64Array { + toReversed(): BigUint64Array; - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; - with(index: number, value: bigint): BigUint64Array; + with(index: number, value: bigint): BigUint64Array; } } diff --git a/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts index b07d4cbe0e93..15ebeac28dc1 100644 --- a/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts @@ -18,46 +18,46 @@ interface ReadonlyArray { at(index: number): T | undefined; } -interface Int8Array { +interface Int8Array { at(index: number): number | undefined; } -interface Uint8Array { +interface Uint8Array { at(index: number): number | undefined; } -interface Uint8ClampedArray { +interface Uint8ClampedArray { at(index: number): number | undefined; } -interface Int16Array { +interface Int16Array { at(index: number): number | undefined; } -interface Uint16Array { +interface Uint16Array { at(index: number): number | undefined; } -interface Int32Array { +interface Int32Array { at(index: number): number | undefined; } -interface Uint32Array { +interface Uint32Array { at(index: number): number | undefined; } -interface Float32Array { +interface Float32Array { at(index: number): number | undefined; } -interface Float64Array { +interface Float64Array { at(index: number): number | undefined; } -interface BigInt64Array { +interface BigInt64Array { at(index: number): bigint | undefined; } -interface BigUint64Array { +interface BigUint64Array { at(index: number): bigint | undefined; } From b09119c2e759df74bf91a58ad9bac03cfc55f706 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 6 Nov 2025 16:54:04 +0700 Subject: [PATCH 056/315] Types improvements --- .gitignore | 5 +---- packages/core-js-types/.gitignore | 2 -- ...diate.d.ts => efficient-script-yielding.d.ts} | 1 + ...ts => object-prototype-accessor-methods.d.ts} | 0 .../src/56/core-js-types/core-js-types.d.ts | 14 ++++++++------ .../src/56/proposals/array-buffer-base64.d.ts | 9 +++++++++ .../src/56/proposals/array-buffer-transfer.d.ts | 2 ++ .../src/56/proposals/array-filtering.d.ts | 1 + .../src/56/proposals/array-find-from-last.d.ts | 1 + .../src/56/proposals/array-flat-map-custom.d.ts | 2 +- .../src/56/proposals/array-flat-map.d.ts | 4 ++-- .../src/56/proposals/array-grouping.d.ts | 1 + .../src/56/proposals/array-includes.d.ts | 1 + .../src/56/proposals/array-unique.d.ts | 1 + .../src/56/proposals/async-iteration.d.ts | 1 + .../src/56/proposals/await-dictionary.d.ts | 7 +++---- .../proposals/change-array-by-copy-custom.d.ts | 2 +- .../data-view-get-set-uint8-clamped.d.ts | 2 ++ .../src/56/proposals/decorator-metadata.d.ts | 4 ++-- .../proposals/explicit-resource-management.d.ts | 7 +++++++ .../src/56/proposals/extractors.d.ts | 5 ----- .../core-js-types/src/56/proposals/float16.d.ts | 4 +--- .../src/56/proposals/iterator-chunking.d.ts | 6 +++--- .../56/proposals/iterator-helpers-custom.d.ts | 12 +++++++++--- .../src/56/proposals/iterator-helpers.d.ts | 16 ++++++++-------- .../src/56/proposals/iterator-joint.d.ts | 9 +++++---- .../src/56/proposals/iterator-range.d.ts | 1 + .../src/56/proposals/iterator-sequencing.d.ts | 4 ++-- .../src/56/proposals/json-parse-with-source.d.ts | 5 +++++ .../src/56/proposals/map-upsert.d.ts | 2 ++ .../src/56/proposals/number-clamp.d.ts | 1 + .../src/56/proposals/promise-all-settled.d.ts | 6 +++--- .../src/56/proposals/promise-with-resolvers.d.ts | 2 ++ .../src/56/proposals/regexp-named-groups.d.ts | 1 + .../src/56/proposals/set-methods-custom.d.ts | 13 +++++++------ .../src/56/proposals/set-methods.d.ts | 5 ----- .../src/56/proposals/string-cooked.d.ts | 1 + .../src/56/proposals/string-dedent.d.ts | 1 + .../56/proposals/string-replace-all-custom.d.ts | 2 +- .../src/56/proposals/symbol-predicates.d.ts | 2 ++ .../core-js/modules/es.object.define-getter.js | 2 +- .../core-js/modules/es.object.define-setter.js | 2 +- .../core-js/modules/es.object.lookup-getter.js | 2 +- .../core-js/modules/es.object.lookup-setter.js | 2 +- .../modules/esnext.symbol.custom-matcher.js | 2 +- packages/core-js/modules/web.clear-immediate.js | 2 +- packages/core-js/modules/web.set-immediate.js | 2 +- scripts/build-entries/get-dependencies.mjs | 4 ++-- 48 files changed, 109 insertions(+), 74 deletions(-) delete mode 100644 packages/core-js-types/.gitignore rename packages/core-js-types/src/56/common/{immediate.d.ts => efficient-script-yielding.d.ts} (99%) rename packages/core-js-types/src/56/common/{object-extend.d.ts => object-prototype-accessor-methods.d.ts} (100%) delete mode 100644 packages/core-js-types/src/56/proposals/extractors.d.ts diff --git a/.gitignore b/.gitignore index 7dc4d22f121b..564aea916b1b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,6 @@ node_modules/ /packages/core-js/stable/ /packages/core-js/stage/ /packages/core-js/index.js -/packages/core-js/index.d.ts /packages/core-js/package.json /packages/core-js/LICENSE /packages/core-js-babel-plugin/LICENSE @@ -46,10 +45,8 @@ node_modules/ /packages/core-js-pure/proposals/ /packages/core-js-pure/stable/ /packages/core-js-pure/stage/ -/packages/core-js-pure/types/ -/packages/core-js-pure/index.js -/packages/core-js-pure/index.d.ts /packages/core-js-pure/configurator.js +/packages/core-js-pure/index.js /packages/core-js-pure/package.json /packages/core-js-pure/LICENSE /packages/core-js-types/dist/ diff --git a/packages/core-js-types/.gitignore b/packages/core-js-types/.gitignore deleted file mode 100644 index bea2b9109cc9..000000000000 --- a/packages/core-js-types/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/dist/ -/LICENSE diff --git a/packages/core-js-types/src/56/common/immediate.d.ts b/packages/core-js-types/src/56/common/efficient-script-yielding.d.ts similarity index 99% rename from packages/core-js-types/src/56/common/immediate.d.ts rename to packages/core-js-types/src/56/common/efficient-script-yielding.d.ts index 758f870509cb..9e077b1e4a8d 100644 --- a/packages/core-js-types/src/56/common/immediate.d.ts +++ b/packages/core-js-types/src/56/common/efficient-script-yielding.d.ts @@ -1,4 +1,5 @@ type Immediate = number | object; declare function setImmediate(handler: (...args: any[]) => void, ...args: any[]): Immediate; + declare function clearImmediate(immediate: Immediate): void; diff --git a/packages/core-js-types/src/56/common/object-extend.d.ts b/packages/core-js-types/src/56/common/object-prototype-accessor-methods.d.ts similarity index 100% rename from packages/core-js-types/src/56/common/object-extend.d.ts rename to packages/core-js-types/src/56/common/object-prototype-accessor-methods.d.ts diff --git a/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts index 8e1e10822eb9..fbd7fdc9fe0d 100644 --- a/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts +++ b/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts @@ -17,23 +17,25 @@ declare global { interface PromiseRejectedResult { status: "rejected"; reason: any; } - interface AsyncIterable { [Symbol.asyncIterator](): AsyncIterator; } + interface AsyncIterable { + [Symbol.asyncIterator](): AsyncIterator; + } } -export type CoreJsDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } +export type CoreJSDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } // from ts 5.2 ? O : Record & object; -export type CoreJsIteratorObject = IteratorObject; +export type CoreJSIteratorObject = IteratorObject; -export type CoreJsFlatArray = typeof globalThis extends { FlatArray: infer O } +export type CoreJSFlatArray = typeof globalThis extends { FlatArray: infer O } // from ts 4.4 ? O : { done: Arr; - recur: Arr extends ReadonlyArray ? CoreJsFlatArray + recur: Arr extends ReadonlyArray ? CoreJSFlatArray : Arr; }[Depth extends -1 ? "done" : "recur"]; -export type CoreJsPromiseSettledResult = typeof globalThis extends { PromiseSettledResult: infer O } +export type CoreJSPromiseSettledResult = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020 ? O : PromiseFulfilledResult | PromiseRejectedResult; diff --git a/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts index 5e8e26075ef3..faec22bae19f 100644 --- a/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts +++ b/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts @@ -4,16 +4,21 @@ // For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.typedarrays.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + type alphabet = 'base64' | 'base64url'; + type lastChunkHandling = 'loose' | 'strict' | 'stop-before-partial'; + type fromBase64Options = { alphabet?: alphabet; lastChunkHandling?: lastChunkHandling; } + type toBase64Options = { alphabet?: alphabet; omitPadding?: boolean; } + type processMetadata = { read: number; written: number; @@ -21,12 +26,16 @@ type processMetadata = { interface Uint8ArrayConstructor { fromBase64(str: string, opts?: fromBase64Options): Uint8Array; + fromHex(str: string): Uint8Array; } interface Uint8Array { setFromBase64(str: string, opts?: fromBase64Options): processMetadata; + setFromHex(str: string): processMetadata; + toBase64(opts?: toBase64Options): string; + toHex(): string; } diff --git a/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts index 880c74f238da..50046c7dc41e 100644 --- a/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts @@ -1,9 +1,11 @@ // proposal stage: 4 // https://github.com/tc39/proposal-arraybuffer-transfer + interface ArrayBuffer { // todo hack for modern ts // get detached(): boolean; transfer(newByteLength?: number): ArrayBuffer; + transferToFixedLength(newByteLength?: number): ArrayBuffer; } diff --git a/packages/core-js-types/src/56/proposals/array-filtering.d.ts b/packages/core-js-types/src/56/proposals/array-filtering.d.ts index 1a9a8fb8aa06..e4b456324fab 100644 --- a/packages/core-js-types/src/56/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/56/proposals/array-filtering.d.ts @@ -1,5 +1,6 @@ // proposal stage: 1 // https://github.com/tc39/proposal-array-filtering + interface Array { filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; } diff --git a/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts index dd14d380e605..0ac8e21d189e 100644 --- a/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts @@ -4,6 +4,7 @@ // For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + interface Array { findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; diff --git a/packages/core-js-types/src/56/proposals/array-flat-map-custom.d.ts b/packages/core-js-types/src/56/proposals/array-flat-map-custom.d.ts index 5fa537b80823..f54e8b3b212e 100644 --- a/packages/core-js-types/src/56/proposals/array-flat-map-custom.d.ts +++ b/packages/core-js-types/src/56/proposals/array-flat-map-custom.d.ts @@ -5,6 +5,6 @@ // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -declare namespace CoreJs { +declare namespace CoreJS { export type ArrayFlatMap = (callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This) => U[]; } diff --git a/packages/core-js-types/src/56/proposals/array-flat-map.d.ts b/packages/core-js-types/src/56/proposals/array-flat-map.d.ts index a067bbdd72e2..5120e58dc54e 100644 --- a/packages/core-js-types/src/56/proposals/array-flat-map.d.ts +++ b/packages/core-js-types/src/56/proposals/array-flat-map.d.ts @@ -5,13 +5,13 @@ // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -import { CoreJsFlatArray } from '../core-js-types/core-js-types'; +import { CoreJSFlatArray } from '../core-js-types/core-js-types'; declare global { interface Array { flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): U[]; - flat(this: A, depth?: D): CoreJsFlatArray[]; + flat(this: A, depth?: D): CoreJSFlatArray[]; } } diff --git a/packages/core-js-types/src/56/proposals/array-grouping.d.ts b/packages/core-js-types/src/56/proposals/array-grouping.d.ts index 54df526927e1..66c410a8c237 100644 --- a/packages/core-js-types/src/56/proposals/array-grouping.d.ts +++ b/packages/core-js-types/src/56/proposals/array-grouping.d.ts @@ -5,6 +5,7 @@ // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.object.d.ts#L7 // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.collection.d.ts#L7 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + interface ObjectConstructor { groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Partial>; } diff --git a/packages/core-js-types/src/56/proposals/array-includes.d.ts b/packages/core-js-types/src/56/proposals/array-includes.d.ts index 25addb6e67a7..0f5cc4b6b628 100644 --- a/packages/core-js-types/src/56/proposals/array-includes.d.ts +++ b/packages/core-js-types/src/56/proposals/array-includes.d.ts @@ -4,6 +4,7 @@ // For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2016.array.include.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + interface Array { includes(searchElement: T, fromIndex?: number): boolean; } diff --git a/packages/core-js-types/src/56/proposals/array-unique.d.ts b/packages/core-js-types/src/56/proposals/array-unique.d.ts index 12f3a5720faa..e2f85333abcc 100644 --- a/packages/core-js-types/src/56/proposals/array-unique.d.ts +++ b/packages/core-js-types/src/56/proposals/array-unique.d.ts @@ -1,5 +1,6 @@ // proposal stage: 1 // https://github.com/tc39/proposal-array-unique + interface Array { uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; } diff --git a/packages/core-js-types/src/56/proposals/async-iteration.d.ts b/packages/core-js-types/src/56/proposals/async-iteration.d.ts index 15f89953861f..9fecd8b65641 100644 --- a/packages/core-js-types/src/56/proposals/async-iteration.d.ts +++ b/packages/core-js-types/src/56/proposals/async-iteration.d.ts @@ -4,6 +4,7 @@ // For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2018.asynciterable.d.ts#L4 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + interface SymbolConstructor { readonly asyncIterator: unique symbol; } diff --git a/packages/core-js-types/src/56/proposals/await-dictionary.d.ts b/packages/core-js-types/src/56/proposals/await-dictionary.d.ts index c6c094ddb28f..3a6e22e45634 100644 --- a/packages/core-js-types/src/56/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/56/proposals/await-dictionary.d.ts @@ -1,14 +1,13 @@ // proposal stage: 1 // https://github.com/tc39/proposal-await-dictionary -import { CoreJsPromiseSettledResult } from '../core-js-types/core-js-types'; -type Dict = { [k: string | symbol]: V }; +import { CoreJSPromiseSettledResult } from '../core-js-types/core-js-types'; declare global { interface PromiseConstructor { - allKeyed>>(promises: D): Promise <{ [k in keyof D]: Awaited }>; + allKeyed>>(promises: D): Promise <{ [k in keyof D]: Awaited }>; - allSettledKeyed>>(promises: D): Promise <{ [k in keyof D]: CoreJsPromiseSettledResult> }>; + allSettledKeyed>>(promises: D): Promise <{ [k in keyof D]: CoreJSPromiseSettledResult> }>; } } diff --git a/packages/core-js-types/src/56/proposals/change-array-by-copy-custom.d.ts b/packages/core-js-types/src/56/proposals/change-array-by-copy-custom.d.ts index 4f6a96004f9e..a40c18137eaf 100644 --- a/packages/core-js-types/src/56/proposals/change-array-by-copy-custom.d.ts +++ b/packages/core-js-types/src/56/proposals/change-array-by-copy-custom.d.ts @@ -5,6 +5,6 @@ // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -declare namespace CoreJs { +declare namespace CoreJS { export type ArrayToSpliced = ((start: number, deleteCount: number, ...items: T[]) => T[]) | ((start: number, deleteCount?: number)=> T[]); } diff --git a/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts index 36e13b639be4..e0022c602323 100644 --- a/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts +++ b/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts @@ -1,6 +1,8 @@ // proposal stage: 1 // https://github.com/tc39/proposal-dataview-get-set-uint8clamped + interface DataView { getUint8Clamped(byteOffset: number): number; + setUint8Clamped(byteOffset: number, value: number): void; } diff --git a/packages/core-js-types/src/56/proposals/decorator-metadata.d.ts b/packages/core-js-types/src/56/proposals/decorator-metadata.d.ts index a1d24d0aa63d..2c2e21069a55 100644 --- a/packages/core-js-types/src/56/proposals/decorator-metadata.d.ts +++ b/packages/core-js-types/src/56/proposals/decorator-metadata.d.ts @@ -1,7 +1,7 @@ // proposal stage: 3 // https://github.com/tc39/proposal-decorator-metadata -import { CoreJsDecoratorMetadataObject } from '../core-js-types/core-js-types.js'; +import { CoreJSDecoratorMetadataObject } from '../core-js-types/core-js-types.js'; declare global { interface SymbolConstructor { @@ -9,7 +9,7 @@ declare global { } interface Function { - [Symbol.metadata]: CoreJsDecoratorMetadataObject | null; + [Symbol.metadata]: CoreJSDecoratorMetadataObject | null; } } diff --git a/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts index 187e8e66a088..beba7817011e 100644 --- a/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts @@ -4,6 +4,7 @@ // For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/0a1aa6d6ebdfa16b82f4a6aaf282089b1d484e05/src/lib/esnext.disposable.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + interface SymbolConstructor { readonly dispose: unique symbol; @@ -25,9 +26,12 @@ interface SuppressedError extends Error { interface SuppressedErrorConstructor { new (error: any, suppressed: any, message?: string): SuppressedError; + (error: any, suppressed: any, message?: string): SuppressedError; + readonly prototype: SuppressedError; } + declare var SuppressedError: SuppressedErrorConstructor; interface DisposableStack { @@ -50,8 +54,10 @@ interface DisposableStack { interface DisposableStackConstructor { new (): DisposableStack; + readonly prototype: DisposableStack; } + declare var DisposableStack: DisposableStackConstructor; interface AsyncDisposableStack { @@ -77,6 +83,7 @@ interface AsyncDisposableStackConstructor { readonly prototype: AsyncDisposableStack; } + declare var AsyncDisposableStack: AsyncDisposableStackConstructor; interface IteratorObject extends Disposable {} diff --git a/packages/core-js-types/src/56/proposals/extractors.d.ts b/packages/core-js-types/src/56/proposals/extractors.d.ts deleted file mode 100644 index f50296ec0c8c..000000000000 --- a/packages/core-js-types/src/56/proposals/extractors.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -// proposal stage: 1 -// https://github.com/tc39/proposal-extractors -interface SymbolConstructor { - readonly customMatcher: unique symbol; -} diff --git a/packages/core-js-types/src/56/proposals/float16.d.ts b/packages/core-js-types/src/56/proposals/float16.d.ts index e88e76bb865d..2d4c49dcc3bc 100644 --- a/packages/core-js-types/src/56/proposals/float16.d.ts +++ b/packages/core-js-types/src/56/proposals/float16.d.ts @@ -9,10 +9,8 @@ interface Math { f16round(x: number): number; } -interface DataView { +interface DataView { getFloat16(byteOffset: number, littleEndian?: boolean): number; setFloat16(byteOffset: number, value: number, littleEndian?: boolean): void; } - - diff --git a/packages/core-js-types/src/56/proposals/iterator-chunking.d.ts b/packages/core-js-types/src/56/proposals/iterator-chunking.d.ts index 45aeffd06693..e6e7b2ef25d3 100644 --- a/packages/core-js-types/src/56/proposals/iterator-chunking.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-chunking.d.ts @@ -1,13 +1,13 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-chunking -import { CoreJsIteratorObject } from '../core-js-types/core-js-types'; +import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; declare global { interface Iterator { - chunks(chunkSize: number): CoreJsIteratorObject; + chunks(chunkSize: number): CoreJSIteratorObject; - windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJsIteratorObject; + windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJSIteratorObject; } } diff --git a/packages/core-js-types/src/56/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/56/proposals/iterator-helpers-custom.d.ts index 4e09b29194ab..29c5f9fa425a 100644 --- a/packages/core-js-types/src/56/proposals/iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-helpers-custom.d.ts @@ -5,8 +5,14 @@ // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -declare namespace CoreJs { - export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => IteratorObject; - export type IteratorMap = (callback: (value: T, index: number) => U) => IteratorObject; +declare namespace CoreJS { + interface IteratorObject extends Iterator {} + + export type CoreJsIteratorObject = IteratorObject; + + export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => CoreJsIteratorObject; + + export type IteratorMap = (callback: (value: T, index: number) => U) => CoreJsIteratorObject; + export type IteratorReduce = (callback: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; } diff --git a/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts index f335eb19f3c1..492f2c0c4ba8 100644 --- a/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts @@ -5,20 +5,20 @@ // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -import { CoreJsIteratorObject } from '../core-js-types/core-js-types'; +import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; declare global { interface Iterator { - map(callbackfn: (value: T, index: number) => U): CoreJsIteratorObject; + map(callbackfn: (value: T, index: number) => U): CoreJSIteratorObject; - filter(predicate: (value: T, index: number) => value is S): CoreJsIteratorObject; - filter(predicate: (value: T, index: number) => unknown): CoreJsIteratorObject; + filter(predicate: (value: T, index: number) => value is S): CoreJSIteratorObject; + filter(predicate: (value: T, index: number) => unknown): CoreJSIteratorObject; - take(limit: number): CoreJsIteratorObject; + take(limit: number): CoreJSIteratorObject; - drop(count: number): CoreJsIteratorObject; + drop(count: number): CoreJSIteratorObject; - flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJsIteratorObject; // ts < 5.6 Iterable + flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; // ts < 5.6 Iterable reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; @@ -37,7 +37,7 @@ declare global { } interface IteratorConstructor { - from(value: Iterator | Iterable): IteratorObject; + from(value: Iterator | Iterable): CoreJSIteratorObject; } var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/56/proposals/iterator-joint.d.ts b/packages/core-js-types/src/56/proposals/iterator-joint.d.ts index 14ca2982fe34..28e9688e09e7 100644 --- a/packages/core-js-types/src/56/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-joint.d.ts @@ -1,20 +1,21 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-joint-iteration -import { CoreJsIteratorObject } from '../core-js-types/core-js-types'; +import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; declare global { type ZipOptions = { mode?: "shortest" | "longest" | "strict"; + padding?: object; }; interface IteratorConstructor { - zip(iterables: Iterable, options?: ZipOptions): CoreJsIteratorObject<[T, U]>; + zip(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[T, U]>; - zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJsIteratorObject<[number, T, U]>; + zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[number, T, U]>; - zipKeyed(record: Record>, options?: ZipOptions): CoreJsIteratorObject<[PropertyKey, T, U]>; + zipKeyed(record: Record>, options?: ZipOptions): CoreJSIteratorObject<[PropertyKey, T, U]>; } var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/56/proposals/iterator-range.d.ts b/packages/core-js-types/src/56/proposals/iterator-range.d.ts index 1f76b5284b12..3d69aa141212 100644 --- a/packages/core-js-types/src/56/proposals/iterator-range.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-range.d.ts @@ -4,6 +4,7 @@ declare global { type IteratorRangeOptions = { step?: T; + inclusive?: boolean; }; diff --git a/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts index 568cf12a08d9..b2c986fb1f20 100644 --- a/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts @@ -1,11 +1,11 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-sequencing -import { CoreJsIteratorObject } from '../core-js-types/core-js-types'; +import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; declare global { interface IteratorConstructor { - concat(...iterators: Iterable[]): CoreJsIteratorObject; + concat(...iterators: Iterable[]): CoreJSIteratorObject; } var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts index 9300e8ffd25a..4ae35de411e0 100644 --- a/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts +++ b/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts @@ -1,17 +1,22 @@ // proposal stage: 3 // https://github.com/tc39/proposal-json-parse-with-source + interface CoreJSReviverContext { readonly __brand: unique symbol; + source: string; } interface CoreJSRawJSON { readonly __brand: unique symbol; + rawJSON: string; } interface JSON { isRawJSON(value: any): value is CoreJSRawJSON; + parse(text: string, reviver?: (key: string, value: any, context: CoreJSReviverContext) => any): T; + rawJSON(value: string): CoreJSRawJSON; } diff --git a/packages/core-js-types/src/56/proposals/map-upsert.d.ts b/packages/core-js-types/src/56/proposals/map-upsert.d.ts index a1e0843e750f..0884acf4d246 100644 --- a/packages/core-js-types/src/56/proposals/map-upsert.d.ts +++ b/packages/core-js-types/src/56/proposals/map-upsert.d.ts @@ -3,10 +3,12 @@ interface Map { getOrInsert(key: K, value: V): V; + getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } interface WeakMap { getOrInsert(key: K, value: V): V; + getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } diff --git a/packages/core-js-types/src/56/proposals/number-clamp.d.ts b/packages/core-js-types/src/56/proposals/number-clamp.d.ts index d60bf3838c44..d2c703e838cf 100644 --- a/packages/core-js-types/src/56/proposals/number-clamp.d.ts +++ b/packages/core-js-types/src/56/proposals/number-clamp.d.ts @@ -1,5 +1,6 @@ // proposal stage: 2 // https://github.com/tc39/proposal-math-clamp + interface Number { clamp(lower: number, upper: number): number; } diff --git a/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts index 5cd75e8f5c02..db0d67f5c719 100644 --- a/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts +++ b/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts @@ -5,13 +5,13 @@ // https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2020.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -import { CoreJsPromiseSettledResult } from '../core-js-types/core-js-types'; +import { CoreJSPromiseSettledResult } from '../core-js-types/core-js-types'; declare global { interface PromiseConstructor { - allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJsPromiseSettledResult>; }>; + allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJSPromiseSettledResult>; }>; - allSettled(values: Iterable>): Promise>[]>; + allSettled(values: Iterable>): Promise>[]>; } } diff --git a/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts index 7d0acfc8e23e..7a0a7efd7030 100644 --- a/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts +++ b/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts @@ -7,7 +7,9 @@ interface PromiseWithResolvers { promise: Promise; + resolve: (value: T | PromiseLike) => void; + reject: (reason?: any) => void; } diff --git a/packages/core-js-types/src/56/proposals/regexp-named-groups.d.ts b/packages/core-js-types/src/56/proposals/regexp-named-groups.d.ts index d262ed4fc084..141f940abfb7 100644 --- a/packages/core-js-types/src/56/proposals/regexp-named-groups.d.ts +++ b/packages/core-js-types/src/56/proposals/regexp-named-groups.d.ts @@ -10,6 +10,7 @@ interface RegExpExecArray extends Array { [key: string]: string; }; } + interface RegExpMatchArray extends Array { groups?: { [key: string]: string; diff --git a/packages/core-js-types/src/56/proposals/set-methods-custom.d.ts b/packages/core-js-types/src/56/proposals/set-methods-custom.d.ts index a684bfd69d7a..6e5e628e8ba2 100644 --- a/packages/core-js-types/src/56/proposals/set-methods-custom.d.ts +++ b/packages/core-js-types/src/56/proposals/set-methods-custom.d.ts @@ -5,15 +5,16 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface ReadonlySetLike { - keys(): Iterator; +declare namespace CoreJS { + interface ReadonlySetLike { + keys(): Iterator; - has(value: T): boolean; + has(value: T): boolean; - readonly size: number; -} + readonly size: number; + } -declare namespace CoreJs { export type SetUnion = (other: ReadonlySetLike) => Set; + export type SetSymmetricDifference = (other: ReadonlySetLike) => Set; } diff --git a/packages/core-js-types/src/56/proposals/set-methods.d.ts b/packages/core-js-types/src/56/proposals/set-methods.d.ts index 14f42bdaecfd..299278b564a6 100644 --- a/packages/core-js-types/src/56/proposals/set-methods.d.ts +++ b/packages/core-js-types/src/56/proposals/set-methods.d.ts @@ -48,8 +48,3 @@ declare global { } export {}; - -declare namespace CoreJs { - export type SetUnion = (other: ReadonlySetLike) => Set; - export type SetSymmetricDifference = (other: ReadonlySetLike) => Set; -} diff --git a/packages/core-js-types/src/56/proposals/string-cooked.d.ts b/packages/core-js-types/src/56/proposals/string-cooked.d.ts index 997d27f10ee3..8968780a6054 100644 --- a/packages/core-js-types/src/56/proposals/string-cooked.d.ts +++ b/packages/core-js-types/src/56/proposals/string-cooked.d.ts @@ -1,5 +1,6 @@ // proposal stage: 1 // https://github.com/tc39/proposal-string-cooked + interface StringConstructor { cooked(template: readonly string[], ...substitutions: any[]): string; diff --git a/packages/core-js-types/src/56/proposals/string-dedent.d.ts b/packages/core-js-types/src/56/proposals/string-dedent.d.ts index 241b621bc2a7..6486f012be0f 100644 --- a/packages/core-js-types/src/56/proposals/string-dedent.d.ts +++ b/packages/core-js-types/src/56/proposals/string-dedent.d.ts @@ -1,5 +1,6 @@ // proposal stage: 2 // https://github.com/tc39/proposal-string-dedent + interface StringConstructor { dedent(strings: TemplateStringsArray, ...values: any[]): string; } diff --git a/packages/core-js-types/src/56/proposals/string-replace-all-custom.d.ts b/packages/core-js-types/src/56/proposals/string-replace-all-custom.d.ts index f5f85d63e101..928f0d7dc10e 100644 --- a/packages/core-js-types/src/56/proposals/string-replace-all-custom.d.ts +++ b/packages/core-js-types/src/56/proposals/string-replace-all-custom.d.ts @@ -5,6 +5,6 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -declare namespace CoreJs { +declare namespace CoreJS { export type StringReplaceAll = ((searchValue: string | RegExp, replaceValue: string) => string) | ((searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string) => string); } diff --git a/packages/core-js-types/src/56/proposals/symbol-predicates.d.ts b/packages/core-js-types/src/56/proposals/symbol-predicates.d.ts index 5188f97cccc0..165818730057 100644 --- a/packages/core-js-types/src/56/proposals/symbol-predicates.d.ts +++ b/packages/core-js-types/src/56/proposals/symbol-predicates.d.ts @@ -1,6 +1,8 @@ // proposal stage: 2 // https://github.com/tc39/proposal-symbol-predicates + interface SymbolConstructor { isRegisteredSymbol(value: any): boolean; + isWellKnownSymbol(value: any): boolean; } diff --git a/packages/core-js/modules/es.object.define-getter.js b/packages/core-js/modules/es.object.define-getter.js index 65c8c0100123..51d8ae01f205 100644 --- a/packages/core-js/modules/es.object.define-getter.js +++ b/packages/core-js/modules/es.object.define-getter.js @@ -1,4 +1,4 @@ -// types: common/object-extend +// types: common/object-prototype-accessor-methods 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/es.object.define-setter.js b/packages/core-js/modules/es.object.define-setter.js index 454c63e1e2e1..68cde586caed 100644 --- a/packages/core-js/modules/es.object.define-setter.js +++ b/packages/core-js/modules/es.object.define-setter.js @@ -1,4 +1,4 @@ -// types: common/object-extend +// types: common/object-prototype-accessor-methods 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/es.object.lookup-getter.js b/packages/core-js/modules/es.object.lookup-getter.js index d66bf41973ff..32956a2f7cf3 100644 --- a/packages/core-js/modules/es.object.lookup-getter.js +++ b/packages/core-js/modules/es.object.lookup-getter.js @@ -1,4 +1,4 @@ -// types: common/object-extend +// types: common/object-prototype-accessor-methods 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/es.object.lookup-setter.js b/packages/core-js/modules/es.object.lookup-setter.js index 100a548bf212..1112d310d93d 100644 --- a/packages/core-js/modules/es.object.lookup-setter.js +++ b/packages/core-js/modules/es.object.lookup-setter.js @@ -1,4 +1,4 @@ -// types: common/object-extend +// types: common/object-prototype-accessor-methods 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/esnext.symbol.custom-matcher.js b/packages/core-js/modules/esnext.symbol.custom-matcher.js index e5cd845dd8ae..7c4b9da8e8df 100644 --- a/packages/core-js/modules/esnext.symbol.custom-matcher.js +++ b/packages/core-js/modules/esnext.symbol.custom-matcher.js @@ -1,4 +1,4 @@ -// types: proposals/extractors +// types: proposals/pattern-matching 'use strict'; var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/web.clear-immediate.js b/packages/core-js/modules/web.clear-immediate.js index 9b655e5509e9..0b514ec42b3e 100644 --- a/packages/core-js/modules/web.clear-immediate.js +++ b/packages/core-js/modules/web.clear-immediate.js @@ -1,4 +1,4 @@ -// types: common/timers +// types: common/efficient-script-yielding 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.set-immediate.js b/packages/core-js/modules/web.set-immediate.js index 0b0a1725b188..b6378cf6aa8e 100644 --- a/packages/core-js/modules/web.set-immediate.js +++ b/packages/core-js/modules/web.set-immediate.js @@ -1,4 +1,4 @@ -// types: common/timers +// types: common/efficient-script-yielding 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/scripts/build-entries/get-dependencies.mjs b/scripts/build-entries/get-dependencies.mjs index a5493fba0b61..3459c7e391f5 100644 --- a/scripts/build-entries/get-dependencies.mjs +++ b/scripts/build-entries/get-dependencies.mjs @@ -6,7 +6,7 @@ const { cyan, red } = chalk; const allModulesSet = new Set(modules); const MODULE_PATH = /\/(?(?:internals|modules)\/[\d\-.a-z]+)$/; -const DIRECTIVE = /^ *\/\/ @dependency: (?(?:es|esnext|web)\.[\d\-.a-z]+)$/gm; +const DEPENDENCY_DIRECTIVE = /^ *\/\/ @dependency: (?(?:es|esnext|web)\.[\d\-.a-z]+)$/gm; const TYPES_DIRECTIVE = /^ *\/\/ types: (?[\d\-./a-z]+)$/gm; const cache = new Map(); @@ -35,7 +35,7 @@ async function getModuleMetadata(path, stack = new Set()) { stack.add(path); const module = String(await fs.readFile(`./packages/core-js/${ path }.js`)); const directDependencies = konan(module).strings.map(normalizeModulePath); - const declaredDependencies = [...module.matchAll(DIRECTIVE)].map(it => normalizeModulePath(it.groups.module)); + const declaredDependencies = [...module.matchAll(DEPENDENCY_DIRECTIVE)].map(it => normalizeModulePath(it.groups.module)); const dependencies = unique([...directDependencies, ...declaredDependencies]); const paths = new Set([path]); const types = new Set(); From 8c4f575549cf2b0258df2a93cea938820399f698 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 7 Nov 2025 21:22:27 +0700 Subject: [PATCH 057/315] Types stabilization for ts 5.5 --- packages/core-js-types/package.json | 14 ++- .../52/common/efficient-script-yielding.d.ts | 5 + .../object-prototype-accessor-methods.d.ts | 9 ++ .../src/52/common/url-parse.d.ts | 7 ++ .../src/52/core-js-types/core-js-types.d.ts | 49 ++++++++ .../accessible-object-hasownproperty.d.ts | 9 ++ .../src/52/proposals/array-buffer-base64.d.ts | 41 +++++++ .../52/proposals/array-buffer-transfer.d.ts | 11 ++ .../src/52/proposals/array-filtering.d.ts | 50 ++++++++ .../52/proposals/array-find-from-last.d.ts | 102 ++++++++++++++++ .../52/proposals/array-flat-map-custom.d.ts | 10 ++ .../src/52/proposals/array-flat-map.d.ts | 18 +++ .../src/52/proposals/array-from-async.d.ts | 16 +++ .../src/52/proposals/array-grouping.d.ts | 15 +++ .../src/52/proposals/array-includes.d.ts | 54 +++++++++ .../proposals/array-is-template-object.d.ts | 5 + .../src/52/proposals/array-unique.d.ts | 50 ++++++++ .../src/52/proposals/async-iteration.d.ts | 10 ++ .../52/proposals/async-iterator-helpers.d.ts | 40 +++++++ .../src/52/proposals/await-dictionary.d.ts | 14 +++ .../change-array-by-copy-custom.d.ts | 10 ++ .../52/proposals/change-array-by-copy.d.ts | 110 ++++++++++++++++++ .../src/52/proposals/collection-of-from.d.ts | 25 ++++ .../data-view-get-set-uint8-clamped.d.ts | 8 ++ .../src/52/proposals/decorator-metadata.d.ts | 16 +++ .../src/52/proposals/error-cause.d.ts | 60 ++++++++++ .../explicit-resource-management.d.ts | 91 +++++++++++++++ .../src/52/proposals/float16.d.ts | 16 +++ .../52/proposals/function-demethodize.d.ts | 5 + .../src/52/proposals/is-error.d.ts | 5 + .../src/52/proposals/iterator-chunking.d.ts | 14 +++ .../52/proposals/iterator-helpers-custom.d.ts | 18 +++ .../src/52/proposals/iterator-helpers.d.ts | 46 ++++++++ .../src/52/proposals/iterator-joint.d.ts | 24 ++++ .../src/52/proposals/iterator-range.d.ts | 18 +++ .../src/52/proposals/iterator-sequencing.d.ts | 14 +++ .../52/proposals/json-parse-with-source.d.ts | 22 ++++ .../src/52/proposals/map-upsert.d.ts | 14 +++ .../src/52/proposals/math-sum.d.ts | 5 + .../src/52/proposals/number-clamp.d.ts | 6 + .../src/52/proposals/object-from-entries.d.ts | 12 ++ .../object-get-own-property-descriptors.d.ts | 12 ++ .../52/proposals/object-values-entries.d.ts | 14 +++ .../src/52/proposals/pattern-matching.d.ts | 6 + .../src/52/proposals/promise-all-settled.d.ts | 18 +++ .../src/52/proposals/promise-any.d.ts | 24 ++++ .../src/52/proposals/promise-finally.d.ts | 10 ++ .../src/52/proposals/promise-try.d.ts | 11 ++ .../52/proposals/promise-with-resolvers.d.ts | 20 ++++ .../src/52/proposals/regexp-dotall-flag.d.ts | 10 ++ .../src/52/proposals/regexp-escaping.d.ts | 8 ++ .../src/52/proposals/regexp-named-groups.d.ts | 18 +++ .../proposals/relative-indexing-method.d.ts | 63 ++++++++++ .../src/52/proposals/set-methods-custom.d.ts | 20 ++++ .../src/52/proposals/set-methods.d.ts | 50 ++++++++ .../src/52/proposals/string-cooked.d.ts | 8 ++ .../src/52/proposals/string-dedent.d.ts | 6 + .../52/proposals/string-left-right-trim.d.ts | 16 +++ .../src/52/proposals/string-match-all.d.ts | 24 ++++ .../src/52/proposals/string-padding.d.ts | 12 ++ .../proposals/string-replace-all-custom.d.ts | 10 ++ .../src/52/proposals/string-replace-all.d.ts | 16 +++ .../src/52/proposals/symbol-description.d.ts | 10 ++ .../src/52/proposals/symbol-predicates.d.ts | 8 ++ .../well-formed-unicode-strings.d.ts | 12 ++ scripts/build-types/index.mjs | 76 +++++++----- .../global/async-iterator-helper.test.ts | 3 +- tests/type-definitions/runner.mjs | 77 ++++++++++-- 68 files changed, 1588 insertions(+), 42 deletions(-) create mode 100644 packages/core-js-types/src/52/common/efficient-script-yielding.d.ts create mode 100644 packages/core-js-types/src/52/common/object-prototype-accessor-methods.d.ts create mode 100644 packages/core-js-types/src/52/common/url-parse.d.ts create mode 100644 packages/core-js-types/src/52/core-js-types/core-js-types.d.ts create mode 100644 packages/core-js-types/src/52/proposals/accessible-object-hasownproperty.d.ts create mode 100644 packages/core-js-types/src/52/proposals/array-buffer-base64.d.ts create mode 100644 packages/core-js-types/src/52/proposals/array-buffer-transfer.d.ts create mode 100644 packages/core-js-types/src/52/proposals/array-filtering.d.ts create mode 100644 packages/core-js-types/src/52/proposals/array-find-from-last.d.ts create mode 100644 packages/core-js-types/src/52/proposals/array-flat-map-custom.d.ts create mode 100644 packages/core-js-types/src/52/proposals/array-flat-map.d.ts create mode 100644 packages/core-js-types/src/52/proposals/array-from-async.d.ts create mode 100644 packages/core-js-types/src/52/proposals/array-grouping.d.ts create mode 100644 packages/core-js-types/src/52/proposals/array-includes.d.ts create mode 100644 packages/core-js-types/src/52/proposals/array-is-template-object.d.ts create mode 100644 packages/core-js-types/src/52/proposals/array-unique.d.ts create mode 100644 packages/core-js-types/src/52/proposals/async-iteration.d.ts create mode 100644 packages/core-js-types/src/52/proposals/async-iterator-helpers.d.ts create mode 100644 packages/core-js-types/src/52/proposals/await-dictionary.d.ts create mode 100644 packages/core-js-types/src/52/proposals/change-array-by-copy-custom.d.ts create mode 100644 packages/core-js-types/src/52/proposals/change-array-by-copy.d.ts create mode 100644 packages/core-js-types/src/52/proposals/collection-of-from.d.ts create mode 100644 packages/core-js-types/src/52/proposals/data-view-get-set-uint8-clamped.d.ts create mode 100644 packages/core-js-types/src/52/proposals/decorator-metadata.d.ts create mode 100644 packages/core-js-types/src/52/proposals/error-cause.d.ts create mode 100644 packages/core-js-types/src/52/proposals/explicit-resource-management.d.ts create mode 100644 packages/core-js-types/src/52/proposals/float16.d.ts create mode 100644 packages/core-js-types/src/52/proposals/function-demethodize.d.ts create mode 100644 packages/core-js-types/src/52/proposals/is-error.d.ts create mode 100644 packages/core-js-types/src/52/proposals/iterator-chunking.d.ts create mode 100644 packages/core-js-types/src/52/proposals/iterator-helpers-custom.d.ts create mode 100644 packages/core-js-types/src/52/proposals/iterator-helpers.d.ts create mode 100644 packages/core-js-types/src/52/proposals/iterator-joint.d.ts create mode 100644 packages/core-js-types/src/52/proposals/iterator-range.d.ts create mode 100644 packages/core-js-types/src/52/proposals/iterator-sequencing.d.ts create mode 100644 packages/core-js-types/src/52/proposals/json-parse-with-source.d.ts create mode 100644 packages/core-js-types/src/52/proposals/map-upsert.d.ts create mode 100644 packages/core-js-types/src/52/proposals/math-sum.d.ts create mode 100644 packages/core-js-types/src/52/proposals/number-clamp.d.ts create mode 100644 packages/core-js-types/src/52/proposals/object-from-entries.d.ts create mode 100644 packages/core-js-types/src/52/proposals/object-get-own-property-descriptors.d.ts create mode 100644 packages/core-js-types/src/52/proposals/object-values-entries.d.ts create mode 100644 packages/core-js-types/src/52/proposals/pattern-matching.d.ts create mode 100644 packages/core-js-types/src/52/proposals/promise-all-settled.d.ts create mode 100644 packages/core-js-types/src/52/proposals/promise-any.d.ts create mode 100644 packages/core-js-types/src/52/proposals/promise-finally.d.ts create mode 100644 packages/core-js-types/src/52/proposals/promise-try.d.ts create mode 100644 packages/core-js-types/src/52/proposals/promise-with-resolvers.d.ts create mode 100644 packages/core-js-types/src/52/proposals/regexp-dotall-flag.d.ts create mode 100644 packages/core-js-types/src/52/proposals/regexp-escaping.d.ts create mode 100644 packages/core-js-types/src/52/proposals/regexp-named-groups.d.ts create mode 100644 packages/core-js-types/src/52/proposals/relative-indexing-method.d.ts create mode 100644 packages/core-js-types/src/52/proposals/set-methods-custom.d.ts create mode 100644 packages/core-js-types/src/52/proposals/set-methods.d.ts create mode 100644 packages/core-js-types/src/52/proposals/string-cooked.d.ts create mode 100644 packages/core-js-types/src/52/proposals/string-dedent.d.ts create mode 100644 packages/core-js-types/src/52/proposals/string-left-right-trim.d.ts create mode 100644 packages/core-js-types/src/52/proposals/string-match-all.d.ts create mode 100644 packages/core-js-types/src/52/proposals/string-padding.d.ts create mode 100644 packages/core-js-types/src/52/proposals/string-replace-all-custom.d.ts create mode 100644 packages/core-js-types/src/52/proposals/string-replace-all.d.ts create mode 100644 packages/core-js-types/src/52/proposals/symbol-description.d.ts create mode 100644 packages/core-js-types/src/52/proposals/symbol-predicates.d.ts create mode 100644 packages/core-js-types/src/52/proposals/well-formed-unicode-strings.d.ts diff --git a/packages/core-js-types/package.json b/packages/core-js-types/package.json index aad08e439a72..85213853ba35 100644 --- a/packages/core-js-types/package.json +++ b/packages/core-js-types/package.json @@ -25,8 +25,16 @@ "email": "zloirock@zloirock.ru", "url": "http://zloirock.ru" }, - "types": "dist/core-js-types.latest.d.ts", + "types": "dist/core-js-types.56.d.ts", "files": [ - "dist/core-js-types.latest.d.ts" - ] + "dist/core-js-types.56.d.ts" + ], + "typesVersions": { + ">=5.6": { + "*": ["dist/core-js-types.56.d.ts"] + }, + ">=5.2": { + "*": ["dist/core-js-types.52.d.ts"] + } + } } diff --git a/packages/core-js-types/src/52/common/efficient-script-yielding.d.ts b/packages/core-js-types/src/52/common/efficient-script-yielding.d.ts new file mode 100644 index 000000000000..9e077b1e4a8d --- /dev/null +++ b/packages/core-js-types/src/52/common/efficient-script-yielding.d.ts @@ -0,0 +1,5 @@ +type Immediate = number | object; + +declare function setImmediate(handler: (...args: any[]) => void, ...args: any[]): Immediate; + +declare function clearImmediate(immediate: Immediate): void; diff --git a/packages/core-js-types/src/52/common/object-prototype-accessor-methods.d.ts b/packages/core-js-types/src/52/common/object-prototype-accessor-methods.d.ts new file mode 100644 index 000000000000..cf148f00e65a --- /dev/null +++ b/packages/core-js-types/src/52/common/object-prototype-accessor-methods.d.ts @@ -0,0 +1,9 @@ +interface Object { + __defineGetter__(prop: PropertyKey, getter: () => any): void; + + __defineSetter__(prop: PropertyKey, setter: (val: any) => void): void; + + __lookupGetter__(prop: PropertyKey): (() => any) | undefined; + + __lookupSetter__(prop: PropertyKey): ((val: any) => void) | undefined; +} diff --git a/packages/core-js-types/src/52/common/url-parse.d.ts b/packages/core-js-types/src/52/common/url-parse.d.ts new file mode 100644 index 000000000000..a32d5e1ec937 --- /dev/null +++ b/packages/core-js-types/src/52/common/url-parse.d.ts @@ -0,0 +1,7 @@ +declare global { + interface URLConstructor { + parse(url: string | URL, base?: string | URL): URL | null; + } +} + +export {}; diff --git a/packages/core-js-types/src/52/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/52/core-js-types/core-js-types.d.ts new file mode 100644 index 000000000000..19ddcb1b9934 --- /dev/null +++ b/packages/core-js-types/src/52/core-js-types/core-js-types.d.ts @@ -0,0 +1,49 @@ +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2019.array.d.ts +// https://github.com/microsoft/TypeScript/blob/6f4fb0145845db22791188c4d38e3a1a0edfd449/src/lib/es2018.asyncgenerator.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare global { + interface IteratorObject extends Iterator {} + + interface AsyncIteratorObject extends AsyncIterator { + [Symbol.asyncIterator](): AsyncIteratorObject; + } + + interface AsyncGenerator extends AsyncIteratorObject { + next(...[value]: [] | [undefined]): Promise>; + return(value: TReturn | PromiseLike): Promise>; + throw(e: any): Promise>; + [Symbol.asyncIterator](): AsyncGenerator; + } + + interface PromiseFulfilledResult { status: "fulfilled"; value: T; } + + interface PromiseRejectedResult { status: "rejected"; reason: any; } + + interface AsyncIterable { + [Symbol.asyncIterator](): AsyncIterator; + } +} + +export type CoreJSDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } // from ts 5.2 + ? O + : Record & object; + +export type CoreJSIteratorObject = IteratorObject; + +export type CoreJSFlatArray = typeof globalThis extends { FlatArray: infer O } // from ts 4.4 + ? O + : { + done: Arr; + recur: Arr extends ReadonlyArray ? CoreJSFlatArray + : Arr; + }[Depth extends -1 ? "done" : "recur"]; + +export type CoreJSPromiseSettledResult = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020 + ? O + : PromiseFulfilledResult | PromiseRejectedResult; + +export type CoreJSBuiltinIteratorReturn = ReturnType extends Iterator + ? TReturn + : any; diff --git a/packages/core-js-types/src/52/proposals/accessible-object-hasownproperty.d.ts b/packages/core-js-types/src/52/proposals/accessible-object-hasownproperty.d.ts new file mode 100644 index 000000000000..a4e51205a188 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/accessible-object-hasownproperty.d.ts @@ -0,0 +1,9 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-accessible-object-hasownproperty + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2022.object.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt +interface ObjectConstructor { + hasOwn(o: object, v: PropertyKey): boolean; +} diff --git a/packages/core-js-types/src/52/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/52/proposals/array-buffer-base64.d.ts new file mode 100644 index 000000000000..faec22bae19f --- /dev/null +++ b/packages/core-js-types/src/52/proposals/array-buffer-base64.d.ts @@ -0,0 +1,41 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-arraybuffer-base64 + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.typedarrays.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +type alphabet = 'base64' | 'base64url'; + +type lastChunkHandling = 'loose' | 'strict' | 'stop-before-partial'; + +type fromBase64Options = { + alphabet?: alphabet; + lastChunkHandling?: lastChunkHandling; +} + +type toBase64Options = { + alphabet?: alphabet; + omitPadding?: boolean; +} + +type processMetadata = { + read: number; + written: number; +} + +interface Uint8ArrayConstructor { + fromBase64(str: string, opts?: fromBase64Options): Uint8Array; + + fromHex(str: string): Uint8Array; +} + +interface Uint8Array { + setFromBase64(str: string, opts?: fromBase64Options): processMetadata; + + setFromHex(str: string): processMetadata; + + toBase64(opts?: toBase64Options): string; + + toHex(): string; +} diff --git a/packages/core-js-types/src/52/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/52/proposals/array-buffer-transfer.d.ts new file mode 100644 index 000000000000..50046c7dc41e --- /dev/null +++ b/packages/core-js-types/src/52/proposals/array-buffer-transfer.d.ts @@ -0,0 +1,11 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-arraybuffer-transfer + +interface ArrayBuffer { + // todo hack for modern ts + // get detached(): boolean; + + transfer(newByteLength?: number): ArrayBuffer; + + transferToFixedLength(newByteLength?: number): ArrayBuffer; +} diff --git a/packages/core-js-types/src/52/proposals/array-filtering.d.ts b/packages/core-js-types/src/52/proposals/array-filtering.d.ts new file mode 100644 index 000000000000..e4b456324fab --- /dev/null +++ b/packages/core-js-types/src/52/proposals/array-filtering.d.ts @@ -0,0 +1,50 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-array-filtering + +interface Array { + filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; +} + +interface Int8Array { + filterReject(callbackFn: (value: number, index: number, target: Int8Array) => boolean, thisArg?: any): Int8Array; +} + +interface Uint8Array { + filterReject(callbackFn: (value: number, index: number, target: Uint8Array) => boolean, thisArg?: any): Uint8Array; +} + +interface Uint8ClampedArray { + filterReject(callbackFn: (value: number, index: number, target: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; +} + +interface Int16Array { + filterReject(callbackFn: (value: number, index: number, target: Int16Array) => boolean, thisArg?: any): Int16Array; +} + +interface Uint16Array { + filterReject(callbackFn: (value: number, index: number, target: Uint16Array) => boolean, thisArg?: any): Uint16Array; +} + +interface Int32Array { + filterReject(callbackFn: (value: number, index: number, target: Int32Array) => boolean, thisArg?: any): Int32Array; +} + +interface Uint32Array { + filterReject(callbackFn: (value: number, index: number, target: Uint32Array) => boolean, thisArg?: any): Uint32Array; +} + +interface Float32Array { + filterReject(callbackFn: (value: number, index: number, target: Float32Array) => boolean, thisArg?: any): Float32Array; +} + +interface Float64Array { + filterReject(callbackFn: (value: number, index: number, target: Float64Array) => boolean, thisArg?: any): Float64Array; +} + +interface BigInt64Array { + filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array; +} + +interface BigUint64Array { + filterReject(callbackFn: (value: bigint, index: number, target: BigUint64Array) => boolean, thisArg?: any): BigUint64Array; +} diff --git a/packages/core-js-types/src/52/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/52/proposals/array-find-from-last.d.ts new file mode 100644 index 000000000000..0ac8e21d189e --- /dev/null +++ b/packages/core-js-types/src/52/proposals/array-find-from-last.d.ts @@ -0,0 +1,102 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-array-find-from-last + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface Array { + findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T | undefined; + + findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; +} + +interface Int8Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Uint8Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Uint8ClampedArray { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Int16Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Uint16Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Int32Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Uint32Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Float32Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface Float64Array { + findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + + findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface BigInt64Array { + findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): bigint | undefined; + + findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; +} + +interface BigUint64Array { + findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): bigint | undefined; + + findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; +} diff --git a/packages/core-js-types/src/52/proposals/array-flat-map-custom.d.ts b/packages/core-js-types/src/52/proposals/array-flat-map-custom.d.ts new file mode 100644 index 000000000000..f54e8b3b212e --- /dev/null +++ b/packages/core-js-types/src/52/proposals/array-flat-map-custom.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-flatMap + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export type ArrayFlatMap = (callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This) => U[]; +} diff --git a/packages/core-js-types/src/52/proposals/array-flat-map.d.ts b/packages/core-js-types/src/52/proposals/array-flat-map.d.ts new file mode 100644 index 000000000000..5120e58dc54e --- /dev/null +++ b/packages/core-js-types/src/52/proposals/array-flat-map.d.ts @@ -0,0 +1,18 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-flatMap + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +import { CoreJSFlatArray } from '../core-js-types/core-js-types'; + +declare global { + interface Array { + flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): U[]; + + flat(this: A, depth?: D): CoreJSFlatArray[]; + } +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/array-from-async.d.ts b/packages/core-js-types/src/52/proposals/array-from-async.d.ts new file mode 100644 index 000000000000..ffe9843e2baa --- /dev/null +++ b/packages/core-js-types/src/52/proposals/array-from-async.d.ts @@ -0,0 +1,16 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-array-from-async + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/esnext.array.d.ts#L6 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare global { + interface ArrayConstructor { + fromAsync(iterableOrArrayLike: AsyncIterable | AsyncGenerator | Iterable> | ArrayLike>): Promise; + + fromAsync(iterableOrArrayLike: AsyncIterable | AsyncGenerator | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; + } +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/array-grouping.d.ts b/packages/core-js-types/src/52/proposals/array-grouping.d.ts new file mode 100644 index 000000000000..66c410a8c237 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/array-grouping.d.ts @@ -0,0 +1,15 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-array-grouping + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.object.d.ts#L7 +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.collection.d.ts#L7 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface ObjectConstructor { + groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Partial>; +} + +interface MapConstructor { + groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Map; +} diff --git a/packages/core-js-types/src/52/proposals/array-includes.d.ts b/packages/core-js-types/src/52/proposals/array-includes.d.ts new file mode 100644 index 000000000000..0f5cc4b6b628 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/array-includes.d.ts @@ -0,0 +1,54 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-Array.prototype.includes + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2016.array.include.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface Array { + includes(searchElement: T, fromIndex?: number): boolean; +} + +interface Int8Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint8Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint8ClampedArray { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Int16Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint16Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Int32Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint32Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Float32Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Float64Array { + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface BigInt64Array { + includes(searchElement: bigint, fromIndex?: number): boolean; +} + +interface BigUint64Array { + includes(searchElement: bigint, fromIndex?: number): boolean; +} diff --git a/packages/core-js-types/src/52/proposals/array-is-template-object.d.ts b/packages/core-js-types/src/52/proposals/array-is-template-object.d.ts new file mode 100644 index 000000000000..6ab53db2e94a --- /dev/null +++ b/packages/core-js-types/src/52/proposals/array-is-template-object.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-array-is-template-object +interface ArrayConstructor { + isTemplateObject(value: any): value is TemplateStringsArray; +} diff --git a/packages/core-js-types/src/52/proposals/array-unique.d.ts b/packages/core-js-types/src/52/proposals/array-unique.d.ts new file mode 100644 index 000000000000..e2f85333abcc --- /dev/null +++ b/packages/core-js-types/src/52/proposals/array-unique.d.ts @@ -0,0 +1,50 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-array-unique + +interface Array { + uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; +} + +interface Int8Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int8Array; +} + +interface Uint8Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8Array; +} + +interface Uint8ClampedArray { + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8ClampedArray; +} + +interface Int16Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int16Array; +} + +interface Uint16Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint16Array; +} + +interface Int32Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int32Array; +} + +interface Uint32Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint32Array; +} + +interface Float32Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float32Array; +} + +interface Float64Array { + uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float64Array; +} + +interface BigInt64Array { + uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigInt64Array; +} + +interface BigUint64Array { + uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigUint64Array; +} diff --git a/packages/core-js-types/src/52/proposals/async-iteration.d.ts b/packages/core-js-types/src/52/proposals/async-iteration.d.ts new file mode 100644 index 000000000000..9fecd8b65641 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/async-iteration.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-async-iteration + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2018.asynciterable.d.ts#L4 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface SymbolConstructor { + readonly asyncIterator: unique symbol; +} diff --git a/packages/core-js-types/src/52/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/52/proposals/async-iterator-helpers.d.ts new file mode 100644 index 000000000000..6af36a9606f1 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/async-iterator-helpers.d.ts @@ -0,0 +1,40 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-async-iterator-helpers + +declare global { + interface AsyncIteratorConstructor { + from(iterable: AsyncIterable | AsyncGenerator | Iterable | AsyncIteratorObject): AsyncIteratorObject; + } + + var AsyncIterator: AsyncIteratorConstructor; + + interface AsyncIterator { + drop(limit: number): AsyncIteratorObject; + + every(predicate: (value: T, index: number) => boolean): Promise; + + filter(predicate: (value: T, index: number) => boolean): AsyncIteratorObject; + + find(predicate: (value: T, index: number) => boolean): Promise; + + flatMap(mapper: (value: T, index: number) => any): AsyncIteratorObject; + + forEach(callbackFn: (value: T, index: number) => void): Promise; + + map(mapper: (value: T, index: number) => any): AsyncIteratorObject; + + reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; + + some(predicate: (value: T, index: number) => boolean): Promise; + + take(limit: number): AsyncIteratorObject; + + toArray(): Promise; + } + + interface Iterator { + toAsync(): AsyncIteratorObject; + } +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/await-dictionary.d.ts b/packages/core-js-types/src/52/proposals/await-dictionary.d.ts new file mode 100644 index 000000000000..3a6e22e45634 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/await-dictionary.d.ts @@ -0,0 +1,14 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-await-dictionary + +import { CoreJSPromiseSettledResult } from '../core-js-types/core-js-types'; + +declare global { + interface PromiseConstructor { + allKeyed>>(promises: D): Promise <{ [k in keyof D]: Awaited }>; + + allSettledKeyed>>(promises: D): Promise <{ [k in keyof D]: CoreJSPromiseSettledResult> }>; + } +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/change-array-by-copy-custom.d.ts b/packages/core-js-types/src/52/proposals/change-array-by-copy-custom.d.ts new file mode 100644 index 000000000000..a40c18137eaf --- /dev/null +++ b/packages/core-js-types/src/52/proposals/change-array-by-copy-custom.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-change-array-by-copy + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export type ArrayToSpliced = ((start: number, deleteCount: number, ...items: T[]) => T[]) | ((start: number, deleteCount?: number)=> T[]); +} diff --git a/packages/core-js-types/src/52/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/52/proposals/change-array-by-copy.d.ts new file mode 100644 index 000000000000..cc8a2d3f4e2f --- /dev/null +++ b/packages/core-js-types/src/52/proposals/change-array-by-copy.d.ts @@ -0,0 +1,110 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-change-array-by-copy + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare global { + interface Array { + toReversed(): T[]; + + toSorted(compareFn?: (a: T, b: T) => number): T[]; + + toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; + + toSpliced(start: number, deleteCount?: number): T[]; + + with(index: number, value: T): T[]; + } + + interface Int8Array { + toReversed(): Int8Array; + + toSorted(compareFn?: (a: number, b: number) => number): Int8Array; + + with(index: number, value: number): Int8Array; + } + + interface Uint8Array { + toReversed(): Uint8Array; + + toSorted(compareFn?: (a: number, b: number) => number): Uint8Array; + + with(index: number, value: number): Uint8Array; + } + + interface Uint8ClampedArray { + toReversed(): Uint8ClampedArray; + + toSorted(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + with(index: number, value: number): Uint8ClampedArray; + } + + interface Int16Array { + toReversed(): Int16Array; + + toSorted(compareFn?: (a: number, b: number) => number): Int16Array; + + with(index: number, value: number): Int16Array; + } + + interface Uint16Array { + toReversed(): Uint16Array; + + toSorted(compareFn?: (a: number, b: number) => number): Uint16Array; + + with(index: number, value: number): Uint16Array; + } + + interface Int32Array { + toReversed(): Int32Array; + + toSorted(compareFn?: (a: number, b: number) => number): Int32Array; + + with(index: number, value: number): Int32Array; + } + + interface Uint32Array { + toReversed(): Uint32Array; + + toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; + + with(index: number, value: number): Uint32Array; + } + + interface Float32Array { + toReversed(): Float32Array; + + toSorted(compareFn?: (a: number, b: number) => number): Float32Array; + + with(index: number, value: number): Float32Array; + } + + interface Float64Array { + toReversed(): Float64Array; + + toSorted(compareFn?: (a: number, b: number) => number): Float64Array; + + with(index: number, value: number): Float64Array; + } + + interface BigInt64Array { + toReversed(): BigInt64Array; + + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; + + with(index: number, value: bigint): BigInt64Array; + } + + interface BigUint64Array { + toReversed(): BigUint64Array; + + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; + + with(index: number, value: bigint): BigUint64Array; + } +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/collection-of-from.d.ts b/packages/core-js-types/src/52/proposals/collection-of-from.d.ts new file mode 100644 index 000000000000..6e6bdeb8e2bd --- /dev/null +++ b/packages/core-js-types/src/52/proposals/collection-of-from.d.ts @@ -0,0 +1,25 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-setmap-offrom +interface MapConstructor { + from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): Map; + + of(...items: [K, V][]): Map; +} + +interface SetConstructor { + from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): Set; + + of(...items: T[]): Set; +} + +interface WeakMapConstructor { + from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): WeakMap; + + of(...items: [K, V][]): WeakMap; +} + +interface WeakSetConstructor { + from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): WeakSet; + + of(...items: T[]): WeakSet; +} diff --git a/packages/core-js-types/src/52/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/52/proposals/data-view-get-set-uint8-clamped.d.ts new file mode 100644 index 000000000000..e0022c602323 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/data-view-get-set-uint8-clamped.d.ts @@ -0,0 +1,8 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-dataview-get-set-uint8clamped + +interface DataView { + getUint8Clamped(byteOffset: number): number; + + setUint8Clamped(byteOffset: number, value: number): void; +} diff --git a/packages/core-js-types/src/52/proposals/decorator-metadata.d.ts b/packages/core-js-types/src/52/proposals/decorator-metadata.d.ts new file mode 100644 index 000000000000..2c2e21069a55 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/decorator-metadata.d.ts @@ -0,0 +1,16 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-decorator-metadata + +import { CoreJSDecoratorMetadataObject } from '../core-js-types/core-js-types.js'; + +declare global { + interface SymbolConstructor { + readonly metadata: unique symbol; + } + + interface Function { + [Symbol.metadata]: CoreJSDecoratorMetadataObject | null; + } +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/error-cause.d.ts b/packages/core-js-types/src/52/proposals/error-cause.d.ts new file mode 100644 index 000000000000..01bdbe8ef1d8 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/error-cause.d.ts @@ -0,0 +1,60 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-error-cause + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/es2022.error.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare global { + interface ErrorOptions { + cause?: unknown; + } + + interface Error { + cause?: unknown; // ts <= 4.7 Error | undefined + } + + interface ErrorConstructor { + new(message?: string, options?: ErrorOptions): Error; + + (message?: string, options?: ErrorOptions): Error; + } + + interface EvalErrorConstructor { + new(message?: string, options?: ErrorOptions): EvalError; + + (message?: string, options?: ErrorOptions): EvalError; + } + + interface RangeErrorConstructor { + new(message?: string, options?: ErrorOptions): RangeError; + + (message?: string, options?: ErrorOptions): RangeError; + } + + interface ReferenceErrorConstructor { + new(message?: string, options?: ErrorOptions): ReferenceError; + + (message?: string, options?: ErrorOptions): ReferenceError; + } + + interface SyntaxErrorConstructor { + new(message?: string, options?: ErrorOptions): SyntaxError; + + (message?: string, options?: ErrorOptions): SyntaxError; + } + + interface TypeErrorConstructor { + new(message?: string, options?: ErrorOptions): TypeError; + + (message?: string, options?: ErrorOptions): TypeError; + } + + interface URIErrorConstructor { + new(message?: string, options?: ErrorOptions): URIError; + + (message?: string, options?: ErrorOptions): URIError; + } +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/52/proposals/explicit-resource-management.d.ts new file mode 100644 index 000000000000..3bce356a9710 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/explicit-resource-management.d.ts @@ -0,0 +1,91 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-explicit-resource-management + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/0a1aa6d6ebdfa16b82f4a6aaf282089b1d484e05/src/lib/esnext.disposable.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface SymbolConstructor { + readonly dispose: unique symbol; + + readonly asyncDispose: unique symbol; +} + +interface Disposable { + [Symbol.dispose](): void; +} + +interface AsyncDisposable { + [Symbol.asyncDispose](): PromiseLike; +} + +interface SuppressedError extends Error { + error: any; + suppressed: any; +} + +interface SuppressedErrorConstructor { + new (error: any, suppressed: any, message?: string): SuppressedError; + + (error: any, suppressed: any, message?: string): SuppressedError; + + readonly prototype: SuppressedError; +} + +declare var SuppressedError: SuppressedErrorConstructor; + +interface DisposableStack { + readonly disposed: boolean; + + dispose(): void; + + use(value: T): T; + + adopt(value: T, onDispose: (value: T) => void): T; + + defer(onDispose: () => void): void; + + move(): DisposableStack; + + [Symbol.dispose](): void; + + readonly [Symbol.toStringTag]: string; +} + +interface DisposableStackConstructor { + new (): DisposableStack; + + readonly prototype: DisposableStack; +} + +declare var DisposableStack: DisposableStackConstructor; + +interface AsyncDisposableStack { + readonly disposed: boolean; + + disposeAsync(): Promise; + + use(value: T): T; + + adopt(value: T, onDisposeAsync: (value: T) => PromiseLike | void): T; + + defer(onDisposeAsync: () => PromiseLike | void): void; + + move(): AsyncDisposableStack; + + [Symbol.asyncDispose](): Promise; + + readonly [Symbol.toStringTag]: string; +} + +interface AsyncDisposableStackConstructor { + new (): AsyncDisposableStack; + + readonly prototype: AsyncDisposableStack; +} + +declare var AsyncDisposableStack: AsyncDisposableStackConstructor; + +interface IteratorObject extends Disposable {} + +interface AsyncIteratorObject extends AsyncDisposable {} diff --git a/packages/core-js-types/src/52/proposals/float16.d.ts b/packages/core-js-types/src/52/proposals/float16.d.ts new file mode 100644 index 000000000000..2d4c49dcc3bc --- /dev/null +++ b/packages/core-js-types/src/52/proposals/float16.d.ts @@ -0,0 +1,16 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-float16array + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.float16.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface Math { + f16round(x: number): number; +} + +interface DataView { + getFloat16(byteOffset: number, littleEndian?: boolean): number; + + setFloat16(byteOffset: number, value: number, littleEndian?: boolean): void; +} diff --git a/packages/core-js-types/src/52/proposals/function-demethodize.d.ts b/packages/core-js-types/src/52/proposals/function-demethodize.d.ts new file mode 100644 index 000000000000..0c829273ed92 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/function-demethodize.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 0 +// https://github.com/js-choi/proposal-function-demethodize +interface Function { + demethodize(this: (this: T, ...args: Args) => R): (thisArg: T, ...args: Args) => R; +} diff --git a/packages/core-js-types/src/52/proposals/is-error.d.ts b/packages/core-js-types/src/52/proposals/is-error.d.ts new file mode 100644 index 000000000000..fc6a8d1fac03 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/is-error.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-is-error +interface ErrorConstructor { + isError(value: any): value is Error; +} diff --git a/packages/core-js-types/src/52/proposals/iterator-chunking.d.ts b/packages/core-js-types/src/52/proposals/iterator-chunking.d.ts new file mode 100644 index 000000000000..e6e7b2ef25d3 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/iterator-chunking.d.ts @@ -0,0 +1,14 @@ +// proposal stage: 2.7 +// https://github.com/tc39/proposal-iterator-chunking + +import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; + +declare global { + interface Iterator { + chunks(chunkSize: number): CoreJSIteratorObject; + + windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJSIteratorObject; + } +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/52/proposals/iterator-helpers-custom.d.ts new file mode 100644 index 000000000000..29c5f9fa425a --- /dev/null +++ b/packages/core-js-types/src/52/proposals/iterator-helpers-custom.d.ts @@ -0,0 +1,18 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-iterator-helpers + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + interface IteratorObject extends Iterator {} + + export type CoreJsIteratorObject = IteratorObject; + + export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => CoreJsIteratorObject; + + export type IteratorMap = (callback: (value: T, index: number) => U) => CoreJsIteratorObject; + + export type IteratorReduce = (callback: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; +} diff --git a/packages/core-js-types/src/52/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/52/proposals/iterator-helpers.d.ts new file mode 100644 index 000000000000..9e261bb2188a --- /dev/null +++ b/packages/core-js-types/src/52/proposals/iterator-helpers.d.ts @@ -0,0 +1,46 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-iterator-helpers + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; + +declare global { + interface Iterator { + map(callbackfn: (value: T, index: number) => U): CoreJSIteratorObject; + + filter(predicate: (value: T, index: number) => value is S): CoreJSIteratorObject; + filter(predicate: (value: T, index: number) => unknown): CoreJSIteratorObject; + + take(limit: number): CoreJSIteratorObject; + + drop(count: number): CoreJSIteratorObject; + + flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; // ts < 5.6 Iterable + + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; + + toArray(): T[]; + + forEach(callbackfn: (value: T, index: number) => void): void; + + some(predicate: (value: T, index: number) => unknown): boolean; + + every(predicate: (value: T, index: number) => unknown): boolean; + + find(predicate: (value: T, index: number) => value is S): S | undefined; + find(predicate: (value: T, index: number) => unknown): T | undefined; + } + + interface IteratorConstructor { + from(value: Iterator | Iterable): CoreJSIteratorObject; + } + + var Iterator: IteratorConstructor; +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/iterator-joint.d.ts b/packages/core-js-types/src/52/proposals/iterator-joint.d.ts new file mode 100644 index 000000000000..28e9688e09e7 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/iterator-joint.d.ts @@ -0,0 +1,24 @@ +// proposal stage: 2.7 +// https://github.com/tc39/proposal-joint-iteration + +import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; + +declare global { + type ZipOptions = { + mode?: "shortest" | "longest" | "strict"; + + padding?: object; + }; + + interface IteratorConstructor { + zip(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[T, U]>; + + zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[number, T, U]>; + + zipKeyed(record: Record>, options?: ZipOptions): CoreJSIteratorObject<[PropertyKey, T, U]>; + } + + var Iterator: IteratorConstructor; +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/iterator-range.d.ts b/packages/core-js-types/src/52/proposals/iterator-range.d.ts new file mode 100644 index 000000000000..3d69aa141212 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/iterator-range.d.ts @@ -0,0 +1,18 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-Number.range + +declare global { + type IteratorRangeOptions = { + step?: T; + + inclusive?: boolean; + }; + + interface IteratorConstructor { + range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): IteratorObject + } + + var Iterator: IteratorConstructor; +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/52/proposals/iterator-sequencing.d.ts new file mode 100644 index 000000000000..b2c986fb1f20 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/iterator-sequencing.d.ts @@ -0,0 +1,14 @@ +// proposal stage: 2.7 +// https://github.com/tc39/proposal-iterator-sequencing + +import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; + +declare global { + interface IteratorConstructor { + concat(...iterators: Iterable[]): CoreJSIteratorObject; + } + + var Iterator: IteratorConstructor; +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/52/proposals/json-parse-with-source.d.ts new file mode 100644 index 000000000000..4ae35de411e0 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/json-parse-with-source.d.ts @@ -0,0 +1,22 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-json-parse-with-source + +interface CoreJSReviverContext { + readonly __brand: unique symbol; + + source: string; +} + +interface CoreJSRawJSON { + readonly __brand: unique symbol; + + rawJSON: string; +} + +interface JSON { + isRawJSON(value: any): value is CoreJSRawJSON; + + parse(text: string, reviver?: (key: string, value: any, context: CoreJSReviverContext) => any): T; + + rawJSON(value: string): CoreJSRawJSON; +} diff --git a/packages/core-js-types/src/52/proposals/map-upsert.d.ts b/packages/core-js-types/src/52/proposals/map-upsert.d.ts new file mode 100644 index 000000000000..0884acf4d246 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/map-upsert.d.ts @@ -0,0 +1,14 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-upsert + +interface Map { + getOrInsert(key: K, value: V): V; + + getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; +} + +interface WeakMap { + getOrInsert(key: K, value: V): V; + + getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; +} diff --git a/packages/core-js-types/src/52/proposals/math-sum.d.ts b/packages/core-js-types/src/52/proposals/math-sum.d.ts new file mode 100644 index 000000000000..b6086c79854c --- /dev/null +++ b/packages/core-js-types/src/52/proposals/math-sum.d.ts @@ -0,0 +1,5 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-math-sum +interface Math { + sumPrecise(...values: number[]): number; +} diff --git a/packages/core-js-types/src/52/proposals/number-clamp.d.ts b/packages/core-js-types/src/52/proposals/number-clamp.d.ts new file mode 100644 index 000000000000..d2c703e838cf --- /dev/null +++ b/packages/core-js-types/src/52/proposals/number-clamp.d.ts @@ -0,0 +1,6 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-math-clamp + +interface Number { + clamp(lower: number, upper: number): number; +} diff --git a/packages/core-js-types/src/52/proposals/object-from-entries.d.ts b/packages/core-js-types/src/52/proposals/object-from-entries.d.ts new file mode 100644 index 000000000000..a4b46b1d81a3 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/object-from-entries.d.ts @@ -0,0 +1,12 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-object-from-entries + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d8aafb3197ebecd7faf919eaa39e77c5805cbff8/src/lib/es2019.object.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface ObjectConstructor { + fromEntries(entries: Iterable): { [k: string]: T; }; + + fromEntries(entries: Iterable): any; +} diff --git a/packages/core-js-types/src/52/proposals/object-get-own-property-descriptors.d.ts b/packages/core-js-types/src/52/proposals/object-get-own-property-descriptors.d.ts new file mode 100644 index 000000000000..03381a3b031f --- /dev/null +++ b/packages/core-js-types/src/52/proposals/object-get-own-property-descriptors.d.ts @@ -0,0 +1,12 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-object-getownpropertydescriptors + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2017.object.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface ObjectConstructor { + getOwnPropertyDescriptors(o: T): { [P in keyof T]: TypedPropertyDescriptor; } & { + [x: string]: PropertyDescriptor; + }; +} diff --git a/packages/core-js-types/src/52/proposals/object-values-entries.d.ts b/packages/core-js-types/src/52/proposals/object-values-entries.d.ts new file mode 100644 index 000000000000..d2f4e35d18c2 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/object-values-entries.d.ts @@ -0,0 +1,14 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-object-values-entries + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2017.object.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface ObjectConstructor { + values(o: { [s: string]: T; } | ArrayLike): T[]; + values(o: {}): any[]; + + entries(o: { [s: string]: T; } | ArrayLike): [string, T][]; + entries(o: {}): [string, any][]; +} diff --git a/packages/core-js-types/src/52/proposals/pattern-matching.d.ts b/packages/core-js-types/src/52/proposals/pattern-matching.d.ts new file mode 100644 index 000000000000..874f263f2930 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/pattern-matching.d.ts @@ -0,0 +1,6 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-pattern-matching + +interface SymbolConstructor { + readonly customMatcher: unique symbol; +} diff --git a/packages/core-js-types/src/52/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/52/proposals/promise-all-settled.d.ts new file mode 100644 index 000000000000..db0d67f5c719 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/promise-all-settled.d.ts @@ -0,0 +1,18 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-promise-allSettled + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2020.promise.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +import { CoreJSPromiseSettledResult } from '../core-js-types/core-js-types'; + +declare global { + interface PromiseConstructor { + allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJSPromiseSettledResult>; }>; + + allSettled(values: Iterable>): Promise>[]>; + } +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/promise-any.d.ts b/packages/core-js-types/src/52/proposals/promise-any.d.ts new file mode 100644 index 000000000000..0470b9436996 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/promise-any.d.ts @@ -0,0 +1,24 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-promise-any + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2021.promise.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface PromiseConstructor { + any(values: T): Promise>; + + any(values: Iterable>): Promise>; +} + +interface AggregateError extends Error { + errors: any[]; +} + +interface AggregateErrorConstructor { + new (errors: Iterable, message?: string): AggregateError; + (errors: Iterable, message?: string): AggregateError; + readonly prototype: AggregateError; +} + +declare var AggregateError: AggregateErrorConstructor; diff --git a/packages/core-js-types/src/52/proposals/promise-finally.d.ts b/packages/core-js-types/src/52/proposals/promise-finally.d.ts new file mode 100644 index 000000000000..1936b256f060 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/promise-finally.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-promise-finally + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2018.promise.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface Promise { + finally(onfinally?: (() => void) | undefined | null): Promise; +} diff --git a/packages/core-js-types/src/52/proposals/promise-try.d.ts b/packages/core-js-types/src/52/proposals/promise-try.d.ts new file mode 100644 index 000000000000..75ff6358f34f --- /dev/null +++ b/packages/core-js-types/src/52/proposals/promise-try.d.ts @@ -0,0 +1,11 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-promise-try + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/esnext.promise.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface PromiseConstructor { + try(callbackFn: (...args: U) => T | PromiseLike, ...args: U): Promise>; +} + diff --git a/packages/core-js-types/src/52/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/52/proposals/promise-with-resolvers.d.ts new file mode 100644 index 000000000000..7a0a7efd7030 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/promise-with-resolvers.d.ts @@ -0,0 +1,20 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-promise-with-resolvers + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2024.promise.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface PromiseWithResolvers { + promise: Promise; + + resolve: (value: T | PromiseLike) => void; + + reject: (reason?: any) => void; +} + +interface PromiseConstructor { + withResolvers(): PromiseWithResolvers; +} + + diff --git a/packages/core-js-types/src/52/proposals/regexp-dotall-flag.d.ts b/packages/core-js-types/src/52/proposals/regexp-dotall-flag.d.ts new file mode 100644 index 000000000000..931f2cedf514 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/regexp-dotall-flag.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-regexp-dotall-flag + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2018.regexp.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface RegExp { + readonly dotAll: boolean; +} diff --git a/packages/core-js-types/src/52/proposals/regexp-escaping.d.ts b/packages/core-js-types/src/52/proposals/regexp-escaping.d.ts new file mode 100644 index 000000000000..e3526cfa3e88 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/regexp-escaping.d.ts @@ -0,0 +1,8 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-regex-escaping + +interface RegExpConstructor { + escape(string: string): string; +} + +declare var RegExp: RegExpConstructor; diff --git a/packages/core-js-types/src/52/proposals/regexp-named-groups.d.ts b/packages/core-js-types/src/52/proposals/regexp-named-groups.d.ts new file mode 100644 index 000000000000..141f940abfb7 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/regexp-named-groups.d.ts @@ -0,0 +1,18 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-regexp-named-groups + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2018.regexp.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface RegExpExecArray extends Array { + groups?: { + [key: string]: string; + }; +} + +interface RegExpMatchArray extends Array { + groups?: { + [key: string]: string; + }; +} diff --git a/packages/core-js-types/src/52/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/52/proposals/relative-indexing-method.d.ts new file mode 100644 index 000000000000..15ebeac28dc1 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/relative-indexing-method.d.ts @@ -0,0 +1,63 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-relative-indexing-method + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.array.d.ts +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface String { + at(index: number): string | undefined; +} + +interface Array { + at(index: number): T | undefined; +} + +interface ReadonlyArray { + at(index: number): T | undefined; +} + +interface Int8Array { + at(index: number): number | undefined; +} + +interface Uint8Array { + at(index: number): number | undefined; +} + +interface Uint8ClampedArray { + at(index: number): number | undefined; +} + +interface Int16Array { + at(index: number): number | undefined; +} + +interface Uint16Array { + at(index: number): number | undefined; +} + +interface Int32Array { + at(index: number): number | undefined; +} + +interface Uint32Array { + at(index: number): number | undefined; +} + +interface Float32Array { + at(index: number): number | undefined; +} + +interface Float64Array { + at(index: number): number | undefined; +} + +interface BigInt64Array { + at(index: number): bigint | undefined; +} + +interface BigUint64Array { + at(index: number): bigint | undefined; +} diff --git a/packages/core-js-types/src/52/proposals/set-methods-custom.d.ts b/packages/core-js-types/src/52/proposals/set-methods-custom.d.ts new file mode 100644 index 000000000000..6e5e628e8ba2 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/set-methods-custom.d.ts @@ -0,0 +1,20 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-set-methods + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + interface ReadonlySetLike { + keys(): Iterator; + + has(value: T): boolean; + + readonly size: number; + } + + export type SetUnion = (other: ReadonlySetLike) => Set; + + export type SetSymmetricDifference = (other: ReadonlySetLike) => Set; +} diff --git a/packages/core-js-types/src/52/proposals/set-methods.d.ts b/packages/core-js-types/src/52/proposals/set-methods.d.ts new file mode 100644 index 000000000000..299278b564a6 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/set-methods.d.ts @@ -0,0 +1,50 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-set-methods + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare global { + interface ReadonlySetLike { + keys(): Iterator; + + has(value: T): boolean; + + readonly size: number; + } + + interface Set { + union(other: ReadonlySetLike): Set; + + intersection(other: ReadonlySetLike): Set; + + difference(other: ReadonlySetLike): Set; + + symmetricDifference(other: ReadonlySetLike): Set; + + isSubsetOf(other: ReadonlySetLike): boolean; + + isSupersetOf(other: ReadonlySetLike): boolean; + + isDisjointFrom(other: ReadonlySetLike): boolean; + } + + interface ReadonlySet { + union(other: ReadonlySetLike): Set; + + intersection(other: ReadonlySetLike): Set; + + difference(other: ReadonlySetLike): Set; + + symmetricDifference(other: ReadonlySetLike): Set; + + isSubsetOf(other: ReadonlySetLike): boolean; + + isSupersetOf(other: ReadonlySetLike): boolean; + + isDisjointFrom(other: ReadonlySetLike): boolean; + } +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/string-cooked.d.ts b/packages/core-js-types/src/52/proposals/string-cooked.d.ts new file mode 100644 index 000000000000..8968780a6054 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/string-cooked.d.ts @@ -0,0 +1,8 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-string-cooked + +interface StringConstructor { + cooked(template: readonly string[], ...substitutions: any[]): string; + + cooked(template: string, ...substitutions: any[]): string; +} diff --git a/packages/core-js-types/src/52/proposals/string-dedent.d.ts b/packages/core-js-types/src/52/proposals/string-dedent.d.ts new file mode 100644 index 000000000000..6486f012be0f --- /dev/null +++ b/packages/core-js-types/src/52/proposals/string-dedent.d.ts @@ -0,0 +1,6 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-string-dedent + +interface StringConstructor { + dedent(strings: TemplateStringsArray, ...values: any[]): string; +} diff --git a/packages/core-js-types/src/52/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/52/proposals/string-left-right-trim.d.ts new file mode 100644 index 000000000000..cbd4ce89a795 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/string-left-right-trim.d.ts @@ -0,0 +1,16 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-string-left-right-trim + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface String { + trimEnd(): string; + + trimStart(): string; + + trimLeft(): string; + + trimRight(): string; +} diff --git a/packages/core-js-types/src/52/proposals/string-match-all.d.ts b/packages/core-js-types/src/52/proposals/string-match-all.d.ts new file mode 100644 index 000000000000..afceb8f5fc28 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/string-match-all.d.ts @@ -0,0 +1,24 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-string-matchall + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +import { CoreJSBuiltinIteratorReturn } from '../core-js-types/core-js-types'; + +declare global { + interface RegExpStringIterator extends IteratorObject { + [Symbol.iterator](): RegExpStringIterator; + } + + interface String { + matchAll(regexp: RegExp): RegExpStringIterator; + } + + interface SymbolConstructor { + readonly matchAll: unique symbol; + } +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/string-padding.d.ts b/packages/core-js-types/src/52/proposals/string-padding.d.ts new file mode 100644 index 000000000000..c4e9a68da923 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/string-padding.d.ts @@ -0,0 +1,12 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-string-pad-start-end + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface String { + padStart(maxLength: number, fillString?: string): string; + + padEnd(maxLength: number, fillString?: string): string; +} diff --git a/packages/core-js-types/src/52/proposals/string-replace-all-custom.d.ts b/packages/core-js-types/src/52/proposals/string-replace-all-custom.d.ts new file mode 100644 index 000000000000..928f0d7dc10e --- /dev/null +++ b/packages/core-js-types/src/52/proposals/string-replace-all-custom.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-string-replaceall + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export type StringReplaceAll = ((searchValue: string | RegExp, replaceValue: string) => string) | ((searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string) => string); +} diff --git a/packages/core-js-types/src/52/proposals/string-replace-all.d.ts b/packages/core-js-types/src/52/proposals/string-replace-all.d.ts new file mode 100644 index 000000000000..9fa6276b406b --- /dev/null +++ b/packages/core-js-types/src/52/proposals/string-replace-all.d.ts @@ -0,0 +1,16 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-string-replaceall + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare global { + interface String { + replaceAll(searchValue: string | RegExp, replaceValue: string): string; + + replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; + } +} + +export {}; diff --git a/packages/core-js-types/src/52/proposals/symbol-description.d.ts b/packages/core-js-types/src/52/proposals/symbol-description.d.ts new file mode 100644 index 000000000000..6d0927220518 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/symbol-description.d.ts @@ -0,0 +1,10 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-Symbol-description + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.symbol.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface Symbol { + readonly description: string | undefined; +} diff --git a/packages/core-js-types/src/52/proposals/symbol-predicates.d.ts b/packages/core-js-types/src/52/proposals/symbol-predicates.d.ts new file mode 100644 index 000000000000..165818730057 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/symbol-predicates.d.ts @@ -0,0 +1,8 @@ +// proposal stage: 2 +// https://github.com/tc39/proposal-symbol-predicates + +interface SymbolConstructor { + isRegisteredSymbol(value: any): boolean; + + isWellKnownSymbol(value: any): boolean; +} diff --git a/packages/core-js-types/src/52/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/52/proposals/well-formed-unicode-strings.d.ts new file mode 100644 index 000000000000..3f4c2caf5e4d --- /dev/null +++ b/packages/core-js-types/src/52/proposals/well-formed-unicode-strings.d.ts @@ -0,0 +1,12 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-is-usv-string + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2024.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +interface String { + isWellFormed(): boolean; + + toWellFormed(): string; +} diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 7decdd943b6b..17da72e1a4c6 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -3,10 +3,13 @@ import { $path, $proposal } from '../build-entries/templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; import { getModulesMetadata, sort } from '../build-entries/get-dependencies.mjs'; import config from './config.mjs'; -import { path, fs } from 'zx'; +import { argv, path, fs } from 'zx'; const { copy, outputFile, pathExists, readdir, remove } = fs; +const versionArg = argv._.find(item => item.startsWith('version=')); +const VERSION = versionArg ? versionArg.slice('version='.length) : undefined; + function modulesToStage(x) { return sort([ ...StableModules, @@ -76,7 +79,7 @@ async function getVersions() { return versions.sort(); } -async function buildTypesForTSVersion(version) { +async function buildTypesDirForTSVersion(version) { const versions = await getVersions(); for (const v of versions) { if (v > version) break; @@ -106,34 +109,47 @@ const ESWithProposalsSet = new Set(ESWithProposalsModules); const StableSet = new Set(StableModules); const ActualSet = new Set(ActualModules); -const tsVersion = config.latestTsVersion; -const bundleName = `${ config.bundleName }.${ tsVersion === config.latestTsVersion ? 'latest' : tsVersion }.d.ts`; -const bundlePath = path.join(config.buildDir, bundleName); -const typesPath = path.join(config.buildDir, tsVersion.toString()); -if (await pathExists(bundlePath)) await remove(bundlePath); -if (await pathExists(typesPath)) await remove(typesPath); -await buildTypesForTSVersion(tsVersion); -await addImports(bundlePath, typesPath); - -for (const [entry, definition] of Object.entries(features)) { - await buildType(bundlePath, `es/${ entry }`, { ...definition, entryFromNamespace: 'es' }); - await buildType(bundlePath, `stable/${ entry }`, { ...definition, entryFromNamespace: 'stable' }); - await buildType(bundlePath, `actual/${ entry }`, { ...definition, entryFromNamespace: 'actual' }); - await buildType(bundlePath, `full/${ entry }`, { ...definition, entryFromNamespace: 'full' }); -} +async function buildTypesForTSVersion(tsVersion) { + tsVersion = tsVersion.toString().replace('.', ''); + const bundleName = `${ config.bundleName }.${ tsVersion === config.latestTsVersion ? 'latest' : tsVersion }.d.ts`; + const bundlePath = path.join(config.buildDir, bundleName); + const typesPath = path.join(config.buildDir, tsVersion.toString()); + if (await pathExists(bundlePath)) await remove(bundlePath); + if (await pathExists(typesPath)) await remove(typesPath); + await buildTypesDirForTSVersion(tsVersion); + await addImports(bundlePath, typesPath); + + for (const [entry, definition] of Object.entries(features)) { + await buildType(bundlePath, `es/${ entry }`, { ...definition, entryFromNamespace: 'es' }); + await buildType(bundlePath, `stable/${ entry }`, { ...definition, entryFromNamespace: 'stable' }); + await buildType(bundlePath, `actual/${ entry }`, { ...definition, entryFromNamespace: 'actual' }); + await buildType(bundlePath, `full/${ entry }`, { ...definition, entryFromNamespace: 'full' }); + } -for (const [name, definition] of Object.entries(proposals)) { - await buildType(bundlePath, `proposals/${ name }`, { ...definition, template: $proposal }); + for (const [name, definition] of Object.entries(proposals)) { + await buildType(bundlePath, `proposals/${ name }`, { ...definition, template: $proposal }); + } + + await buildType(bundlePath, 'stage/3', { template: $path, modules: ActualModules, subset: 'es-stage' }); + await buildType(bundlePath, 'stage/2.7', { template: $path, modules: modulesToStage(2.7), subset: 'es-stage' }); + await buildType(bundlePath, 'stage/2', { template: $path, modules: modulesToStage(2), subset: 'es-stage' }); + await buildType(bundlePath, 'stage/1', { template: $path, modules: modulesToStage(1), subset: 'es-stage' }); + await buildType(bundlePath, 'stage/0', { template: $path, modules: AllModules, subset: 'es-stage' }); + + await buildType(bundlePath, 'es/index', { template: $path, modules: ESModules, subset: 'es' }); + await buildType(bundlePath, 'stable/index', { template: $path, modules: StableModules, subset: 'stable' }); + await buildType(bundlePath, 'actual/index', { template: $path, modules: ActualModules }); + await buildType(bundlePath, 'full/index', { template: $path, modules: AllModules }); + await buildType(bundlePath, 'index', { template: $path, modules: ActualModules }); } -await buildType(bundlePath, 'stage/3', { template: $path, modules: ActualModules, subset: 'es-stage' }); -await buildType(bundlePath, 'stage/2.7', { template: $path, modules: modulesToStage(2.7), subset: 'es-stage' }); -await buildType(bundlePath, 'stage/2', { template: $path, modules: modulesToStage(2), subset: 'es-stage' }); -await buildType(bundlePath, 'stage/1', { template: $path, modules: modulesToStage(1), subset: 'es-stage' }); -await buildType(bundlePath, 'stage/0', { template: $path, modules: AllModules, subset: 'es-stage' }); - -await buildType(bundlePath, 'es/index', { template: $path, modules: ESModules, subset: 'es' }); -await buildType(bundlePath, 'stable/index', { template: $path, modules: StableModules, subset: 'stable' }); -await buildType(bundlePath, 'actual/index', { template: $path, modules: ActualModules }); -await buildType(bundlePath, 'full/index', { template: $path, modules: AllModules }); -await buildType(bundlePath, 'index', { template: $path, modules: ActualModules }); +if (VERSION) { + await buildTypesForTSVersion(VERSION); +} else { + const tsVersionBreakpoints = [ + 5.2, + 5.6, + ]; + await remove(config.buildDir); + tsVersionBreakpoints.forEach(async version => await buildTypesForTSVersion(version)); +} diff --git a/tests/type-definitions/proposals/global/async-iterator-helper.test.ts b/tests/type-definitions/proposals/global/async-iterator-helper.test.ts index eef9cce999a0..040653aebd31 100644 --- a/tests/type-definitions/proposals/global/async-iterator-helper.test.ts +++ b/tests/type-definitions/proposals/global/async-iterator-helper.test.ts @@ -14,10 +14,9 @@ declare const ilb: Iterable; declare const is: Iterator; declare const itn: Iterator; declare const ailb: AsyncIterable; -async function* ag(): AsyncIterable { yield 'foo'; } AsyncIterator.from(ain); -AsyncIterator.from(ag()); +AsyncIterator.from((async function* () { yield 1; yield 2; })()); AsyncIterator.from(ilb); AsyncIterator.from(ailb); AsyncIterator.from(aio); diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 3e7d0be26ba7..71d481becc67 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -1,13 +1,76 @@ await $`tsc`; await $`tsc -p tsconfig.require.json`; -// await $`npx -p typescript@5.5 tsc -p proposals/global/tsconfig.esnext.json`; +const targets = [ + 'esnext', + 'es2023', + 'es6', +]; -await $`tsc -p proposals/global/tsconfig.esnext.json`; -await $`tsc -p proposals/global/tsconfig.es2023.json`; -await $`tsc -p proposals/global/tsconfig.es6.json`; +const typeScriptVersions = [ + '5.9', + '5.8', + '5.7', + '5.6', + // '5.5' +]; -await $`tsc -p proposals/pure/tsconfig.esnext.json`; -await $`tsc -p proposals/pure/tsconfig.es2023.json`; -await $`tsc -p proposals/pure/tsconfig.es6.json`; +const runTestsOnEnv = async function (typeScriptVersion, target, type) { + $.verbose = false; + const command = `npx -p typescript@${ typeScriptVersion } tsc -p proposals/${ type }/tsconfig.${ target }.json`; + echo(`$ ${ command }`); + try { + await $`npx -p typescript@${ typeScriptVersion } tsc -p proposals/${ type }/tsconfig.${ target }.json`.quiet(); + echo(chalk.green(`$ ${ command }`)); + } catch (error) { + echo(`$ ${ chalk.red(command) }\n ${ error }`); + process.exit(1); + } +}; + +// for (const version of typeScriptVersions) { +// for (const target of targets) { +// await Promise.all([ +// runTestsOnEnv(version, target, 'global'), +// runTestsOnEnv(version, target, 'pure') +// ]); +// } +// } +// 51 + +// await Promise.all( +// typeScriptVersions.flatMap(version => +// targets.flatMap(target => [ +// runTestsOnEnv(version, target, 'global'), +// runTestsOnEnv(version, target, 'pure') +// ]) +// ) +// ); +// 22 + +await Promise.all( + typeScriptVersions.flatMap(version => targets.map(async target => { + await runTestsOnEnv(version, target, 'global'); + await runTestsOnEnv(version, target, 'pure'); + })), +); +// 19 + +// for (const version of typeScriptVersions) { +// await Promise.all( +// targets.flatMap(target => [ +// runTestsOnEnv(version, target, 'global'), +// runTestsOnEnv(version, target, 'pure') +// ]) +// ); +// } +// 59 + +// await $`tsc -p proposals/global/tsconfig.esnext.json`; +// await $`tsc -p proposals/global/tsconfig.es2023.json`; +// await $`tsc -p proposals/global/tsconfig.es6.json`; +// +// await $`tsc -p proposals/pure/tsconfig.esnext.json`; +// await $`tsc -p proposals/pure/tsconfig.es2023.json`; +// await $`tsc -p proposals/pure/tsconfig.es6.json`; From 468480719faf62ad18c8381f8004f8987648ea28 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 11 Nov 2025 03:32:42 +0700 Subject: [PATCH 058/315] Move common code to helpers --- scripts/build-entries/helpers.mjs | 16 ++++++++++++++++ scripts/build-entries/index.mjs | 29 ++++++++--------------------- scripts/build-types/index.mjs | 29 ++++++++--------------------- 3 files changed, 32 insertions(+), 42 deletions(-) create mode 100644 scripts/build-entries/helpers.mjs diff --git a/scripts/build-entries/helpers.mjs b/scripts/build-entries/helpers.mjs new file mode 100644 index 000000000000..a51cfe999a1f --- /dev/null +++ b/scripts/build-entries/helpers.mjs @@ -0,0 +1,16 @@ +import { sort } from './get-dependencies.mjs'; +import { proposals } from './entries-definitions.mjs'; + +export function modulesToStage(stableModules, x) { + return sort([ + ...stableModules, + ...Object.values(proposals).flatMap(({ stage, modules }) => stage >= x ? modules : []), + ]); +} + +export function expandModules(modules, filter, allModules) { + if (!Array.isArray(modules)) modules = [modules]; + modules = modules.flatMap(it => it instanceof RegExp ? allModules.filter(path => it.test(path)) : [it]); + if (filter) modules = modules.filter(it => typeof it != 'string' || filter.has(it)); + return modules; +} diff --git a/scripts/build-entries/index.mjs b/scripts/build-entries/index.mjs index 777b33c112b0..57a34ff89bc5 100644 --- a/scripts/build-entries/index.mjs +++ b/scripts/build-entries/index.mjs @@ -1,23 +1,17 @@ -import { getModulesMetadata, sort } from './get-dependencies.mjs'; +import { getModulesMetadata } from './get-dependencies.mjs'; import { features, proposals } from './entries-definitions.mjs'; import { $proposal, $path, wrapEntry } from './templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; +import { expandModules, modulesToStage } from './helpers.mjs'; const { mkdir, writeFile, readJson, writeJson } = fs; const { dirname } = path; const { cyan, green } = chalk; -function modulesToStage(x) { - return sort([ - ...StableModules, - ...Object.values(proposals).flatMap(({ stage, modules }) => stage >= x ? modules : []), - ]); -} - const ESModules = AllModules.filter(it => it.startsWith('es.')); const ESWithProposalsModules = AllModules.filter(it => it.startsWith('es')); const StableModules = AllModules.filter(it => it.match(/^(?:es|web)\./)); -const ActualModules = modulesToStage(3); +const ActualModules = modulesToStage(StableModules, 3); const ESSet = new Set(ESModules); const ESWithProposalsSet = new Set(ESWithProposalsModules); @@ -40,13 +34,6 @@ const entriesMap = AllModules.reduce((memo, it) => { return memo; }, {}); -function expandModules(modules, filter) { - if (!Array.isArray(modules)) modules = [modules]; - modules = modules.flatMap(it => it instanceof RegExp ? AllModules.filter(path => it.test(path)) : [it]); - if (filter) modules = modules.filter(it => typeof it != 'string' || filter.has(it)); - return modules; -} - async function buildEntry(entry, options) { let { entryFromNamespace, @@ -73,11 +60,11 @@ async function buildEntry(entry, options) { filter ??= ESWithProposalsSet; } - if (!enforceEntryCreation && !expandModules(modules[0], filter).length) return; + if (!enforceEntryCreation && !expandModules(modules[0], filter, AllModules).length) return; const rawModules = modules; - modules = expandModules(modules, filter); + modules = expandModules(modules, filter, AllModules); const level = entry.split('/').length - 1; @@ -127,9 +114,9 @@ for (const [name, definition] of Object.entries(proposals)) { } await buildEntry('stage/3', { template: $path, modules: ActualModules, subset: 'es-stage' }); -await buildEntry('stage/2.7', { template: $path, modules: modulesToStage(2.7), subset: 'es-stage' }); -await buildEntry('stage/2', { template: $path, modules: modulesToStage(2), subset: 'es-stage' }); -await buildEntry('stage/1', { template: $path, modules: modulesToStage(1), subset: 'es-stage' }); +await buildEntry('stage/2.7', { template: $path, modules: modulesToStage(StableModules, 2.7), subset: 'es-stage' }); +await buildEntry('stage/2', { template: $path, modules: modulesToStage(StableModules, 2), subset: 'es-stage' }); +await buildEntry('stage/1', { template: $path, modules: modulesToStage(StableModules, 1), subset: 'es-stage' }); await buildEntry('stage/0', { template: $path, modules: AllModules, subset: 'es-stage' }); await buildEntry('es/index', { template: $path, modules: ESModules, subset: 'es' }); diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 17da72e1a4c6..1089afa71a69 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -1,29 +1,16 @@ import { features, proposals } from '../build-entries/entries-definitions.mjs'; import { $path, $proposal } from '../build-entries/templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; -import { getModulesMetadata, sort } from '../build-entries/get-dependencies.mjs'; +import { getModulesMetadata } from '../build-entries/get-dependencies.mjs'; import config from './config.mjs'; import { argv, path, fs } from 'zx'; +import { expandModules, modulesToStage } from '../build-entries/helpers.mjs'; const { copy, outputFile, pathExists, readdir, remove } = fs; const versionArg = argv._.find(item => item.startsWith('version=')); const VERSION = versionArg ? versionArg.slice('version='.length) : undefined; -function modulesToStage(x) { - return sort([ - ...StableModules, - ...Object.values(proposals).flatMap(({ stage, modules }) => stage >= x ? modules : []), - ]); -} - -function expandModules(modules, filter) { - if (!Array.isArray(modules)) modules = [modules]; - modules = modules.flatMap(it => it instanceof RegExp ? AllModules.filter(p => it.test(p)) : [it]); - if (filter) modules = modules.filter(it => typeof it != 'string' || filter.has(it)); - return modules; -} - async function buildType(typeFilePath, entry, options) { let { entryFromNamespace, @@ -50,11 +37,11 @@ async function buildType(typeFilePath, entry, options) { filter ??= ESWithProposalsSet; } - if (!enforceEntryCreation && !expandModules(modules[0], filter).length) return; + if (!enforceEntryCreation && !expandModules(modules[0], filter, AllModules).length) return; const rawModules = modules; - modules = expandModules(modules, filter); + modules = expandModules(modules, filter, AllModules); const level = entry.split('/').length - 1; @@ -102,7 +89,7 @@ async function addImports(filePath, fromPath) { const ESModules = AllModules.filter(it => it.startsWith('es.')); const ESWithProposalsModules = AllModules.filter(it => it.startsWith('es')); const StableModules = AllModules.filter(it => it.match(/^(?:es|web)\./)); -const ActualModules = modulesToStage(3); +const ActualModules = modulesToStage(StableModules, 3); const ESSet = new Set(ESModules); const ESWithProposalsSet = new Set(ESWithProposalsModules); @@ -131,9 +118,9 @@ async function buildTypesForTSVersion(tsVersion) { } await buildType(bundlePath, 'stage/3', { template: $path, modules: ActualModules, subset: 'es-stage' }); - await buildType(bundlePath, 'stage/2.7', { template: $path, modules: modulesToStage(2.7), subset: 'es-stage' }); - await buildType(bundlePath, 'stage/2', { template: $path, modules: modulesToStage(2), subset: 'es-stage' }); - await buildType(bundlePath, 'stage/1', { template: $path, modules: modulesToStage(1), subset: 'es-stage' }); + await buildType(bundlePath, 'stage/2.7', { template: $path, modules: modulesToStage(StableModules, 2.7), subset: 'es-stage' }); + await buildType(bundlePath, 'stage/2', { template: $path, modules: modulesToStage(StableModules, 2), subset: 'es-stage' }); + await buildType(bundlePath, 'stage/1', { template: $path, modules: modulesToStage(StableModules, 1), subset: 'es-stage' }); await buildType(bundlePath, 'stage/0', { template: $path, modules: AllModules, subset: 'es-stage' }); await buildType(bundlePath, 'es/index', { template: $path, modules: ESModules, subset: 'es' }); From 68debe961072c725e80510d05b197b89482bf74b Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 12 Nov 2025 04:24:53 +0700 Subject: [PATCH 059/315] Test core-js types with env types --- .../proposals/global/tsconfig.es2023.json | 7 -- .../proposals/global/tsconfig.es6.json | 7 -- .../proposals/global/tsconfig.esnext.json | 7 -- .../proposals/global/tsconfig.json | 4 + .../proposals/pure/tsconfig.es2023.json | 7 -- .../proposals/pure/tsconfig.es6.json | 7 -- .../proposals/pure/tsconfig.esnext.json | 7 -- .../proposals/pure/tsconfig.json | 4 + tests/type-definitions/runner.mjs | 95 +++++++++++-------- 9 files changed, 62 insertions(+), 83 deletions(-) delete mode 100644 tests/type-definitions/proposals/global/tsconfig.es2023.json delete mode 100644 tests/type-definitions/proposals/global/tsconfig.es6.json delete mode 100644 tests/type-definitions/proposals/global/tsconfig.esnext.json create mode 100644 tests/type-definitions/proposals/global/tsconfig.json delete mode 100644 tests/type-definitions/proposals/pure/tsconfig.es2023.json delete mode 100644 tests/type-definitions/proposals/pure/tsconfig.es6.json delete mode 100644 tests/type-definitions/proposals/pure/tsconfig.esnext.json create mode 100644 tests/type-definitions/proposals/pure/tsconfig.json diff --git a/tests/type-definitions/proposals/global/tsconfig.es2023.json b/tests/type-definitions/proposals/global/tsconfig.es2023.json deleted file mode 100644 index 37b2484b4ee4..000000000000 --- a/tests/type-definitions/proposals/global/tsconfig.es2023.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./*.ts"], - "compilerOptions": { - "target": "es2023" - } -} diff --git a/tests/type-definitions/proposals/global/tsconfig.es6.json b/tests/type-definitions/proposals/global/tsconfig.es6.json deleted file mode 100644 index ae985035ec9c..000000000000 --- a/tests/type-definitions/proposals/global/tsconfig.es6.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./*.ts"], - "compilerOptions": { - "target": "es6" - } -} diff --git a/tests/type-definitions/proposals/global/tsconfig.esnext.json b/tests/type-definitions/proposals/global/tsconfig.esnext.json deleted file mode 100644 index e5838f861aa9..000000000000 --- a/tests/type-definitions/proposals/global/tsconfig.esnext.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./*.ts"], - "compilerOptions": { - "target": "esnext" - } -} diff --git a/tests/type-definitions/proposals/global/tsconfig.json b/tests/type-definitions/proposals/global/tsconfig.json new file mode 100644 index 000000000000..1fcfc7ee75bf --- /dev/null +++ b/tests/type-definitions/proposals/global/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./*.ts"] +} diff --git a/tests/type-definitions/proposals/pure/tsconfig.es2023.json b/tests/type-definitions/proposals/pure/tsconfig.es2023.json deleted file mode 100644 index 37b2484b4ee4..000000000000 --- a/tests/type-definitions/proposals/pure/tsconfig.es2023.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./*.ts"], - "compilerOptions": { - "target": "es2023" - } -} diff --git a/tests/type-definitions/proposals/pure/tsconfig.es6.json b/tests/type-definitions/proposals/pure/tsconfig.es6.json deleted file mode 100644 index ae985035ec9c..000000000000 --- a/tests/type-definitions/proposals/pure/tsconfig.es6.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./*.ts"], - "compilerOptions": { - "target": "es6" - } -} diff --git a/tests/type-definitions/proposals/pure/tsconfig.esnext.json b/tests/type-definitions/proposals/pure/tsconfig.esnext.json deleted file mode 100644 index e5838f861aa9..000000000000 --- a/tests/type-definitions/proposals/pure/tsconfig.esnext.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./*.ts"], - "compilerOptions": { - "target": "esnext" - } -} diff --git a/tests/type-definitions/proposals/pure/tsconfig.json b/tests/type-definitions/proposals/pure/tsconfig.json new file mode 100644 index 000000000000..1fcfc7ee75bf --- /dev/null +++ b/tests/type-definitions/proposals/pure/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./*.ts"] +} diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 71d481becc67..36f9bf81c0d8 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -1,3 +1,5 @@ +import os from 'node:os'; + await $`tsc`; await $`tsc -p tsconfig.require.json`; @@ -6,7 +8,6 @@ const targets = [ 'es2023', 'es6', ]; - const typeScriptVersions = [ '5.9', '5.8', @@ -14,57 +15,70 @@ const typeScriptVersions = [ '5.6', // '5.5' ]; +const envs = [ + null, + '@types/node@24', + '@types/node@20', + // '@types/node@18', + '@types/bun@latest', +]; +const types = [ + 'global', + 'pure', +]; +const libs = [ + null, + 'dom', +]; -const runTestsOnEnv = async function (typeScriptVersion, target, type) { +const runTestsOnEnv = async function ({ typeScriptVersion, target, type, env, lib }) { $.verbose = false; - const command = `npx -p typescript@${ typeScriptVersion } tsc -p proposals/${ type }/tsconfig.${ target }.json`; + const command = `npx -p typescript@${ typeScriptVersion }${ env ? ` -p ${ env }` : '' } tsc -p proposals/${ type }/tsconfig.json --target ${ target }${ lib ? ` --lib ${ lib }` : '' }`; echo(`$ ${ command }`); try { - await $`npx -p typescript@${ typeScriptVersion } tsc -p proposals/${ type }/tsconfig.${ target }.json`.quiet(); + if (env && lib) { + await $`npx -p typescript@${ typeScriptVersion } -p ${ env } tsc -p proposals/${ type }/tsconfig.json --target ${ target } --lib ${ target },${ lib }`.quiet(); + } else if (env) { + await $`npx -p typescript@${ typeScriptVersion } -p ${ env } tsc -p proposals/${ type }/tsconfig.json --target ${ target }`.quiet(); + } else if (lib) { + await $`npx -p typescript@${ typeScriptVersion } tsc -p proposals/${ type }/tsconfig.json --target ${ target } --lib ${ target },${ lib }`.quiet(); + } else { + await $`npx -p typescript@${ typeScriptVersion } tsc -p proposals/${ type }/tsconfig.json --target ${ target }`.quiet(); + } echo(chalk.green(`$ ${ command }`)); } catch (error) { echo(`$ ${ chalk.red(command) }\n ${ error }`); + // eslint-disable-next-line node/no-process-exit -- it's needed here process.exit(1); } }; -// for (const version of typeScriptVersions) { -// for (const target of targets) { -// await Promise.all([ -// runTestsOnEnv(version, target, 'global'), -// runTestsOnEnv(version, target, 'pure') -// ]); -// } -// } -// 51 - -// await Promise.all( -// typeScriptVersions.flatMap(version => -// targets.flatMap(target => [ -// runTestsOnEnv(version, target, 'global'), -// runTestsOnEnv(version, target, 'pure') -// ]) -// ) -// ); -// 22 +async function runLimited(configs, limit) { + let i = 0; + async function worker() { + while (i < configs.length) { + const idx = i++; + await runTestsOnEnv(configs[idx]); + } + } + await Promise.all(Array.from({ length: limit }, worker)); +} -await Promise.all( - typeScriptVersions.flatMap(version => targets.map(async target => { - await runTestsOnEnv(version, target, 'global'); - await runTestsOnEnv(version, target, 'pure'); - })), -); -// 19 +const taskConfigs = []; +for (const type of types) { + for (const target of targets) { + for (const typeScriptVersion of typeScriptVersions) { + for (const env of envs) { + for (const lib of libs) { + taskConfigs.push({ env, lib, target, type, typeScriptVersion }); + } + } + } + } +} -// for (const version of typeScriptVersions) { -// await Promise.all( -// targets.flatMap(target => [ -// runTestsOnEnv(version, target, 'global'), -// runTestsOnEnv(version, target, 'pure') -// ]) -// ); -// } -// 59 +const numCPUs = os.cpus().length; +await runLimited(taskConfigs, Math.max(numCPUs - 1, 1)); // await $`tsc -p proposals/global/tsconfig.esnext.json`; // await $`tsc -p proposals/global/tsconfig.es2023.json`; @@ -72,5 +86,4 @@ await Promise.all( // // await $`tsc -p proposals/pure/tsconfig.esnext.json`; // await $`tsc -p proposals/pure/tsconfig.es2023.json`; -// await $`tsc -p proposals/pure/tsconfig.es6.json`; - +// await $`tsc -p proposals/pure/tsconfig.es6.node.json`; From 7cda6f1c48186c82d659b76394f387c91cafd345 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 13 Nov 2025 00:54:43 +0700 Subject: [PATCH 060/315] JSDocs for types --- .../accessible-object-hasownproperty.d.ts | 5 + .../src/56/proposals/array-buffer-base64.d.ts | 42 ++- .../56/proposals/array-buffer-transfer.d.ts | 17 ++ .../src/56/proposals/array-filtering.d.ts | 77 ++++++ .../56/proposals/array-find-from-last.d.ts | 219 ++++++++++++++- .../src/56/proposals/array-flat-map.d.ts | 16 ++ .../src/56/proposals/array-from-async.d.ts | 12 + .../src/56/proposals/array-grouping.d.ts | 10 + .../src/56/proposals/array-includes.d.ts | 60 +++++ .../proposals/array-is-template-object.d.ts | 6 + .../src/56/proposals/array-unique.d.ts | 72 +++++ .../src/56/proposals/async-iteration.d.ts | 4 + .../56/proposals/async-iterator-helpers.d.ts | 64 +++++ .../src/56/proposals/await-dictionary.d.ts | 13 + .../56/proposals/change-array-by-copy.d.ts | 255 +++++++++++++++++- .../src/56/proposals/collection-of-from.d.ts | 57 ++++ .../data-view-get-set-uint8-clamped.d.ts | 12 + .../explicit-resource-management.d.ts | 106 ++++++++ .../src/56/proposals/float16.d.ts | 16 ++ .../56/proposals/function-demethodize.d.ts | 4 + .../src/56/proposals/is-error.d.ts | 8 + .../src/56/proposals/iterator-chunking.d.ts | 12 + .../src/56/proposals/iterator-helpers.d.ts | 69 +++++ .../src/56/proposals/iterator-joint.d.ts | 30 ++- .../src/56/proposals/iterator-range.d.ts | 9 + .../src/56/proposals/iterator-sequencing.d.ts | 5 + .../56/proposals/json-parse-with-source.d.ts | 17 ++ .../src/56/proposals/map-upsert.d.ts | 26 ++ .../src/56/proposals/math-sum.d.ts | 5 + .../src/56/proposals/number-clamp.d.ts | 6 + .../src/56/proposals/object-from-entries.d.ts | 8 + .../object-get-own-property-descriptors.d.ts | 4 + .../56/proposals/object-values-entries.d.ts | 16 ++ .../src/56/proposals/promise-all-settled.d.ts | 12 + .../src/56/proposals/promise-any.d.ts | 10 + .../src/56/proposals/promise-finally.d.ts | 6 + .../src/56/proposals/promise-try.d.ts | 13 + .../56/proposals/promise-with-resolvers.d.ts | 8 + .../src/56/proposals/regexp-dotall-flag.d.ts | 4 + .../src/56/proposals/regexp-escaping.d.ts | 5 + .../proposals/relative-indexing-method.d.ts | 56 ++++ .../src/56/proposals/set-methods.d.ts | 51 ++++ .../src/56/proposals/string-cooked.d.ts | 13 +- .../src/56/proposals/string-dedent.d.ts | 7 + .../56/proposals/string-left-right-trim.d.ts | 8 + .../src/56/proposals/string-match-all.d.ts | 5 + .../src/56/proposals/string-padding.d.ts | 22 ++ .../src/56/proposals/string-replace-all.d.ts | 12 +- .../src/56/proposals/symbol-description.d.ts | 3 + .../src/56/proposals/symbol-predicates.d.ts | 8 + .../well-formed-unicode-strings.d.ts | 6 + 51 files changed, 1510 insertions(+), 21 deletions(-) diff --git a/packages/core-js-types/src/56/proposals/accessible-object-hasownproperty.d.ts b/packages/core-js-types/src/56/proposals/accessible-object-hasownproperty.d.ts index a4e51205a188..fa4e7515fd94 100644 --- a/packages/core-js-types/src/56/proposals/accessible-object-hasownproperty.d.ts +++ b/packages/core-js-types/src/56/proposals/accessible-object-hasownproperty.d.ts @@ -5,5 +5,10 @@ // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2022.object.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface ObjectConstructor { + /** + * Determines whether an object has a property with the specified name. + * @param o An object. + * @param v A property name. + */ hasOwn(o: object, v: PropertyKey): boolean; } diff --git a/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts index faec22bae19f..dbc36f0df75f 100644 --- a/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts +++ b/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts @@ -25,17 +25,51 @@ type processMetadata = { } interface Uint8ArrayConstructor { - fromBase64(str: string, opts?: fromBase64Options): Uint8Array; + /** + * Creates a new `Uint8Array` from a base64-encoded string. + * @param string The base64-encoded string. + * @param options If provided, specifies the alphabet and handling of the last chunk. + * @returns A new `Uint8Array` instance. + * @throws {SyntaxError} If the input string contains characters outside the specified alphabet, or if the last + * chunk is inconsistent with the `lastChunkHandling` option. + */ + fromBase64(string: string, options?: fromBase64Options): Uint8Array; + /** + * Creates a new `Uint8Array` from a base16-encoded string. + * @returns A new `Uint8Array` instance. + */ fromHex(str: string): Uint8Array; } interface Uint8Array { - setFromBase64(str: string, opts?: fromBase64Options): processMetadata; + /** + * Sets the `Uint8Array` from a base64-encoded string. + * @param string The base64-encoded string. + * @param options If provided, specifies the alphabet and handling of the last chunk. + * @returns An object containing the number of bytes read and written. + * @throws {SyntaxError} If the input string contains characters outside the specified alphabet, or if the last + * chunk is inconsistent with the `lastChunkHandling` option. + */ + setFromBase64(string: string, options?: fromBase64Options): processMetadata; - setFromHex(str: string): processMetadata; + /** + * Sets the `Uint8Array` from a base16-encoded string. + * @param string The base16-encoded string. + * @returns An object containing the number of bytes read and written. + */ + setFromHex(string: string): processMetadata; - toBase64(opts?: toBase64Options): string; + /** + * Converts the `Uint8Array` to a base64-encoded string. + * @param options If provided, sets the alphabet and padding behavior used. + * @returns A base64-encoded string. + */ + toBase64(options?: toBase64Options): string; + /** + * Converts the `Uint8Array` to a base16-encoded string. + * @returns A base16-encoded string. + */ toHex(): string; } diff --git a/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts index 50046c7dc41e..b11b4866241c 100644 --- a/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts @@ -1,11 +1,28 @@ // proposal stage: 4 // https://github.com/tc39/proposal-arraybuffer-transfer +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/es2024.arraybuffer.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + interface ArrayBuffer { // todo hack for modern ts // get detached(): boolean; + /** + * Creates a new `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. + * @param newByteLength If provided, specifies the `byteLength` of the new `ArrayBuffer` + * @throws {RangeError} If this `ArrayBuffer` is resizable and newByteLength is greater than the `maxByteLength` of this `ArrayBuffer` + * @throws {TypeError} If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @returns A new `ArrayBuffer` object + */ transfer(newByteLength?: number): ArrayBuffer; + /** + * Creates a new non-resizable `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. + * @param newByteLength If provided, specifies the `byteLength` of the new `ArrayBuffer` + * @throws {TypeError} If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @returns A new `ArrayBuffer` object + */ transferToFixedLength(newByteLength?: number): ArrayBuffer; } diff --git a/packages/core-js-types/src/56/proposals/array-filtering.d.ts b/packages/core-js-types/src/56/proposals/array-filtering.d.ts index e4b456324fab..4b7353c68698 100644 --- a/packages/core-js-types/src/56/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/56/proposals/array-filtering.d.ts @@ -2,38 +2,101 @@ // https://github.com/tc39/proposal-array-filtering interface Array { + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; } interface Int8Array { + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ filterReject(callbackFn: (value: number, index: number, target: Int8Array) => boolean, thisArg?: any): Int8Array; } interface Uint8Array { + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ filterReject(callbackFn: (value: number, index: number, target: Uint8Array) => boolean, thisArg?: any): Uint8Array; } interface Uint8ClampedArray { + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ filterReject(callbackFn: (value: number, index: number, target: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; } interface Int16Array { + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ filterReject(callbackFn: (value: number, index: number, target: Int16Array) => boolean, thisArg?: any): Int16Array; } interface Uint16Array { + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ filterReject(callbackFn: (value: number, index: number, target: Uint16Array) => boolean, thisArg?: any): Uint16Array; } interface Int32Array { + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ filterReject(callbackFn: (value: number, index: number, target: Int32Array) => boolean, thisArg?: any): Int32Array; } interface Uint32Array { + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ filterReject(callbackFn: (value: number, index: number, target: Uint32Array) => boolean, thisArg?: any): Uint32Array; } interface Float32Array { + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ filterReject(callbackFn: (value: number, index: number, target: Float32Array) => boolean, thisArg?: any): Float32Array; } @@ -42,9 +105,23 @@ interface Float64Array { } interface BigInt64Array { + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array; } interface BigUint64Array { + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ filterReject(callbackFn: (value: bigint, index: number, target: BigUint64Array) => boolean, thisArg?: any): BigUint64Array; } diff --git a/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts index 0ac8e21d189e..034e9f7304f4 100644 --- a/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts @@ -6,97 +6,292 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface Array { + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T | undefined; + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; } interface Int8Array { + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } interface Uint8Array { + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } interface Uint8ClampedArray { + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } interface Int16Array { + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } interface Uint16Array { + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } interface Int32Array { + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } interface Uint32Array { + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } interface Float32Array { + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } interface Float64Array { + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } interface BigInt64Array { + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): bigint | undefined; + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; } interface BigUint64Array { + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): bigint | undefined; + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; } diff --git a/packages/core-js-types/src/56/proposals/array-flat-map.d.ts b/packages/core-js-types/src/56/proposals/array-flat-map.d.ts index 5120e58dc54e..f861f0b25a6c 100644 --- a/packages/core-js-types/src/56/proposals/array-flat-map.d.ts +++ b/packages/core-js-types/src/56/proposals/array-flat-map.d.ts @@ -9,8 +9,24 @@ import { CoreJSFlatArray } from '../core-js-types/core-js-types'; declare global { interface Array { + /** + * 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 callback 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 this keyword can refer in the callback function. If + * thisArg is omitted, undefined is used as this value. + */ flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): 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(this: A, depth?: D): CoreJSFlatArray[]; } } diff --git a/packages/core-js-types/src/56/proposals/array-from-async.d.ts b/packages/core-js-types/src/56/proposals/array-from-async.d.ts index b0f1c21cd725..8dfef687701c 100644 --- a/packages/core-js-types/src/56/proposals/array-from-async.d.ts +++ b/packages/core-js-types/src/56/proposals/array-from-async.d.ts @@ -7,8 +7,20 @@ declare global { interface ArrayConstructor { + /** + * Creates an array from an async iterator or iterable object. + * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. + */ fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; + /** + * Creates an array from an async iterator or iterable object. + * + * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. + * @param mapFn A mapping function to call on every element of iterableOrArrayLike. + * Each return value is awaited before being added to result array. + * @param thisArg Value of 'this' used when executing mapFn. + */ fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } } diff --git a/packages/core-js-types/src/56/proposals/array-grouping.d.ts b/packages/core-js-types/src/56/proposals/array-grouping.d.ts index 66c410a8c237..bedadd456513 100644 --- a/packages/core-js-types/src/56/proposals/array-grouping.d.ts +++ b/packages/core-js-types/src/56/proposals/array-grouping.d.ts @@ -7,9 +7,19 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface ObjectConstructor { + /** + * 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. + */ groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Partial>; } interface MapConstructor { + /** + * 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. + */ groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Map; } diff --git a/packages/core-js-types/src/56/proposals/array-includes.d.ts b/packages/core-js-types/src/56/proposals/array-includes.d.ts index 0f5cc4b6b628..55d17beeb3ee 100644 --- a/packages/core-js-types/src/56/proposals/array-includes.d.ts +++ b/packages/core-js-types/src/56/proposals/array-includes.d.ts @@ -6,49 +6,109 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface Array { + /** + * 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(searchElement: T, fromIndex?: number): boolean; } interface Int8Array { + /** + * 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(searchElement: number, fromIndex?: number): boolean; } interface Uint8Array { + /** + * 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(searchElement: number, fromIndex?: number): boolean; } interface Uint8ClampedArray { + /** + * 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(searchElement: number, fromIndex?: number): boolean; } interface Int16Array { + /** + * 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(searchElement: number, fromIndex?: number): boolean; } interface Uint16Array { + /** + * 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(searchElement: number, fromIndex?: number): boolean; } interface Int32Array { + /** + * 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(searchElement: number, fromIndex?: number): boolean; } interface Uint32Array { + /** + * 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(searchElement: number, fromIndex?: number): boolean; } interface Float32Array { + /** + * 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(searchElement: number, fromIndex?: number): boolean; } interface Float64Array { + /** + * 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(searchElement: number, fromIndex?: number): boolean; } interface BigInt64Array { + /** + * 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(searchElement: bigint, fromIndex?: number): boolean; } interface BigUint64Array { + /** + * 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(searchElement: bigint, fromIndex?: number): boolean; } diff --git a/packages/core-js-types/src/56/proposals/array-is-template-object.d.ts b/packages/core-js-types/src/56/proposals/array-is-template-object.d.ts index 6ab53db2e94a..92ff3106613d 100644 --- a/packages/core-js-types/src/56/proposals/array-is-template-object.d.ts +++ b/packages/core-js-types/src/56/proposals/array-is-template-object.d.ts @@ -1,5 +1,11 @@ // proposal stage: 2 // https://github.com/tc39/proposal-array-is-template-object + interface ArrayConstructor { + /** + * Determines whether an `value` is a `TemplateStringsArray` + * @param value + * @returns `true` if `value` is a `TemplateStringsArray`, otherwise `false` + */ isTemplateObject(value: any): value is TemplateStringsArray; } diff --git a/packages/core-js-types/src/56/proposals/array-unique.d.ts b/packages/core-js-types/src/56/proposals/array-unique.d.ts index e2f85333abcc..d17ffc3d8d8b 100644 --- a/packages/core-js-types/src/56/proposals/array-unique.d.ts +++ b/packages/core-js-types/src/56/proposals/array-unique.d.ts @@ -2,49 +2,121 @@ // https://github.com/tc39/proposal-array-unique interface Array { + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; } interface Int8Array { + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int8Array; } interface Uint8Array { + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8Array; } interface Uint8ClampedArray { + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8ClampedArray; } interface Int16Array { + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int16Array; } interface Uint16Array { + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint16Array; } interface Int32Array { + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int32Array; } interface Uint32Array { + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint32Array; } interface Float32Array { + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float32Array; } interface Float64Array { + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float64Array; } interface BigInt64Array { + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigInt64Array; } interface BigUint64Array { + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigUint64Array; } diff --git a/packages/core-js-types/src/56/proposals/async-iteration.d.ts b/packages/core-js-types/src/56/proposals/async-iteration.d.ts index 9fecd8b65641..98856336caf0 100644 --- a/packages/core-js-types/src/56/proposals/async-iteration.d.ts +++ b/packages/core-js-types/src/56/proposals/async-iteration.d.ts @@ -6,5 +6,9 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface SymbolConstructor { + /** + * A method that returns the default async iterator for an object. Called by the semantics of + * the for-await-of statement. + */ readonly asyncIterator: unique symbol; } diff --git a/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts index e14886bd6a75..538421b74e27 100644 --- a/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts @@ -3,36 +3,100 @@ declare global { interface AsyncIteratorConstructor { + /** + * Creates an `AsyncIterator` from an iterable object + * @param iterable An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` + * @returns A new `AsyncIterator` instance + */ from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; } var AsyncIterator: AsyncIteratorConstructor; interface AsyncIterator { + /** + * Drops elements from the iterator until the limit is reached + * @param limit The number of elements to drop + * @returns A new `AsyncIterator` + */ drop(limit: number): AsyncIteratorObject; + /** + * Check if every value generated by the iterator passes the `predicate` function. + * @param predicate A function that tests each element of the iterator + * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` + */ every(predicate: (value: T, index: number) => boolean): Promise; + /** + * Creates a new `AsyncIterator` that contains only the elements that pass the `predicate` function. + * @param predicate A function that tests each element of the iterator + * @returns A new `AsyncIterator` + */ filter(predicate: (value: T, index: number) => boolean): AsyncIteratorObject; + /** + * Finds the first element in the iterator that satisfies the `predicate` function. + * @param predicate A function that tests each element of the iterator + * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` + */ find(predicate: (value: T, index: number) => boolean): Promise; + /** + * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. + * @param mapper A function that transforms each element of the iterator + * @returns A new `AsyncIterator` + */ flatMap(mapper: (value: T, index: number) => any): AsyncIteratorObject; + /** + * Executes a provided function once for each element in the iterator. + * @param callbackFn A function that is called for each element of the iterator + * @returns A `Promise` that resolves when all elements have been processed + */ forEach(callbackFn: (value: T, index: number) => void): Promise; + /** + * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. + * @param mapper A function that transforms each element of the iterator + * @returns A new `AsyncIterator` + */ map(mapper: (value: T, index: number) => any): AsyncIteratorObject; + /** + * Reduces the elements of the iterator to a single value using the `reducer` function. + * @param reducer A function that combines two elements of the iterator + * @param initialValue An optional initial value to start the reduction + * @returns A `Promise` that resolves to the reduced value + */ reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; + /** + * Checks if any value in the iterator matches a given `predicate` + * @param predicate A function that tests each element of the iterator + * @returns A `Promise` that resolves to `true` if any element passes the `predicate`, otherwise `false` + */ some(predicate: (value: T, index: number) => boolean): Promise; + /** + * Creates a new `AsyncIterator` that yields only the first `limit` elements from the original iterator. + * @param limit The maximum number of elements to take + * @returns A new `AsyncIterator` + */ take(limit: number): AsyncIteratorObject; + /** + * Collects all elements from the iterator into an array. + * @returns A `Promise` that resolves to an array containing all elements from the iterator + */ toArray(): Promise; } interface Iterator { + /** + * Creates an `AsyncIterator` from the current `Iterator` + * @returns A new `AsyncIterator` instance + */ toAsync(): AsyncIteratorObject; } } diff --git a/packages/core-js-types/src/56/proposals/await-dictionary.d.ts b/packages/core-js-types/src/56/proposals/await-dictionary.d.ts index 3a6e22e45634..c9741c3a1ded 100644 --- a/packages/core-js-types/src/56/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/56/proposals/await-dictionary.d.ts @@ -5,8 +5,21 @@ import { CoreJSPromiseSettledResult } from '../core-js-types/core-js-types'; declare global { interface PromiseConstructor { + /** + * Takes an object of promises and returns a single Promise that resolves to an object + * with the same keys and fulfilled values, or rejects as soon as any of the input promises rejects. + * @param promises An object of promises + * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. + */ allKeyed>>(promises: D): Promise <{ [k in keyof D]: Awaited }>; + /** + * Takes an object whose values are promises and returns a single `Promise` that resolves + * to an object with the same keys, after all of the input promises have settled. + * @param promises An object of promises + * @returns A new Promise that resolves to an object with the same keys as the input object, + * where each key maps to the settlement result ({ status, value } or { status, reason }) of the corresponding promise. + */ allSettledKeyed>>(promises: D): Promise <{ [k in keyof D]: CoreJSPromiseSettledResult> }>; } } diff --git a/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts index cc8a2d3f4e2f..98e73b584f69 100644 --- a/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts +++ b/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts @@ -7,102 +7,355 @@ declare global { interface Array { + /** + * @returns A copy of an array with its elements reversed. + */ toReversed(): T[]; + /** + * Returns a copy of an array with its elements sorted. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. + * ```ts + * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] + * ``` + */ toSorted(compareFn?: (a: T, b: T) => number): T[]; + /** + * Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. + * @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 copied array in place of the deleted elements. + * @returns The copied array. + */ toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; - + /** + * Copies an array and removes elements while returning the remaining 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 A copy of the original array with the remaining elements. + */ toSpliced(start: number, deleteCount?: number): T[]; + /** + * Copies an array, then overwrites the value at the provided index with the + * given value. If the index is negative, then it replaces from the end + * of the array. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to write into the copied array. + * @returns The copied array with the updated value. + */ with(index: number, value: T): T[]; } interface Int8Array { + /** + * @returns A copy of an array with its elements reversed. + */ toReversed(): Int8Array; + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Int8Array.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Int8Array(4) [1, 2, 11, 22] + * ``` + */ toSorted(compareFn?: (a: number, b: number) => number): Int8Array; + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ with(index: number, value: number): Int8Array; } interface Uint8Array { + /** + * @returns A copy of an array with its elements reversed. + */ toReversed(): Uint8Array; + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Uint8Array.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint8Array(4) [1, 2, 11, 22] + * ``` + */ toSorted(compareFn?: (a: number, b: number) => number): Uint8Array; + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ with(index: number, value: number): Uint8Array; } interface Uint8ClampedArray { + /** + * @returns A copy of an array with its elements reversed. + */ toReversed(): Uint8ClampedArray; + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Uint8ClampedArray.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint8ClampedArray(4) [1, 2, 11, 22] + * ``` + */ toSorted(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ with(index: number, value: number): Uint8ClampedArray; } interface Int16Array { + /** + * @returns A copy of an array with its elements reversed. + */ toReversed(): Int16Array; + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Int16Array.from([11, 2, -22, 1]); + * myNums.toSorted((a, b) => a - b) // Int16Array(4) [-22, 1, 2, 11] + * ``` + */ toSorted(compareFn?: (a: number, b: number) => number): Int16Array; + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ with(index: number, value: number): Int16Array; } interface Uint16Array { + /** + * @returns A copy of an array with its elements reversed. + */ toReversed(): Uint16Array; + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Uint16Array.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint16Array(4) [1, 2, 11, 22] + * ``` + */ toSorted(compareFn?: (a: number, b: number) => number): Uint16Array; + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ with(index: number, value: number): Uint16Array; } interface Int32Array { + /** + * @returns A copy of an array with its elements reversed. + */ toReversed(): Int32Array; + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Int32Array.from([11, 2, -22, 1]); + * myNums.toSorted((a, b) => a - b) // Int32Array(4) [-22, 1, 2, 11] + * ``` + */ toSorted(compareFn?: (a: number, b: number) => number): Int32Array; + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ with(index: number, value: number): Int32Array; } interface Uint32Array { + /** + * @returns A copy of an array with its elements reversed. + */ toReversed(): Uint32Array; + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Int32Array.from([11, 2, -22, 1]); + * myNums.toSorted((a, b) => a - b) // Int32Array(4) [-22, 1, 2, 11] + * ``` + */ toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ with(index: number, value: number): Uint32Array; } interface Float32Array { + /** + * @returns A copy of an array with its elements reversed. + */ toReversed(): Float32Array; + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Float32Array.from([11.25, 2, -22.5, 1]); + * myNums.toSorted((a, b) => a - b) // Float32Array(4) [-22.5, 1, 2, 11.5] + * ``` + */ toSorted(compareFn?: (a: number, b: number) => number): Float32Array; + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ with(index: number, value: number): Float32Array; } interface Float64Array { + /** + * @returns A copy of an array with its elements reversed. + */ toReversed(): Float64Array; + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Float64Array.from([11.25, 2, -22.5, 1]); + * myNums.toSorted((a, b) => a - b) // Float64Array(4) [-22.5, 1, 2, 11.5] + * ``` + */ toSorted(compareFn?: (a: number, b: number) => number): Float64Array; + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ with(index: number, value: number): Float64Array; } interface BigInt64Array { + /** + * @returns A copy of an array with its elements reversed. + */ toReversed(): BigInt64Array; + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = BigInt64Array.from([11n, 2n, -22n, 1n]); + * myNums.toSorted((a, b) => Number(a - b)) // BigInt64Array(4) [-22n, 1n, 2n, 11n] + * ``` + */ toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; + /** + * Copies the array and inserts the given bigint at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ with(index: number, value: bigint): BigInt64Array; } interface BigUint64Array { + /** + * @returns A copy of an array with its elements reversed. + */ toReversed(): BigUint64Array; + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = BigUint64Array.from([11n, 2n, 22n, 1n]); + * myNums.toSorted((a, b) => Number(a - b)) // BigUint64Array(4) [1n, 2n, 11n, 22n] + * ``` + */ toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; + /** + * Copies the array and inserts the given bigint at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ with(index: number, value: bigint): BigUint64Array; } } diff --git a/packages/core-js-types/src/56/proposals/collection-of-from.d.ts b/packages/core-js-types/src/56/proposals/collection-of-from.d.ts index 6e6bdeb8e2bd..1e8b409b0182 100644 --- a/packages/core-js-types/src/56/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/56/proposals/collection-of-from.d.ts @@ -1,25 +1,82 @@ // proposal stage: 1 // https://github.com/tc39/proposal-setmap-offrom + interface MapConstructor { + /** + * Creates a new `Map` instance from an iterable or array-like object of [key, value] pairs. + * Optionally, applies a mapping function to each pair. + * @param source Iterable or array-like object of [key, value] pairs. + * @param mapFn Function to call on every [key, value] pair before adding to the `Map`. + * @param thisArg Value to use as this when executing mapFn. + * @return A new `Map` instance. + */ from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): Map; + /** + * Creates a new `Map` instance from a variable number of arguments, + * where each pair of arguments is interpreted as a key and a value. + * @param items An even number of arguments representing key-value pairs. + * @return A new `Map` instance. + */ of(...items: [K, V][]): Map; } interface SetConstructor { + /** + * Creates a new `Set` instance from an iterable or array-like object of [key, value] pairs. + * Optionally, applies a mapping function to each pair. + * @param source Iterable or array-like object of [key, value] pairs. + * @param mapFn Function to call on every [key, value] pair before adding to the `Set`. + * @param thisArg Value to use as this when executing mapFn. + * @return A new `Set` instance. + */ from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): Set; + /** + * Creates a new `Set` instance from a variable number of arguments, + * where each pair of arguments is interpreted as a key and a value. + * @param items An even number of arguments representing key-value pairs. + * @return A new `Set` instance. + */ of(...items: T[]): Set; } interface WeakMapConstructor { + /** + * Creates a new `WeakMap` instance from an iterable or array-like object of [key, value] pairs. + * Optionally, applies a mapping function to each pair. + * @param source Iterable or array-like object of [key, value] pairs. + * @param mapFn Function to call on every [key, value] pair before adding to the `WeakMap`. + * @param thisArg Value to use as this when executing mapFn. + * @return A new `WeakMap` instance. + */ from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): WeakMap; + /** + * Creates a new `WeakMap` instance from a variable number of arguments, + * where each pair of arguments is interpreted as a key and a value. + * @param items An even number of arguments representing key-value pairs. + * @return A new `Weak` instance. + */ of(...items: [K, V][]): WeakMap; } interface WeakSetConstructor { + /** + * Creates a new `WeakSet` instance from an iterable or array-like object of [key, value] pairs. + * Optionally, applies a mapping function to each pair. + * @param source Iterable or array-like object of [key, value] pairs. + * @param mapFn Function to call on every [key, value] pair before adding to the `WeakSet`. + * @param thisArg Value to use as this when executing mapFn. + * @return A new `WeakSet` instance. + */ from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): WeakSet; + /** + * Creates a new `WeakSet` instance from a variable number of arguments, + * where each pair of arguments is interpreted as a key and a value. + * @param items An even number of arguments representing key-value pairs. + * @return A new `WeakSet` instance. + */ of(...items: T[]): WeakSet; } diff --git a/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts index e0022c602323..e0b8c45ea1fd 100644 --- a/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts +++ b/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts @@ -2,7 +2,19 @@ // https://github.com/tc39/proposal-dataview-get-set-uint8clamped interface DataView { + /** + * Reads an unsigned 8-bit integer at the specified byte offset from the DataView, + * interpreting the byte as a clamped 8-bit unsigned value (same as Uint8ClampedArray). + * @param byteOffset The offset, in bytes, from the start of the DataView. + * @returns The unsigned 8-bit integer at the given offset. + */ getUint8Clamped(byteOffset: number): number; + /** + * Stores a value as an unsigned 8-bit integer at the specified byte offset in the DataView, + * clamping the input to the 0–255 range and rounding to the nearest integer as per Uint8ClampedArray behavior. + * @param byteOffset The offset, in bytes, from the start of the DataView. + * @param value The value to store; it will be clamped to the range 0–255 and rounded to the nearest integer. + */ setUint8Clamped(byteOffset: number, value: number): void; } diff --git a/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts index beba7817011e..9fba6db4359d 100644 --- a/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts @@ -6,8 +6,14 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface SymbolConstructor { + /** + * A method that is used to release resources held by an object. Called by the semantics of the `using` statement. + */ readonly dispose: unique symbol; + /** + * A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement. + */ readonly asyncDispose: unique symbol; } @@ -35,16 +41,66 @@ interface SuppressedErrorConstructor { declare var SuppressedError: SuppressedErrorConstructor; interface DisposableStack { + /** + * Returns a value indicating whether this stack has been disposed. + */ readonly disposed: boolean; + /** + * Disposes each resource in the stack in the reverse order that they were added. + */ dispose(): void; + /** + * Adds a disposable resource to the stack, returning the resource. + * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @returns The provided {@link value}. + */ use(value: T): T; + /** + * Adds a value and associated disposal callback as a resource to the stack. + * @param value The value to add. + * @param onDispose The callback to use in place of a `[Symbol.dispose]()` method. Will be invoked with `value` + * as the first parameter. + * @returns The provided {@link value}. + */ adopt(value: T, onDispose: (value: T) => void): T; + /** + * Adds a callback to be invoked when the stack is disposed. + */ defer(onDispose: () => void): void; + /** + * Move all resources out of this stack and into a new `DisposableStack`, and marks this stack as disposed. + * @example + * ```ts + * class C { + * #res1: Disposable; + * #res2: Disposable; + * #disposables: DisposableStack; + * constructor() { + * // stack will be disposed when exiting constructor for any reason + * using stack = new DisposableStack(); + * + * // get first resource + * this.#res1 = stack.use(getResource1()); + * + * // get second resource. If this fails, both `stack` and `#res1` will be disposed. + * this.#res2 = stack.use(getResource2()); + * + * // all operations succeeded, move resources out of `stack` so that they aren't disposed + * // when constructor exits + * this.#disposables = stack.move(); + * } + * + * [Symbol.dispose]() { + * this.#disposables.dispose(); + * } + * } + * ``` + */ move(): DisposableStack; [Symbol.dispose](): void; @@ -61,16 +117,66 @@ interface DisposableStackConstructor { declare var DisposableStack: DisposableStackConstructor; interface AsyncDisposableStack { + /** + * Returns a value indicating whether this stack has been disposed. + */ readonly disposed: boolean; + /** + * Disposes each resource in the stack in the reverse order that they were added. + */ disposeAsync(): Promise; + /** + * Adds a disposable resource to the stack, returning the resource. + * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @returns The provided {@link value}. + */ use(value: T): T; + /** + * Adds a value and associated disposal callback as a resource to the stack. + * @param value The value to add. + * @param onDisposeAsync The callback to use in place of a `[Symbol.asyncDispose]()` method. Will be invoked with `value` + * as the first parameter. + * @returns The provided {@link value}. + */ adopt(value: T, onDisposeAsync: (value: T) => PromiseLike | void): T; + /** + * Adds a callback to be invoked when the stack is disposed. + */ defer(onDisposeAsync: () => PromiseLike | void): void; + /** + * Move all resources out of this stack and into a new `DisposableStack`, and marks this stack as disposed. + * @example + * ```ts + * class C { + * #res1: Disposable; + * #res2: Disposable; + * #disposables: DisposableStack; + * constructor() { + * // stack will be disposed when exiting constructor for any reason + * using stack = new DisposableStack(); + * + * // get first resource + * this.#res1 = stack.use(getResource1()); + * + * // get second resource. If this fails, both `stack` and `#res1` will be disposed. + * this.#res2 = stack.use(getResource2()); + * + * // all operations succeeded, move resources out of `stack` so that they aren't disposed + * // when constructor exits + * this.#disposables = stack.move(); + * } + * + * [Symbol.dispose]() { + * this.#disposables.dispose(); + * } + * } + * ``` + */ move(): AsyncDisposableStack; [Symbol.asyncDispose](): Promise; diff --git a/packages/core-js-types/src/56/proposals/float16.d.ts b/packages/core-js-types/src/56/proposals/float16.d.ts index 2d4c49dcc3bc..5a667aeac6a3 100644 --- a/packages/core-js-types/src/56/proposals/float16.d.ts +++ b/packages/core-js-types/src/56/proposals/float16.d.ts @@ -6,11 +6,27 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface Math { + /** + * Returns the nearest half precision float representation of a number. + * @param x A numeric expression. + */ f16round(x: number): number; } interface DataView { + /** + * Gets the Float16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multibyte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. + */ getFloat16(byteOffset: number, littleEndian?: boolean): number; + /** + * Stores a Float16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written. + */ setFloat16(byteOffset: number, value: number, littleEndian?: boolean): void; } diff --git a/packages/core-js-types/src/56/proposals/function-demethodize.d.ts b/packages/core-js-types/src/56/proposals/function-demethodize.d.ts index 0c829273ed92..ba2239788c1f 100644 --- a/packages/core-js-types/src/56/proposals/function-demethodize.d.ts +++ b/packages/core-js-types/src/56/proposals/function-demethodize.d.ts @@ -1,5 +1,9 @@ // proposal stage: 0 // https://github.com/js-choi/proposal-function-demethodize interface Function { + /** + * Creates a function that calls the original with its first argument as `this` and the rest as regular arguments. + * @returns {Function} A new function that applies the original function with its `this` set to the first argument. + */ demethodize(this: (this: T, ...args: Args) => R): (thisArg: T, ...args: Args) => R; } diff --git a/packages/core-js-types/src/56/proposals/is-error.d.ts b/packages/core-js-types/src/56/proposals/is-error.d.ts index fc6a8d1fac03..6d4ca1586cd3 100644 --- a/packages/core-js-types/src/56/proposals/is-error.d.ts +++ b/packages/core-js-types/src/56/proposals/is-error.d.ts @@ -1,5 +1,13 @@ // proposal stage: 3 // https://github.com/tc39/proposal-is-error + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/esnext.error.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + interface ErrorConstructor { + /** + * Indicates whether the argument provided is a built-in Error instance or not. + */ isError(value: any): value is Error; } diff --git a/packages/core-js-types/src/56/proposals/iterator-chunking.d.ts b/packages/core-js-types/src/56/proposals/iterator-chunking.d.ts index e6e7b2ef25d3..f43c557491b5 100644 --- a/packages/core-js-types/src/56/proposals/iterator-chunking.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-chunking.d.ts @@ -5,8 +5,20 @@ import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; declare global { interface Iterator { + /** + * Yields arrays containing up to the specified number of elements + * chunked from the source iterator. + * @param chunkSize The maximum number of elements per chunk. Must be a positive integer. + * @returns An iterator yielding arrays of at most `chunkSize` elements from the source iterator. + */ chunks(chunkSize: number): CoreJSIteratorObject; + /** + * Yields overlapping arrays (windows) of the given size from the iterator. + * @param windowSize The size of each window. Must be a positive integer. + * @param undersized 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. + * @returns An iterator yielding arrays of the specified window size. + */ windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJSIteratorObject; } } diff --git a/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts index 492f2c0c4ba8..ad65d6bd6e6a 100644 --- a/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts @@ -9,34 +9,103 @@ import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; declare global { interface Iterator { + /** + * Creates an iterator whose values are the result of applying the callback to the values from this iterator. + * @param callbackfn A function that accepts up to two arguments to be used to transform values from the underlying iterator. + */ map(callbackfn: (value: T, index: number) => U): CoreJSIteratorObject; + /** + * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. + * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + */ filter(predicate: (value: T, index: number) => value is S): CoreJSIteratorObject; + /** + * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. + * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + */ filter(predicate: (value: T, index: number) => unknown): CoreJSIteratorObject; + /** + * Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached. + * @param limit The maximum number of values to yield. + */ take(limit: number): CoreJSIteratorObject; + /** + * Creates an iterator whose values are the values from this iterator after skipping the provided count. + * @param count The number of values to drop. + */ drop(count: number): CoreJSIteratorObject; + /** + * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. + * @param callback A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. + */ flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; // ts < 5.6 Iterable + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. + */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. + */ reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; + /** + * Creates a new array from the values yielded by this iterator. + */ toArray(): T[]; + /** + * Performs the specified action for each element in the iterator. + * @param callbackfn A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. + */ forEach(callbackfn: (value: T, index: number) => void): void; + /** + * Determines whether the specified callback function returns true for any element of this iterator. + * @param predicate A function that accepts up to two arguments. The `some` method calls + * the predicate function for each element in this iterator until the predicate returns a value + * true, or until the end of the iterator. + */ some(predicate: (value: T, index: number) => unknown): boolean; + /** + * Determines whether all the members of this iterator satisfy the specified test. + * @param predicate A function that accepts up to two arguments. The every method calls + * the predicate function for each element in this iterator until the predicate returns + * false, or until the end of this iterator. + */ every(predicate: (value: T, index: number) => unknown): boolean; + /** + * Returns the value of the first element in this iterator where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of this iterator, in + * 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. + */ find(predicate: (value: T, index: number) => value is S): S | undefined; find(predicate: (value: T, index: number) => unknown): T | undefined; } interface IteratorConstructor { + /** + * Creates a native iterator from an iterator or iterable object. + * Returns its input if the input already inherits from the built-in Iterator class. + * @param value An iterator or iterable object to convert a native iterator. + */ from(value: Iterator | Iterable): CoreJSIteratorObject; } diff --git a/packages/core-js-types/src/56/proposals/iterator-joint.d.ts b/packages/core-js-types/src/56/proposals/iterator-joint.d.ts index 28e9688e09e7..4e702cbaf437 100644 --- a/packages/core-js-types/src/56/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-joint.d.ts @@ -5,16 +5,42 @@ import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; declare global { type ZipOptions = { - mode?: "shortest" | "longest" | "strict"; + mode?: 'shortest' | 'longest' | 'strict'; padding?: object; }; interface IteratorConstructor { + /** + * Takes an iterable of iterables and produces an iterable of arrays where position corresponds + * to position in the passed iterable. + * @param iterables An Iterable of iterables. + * @param options Optional object: + * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; + * - padding: an object specifying padding values for each key when mode is 'longest'. + * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. + */ zip(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[T, U]>; + /** + * takes an object whose values are iterables and produces an iterable of objects where keys. + * correspond to keys in the passed object. + * @param iterables An Iterable of iterables. + * @param options Optional object: + * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; + * - padding: an object specifying padding values for each key when mode is 'longest'. + * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. + */ zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[number, T, U]>; - + /** + * takes an object whose values are iterables and produces an iterable of objects where keys. + * correspond to keys in the passed object. + * @param record An object of iterables. + * @param options Optional object: + * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; + * - padding: an object specifying padding values for each key when mode is 'longest'. + * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. + */ zipKeyed(record: Record>, options?: ZipOptions): CoreJSIteratorObject<[PropertyKey, T, U]>; } diff --git a/packages/core-js-types/src/56/proposals/iterator-range.d.ts b/packages/core-js-types/src/56/proposals/iterator-range.d.ts index 3d69aa141212..57a6a1602efd 100644 --- a/packages/core-js-types/src/56/proposals/iterator-range.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-range.d.ts @@ -9,6 +9,15 @@ declare global { }; interface IteratorConstructor { + /** + * Returns an iterator that generates a sequence of numbers or bigints within a range. + * @param start The starting value of the sequence. + * @param end The end value of the sequence (exclusive by default). + * @param options Optional object: + * - step: The difference between consecutive values (default is 1). + * - inclusive: If true, the end value is included in the range (default is false). + * @returns An iterator of numbers or bigints. + */ range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): IteratorObject } diff --git a/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts index b2c986fb1f20..fbdd20b87752 100644 --- a/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts @@ -5,6 +5,11 @@ import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; declare global { interface IteratorConstructor { + /** + * Creates an iterator that sequentially yields values from the provided iterables. + * @param iterators The iterables to concatenate. + * @returns An iterator yielding values from each input iterable in sequence. + */ concat(...iterators: Iterable[]): CoreJSIteratorObject; } diff --git a/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts index 4ae35de411e0..65d470bee47f 100644 --- a/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts +++ b/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts @@ -14,9 +14,26 @@ interface CoreJSRawJSON { } interface JSON { + /** + * Determines whether a value is a RawJSON object. + * @param value + */ isRawJSON(value: any): value is CoreJSRawJSON; + /** + * Parses a JSON string, allowing the reviver function to access + * the exact source text and position of each parsed value. + * @param text The JSON string to parse. + * @param reviver A function that transforms the results. It is called for each member of the object. + * The function receives three arguments: the key, the value, and a context object + * containing the source text and position. + * @returns Parsed JavaScript value. + */ parse(text: string, reviver?: (key: string, value: any, context: CoreJSReviverContext) => any): T; + /** + * Creates a RawJSON object from a JSON string. + * @param value + */ rawJSON(value: string): CoreJSRawJSON; } diff --git a/packages/core-js-types/src/56/proposals/map-upsert.d.ts b/packages/core-js-types/src/56/proposals/map-upsert.d.ts index 0884acf4d246..987e9a9d7a2f 100644 --- a/packages/core-js-types/src/56/proposals/map-upsert.d.ts +++ b/packages/core-js-types/src/56/proposals/map-upsert.d.ts @@ -2,13 +2,39 @@ // https://github.com/tc39/proposal-upsert interface Map { + /** + * Gets the value for the given key. If the key does not exist, inserts the provided value and returns it. + * @param key + * @param value + * @returns The existing or inserted value. + */ getOrInsert(key: K, value: V): V; + /** + * Gets the value for the given key. If the key does not exist, + * computes the value using the provided callback function, inserts it, and returns it. + * @param key + * @param callbackFn A function that computes the value to insert if the key does not exist. + * @returns The existing or computed and inserted value. + */ getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } interface WeakMap { + /** + * Gets the value for the given key. If the key does not exist, inserts the provided value and returns it. + * @param key + * @param value + * @returns The existing or inserted value. + */ getOrInsert(key: K, value: V): V; + /** + * Gets the value for the given key. If the key does not exist, + * computes the value using the provided callback function, inserts it, and returns it. + * @param key + * @param callbackFn A function that computes the value to insert if the key does not exist. + * @returns The existing or computed and inserted value. + */ getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } diff --git a/packages/core-js-types/src/56/proposals/math-sum.d.ts b/packages/core-js-types/src/56/proposals/math-sum.d.ts index b6086c79854c..abad11a68bbc 100644 --- a/packages/core-js-types/src/56/proposals/math-sum.d.ts +++ b/packages/core-js-types/src/56/proposals/math-sum.d.ts @@ -1,5 +1,10 @@ // proposal stage: 3 // https://github.com/tc39/proposal-math-sum interface Math { + /** + * Returns the sum of all given values. + * @param values + * @returns The sum of all given values. + */ sumPrecise(...values: number[]): number; } diff --git a/packages/core-js-types/src/56/proposals/number-clamp.d.ts b/packages/core-js-types/src/56/proposals/number-clamp.d.ts index d2c703e838cf..f57f14337100 100644 --- a/packages/core-js-types/src/56/proposals/number-clamp.d.ts +++ b/packages/core-js-types/src/56/proposals/number-clamp.d.ts @@ -2,5 +2,11 @@ // https://github.com/tc39/proposal-math-clamp interface Number { + /** + * Clamps the number within the inclusive lower and upper bounds. + * @param lower + * @param upper + * @returns The clamped number. + */ clamp(lower: number, upper: number): number; } diff --git a/packages/core-js-types/src/56/proposals/object-from-entries.d.ts b/packages/core-js-types/src/56/proposals/object-from-entries.d.ts index a4b46b1d81a3..30ce944a2a8a 100644 --- a/packages/core-js-types/src/56/proposals/object-from-entries.d.ts +++ b/packages/core-js-types/src/56/proposals/object-from-entries.d.ts @@ -6,7 +6,15 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface ObjectConstructor { + /** + * 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. + */ fromEntries(entries: Iterable): { [k: string]: 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. + */ fromEntries(entries: Iterable): any; } diff --git a/packages/core-js-types/src/56/proposals/object-get-own-property-descriptors.d.ts b/packages/core-js-types/src/56/proposals/object-get-own-property-descriptors.d.ts index 03381a3b031f..891d0ac337f4 100644 --- a/packages/core-js-types/src/56/proposals/object-get-own-property-descriptors.d.ts +++ b/packages/core-js-types/src/56/proposals/object-get-own-property-descriptors.d.ts @@ -6,6 +6,10 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface ObjectConstructor { + /** + * 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/packages/core-js-types/src/56/proposals/object-values-entries.d.ts b/packages/core-js-types/src/56/proposals/object-values-entries.d.ts index d2f4e35d18c2..7f9b6b14490d 100644 --- a/packages/core-js-types/src/56/proposals/object-values-entries.d.ts +++ b/packages/core-js-types/src/56/proposals/object-values-entries.d.ts @@ -6,9 +6,25 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface ObjectConstructor { + /** + * Returns an array of values of the enumerable own 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: { [s: string]: T; } | ArrayLike): T[]; + /** + * Returns an array of values of the enumerable own 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: {}): any[]; + /** + * Returns an array of key/values of the enumerable own 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: { [s: string]: T; } | ArrayLike): [string, T][]; + /** + * Returns an array of key/values of the enumerable own 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: {}): [string, any][]; } diff --git a/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts index db0d67f5c719..5b6994315aac 100644 --- a/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts +++ b/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts @@ -9,8 +9,20 @@ import { CoreJSPromiseSettledResult } from '../core-js-types/core-js-types'; declare global { interface PromiseConstructor { + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJSPromiseSettledResult>; }>; + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ allSettled(values: Iterable>): Promise>[]>; } } diff --git a/packages/core-js-types/src/56/proposals/promise-any.d.ts b/packages/core-js-types/src/56/proposals/promise-any.d.ts index 0470b9436996..80b35c56fa4e 100644 --- a/packages/core-js-types/src/56/proposals/promise-any.d.ts +++ b/packages/core-js-types/src/56/proposals/promise-any.d.ts @@ -6,8 +6,18 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface PromiseConstructor { + /** + * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. + * @param values An array or iterable of Promises. + * @returns A new Promise. + */ any(values: T): Promise>; + /** + * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. + * @param values An array or iterable of Promises. + * @returns A new Promise. + */ any(values: Iterable>): Promise>; } diff --git a/packages/core-js-types/src/56/proposals/promise-finally.d.ts b/packages/core-js-types/src/56/proposals/promise-finally.d.ts index 1936b256f060..f84a3c70209d 100644 --- a/packages/core-js-types/src/56/proposals/promise-finally.d.ts +++ b/packages/core-js-types/src/56/proposals/promise-finally.d.ts @@ -6,5 +6,11 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface Promise { + /** + * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The + * resolved value cannot be modified from the callback. + * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). + * @returns A Promise for the completion of the callback. + */ finally(onfinally?: (() => void) | undefined | null): Promise; } diff --git a/packages/core-js-types/src/56/proposals/promise-try.d.ts b/packages/core-js-types/src/56/proposals/promise-try.d.ts index 75ff6358f34f..4ccdc516313a 100644 --- a/packages/core-js-types/src/56/proposals/promise-try.d.ts +++ b/packages/core-js-types/src/56/proposals/promise-try.d.ts @@ -6,6 +6,19 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface PromiseConstructor { + /** + * Takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result + * in a Promise. + * + * @param callbackFn A function that is called synchronously. It can do anything: either return + * a value, throw an error, or return a promise. + * @param args Additional arguments, that will be passed to the callback. + * + * @returns A Promise that is: + * - Already fulfilled, if the callback synchronously returns a value. + * - Already rejected, if the callback synchronously throws an error. + * - Asynchronously fulfilled or rejected, if the callback returns a promise. + */ try(callbackFn: (...args: U) => T | PromiseLike, ...args: U): Promise>; } diff --git a/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts index 7a0a7efd7030..40f5a7088944 100644 --- a/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts +++ b/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts @@ -14,6 +14,14 @@ interface PromiseWithResolvers { } interface PromiseConstructor { + /** + * Creates a new Promise and returns it in an object, along with its resolve and reject functions. + * @returns An object with the properties `promise`, `resolve`, and `reject`. + * + * ```ts + * const { promise, resolve, reject } = Promise.withResolvers(); + * ``` + */ withResolvers(): PromiseWithResolvers; } diff --git a/packages/core-js-types/src/56/proposals/regexp-dotall-flag.d.ts b/packages/core-js-types/src/56/proposals/regexp-dotall-flag.d.ts index 931f2cedf514..08bf52331aa3 100644 --- a/packages/core-js-types/src/56/proposals/regexp-dotall-flag.d.ts +++ b/packages/core-js-types/src/56/proposals/regexp-dotall-flag.d.ts @@ -6,5 +6,9 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface RegExp { + /** + * Returns a Boolean value indicating the state of the dotAll flag (s) used with a regular expression. + * Default is false. Read-only. + */ readonly dotAll: boolean; } diff --git a/packages/core-js-types/src/56/proposals/regexp-escaping.d.ts b/packages/core-js-types/src/56/proposals/regexp-escaping.d.ts index e3526cfa3e88..2d22fea70fa8 100644 --- a/packages/core-js-types/src/56/proposals/regexp-escaping.d.ts +++ b/packages/core-js-types/src/56/proposals/regexp-escaping.d.ts @@ -2,6 +2,11 @@ // https://github.com/tc39/proposal-regex-escaping interface RegExpConstructor { + /** + * Escapes a string to be used in a regular expression. + * @param string + * @returns The escaped string. + */ escape(string: string): string; } diff --git a/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts index 15ebeac28dc1..edffdc89fcc4 100644 --- a/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts @@ -7,57 +7,113 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface String { + /** + * Returns a new String consisting of the single UTF-16 code unit located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): string | undefined; } interface Array { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): T | undefined; } interface ReadonlyArray { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): T | undefined; } interface Int8Array { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): number | undefined; } interface Uint8Array { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): number | undefined; } interface Uint8ClampedArray { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): number | undefined; } interface Int16Array { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): number | undefined; } interface Uint16Array { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): number | undefined; } interface Int32Array { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): number | undefined; } interface Uint32Array { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): number | undefined; } interface Float32Array { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): number | undefined; } interface Float64Array { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): number | undefined; } interface BigInt64Array { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): bigint | undefined; } interface BigUint64Array { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ at(index: number): bigint | undefined; } diff --git a/packages/core-js-types/src/56/proposals/set-methods.d.ts b/packages/core-js-types/src/56/proposals/set-methods.d.ts index 299278b564a6..6105faf431b6 100644 --- a/packages/core-js-types/src/56/proposals/set-methods.d.ts +++ b/packages/core-js-types/src/56/proposals/set-methods.d.ts @@ -7,42 +7,93 @@ declare global { interface ReadonlySetLike { + /** + * Despite its name, returns an iterator of the values in the set-like. + */ keys(): Iterator; + /** + * @returns a boolean indicating whether an element with the specified value exists in the set-like or not. + */ has(value: T): boolean; + /** + * @returns the number of (unique) elements in the set-like. + */ readonly size: number; } interface Set { + /** + * @returns a new Set containing all the elements in this Set and also all the elements in the argument. + */ union(other: ReadonlySetLike): Set; + /** + * @returns a new Set containing all the elements which are both in this Set and in the argument. + */ intersection(other: ReadonlySetLike): Set; + /** + * @returns a new Set containing all the elements in this Set which are not also in the argument. + */ difference(other: ReadonlySetLike): Set; + /** + * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. + */ symmetricDifference(other: ReadonlySetLike): Set; + /** + * @returns a boolean indicating whether all the elements in this Set are also in the argument. + */ isSubsetOf(other: ReadonlySetLike): boolean; + /** + * @returns a boolean indicating whether all the elements in the argument are also in this Set. + */ isSupersetOf(other: ReadonlySetLike): boolean; + /** + * @returns a boolean indicating whether this Set has no elements in common with the argument. + */ isDisjointFrom(other: ReadonlySetLike): boolean; } interface ReadonlySet { + /** + * @returns a new Set containing all the elements in this Set and also all the elements in the argument. + */ union(other: ReadonlySetLike): Set; + /** + * @returns a new Set containing all the elements which are both in this Set and in the argument. + */ intersection(other: ReadonlySetLike): Set; + /** + * @returns a new Set containing all the elements in this Set which are not also in the argument. + */ difference(other: ReadonlySetLike): Set; + /** + * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. + */ symmetricDifference(other: ReadonlySetLike): Set; + /** + * @returns a boolean indicating whether all the elements in this Set are also in the argument. + */ isSubsetOf(other: ReadonlySetLike): boolean; + /** + * @returns a boolean indicating whether all the elements in the argument are also in this Set. + */ isSupersetOf(other: ReadonlySetLike): boolean; + /** + * @returns a boolean indicating whether this Set has no elements in common with the argument. + */ isDisjointFrom(other: ReadonlySetLike): boolean; } } diff --git a/packages/core-js-types/src/56/proposals/string-cooked.d.ts b/packages/core-js-types/src/56/proposals/string-cooked.d.ts index 8968780a6054..a04ec91d14f6 100644 --- a/packages/core-js-types/src/56/proposals/string-cooked.d.ts +++ b/packages/core-js-types/src/56/proposals/string-cooked.d.ts @@ -2,7 +2,18 @@ // https://github.com/tc39/proposal-string-cooked interface StringConstructor { + /** + * Processes a template literal, interpreting escape sequences. + * @param template Array of string literals. + * @param substitutions The substitutions for the template literal. + * @returns The processed string with escape sequences interpreted. + */ cooked(template: readonly string[], ...substitutions: any[]): string; - + /** + * Processes a template literal, interpreting escape sequences. + * @param template The template literal to process. + * @param substitutions The substitutions for the template literal. + * @returns The processed string with escape sequences interpreted. + */ cooked(template: string, ...substitutions: any[]): string; } diff --git a/packages/core-js-types/src/56/proposals/string-dedent.d.ts b/packages/core-js-types/src/56/proposals/string-dedent.d.ts index 6486f012be0f..a0c4d9877b7d 100644 --- a/packages/core-js-types/src/56/proposals/string-dedent.d.ts +++ b/packages/core-js-types/src/56/proposals/string-dedent.d.ts @@ -2,5 +2,12 @@ // https://github.com/tc39/proposal-string-dedent interface StringConstructor { + /** + * Template tag that removes common leading whitespace from every line in the resulting string, + * preserving relative indentation and blank lines. + * @param strings The template strings array. + * @param values Values to be interpolated into the template string. + * @returns The dedented string. + */ dedent(strings: TemplateStringsArray, ...values: any[]): string; } diff --git a/packages/core-js-types/src/56/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/56/proposals/string-left-right-trim.d.ts index cbd4ce89a795..d999e437c433 100644 --- a/packages/core-js-types/src/56/proposals/string-left-right-trim.d.ts +++ b/packages/core-js-types/src/56/proposals/string-left-right-trim.d.ts @@ -6,11 +6,19 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface String { + /** Removes the trailing white space and line terminator characters from a string. */ trimEnd(): string; + /** Removes the leading white space and line terminator characters from a string. */ trimStart(): string; + /** + * Removes the leading white space and line terminator characters from a string. + */ trimLeft(): string; + /** + * Removes the trailing white space and line terminator characters from a string. + */ trimRight(): string; } diff --git a/packages/core-js-types/src/56/proposals/string-match-all.d.ts b/packages/core-js-types/src/56/proposals/string-match-all.d.ts index 7ff2b331433d..1c872989e57a 100644 --- a/packages/core-js-types/src/56/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/56/proposals/string-match-all.d.ts @@ -11,6 +11,11 @@ declare global { } interface String { + /** + * Matches a string with a regular expression, and returns an iterable of matches + * containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ matchAll(regexp: RegExp): RegExpStringIterator; } diff --git a/packages/core-js-types/src/56/proposals/string-padding.d.ts b/packages/core-js-types/src/56/proposals/string-padding.d.ts index c4e9a68da923..9fcb6eb5062f 100644 --- a/packages/core-js-types/src/56/proposals/string-padding.d.ts +++ b/packages/core-js-types/src/56/proposals/string-padding.d.ts @@ -6,7 +6,29 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface String { + /** + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the start (left) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ padStart(maxLength: number, fillString?: string): string; + /** + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the end (right) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ padEnd(maxLength: number, fillString?: string): string; } diff --git a/packages/core-js-types/src/56/proposals/string-replace-all.d.ts b/packages/core-js-types/src/56/proposals/string-replace-all.d.ts index 9fa6276b406b..3e39084839c9 100644 --- a/packages/core-js-types/src/56/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/56/proposals/string-replace-all.d.ts @@ -2,13 +2,23 @@ // https://github.com/tc39/proposal-string-replaceall // For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts +// https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/es2021.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt declare global { interface String { + /** + * Replace all instances of a substring in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ replaceAll(searchValue: string | RegExp, replaceValue: string): string; + /** + * Replace all instances of a substring in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replacer A function that returns the replacement text. + */ replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } } diff --git a/packages/core-js-types/src/56/proposals/symbol-description.d.ts b/packages/core-js-types/src/56/proposals/symbol-description.d.ts index 6d0927220518..5aa1e41485c5 100644 --- a/packages/core-js-types/src/56/proposals/symbol-description.d.ts +++ b/packages/core-js-types/src/56/proposals/symbol-description.d.ts @@ -6,5 +6,8 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface Symbol { + /** + * Expose the [[Description]] internal slot of a symbol directly. + */ readonly description: string | undefined; } diff --git a/packages/core-js-types/src/56/proposals/symbol-predicates.d.ts b/packages/core-js-types/src/56/proposals/symbol-predicates.d.ts index 165818730057..cb97a1c2d394 100644 --- a/packages/core-js-types/src/56/proposals/symbol-predicates.d.ts +++ b/packages/core-js-types/src/56/proposals/symbol-predicates.d.ts @@ -2,7 +2,15 @@ // https://github.com/tc39/proposal-symbol-predicates interface SymbolConstructor { + /** + * Determines whether the given value is a registered symbol. + * @param value + */ isRegisteredSymbol(value: any): boolean; + /** + * Determines whether the given value is a well-known symbol. + * @param value + */ isWellKnownSymbol(value: any): boolean; } diff --git a/packages/core-js-types/src/56/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/56/proposals/well-formed-unicode-strings.d.ts index 3f4c2caf5e4d..d8bd59d73d03 100644 --- a/packages/core-js-types/src/56/proposals/well-formed-unicode-strings.d.ts +++ b/packages/core-js-types/src/56/proposals/well-formed-unicode-strings.d.ts @@ -6,7 +6,13 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface String { + /** + * Returns true if all leading surrogates and trailing surrogates appear paired and in order. + */ isWellFormed(): boolean; + /** + * Returns a string where all lone or out-of-order surrogates have been replaced by the Unicode replacement character (U+FFFD). + */ toWellFormed(): string; } From 9f70ea33ef6b68bca97e2eaa233e613bcff6e8a2 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 14 Nov 2025 17:53:44 +0700 Subject: [PATCH 061/315] Test core-js types with environment types --- .gitignore | 1 + tests/type-definitions/package-lock.json | 34 +------------ tests/type-definitions/package.json | 6 +-- tests/type-definitions/runner.mjs | 62 +++++++++++++++++++----- 4 files changed, 54 insertions(+), 49 deletions(-) diff --git a/.gitignore b/.gitignore index 564aea916b1b..3299a2f4d86f 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,7 @@ node_modules/ /tests/compat/compat-data.js /tests/unit-global/index.js /tests/unit-pure/index.js +/tests/type-definitions/tmp/ /website/templates/ /website/dist/ /website/src/public/ diff --git a/tests/type-definitions/package-lock.json b/tests/type-definitions/package-lock.json index fbfbfd5d2474..d36672ed25f6 100644 --- a/tests/type-definitions/package-lock.json +++ b/tests/type-definitions/package-lock.json @@ -4,39 +4,7 @@ "requires": true, "packages": { "": { - "name": "tests/type-definitions", - "devDependencies": { - "@core-js/types": "../../packages/core-js-types/", - "typescript": "^5.9.3" - } - }, - "../../packages/core-js-types": { - "name": "@core-js/types", - "version": "4.0.0-alpha.0", - "dev": true, - "license": "SEE LICENSE IN LICENSE.md", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, - "node_modules/@core-js/types": { - "resolved": "../../packages/core-js-types", - "link": true - }, - "node_modules/typescript": { - "version": "5.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", - "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } + "name": "tests/type-definitions" } } } diff --git a/tests/type-definitions/package.json b/tests/type-definitions/package.json index 33e48397afbe..fcf49f09a0c2 100644 --- a/tests/type-definitions/package.json +++ b/tests/type-definitions/package.json @@ -1,7 +1,3 @@ { - "name": "tests/type-definitions", - "devDependencies": { - "@core-js/types": "../../packages/core-js-types/", - "typescript": "^5.9.3" - } + "name": "tests/type-definitions" } diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 36f9bf81c0d8..a98ea4c19faa 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -1,7 +1,8 @@ import os from 'node:os'; +import { fs } from 'zx'; -await $`tsc`; -await $`tsc -p tsconfig.require.json`; +const { mkdir, writeJson } = fs; +const TMP_DIR = './tmp/'; const targets = [ 'esnext', @@ -19,8 +20,10 @@ const envs = [ null, '@types/node@24', '@types/node@20', - // '@types/node@18', - '@types/bun@latest', + '@types/node@18', + '@types/node@16', + // '@types/node@15', // fails + // '@types/bun@latest', // fails ]; const types = [ 'global', @@ -31,29 +34,40 @@ const libs = [ 'dom', ]; +let tested = 0; +let failed = 0; + +const getEnvPath = function (env) { + if (!env) return null; + return path.join(TMP_DIR, env.replaceAll('/', '-').replaceAll('@', '')); +}; + const runTestsOnEnv = async function ({ typeScriptVersion, target, type, env, lib }) { $.verbose = false; - const command = `npx -p typescript@${ typeScriptVersion }${ env ? ` -p ${ env }` : '' } tsc -p proposals/${ type }/tsconfig.json --target ${ target }${ lib ? ` --lib ${ lib }` : '' }`; + const envLibName = env ? env.substring(0, env.lastIndexOf('@')) : ''; + const command = `npx -p typescript@${ typeScriptVersion }${ env ? ` -p ${ env }` : '' } ` + + `tsc -p proposals/${ type }/tsconfig.json --target ${ target }${ lib ? ` --lib ${ target },${ lib }` : '' }${ env ? ` --types @core-js/types,${ envLibName }` : '' }`; echo(`$ ${ command }`); try { if (env && lib) { - await $`npx -p typescript@${ typeScriptVersion } -p ${ env } tsc -p proposals/${ type }/tsconfig.json --target ${ target } --lib ${ target },${ lib }`.quiet(); + await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target },${ lib } --types @core-js/types,${ envLibName }`.quiet(); } else if (env) { - await $`npx -p typescript@${ typeScriptVersion } -p ${ env } tsc -p proposals/${ type }/tsconfig.json --target ${ target }`.quiet(); + await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --types @core-js/types,${ envLibName }`.quiet(); } else if (lib) { await $`npx -p typescript@${ typeScriptVersion } tsc -p proposals/${ type }/tsconfig.json --target ${ target } --lib ${ target },${ lib }`.quiet(); } else { await $`npx -p typescript@${ typeScriptVersion } tsc -p proposals/${ type }/tsconfig.json --target ${ target }`.quiet(); } echo(chalk.green(`$ ${ command }`)); + tested++; } catch (error) { + tested++; + failed++; echo(`$ ${ chalk.red(command) }\n ${ error }`); - // eslint-disable-next-line node/no-process-exit -- it's needed here - process.exit(1); } }; -async function runLimited(configs, limit) { +const runLimited = async function (configs, limit) { let i = 0; async function worker() { while (i < configs.length) { @@ -62,7 +76,7 @@ async function runLimited(configs, limit) { } } await Promise.all(Array.from({ length: limit }, worker)); -} +}; const taskConfigs = []; for (const type of types) { @@ -77,8 +91,34 @@ for (const type of types) { } } +const clearTmpDir = async function () { + await $`rm -rf ${ TMP_DIR }`; +}; + +const prepareEnvironment = async function (environments, coreJsTypes) { + await clearTmpDir(); + for (const env of environments) { + if (!env) continue; + const tmpEnvDir = getEnvPath(env); + await mkdir(tmpEnvDir, { recursive: true }); + await $({ cwd: tmpEnvDir })`npm init -y > /dev/null 2>&1`; + await $({ cwd: tmpEnvDir })`npm install ${ env }`; + for (const type of coreJsTypes) { + await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.json`), { + extends: '../../tsconfig.json', + include: [`../../proposals/${ type }/*.ts`], + }); + } + } +}; + +await $`npx -p typescript@5.9 tsc`; +await $`npx -p typescript@5.9 -p @types/node@24 tsc -p tsconfig.require.json`; const numCPUs = os.cpus().length; +await prepareEnvironment(envs, types); await runLimited(taskConfigs, Math.max(numCPUs - 1, 1)); +await clearTmpDir(); +echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); // await $`tsc -p proposals/global/tsconfig.esnext.json`; // await $`tsc -p proposals/global/tsconfig.es2023.json`; From 07fc048a29ba54e8dfde6055ecace2e47da259f0 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 14 Nov 2025 22:14:08 +0700 Subject: [PATCH 062/315] Type definition test dir refactoring & add atob test --- .../accessible-object-hasownproperty.test.ts | 0 .../proposals}/array-buffer-base64.test.ts | 0 .../proposals}/array-buffer-transfer.test.ts | 0 .../proposals}/array-filtering.test.ts | 0 .../proposals}/array-find-from-last.test.ts | 0 .../proposals}/array-flat-map.test.ts | 0 .../proposals}/array-from-async.test.ts | 0 .../proposals}/array-grouping.test.ts | 0 .../proposals}/array-includes.test.ts | 0 .../proposals}/array-is-template-object.test.ts | 0 .../global => global/proposals}/array-unique.test.ts | 0 .../proposals}/async-iteration.test.ts | 0 .../proposals}/async-iterator-helper.test.ts | 0 .../proposals}/await-dictionary.test.ts | 0 .../proposals}/change-array-by-copy.test.ts | 0 .../proposals}/collection-of-from.test.ts | 0 .../data-view-get-set-uint8-clamped.test.ts | 0 .../proposals}/decorator-metadata.test.ts | 0 .../global => global/proposals}/error-cause.test.ts | 0 .../proposals}/explicit-resource-management.test.ts | 0 .../global => global/proposals}/extractors.test.ts | 0 .../global => global/proposals}/float16.test.ts | 0 .../proposals}/function-demethodize.test.ts | 0 .../global => global/proposals}/immediate.test.ts | 0 .../global => global/proposals}/is-error.test.ts | 0 .../proposals}/iterator-chunking.test.ts | 0 .../proposals}/iterator-helpers.test.ts | 0 .../proposals}/iterator-joint.test.ts | 0 .../proposals}/iterator-range.test.ts | 0 .../proposals}/iterator-sequencing.test.ts | 0 .../proposals}/json-parse-with-source.test.ts | 0 .../global => global/proposals}/map-upsert.test.ts | 0 .../global => global/proposals}/math-sum.test.ts | 0 .../global => global/proposals}/number-clamp.test.ts | 0 .../proposals}/object-from-entries.test.ts | 0 .../object-get-own-property-descriptors.test.ts | 0 .../proposals}/object-values-entries.test.ts | 0 .../proposals}/pattern-matching.test.ts | 0 .../proposals}/promise-all-settled.test.ts | 0 .../global => global/proposals}/promise-any.test.ts | 0 .../proposals}/promise-finally.test.ts | 0 .../global => global/proposals}/promise-try.test.ts | 0 .../proposals}/promise-with-resolvers.test.ts | 0 .../proposals}/regexp-dotall-flag.test.ts | 0 .../proposals}/regexp-escaping.test.ts | 0 .../proposals}/regexp-named-groups.test.ts | 0 .../proposals}/relative-indexing-method.test.ts | 0 .../global => global/proposals}/set-methods.test.ts | 0 .../global => global/proposals}/string-cooked.test.ts | 0 .../global => global/proposals}/string-dedent.test.ts | 0 .../proposals}/string-left-right-trim.test.ts | 0 .../proposals}/string-match-all.test.ts | 0 .../proposals}/string-padding.test.ts | 0 .../proposals}/string-replace-all.test.ts | 0 .../proposals}/symbol-description.test.ts | 0 .../proposals}/symbol-predicates.test.ts | 0 .../proposals}/well-formed-unicode-strings.test.ts | 0 tests/type-definitions/global/tsconfig.json | 4 ++++ tests/type-definitions/global/web/atob.global.test.ts | 11 +++++++++++ tests/type-definitions/proposals/global/tsconfig.json | 4 ---- tests/type-definitions/proposals/pure/tsconfig.json | 4 ---- .../accessible-object-hasownproperty.test.ts | 0 .../pure => pure/proposals}/array-filtering.test.ts | 0 .../proposals}/array-find-from-last.test.ts | 0 .../pure => pure/proposals}/array-flat-map.test.ts | 0 .../pure => pure/proposals}/array-grouping.test.ts | 0 .../pure => pure/proposals}/array-includes.test.ts | 0 .../proposals}/array-is-template-object.test.ts | 0 .../pure => pure/proposals}/array-unique.test.ts | 0 .../pure => pure/proposals}/async-iteration.test.ts | 0 .../proposals}/async-iterator-helper.test.ts | 0 .../pure => pure/proposals}/await-dictionary.test.ts | 0 .../proposals}/change-array-by-copy.test.ts | 0 .../proposals}/collection-of-from.test.ts | 0 .../proposals}/decorator-metadata.test.ts | 0 .../proposals}/explicit-resource-management.test.ts | 0 .../pure => pure/proposals}/extractors.test.ts | 0 .../pure => pure/proposals}/float16.test.ts | 0 .../proposals}/function-demethodize.test.ts | 0 .../pure => pure/proposals}/immediate.test.ts | 0 .../pure => pure/proposals}/is-error.test.ts | 0 .../pure => pure/proposals}/iterator-chunking.test.ts | 0 .../pure => pure/proposals}/iterator-helpers.test.ts | 0 .../pure => pure/proposals}/iterator-joint.test.ts | 0 .../pure => pure/proposals}/iterator-range.test.ts | 0 .../proposals}/iterator-sequencing.test.ts | 0 .../proposals}/json-parse-with-source.test.ts | 0 .../pure => pure/proposals}/map-upsert.test.ts | 0 .../pure => pure/proposals}/math-sum.test.ts | 0 .../pure => pure/proposals}/number-clamp.test.ts | 0 .../proposals}/object-from-entries.test.ts | 0 .../object-get-own-property-descriptors.test.ts | 0 .../proposals}/object-values-entries.test.ts | 0 .../pure => pure/proposals}/pattern-matching.test.ts | 0 .../proposals}/promise-all-settled.test.ts | 0 .../pure => pure/proposals}/promise-any.test.ts | 0 .../pure => pure/proposals}/promise-finally.test.ts | 0 .../pure => pure/proposals}/promise-try.test.ts | 0 .../proposals}/promise-with-resolvers.test.ts | 0 .../pure => pure/proposals}/regexp-escaping.test.ts | 0 .../proposals}/relative-indexing-method.test.ts | 0 .../pure => pure/proposals}/set-methods.test.ts | 0 .../pure => pure/proposals}/string-cooked.test.ts | 0 .../pure => pure/proposals}/string-dedent.test.ts | 0 .../proposals}/string-left-right-trim.test.ts | 0 .../pure => pure/proposals}/string-match-all.test.ts | 0 .../pure => pure/proposals}/string-padding.test.ts | 0 .../proposals}/string-replace-all.test.ts | 0 .../pure => pure/proposals}/symbol-predicates.test.ts | 0 .../proposals}/well-formed-unicode-strings.test.ts | 0 tests/type-definitions/pure/tsconfig.json | 4 ++++ tests/type-definitions/pure/web/atob.pure.test.ts | 10 ++++++++++ tests/type-definitions/runner.mjs | 8 ++++---- 113 files changed, 33 insertions(+), 12 deletions(-) rename tests/type-definitions/{proposals/global => global/proposals}/accessible-object-hasownproperty.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/array-buffer-base64.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/array-buffer-transfer.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/array-filtering.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/array-find-from-last.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/array-flat-map.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/array-from-async.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/array-grouping.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/array-includes.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/array-is-template-object.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/array-unique.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/async-iteration.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/async-iterator-helper.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/await-dictionary.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/change-array-by-copy.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/collection-of-from.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/data-view-get-set-uint8-clamped.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/decorator-metadata.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/error-cause.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/explicit-resource-management.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/extractors.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/float16.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/function-demethodize.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/immediate.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/is-error.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/iterator-chunking.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/iterator-helpers.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/iterator-joint.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/iterator-range.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/iterator-sequencing.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/json-parse-with-source.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/map-upsert.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/math-sum.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/number-clamp.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/object-from-entries.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/object-get-own-property-descriptors.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/object-values-entries.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/pattern-matching.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/promise-all-settled.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/promise-any.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/promise-finally.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/promise-try.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/promise-with-resolvers.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/regexp-dotall-flag.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/regexp-escaping.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/regexp-named-groups.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/relative-indexing-method.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/set-methods.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/string-cooked.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/string-dedent.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/string-left-right-trim.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/string-match-all.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/string-padding.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/string-replace-all.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/symbol-description.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/symbol-predicates.test.ts (100%) rename tests/type-definitions/{proposals/global => global/proposals}/well-formed-unicode-strings.test.ts (100%) create mode 100644 tests/type-definitions/global/tsconfig.json create mode 100644 tests/type-definitions/global/web/atob.global.test.ts delete mode 100644 tests/type-definitions/proposals/global/tsconfig.json delete mode 100644 tests/type-definitions/proposals/pure/tsconfig.json rename tests/type-definitions/{proposals/pure => pure/proposals}/accessible-object-hasownproperty.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/array-filtering.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/array-find-from-last.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/array-flat-map.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/array-grouping.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/array-includes.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/array-is-template-object.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/array-unique.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/async-iteration.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/async-iterator-helper.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/await-dictionary.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/change-array-by-copy.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/collection-of-from.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/decorator-metadata.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/explicit-resource-management.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/extractors.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/float16.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/function-demethodize.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/immediate.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/is-error.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/iterator-chunking.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/iterator-helpers.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/iterator-joint.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/iterator-range.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/iterator-sequencing.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/json-parse-with-source.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/map-upsert.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/math-sum.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/number-clamp.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/object-from-entries.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/object-get-own-property-descriptors.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/object-values-entries.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/pattern-matching.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/promise-all-settled.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/promise-any.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/promise-finally.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/promise-try.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/promise-with-resolvers.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/regexp-escaping.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/relative-indexing-method.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/set-methods.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/string-cooked.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/string-dedent.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/string-left-right-trim.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/string-match-all.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/string-padding.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/string-replace-all.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/symbol-predicates.test.ts (100%) rename tests/type-definitions/{proposals/pure => pure/proposals}/well-formed-unicode-strings.test.ts (100%) create mode 100644 tests/type-definitions/pure/tsconfig.json create mode 100644 tests/type-definitions/pure/web/atob.pure.test.ts diff --git a/tests/type-definitions/proposals/global/accessible-object-hasownproperty.test.ts b/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/accessible-object-hasownproperty.test.ts rename to tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts diff --git a/tests/type-definitions/proposals/global/array-buffer-base64.test.ts b/tests/type-definitions/global/proposals/array-buffer-base64.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/array-buffer-base64.test.ts rename to tests/type-definitions/global/proposals/array-buffer-base64.test.ts diff --git a/tests/type-definitions/proposals/global/array-buffer-transfer.test.ts b/tests/type-definitions/global/proposals/array-buffer-transfer.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/array-buffer-transfer.test.ts rename to tests/type-definitions/global/proposals/array-buffer-transfer.test.ts diff --git a/tests/type-definitions/proposals/global/array-filtering.test.ts b/tests/type-definitions/global/proposals/array-filtering.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/array-filtering.test.ts rename to tests/type-definitions/global/proposals/array-filtering.test.ts diff --git a/tests/type-definitions/proposals/global/array-find-from-last.test.ts b/tests/type-definitions/global/proposals/array-find-from-last.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/array-find-from-last.test.ts rename to tests/type-definitions/global/proposals/array-find-from-last.test.ts diff --git a/tests/type-definitions/proposals/global/array-flat-map.test.ts b/tests/type-definitions/global/proposals/array-flat-map.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/array-flat-map.test.ts rename to tests/type-definitions/global/proposals/array-flat-map.test.ts diff --git a/tests/type-definitions/proposals/global/array-from-async.test.ts b/tests/type-definitions/global/proposals/array-from-async.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/array-from-async.test.ts rename to tests/type-definitions/global/proposals/array-from-async.test.ts diff --git a/tests/type-definitions/proposals/global/array-grouping.test.ts b/tests/type-definitions/global/proposals/array-grouping.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/array-grouping.test.ts rename to tests/type-definitions/global/proposals/array-grouping.test.ts diff --git a/tests/type-definitions/proposals/global/array-includes.test.ts b/tests/type-definitions/global/proposals/array-includes.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/array-includes.test.ts rename to tests/type-definitions/global/proposals/array-includes.test.ts diff --git a/tests/type-definitions/proposals/global/array-is-template-object.test.ts b/tests/type-definitions/global/proposals/array-is-template-object.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/array-is-template-object.test.ts rename to tests/type-definitions/global/proposals/array-is-template-object.test.ts diff --git a/tests/type-definitions/proposals/global/array-unique.test.ts b/tests/type-definitions/global/proposals/array-unique.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/array-unique.test.ts rename to tests/type-definitions/global/proposals/array-unique.test.ts diff --git a/tests/type-definitions/proposals/global/async-iteration.test.ts b/tests/type-definitions/global/proposals/async-iteration.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/async-iteration.test.ts rename to tests/type-definitions/global/proposals/async-iteration.test.ts diff --git a/tests/type-definitions/proposals/global/async-iterator-helper.test.ts b/tests/type-definitions/global/proposals/async-iterator-helper.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/async-iterator-helper.test.ts rename to tests/type-definitions/global/proposals/async-iterator-helper.test.ts diff --git a/tests/type-definitions/proposals/global/await-dictionary.test.ts b/tests/type-definitions/global/proposals/await-dictionary.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/await-dictionary.test.ts rename to tests/type-definitions/global/proposals/await-dictionary.test.ts diff --git a/tests/type-definitions/proposals/global/change-array-by-copy.test.ts b/tests/type-definitions/global/proposals/change-array-by-copy.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/change-array-by-copy.test.ts rename to tests/type-definitions/global/proposals/change-array-by-copy.test.ts diff --git a/tests/type-definitions/proposals/global/collection-of-from.test.ts b/tests/type-definitions/global/proposals/collection-of-from.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/collection-of-from.test.ts rename to tests/type-definitions/global/proposals/collection-of-from.test.ts diff --git a/tests/type-definitions/proposals/global/data-view-get-set-uint8-clamped.test.ts b/tests/type-definitions/global/proposals/data-view-get-set-uint8-clamped.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/data-view-get-set-uint8-clamped.test.ts rename to tests/type-definitions/global/proposals/data-view-get-set-uint8-clamped.test.ts diff --git a/tests/type-definitions/proposals/global/decorator-metadata.test.ts b/tests/type-definitions/global/proposals/decorator-metadata.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/decorator-metadata.test.ts rename to tests/type-definitions/global/proposals/decorator-metadata.test.ts diff --git a/tests/type-definitions/proposals/global/error-cause.test.ts b/tests/type-definitions/global/proposals/error-cause.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/error-cause.test.ts rename to tests/type-definitions/global/proposals/error-cause.test.ts diff --git a/tests/type-definitions/proposals/global/explicit-resource-management.test.ts b/tests/type-definitions/global/proposals/explicit-resource-management.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/explicit-resource-management.test.ts rename to tests/type-definitions/global/proposals/explicit-resource-management.test.ts diff --git a/tests/type-definitions/proposals/global/extractors.test.ts b/tests/type-definitions/global/proposals/extractors.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/extractors.test.ts rename to tests/type-definitions/global/proposals/extractors.test.ts diff --git a/tests/type-definitions/proposals/global/float16.test.ts b/tests/type-definitions/global/proposals/float16.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/float16.test.ts rename to tests/type-definitions/global/proposals/float16.test.ts diff --git a/tests/type-definitions/proposals/global/function-demethodize.test.ts b/tests/type-definitions/global/proposals/function-demethodize.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/function-demethodize.test.ts rename to tests/type-definitions/global/proposals/function-demethodize.test.ts diff --git a/tests/type-definitions/proposals/global/immediate.test.ts b/tests/type-definitions/global/proposals/immediate.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/immediate.test.ts rename to tests/type-definitions/global/proposals/immediate.test.ts diff --git a/tests/type-definitions/proposals/global/is-error.test.ts b/tests/type-definitions/global/proposals/is-error.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/is-error.test.ts rename to tests/type-definitions/global/proposals/is-error.test.ts diff --git a/tests/type-definitions/proposals/global/iterator-chunking.test.ts b/tests/type-definitions/global/proposals/iterator-chunking.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/iterator-chunking.test.ts rename to tests/type-definitions/global/proposals/iterator-chunking.test.ts diff --git a/tests/type-definitions/proposals/global/iterator-helpers.test.ts b/tests/type-definitions/global/proposals/iterator-helpers.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/iterator-helpers.test.ts rename to tests/type-definitions/global/proposals/iterator-helpers.test.ts diff --git a/tests/type-definitions/proposals/global/iterator-joint.test.ts b/tests/type-definitions/global/proposals/iterator-joint.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/iterator-joint.test.ts rename to tests/type-definitions/global/proposals/iterator-joint.test.ts diff --git a/tests/type-definitions/proposals/global/iterator-range.test.ts b/tests/type-definitions/global/proposals/iterator-range.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/iterator-range.test.ts rename to tests/type-definitions/global/proposals/iterator-range.test.ts diff --git a/tests/type-definitions/proposals/global/iterator-sequencing.test.ts b/tests/type-definitions/global/proposals/iterator-sequencing.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/iterator-sequencing.test.ts rename to tests/type-definitions/global/proposals/iterator-sequencing.test.ts diff --git a/tests/type-definitions/proposals/global/json-parse-with-source.test.ts b/tests/type-definitions/global/proposals/json-parse-with-source.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/json-parse-with-source.test.ts rename to tests/type-definitions/global/proposals/json-parse-with-source.test.ts diff --git a/tests/type-definitions/proposals/global/map-upsert.test.ts b/tests/type-definitions/global/proposals/map-upsert.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/map-upsert.test.ts rename to tests/type-definitions/global/proposals/map-upsert.test.ts diff --git a/tests/type-definitions/proposals/global/math-sum.test.ts b/tests/type-definitions/global/proposals/math-sum.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/math-sum.test.ts rename to tests/type-definitions/global/proposals/math-sum.test.ts diff --git a/tests/type-definitions/proposals/global/number-clamp.test.ts b/tests/type-definitions/global/proposals/number-clamp.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/number-clamp.test.ts rename to tests/type-definitions/global/proposals/number-clamp.test.ts diff --git a/tests/type-definitions/proposals/global/object-from-entries.test.ts b/tests/type-definitions/global/proposals/object-from-entries.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/object-from-entries.test.ts rename to tests/type-definitions/global/proposals/object-from-entries.test.ts diff --git a/tests/type-definitions/proposals/global/object-get-own-property-descriptors.test.ts b/tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/object-get-own-property-descriptors.test.ts rename to tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts diff --git a/tests/type-definitions/proposals/global/object-values-entries.test.ts b/tests/type-definitions/global/proposals/object-values-entries.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/object-values-entries.test.ts rename to tests/type-definitions/global/proposals/object-values-entries.test.ts diff --git a/tests/type-definitions/proposals/global/pattern-matching.test.ts b/tests/type-definitions/global/proposals/pattern-matching.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/pattern-matching.test.ts rename to tests/type-definitions/global/proposals/pattern-matching.test.ts diff --git a/tests/type-definitions/proposals/global/promise-all-settled.test.ts b/tests/type-definitions/global/proposals/promise-all-settled.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/promise-all-settled.test.ts rename to tests/type-definitions/global/proposals/promise-all-settled.test.ts diff --git a/tests/type-definitions/proposals/global/promise-any.test.ts b/tests/type-definitions/global/proposals/promise-any.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/promise-any.test.ts rename to tests/type-definitions/global/proposals/promise-any.test.ts diff --git a/tests/type-definitions/proposals/global/promise-finally.test.ts b/tests/type-definitions/global/proposals/promise-finally.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/promise-finally.test.ts rename to tests/type-definitions/global/proposals/promise-finally.test.ts diff --git a/tests/type-definitions/proposals/global/promise-try.test.ts b/tests/type-definitions/global/proposals/promise-try.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/promise-try.test.ts rename to tests/type-definitions/global/proposals/promise-try.test.ts diff --git a/tests/type-definitions/proposals/global/promise-with-resolvers.test.ts b/tests/type-definitions/global/proposals/promise-with-resolvers.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/promise-with-resolvers.test.ts rename to tests/type-definitions/global/proposals/promise-with-resolvers.test.ts diff --git a/tests/type-definitions/proposals/global/regexp-dotall-flag.test.ts b/tests/type-definitions/global/proposals/regexp-dotall-flag.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/regexp-dotall-flag.test.ts rename to tests/type-definitions/global/proposals/regexp-dotall-flag.test.ts diff --git a/tests/type-definitions/proposals/global/regexp-escaping.test.ts b/tests/type-definitions/global/proposals/regexp-escaping.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/regexp-escaping.test.ts rename to tests/type-definitions/global/proposals/regexp-escaping.test.ts diff --git a/tests/type-definitions/proposals/global/regexp-named-groups.test.ts b/tests/type-definitions/global/proposals/regexp-named-groups.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/regexp-named-groups.test.ts rename to tests/type-definitions/global/proposals/regexp-named-groups.test.ts diff --git a/tests/type-definitions/proposals/global/relative-indexing-method.test.ts b/tests/type-definitions/global/proposals/relative-indexing-method.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/relative-indexing-method.test.ts rename to tests/type-definitions/global/proposals/relative-indexing-method.test.ts diff --git a/tests/type-definitions/proposals/global/set-methods.test.ts b/tests/type-definitions/global/proposals/set-methods.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/set-methods.test.ts rename to tests/type-definitions/global/proposals/set-methods.test.ts diff --git a/tests/type-definitions/proposals/global/string-cooked.test.ts b/tests/type-definitions/global/proposals/string-cooked.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/string-cooked.test.ts rename to tests/type-definitions/global/proposals/string-cooked.test.ts diff --git a/tests/type-definitions/proposals/global/string-dedent.test.ts b/tests/type-definitions/global/proposals/string-dedent.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/string-dedent.test.ts rename to tests/type-definitions/global/proposals/string-dedent.test.ts diff --git a/tests/type-definitions/proposals/global/string-left-right-trim.test.ts b/tests/type-definitions/global/proposals/string-left-right-trim.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/string-left-right-trim.test.ts rename to tests/type-definitions/global/proposals/string-left-right-trim.test.ts diff --git a/tests/type-definitions/proposals/global/string-match-all.test.ts b/tests/type-definitions/global/proposals/string-match-all.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/string-match-all.test.ts rename to tests/type-definitions/global/proposals/string-match-all.test.ts diff --git a/tests/type-definitions/proposals/global/string-padding.test.ts b/tests/type-definitions/global/proposals/string-padding.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/string-padding.test.ts rename to tests/type-definitions/global/proposals/string-padding.test.ts diff --git a/tests/type-definitions/proposals/global/string-replace-all.test.ts b/tests/type-definitions/global/proposals/string-replace-all.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/string-replace-all.test.ts rename to tests/type-definitions/global/proposals/string-replace-all.test.ts diff --git a/tests/type-definitions/proposals/global/symbol-description.test.ts b/tests/type-definitions/global/proposals/symbol-description.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/symbol-description.test.ts rename to tests/type-definitions/global/proposals/symbol-description.test.ts diff --git a/tests/type-definitions/proposals/global/symbol-predicates.test.ts b/tests/type-definitions/global/proposals/symbol-predicates.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/symbol-predicates.test.ts rename to tests/type-definitions/global/proposals/symbol-predicates.test.ts diff --git a/tests/type-definitions/proposals/global/well-formed-unicode-strings.test.ts b/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts similarity index 100% rename from tests/type-definitions/proposals/global/well-formed-unicode-strings.test.ts rename to tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts diff --git a/tests/type-definitions/global/tsconfig.json b/tests/type-definitions/global/tsconfig.json new file mode 100644 index 000000000000..5197ce2769f4 --- /dev/null +++ b/tests/type-definitions/global/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.json", + "include": ["./**/*.ts"] +} diff --git a/tests/type-definitions/global/web/atob.global.test.ts b/tests/type-definitions/global/web/atob.global.test.ts new file mode 100644 index 000000000000..3da270552c11 --- /dev/null +++ b/tests/type-definitions/global/web/atob.global.test.ts @@ -0,0 +1,11 @@ +import '@core-js/full'; +import '@core-js/types'; + +const s: string = atob("SGVsbG8gd29ybGQ="); + +// @ts-expect-error +atob(); +// @ts-expect-error +atob(123); +// @ts-expect-error +atob({}); diff --git a/tests/type-definitions/proposals/global/tsconfig.json b/tests/type-definitions/proposals/global/tsconfig.json deleted file mode 100644 index 1fcfc7ee75bf..000000000000 --- a/tests/type-definitions/proposals/global/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./*.ts"] -} diff --git a/tests/type-definitions/proposals/pure/tsconfig.json b/tests/type-definitions/proposals/pure/tsconfig.json deleted file mode 100644 index 1fcfc7ee75bf..000000000000 --- a/tests/type-definitions/proposals/pure/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./*.ts"] -} diff --git a/tests/type-definitions/proposals/pure/accessible-object-hasownproperty.test.ts b/tests/type-definitions/pure/proposals/accessible-object-hasownproperty.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/accessible-object-hasownproperty.test.ts rename to tests/type-definitions/pure/proposals/accessible-object-hasownproperty.test.ts diff --git a/tests/type-definitions/proposals/pure/array-filtering.test.ts b/tests/type-definitions/pure/proposals/array-filtering.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/array-filtering.test.ts rename to tests/type-definitions/pure/proposals/array-filtering.test.ts diff --git a/tests/type-definitions/proposals/pure/array-find-from-last.test.ts b/tests/type-definitions/pure/proposals/array-find-from-last.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/array-find-from-last.test.ts rename to tests/type-definitions/pure/proposals/array-find-from-last.test.ts diff --git a/tests/type-definitions/proposals/pure/array-flat-map.test.ts b/tests/type-definitions/pure/proposals/array-flat-map.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/array-flat-map.test.ts rename to tests/type-definitions/pure/proposals/array-flat-map.test.ts diff --git a/tests/type-definitions/proposals/pure/array-grouping.test.ts b/tests/type-definitions/pure/proposals/array-grouping.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/array-grouping.test.ts rename to tests/type-definitions/pure/proposals/array-grouping.test.ts diff --git a/tests/type-definitions/proposals/pure/array-includes.test.ts b/tests/type-definitions/pure/proposals/array-includes.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/array-includes.test.ts rename to tests/type-definitions/pure/proposals/array-includes.test.ts diff --git a/tests/type-definitions/proposals/pure/array-is-template-object.test.ts b/tests/type-definitions/pure/proposals/array-is-template-object.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/array-is-template-object.test.ts rename to tests/type-definitions/pure/proposals/array-is-template-object.test.ts diff --git a/tests/type-definitions/proposals/pure/array-unique.test.ts b/tests/type-definitions/pure/proposals/array-unique.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/array-unique.test.ts rename to tests/type-definitions/pure/proposals/array-unique.test.ts diff --git a/tests/type-definitions/proposals/pure/async-iteration.test.ts b/tests/type-definitions/pure/proposals/async-iteration.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/async-iteration.test.ts rename to tests/type-definitions/pure/proposals/async-iteration.test.ts diff --git a/tests/type-definitions/proposals/pure/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/async-iterator-helper.test.ts rename to tests/type-definitions/pure/proposals/async-iterator-helper.test.ts diff --git a/tests/type-definitions/proposals/pure/await-dictionary.test.ts b/tests/type-definitions/pure/proposals/await-dictionary.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/await-dictionary.test.ts rename to tests/type-definitions/pure/proposals/await-dictionary.test.ts diff --git a/tests/type-definitions/proposals/pure/change-array-by-copy.test.ts b/tests/type-definitions/pure/proposals/change-array-by-copy.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/change-array-by-copy.test.ts rename to tests/type-definitions/pure/proposals/change-array-by-copy.test.ts diff --git a/tests/type-definitions/proposals/pure/collection-of-from.test.ts b/tests/type-definitions/pure/proposals/collection-of-from.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/collection-of-from.test.ts rename to tests/type-definitions/pure/proposals/collection-of-from.test.ts diff --git a/tests/type-definitions/proposals/pure/decorator-metadata.test.ts b/tests/type-definitions/pure/proposals/decorator-metadata.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/decorator-metadata.test.ts rename to tests/type-definitions/pure/proposals/decorator-metadata.test.ts diff --git a/tests/type-definitions/proposals/pure/explicit-resource-management.test.ts b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/explicit-resource-management.test.ts rename to tests/type-definitions/pure/proposals/explicit-resource-management.test.ts diff --git a/tests/type-definitions/proposals/pure/extractors.test.ts b/tests/type-definitions/pure/proposals/extractors.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/extractors.test.ts rename to tests/type-definitions/pure/proposals/extractors.test.ts diff --git a/tests/type-definitions/proposals/pure/float16.test.ts b/tests/type-definitions/pure/proposals/float16.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/float16.test.ts rename to tests/type-definitions/pure/proposals/float16.test.ts diff --git a/tests/type-definitions/proposals/pure/function-demethodize.test.ts b/tests/type-definitions/pure/proposals/function-demethodize.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/function-demethodize.test.ts rename to tests/type-definitions/pure/proposals/function-demethodize.test.ts diff --git a/tests/type-definitions/proposals/pure/immediate.test.ts b/tests/type-definitions/pure/proposals/immediate.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/immediate.test.ts rename to tests/type-definitions/pure/proposals/immediate.test.ts diff --git a/tests/type-definitions/proposals/pure/is-error.test.ts b/tests/type-definitions/pure/proposals/is-error.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/is-error.test.ts rename to tests/type-definitions/pure/proposals/is-error.test.ts diff --git a/tests/type-definitions/proposals/pure/iterator-chunking.test.ts b/tests/type-definitions/pure/proposals/iterator-chunking.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/iterator-chunking.test.ts rename to tests/type-definitions/pure/proposals/iterator-chunking.test.ts diff --git a/tests/type-definitions/proposals/pure/iterator-helpers.test.ts b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/iterator-helpers.test.ts rename to tests/type-definitions/pure/proposals/iterator-helpers.test.ts diff --git a/tests/type-definitions/proposals/pure/iterator-joint.test.ts b/tests/type-definitions/pure/proposals/iterator-joint.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/iterator-joint.test.ts rename to tests/type-definitions/pure/proposals/iterator-joint.test.ts diff --git a/tests/type-definitions/proposals/pure/iterator-range.test.ts b/tests/type-definitions/pure/proposals/iterator-range.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/iterator-range.test.ts rename to tests/type-definitions/pure/proposals/iterator-range.test.ts diff --git a/tests/type-definitions/proposals/pure/iterator-sequencing.test.ts b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/iterator-sequencing.test.ts rename to tests/type-definitions/pure/proposals/iterator-sequencing.test.ts diff --git a/tests/type-definitions/proposals/pure/json-parse-with-source.test.ts b/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/json-parse-with-source.test.ts rename to tests/type-definitions/pure/proposals/json-parse-with-source.test.ts diff --git a/tests/type-definitions/proposals/pure/map-upsert.test.ts b/tests/type-definitions/pure/proposals/map-upsert.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/map-upsert.test.ts rename to tests/type-definitions/pure/proposals/map-upsert.test.ts diff --git a/tests/type-definitions/proposals/pure/math-sum.test.ts b/tests/type-definitions/pure/proposals/math-sum.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/math-sum.test.ts rename to tests/type-definitions/pure/proposals/math-sum.test.ts diff --git a/tests/type-definitions/proposals/pure/number-clamp.test.ts b/tests/type-definitions/pure/proposals/number-clamp.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/number-clamp.test.ts rename to tests/type-definitions/pure/proposals/number-clamp.test.ts diff --git a/tests/type-definitions/proposals/pure/object-from-entries.test.ts b/tests/type-definitions/pure/proposals/object-from-entries.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/object-from-entries.test.ts rename to tests/type-definitions/pure/proposals/object-from-entries.test.ts diff --git a/tests/type-definitions/proposals/pure/object-get-own-property-descriptors.test.ts b/tests/type-definitions/pure/proposals/object-get-own-property-descriptors.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/object-get-own-property-descriptors.test.ts rename to tests/type-definitions/pure/proposals/object-get-own-property-descriptors.test.ts diff --git a/tests/type-definitions/proposals/pure/object-values-entries.test.ts b/tests/type-definitions/pure/proposals/object-values-entries.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/object-values-entries.test.ts rename to tests/type-definitions/pure/proposals/object-values-entries.test.ts diff --git a/tests/type-definitions/proposals/pure/pattern-matching.test.ts b/tests/type-definitions/pure/proposals/pattern-matching.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/pattern-matching.test.ts rename to tests/type-definitions/pure/proposals/pattern-matching.test.ts diff --git a/tests/type-definitions/proposals/pure/promise-all-settled.test.ts b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/promise-all-settled.test.ts rename to tests/type-definitions/pure/proposals/promise-all-settled.test.ts diff --git a/tests/type-definitions/proposals/pure/promise-any.test.ts b/tests/type-definitions/pure/proposals/promise-any.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/promise-any.test.ts rename to tests/type-definitions/pure/proposals/promise-any.test.ts diff --git a/tests/type-definitions/proposals/pure/promise-finally.test.ts b/tests/type-definitions/pure/proposals/promise-finally.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/promise-finally.test.ts rename to tests/type-definitions/pure/proposals/promise-finally.test.ts diff --git a/tests/type-definitions/proposals/pure/promise-try.test.ts b/tests/type-definitions/pure/proposals/promise-try.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/promise-try.test.ts rename to tests/type-definitions/pure/proposals/promise-try.test.ts diff --git a/tests/type-definitions/proposals/pure/promise-with-resolvers.test.ts b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/promise-with-resolvers.test.ts rename to tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts diff --git a/tests/type-definitions/proposals/pure/regexp-escaping.test.ts b/tests/type-definitions/pure/proposals/regexp-escaping.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/regexp-escaping.test.ts rename to tests/type-definitions/pure/proposals/regexp-escaping.test.ts diff --git a/tests/type-definitions/proposals/pure/relative-indexing-method.test.ts b/tests/type-definitions/pure/proposals/relative-indexing-method.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/relative-indexing-method.test.ts rename to tests/type-definitions/pure/proposals/relative-indexing-method.test.ts diff --git a/tests/type-definitions/proposals/pure/set-methods.test.ts b/tests/type-definitions/pure/proposals/set-methods.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/set-methods.test.ts rename to tests/type-definitions/pure/proposals/set-methods.test.ts diff --git a/tests/type-definitions/proposals/pure/string-cooked.test.ts b/tests/type-definitions/pure/proposals/string-cooked.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/string-cooked.test.ts rename to tests/type-definitions/pure/proposals/string-cooked.test.ts diff --git a/tests/type-definitions/proposals/pure/string-dedent.test.ts b/tests/type-definitions/pure/proposals/string-dedent.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/string-dedent.test.ts rename to tests/type-definitions/pure/proposals/string-dedent.test.ts diff --git a/tests/type-definitions/proposals/pure/string-left-right-trim.test.ts b/tests/type-definitions/pure/proposals/string-left-right-trim.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/string-left-right-trim.test.ts rename to tests/type-definitions/pure/proposals/string-left-right-trim.test.ts diff --git a/tests/type-definitions/proposals/pure/string-match-all.test.ts b/tests/type-definitions/pure/proposals/string-match-all.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/string-match-all.test.ts rename to tests/type-definitions/pure/proposals/string-match-all.test.ts diff --git a/tests/type-definitions/proposals/pure/string-padding.test.ts b/tests/type-definitions/pure/proposals/string-padding.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/string-padding.test.ts rename to tests/type-definitions/pure/proposals/string-padding.test.ts diff --git a/tests/type-definitions/proposals/pure/string-replace-all.test.ts b/tests/type-definitions/pure/proposals/string-replace-all.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/string-replace-all.test.ts rename to tests/type-definitions/pure/proposals/string-replace-all.test.ts diff --git a/tests/type-definitions/proposals/pure/symbol-predicates.test.ts b/tests/type-definitions/pure/proposals/symbol-predicates.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/symbol-predicates.test.ts rename to tests/type-definitions/pure/proposals/symbol-predicates.test.ts diff --git a/tests/type-definitions/proposals/pure/well-formed-unicode-strings.test.ts b/tests/type-definitions/pure/proposals/well-formed-unicode-strings.test.ts similarity index 100% rename from tests/type-definitions/proposals/pure/well-formed-unicode-strings.test.ts rename to tests/type-definitions/pure/proposals/well-formed-unicode-strings.test.ts diff --git a/tests/type-definitions/pure/tsconfig.json b/tests/type-definitions/pure/tsconfig.json new file mode 100644 index 000000000000..5197ce2769f4 --- /dev/null +++ b/tests/type-definitions/pure/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.json", + "include": ["./**/*.ts"] +} diff --git a/tests/type-definitions/pure/web/atob.pure.test.ts b/tests/type-definitions/pure/web/atob.pure.test.ts new file mode 100644 index 000000000000..2dd8cd14b1e3 --- /dev/null +++ b/tests/type-definitions/pure/web/atob.pure.test.ts @@ -0,0 +1,10 @@ +import $atob from '@core-js/pure/full/atob'; + +const s: string = $atob("SGVsbG8gd29ybGQ="); + +// @ts-expect-error +$atob(); +// @ts-expect-error +$atob(123); +// @ts-expect-error +$atob({}); diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index a98ea4c19faa..9242f5b7799d 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -46,7 +46,7 @@ const runTestsOnEnv = async function ({ typeScriptVersion, target, type, env, li $.verbose = false; const envLibName = env ? env.substring(0, env.lastIndexOf('@')) : ''; const command = `npx -p typescript@${ typeScriptVersion }${ env ? ` -p ${ env }` : '' } ` - + `tsc -p proposals/${ type }/tsconfig.json --target ${ target }${ lib ? ` --lib ${ target },${ lib }` : '' }${ env ? ` --types @core-js/types,${ envLibName }` : '' }`; + + `tsc -p ${ type }/tsconfig.json --target ${ target }${ lib ? ` --lib ${ target },${ lib }` : '' }${ env ? ` --types @core-js/types,${ envLibName }` : '' }`; echo(`$ ${ command }`); try { if (env && lib) { @@ -54,9 +54,9 @@ const runTestsOnEnv = async function ({ typeScriptVersion, target, type, env, li } else if (env) { await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --types @core-js/types,${ envLibName }`.quiet(); } else if (lib) { - await $`npx -p typescript@${ typeScriptVersion } tsc -p proposals/${ type }/tsconfig.json --target ${ target } --lib ${ target },${ lib }`.quiet(); + await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target },${ lib }`.quiet(); } else { - await $`npx -p typescript@${ typeScriptVersion } tsc -p proposals/${ type }/tsconfig.json --target ${ target }`.quiet(); + await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig.json --target ${ target }`.quiet(); } echo(chalk.green(`$ ${ command }`)); tested++; @@ -106,7 +106,7 @@ const prepareEnvironment = async function (environments, coreJsTypes) { for (const type of coreJsTypes) { await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.json`), { extends: '../../tsconfig.json', - include: [`../../proposals/${ type }/*.ts`], + include: [`../../${ type }/**/*.ts`], }); } } From 1ac7649d9b48ceb97c1b71add430425a7901635b Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 18 Nov 2025 21:06:28 +0700 Subject: [PATCH 063/315] Web types & tests --- .../efficient-script-yielding.d.ts | 0 .../src/52/{common => web}/url-parse.d.ts | 0 .../56/common/efficient-script-yielding.d.ts | 5 ----- packages/core-js-types/src/56/web/atob.d.ts | 6 +++++ packages/core-js-types/src/56/web/btoa.d.ts | 7 ++++++ .../src/56/web/efficient-script-yielding.d.ts | 15 +++++++++++++ .../src/56/web/queue-microtask.d.ts | 9 ++++++++ .../src/56/web/structured-clone.d.ts | 14 ++++++++++++ .../core-js-types/src/56/web/url-to-json.d.ts | 3 +++ packages/core-js/modules/web.atob.js | 1 + packages/core-js/modules/web.btoa.js | 1 + .../core-js/modules/web.clear-immediate.js | 2 +- .../core-js/modules/web.queue-microtask.js | 1 + packages/core-js/modules/web.set-immediate.js | 2 +- .../core-js/modules/web.structured-clone.js | 1 + packages/core-js/modules/web.url.to-json.js | 1 + .../web/{atob.global.test.ts => atob.test.ts} | 0 .../type-definitions/global/web/btoa.test.ts | 11 ++++++++++ .../global/web/dom-exception.test.ts | 12 ++++++++++ .../efficient-script-yielding.test.ts} | 0 .../global/web/queue-microtask.test.ts | 12 ++++++++++ .../type-definitions/global/web/self.test.ts | 10 +++++++++ .../global/web/structured-clone.test.ts | 16 ++++++++++++++ .../global/web/url-search-params.test.ts | 13 +++++++++++ .../global/web/url-to-json.test.ts | 22 +++++++++++++++++++ .../web/{atob.pure.test.ts => atob.test.ts} | 0 tests/type-definitions/pure/web/btoa.test.ts | 10 +++++++++ .../efficient-script-yielding.test.ts} | 0 .../pure/web/queue-microtask.test.ts | 11 ++++++++++ .../pure/web/structured-clone.test.ts | 15 +++++++++++++ tests/type-definitions/runner.mjs | 8 +++---- 31 files changed, 197 insertions(+), 11 deletions(-) rename packages/core-js-types/src/52/{common => web}/efficient-script-yielding.d.ts (100%) rename packages/core-js-types/src/52/{common => web}/url-parse.d.ts (100%) delete mode 100644 packages/core-js-types/src/56/common/efficient-script-yielding.d.ts create mode 100644 packages/core-js-types/src/56/web/atob.d.ts create mode 100644 packages/core-js-types/src/56/web/btoa.d.ts create mode 100644 packages/core-js-types/src/56/web/efficient-script-yielding.d.ts create mode 100644 packages/core-js-types/src/56/web/queue-microtask.d.ts create mode 100644 packages/core-js-types/src/56/web/structured-clone.d.ts create mode 100644 packages/core-js-types/src/56/web/url-to-json.d.ts rename tests/type-definitions/global/web/{atob.global.test.ts => atob.test.ts} (100%) create mode 100644 tests/type-definitions/global/web/btoa.test.ts create mode 100644 tests/type-definitions/global/web/dom-exception.test.ts rename tests/type-definitions/global/{proposals/immediate.test.ts => web/efficient-script-yielding.test.ts} (100%) create mode 100644 tests/type-definitions/global/web/queue-microtask.test.ts create mode 100644 tests/type-definitions/global/web/self.test.ts create mode 100644 tests/type-definitions/global/web/structured-clone.test.ts create mode 100644 tests/type-definitions/global/web/url-search-params.test.ts create mode 100644 tests/type-definitions/global/web/url-to-json.test.ts rename tests/type-definitions/pure/web/{atob.pure.test.ts => atob.test.ts} (100%) create mode 100644 tests/type-definitions/pure/web/btoa.test.ts rename tests/type-definitions/pure/{proposals/immediate.test.ts => web/efficient-script-yielding.test.ts} (100%) create mode 100644 tests/type-definitions/pure/web/queue-microtask.test.ts create mode 100644 tests/type-definitions/pure/web/structured-clone.test.ts diff --git a/packages/core-js-types/src/52/common/efficient-script-yielding.d.ts b/packages/core-js-types/src/52/web/efficient-script-yielding.d.ts similarity index 100% rename from packages/core-js-types/src/52/common/efficient-script-yielding.d.ts rename to packages/core-js-types/src/52/web/efficient-script-yielding.d.ts diff --git a/packages/core-js-types/src/52/common/url-parse.d.ts b/packages/core-js-types/src/52/web/url-parse.d.ts similarity index 100% rename from packages/core-js-types/src/52/common/url-parse.d.ts rename to packages/core-js-types/src/52/web/url-parse.d.ts diff --git a/packages/core-js-types/src/56/common/efficient-script-yielding.d.ts b/packages/core-js-types/src/56/common/efficient-script-yielding.d.ts deleted file mode 100644 index 9e077b1e4a8d..000000000000 --- a/packages/core-js-types/src/56/common/efficient-script-yielding.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -type Immediate = number | object; - -declare function setImmediate(handler: (...args: any[]) => void, ...args: any[]): Immediate; - -declare function clearImmediate(immediate: Immediate): void; diff --git a/packages/core-js-types/src/56/web/atob.d.ts b/packages/core-js-types/src/56/web/atob.d.ts new file mode 100644 index 000000000000..d08b3902da6c --- /dev/null +++ b/packages/core-js-types/src/56/web/atob.d.ts @@ -0,0 +1,6 @@ +/** + * Decodes a string of data which has been encoded using Base64 encoding. + * @param data A base64-encoded string, using the alphabet produced by btoa(). + * @returns A binary string containing raw bytes decoded from encodedData. + */ +declare function atob(data: string): string; diff --git a/packages/core-js-types/src/56/web/btoa.d.ts b/packages/core-js-types/src/56/web/btoa.d.ts new file mode 100644 index 000000000000..f4eac3d5ad11 --- /dev/null +++ b/packages/core-js-types/src/56/web/btoa.d.ts @@ -0,0 +1,7 @@ +/** + * Creates a Base64-encoded ASCII string from a binary string + * (i.e., a string in which each character in the string is treated as a byte of binary data) + * @param data The binary string to encode + * @returns An ASCII string containing the Base64 representation of data + */ +declare function btoa(data: string): string; diff --git a/packages/core-js-types/src/56/web/efficient-script-yielding.d.ts b/packages/core-js-types/src/56/web/efficient-script-yielding.d.ts new file mode 100644 index 000000000000..2a46793da57e --- /dev/null +++ b/packages/core-js-types/src/56/web/efficient-script-yielding.d.ts @@ -0,0 +1,15 @@ +type Immediate = number | object; + +/** + * Schedules the execution of a function as soon as possible after the current script yields. + * @param handler The function to execute. + * @param args Arguments to pass to the handler function. + * @returns An identifier that can be used to cancel the scheduled function. + */ +declare function setImmediate(handler: (...args: any[]) => void, ...args: any[]): Immediate; + +/** + * Cancels a function scheduled with setImmediate. + * @param immediate The identifier of the scheduled function to cancel. + */ +declare function clearImmediate(immediate: Immediate): void; diff --git a/packages/core-js-types/src/56/web/queue-microtask.d.ts b/packages/core-js-types/src/56/web/queue-microtask.d.ts new file mode 100644 index 000000000000..584b60656a64 --- /dev/null +++ b/packages/core-js-types/src/56/web/queue-microtask.d.ts @@ -0,0 +1,9 @@ +interface VoidFunction { + (): void; +} + +/** + * Queues a microtask to be executed at a later time. + * @param callback A function to be executed in the microtask. + */ +declare function queueMicrotask(callback: VoidFunction): void; diff --git a/packages/core-js-types/src/56/web/structured-clone.d.ts b/packages/core-js-types/src/56/web/structured-clone.d.ts new file mode 100644 index 000000000000..13f3367b9b3a --- /dev/null +++ b/packages/core-js-types/src/56/web/structured-clone.d.ts @@ -0,0 +1,14 @@ +interface CoreJSStructuredSerializeOptions { + readonly __brand?: unique symbol; + + transfer?: any[]; +} + +/** + * Creates a deep clone of a given value using the structured clone algorithm. + * @param value The value to be cloned. + * @param options An optional object that may contain a transfer property, + * which is an array of transferable objects to be transferred rather than cloned. + * @returns A deep clone of the provided value. + */ +declare function structuredClone(value: T, options?: CoreJSStructuredSerializeOptions): T; diff --git a/packages/core-js-types/src/56/web/url-to-json.d.ts b/packages/core-js-types/src/56/web/url-to-json.d.ts new file mode 100644 index 000000000000..6ecf69d921b0 --- /dev/null +++ b/packages/core-js-types/src/56/web/url-to-json.d.ts @@ -0,0 +1,3 @@ +interface URL { + toJSON(): string; +} diff --git a/packages/core-js/modules/web.atob.js b/packages/core-js/modules/web.atob.js index 051b1cbfba23..10da7c1c0097 100644 --- a/packages/core-js/modules/web.atob.js +++ b/packages/core-js/modules/web.atob.js @@ -1,3 +1,4 @@ +// types: web/atob 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.btoa.js b/packages/core-js/modules/web.btoa.js index ac75becfdf68..127020dc1058 100644 --- a/packages/core-js/modules/web.btoa.js +++ b/packages/core-js/modules/web.btoa.js @@ -1,3 +1,4 @@ +// types: web/btoa 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.clear-immediate.js b/packages/core-js/modules/web.clear-immediate.js index 0b514ec42b3e..652cb967faca 100644 --- a/packages/core-js/modules/web.clear-immediate.js +++ b/packages/core-js/modules/web.clear-immediate.js @@ -1,4 +1,4 @@ -// types: common/efficient-script-yielding +// types: web/efficient-script-yielding 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.queue-microtask.js b/packages/core-js/modules/web.queue-microtask.js index 3f20cf2a0d59..25b9c191b72f 100644 --- a/packages/core-js/modules/web.queue-microtask.js +++ b/packages/core-js/modules/web.queue-microtask.js @@ -1,3 +1,4 @@ +// types: web/queue-microtask 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.set-immediate.js b/packages/core-js/modules/web.set-immediate.js index b6378cf6aa8e..68ab987df0b5 100644 --- a/packages/core-js/modules/web.set-immediate.js +++ b/packages/core-js/modules/web.set-immediate.js @@ -1,4 +1,4 @@ -// types: common/efficient-script-yielding +// types: web/efficient-script-yielding 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.structured-clone.js b/packages/core-js/modules/web.structured-clone.js index 8de9f9874b27..06acce0dd7d1 100644 --- a/packages/core-js/modules/web.structured-clone.js +++ b/packages/core-js/modules/web.structured-clone.js @@ -1,3 +1,4 @@ +// types: web/structured-clone 'use strict'; var IS_PURE = require('../internals/is-pure'); var $ = require('../internals/export'); diff --git a/packages/core-js/modules/web.url.to-json.js b/packages/core-js/modules/web.url.to-json.js index 879b80c18f17..27c1b608f5bf 100644 --- a/packages/core-js/modules/web.url.to-json.js +++ b/packages/core-js/modules/web.url.to-json.js @@ -1,3 +1,4 @@ +// types: web/url-to-json 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/tests/type-definitions/global/web/atob.global.test.ts b/tests/type-definitions/global/web/atob.test.ts similarity index 100% rename from tests/type-definitions/global/web/atob.global.test.ts rename to tests/type-definitions/global/web/atob.test.ts diff --git a/tests/type-definitions/global/web/btoa.test.ts b/tests/type-definitions/global/web/btoa.test.ts new file mode 100644 index 000000000000..2a4539a0d733 --- /dev/null +++ b/tests/type-definitions/global/web/btoa.test.ts @@ -0,0 +1,11 @@ +import '@core-js/full'; +import '@core-js/types'; + +const s: string = btoa("SGVsbG8gd29ybGQ="); + +// @ts-expect-error +atob(); +// @ts-expect-error +atob(123); +// @ts-expect-error +atob({}); diff --git a/tests/type-definitions/global/web/dom-exception.test.ts b/tests/type-definitions/global/web/dom-exception.test.ts new file mode 100644 index 000000000000..6833f98459c3 --- /dev/null +++ b/tests/type-definitions/global/web/dom-exception.test.ts @@ -0,0 +1,12 @@ +// todo add after it becomes possible to create a type +// import '@core-js/full'; +// import '@core-js/types'; +// +// const ex1 = new DOMException(); +// const ex2 = new DOMException('Some message'); +// const ex3 = new DOMException('Some message', 'SyntaxError'); +// +// // @ts-expect-error +// // DOMException(); +// // @ts-expect-error +// DOMException(123); diff --git a/tests/type-definitions/global/proposals/immediate.test.ts b/tests/type-definitions/global/web/efficient-script-yielding.test.ts similarity index 100% rename from tests/type-definitions/global/proposals/immediate.test.ts rename to tests/type-definitions/global/web/efficient-script-yielding.test.ts diff --git a/tests/type-definitions/global/web/queue-microtask.test.ts b/tests/type-definitions/global/web/queue-microtask.test.ts new file mode 100644 index 000000000000..886d1616da5c --- /dev/null +++ b/tests/type-definitions/global/web/queue-microtask.test.ts @@ -0,0 +1,12 @@ +import '@core-js/full'; +import '@core-js/types'; + +queueMicrotask((): void => {}); +queueMicrotask(function (): void {}); + +// @ts-expect-error +queueMicrotask(); +// @ts-expect-error +queueMicrotask('not a function'); +// @ts-expect-error +queueMicrotask((a) => {}); diff --git a/tests/type-definitions/global/web/self.test.ts b/tests/type-definitions/global/web/self.test.ts new file mode 100644 index 000000000000..c643a10550ba --- /dev/null +++ b/tests/type-definitions/global/web/self.test.ts @@ -0,0 +1,10 @@ +// todo add after it becomes possible to create a type +// import '@core-js/full'; +// import '@core-js/types'; +// +// const ref: typeof globalThis = self; +// +// // @ts-expect-error +// self(); +// // @ts-expect-error +// self = {}; diff --git a/tests/type-definitions/global/web/structured-clone.test.ts b/tests/type-definitions/global/web/structured-clone.test.ts new file mode 100644 index 000000000000..c8cb11a33986 --- /dev/null +++ b/tests/type-definitions/global/web/structured-clone.test.ts @@ -0,0 +1,16 @@ +import '@core-js/full'; +import '@core-js/types'; + +const n: number = structuredClone(5); +const s: string = structuredClone('text'); + +declare const buffer: ArrayBuffer; +const obj = { buffer }; +const cloned: typeof obj = structuredClone(obj, { transfer: [buffer] }); + +// @ts-expect-error +structuredClone(); +// @ts-expect-error +structuredClone('text', {}, 'extra'); +// @ts-expect-error +const n2: number = structuredClone('1'); diff --git a/tests/type-definitions/global/web/url-search-params.test.ts b/tests/type-definitions/global/web/url-search-params.test.ts new file mode 100644 index 000000000000..6e28466cd5d1 --- /dev/null +++ b/tests/type-definitions/global/web/url-search-params.test.ts @@ -0,0 +1,13 @@ +// todo add after it becomes possible to create a type +// import '@core-js/full'; +// import '@core-js/types'; +// +// const u0 = new URLSearchParams(); +// const u1 = new URLSearchParams('a=1&b=2'); +// const u2 = new URLSearchParams([['a', '1'], ['b', '2']]); +// const u3 = new URLSearchParams({ a: '1', b: '2' }); +// +// // @ts-expect-error +// new URLSearchParams(123); +// // @ts-expect-error +// new URLSearchParams([1, 2, 3]); diff --git a/tests/type-definitions/global/web/url-to-json.test.ts b/tests/type-definitions/global/web/url-to-json.test.ts new file mode 100644 index 000000000000..e4180029132e --- /dev/null +++ b/tests/type-definitions/global/web/url-to-json.test.ts @@ -0,0 +1,22 @@ +import '@core-js/full'; +import '@core-js/types'; + +declare const urlLike: URL; +const str: string = urlLike.toJSON(); + +// @ts-expect-error +const num: number = urlLike.toJSON(); +// @ts-expect-error +urlLike.toJSON('param'); + +// todo add after URL becomes constructable in types +// const url1 = new URL('https://example.com'); +// new URL('page', 'https://example.com'); +// new URL('/path', url1); +// +// // @ts-expect-error +// new URL(); +// // @ts-expect-error +// new URL(123); +// // @ts-expect-error +// new URL('abc', 456); diff --git a/tests/type-definitions/pure/web/atob.pure.test.ts b/tests/type-definitions/pure/web/atob.test.ts similarity index 100% rename from tests/type-definitions/pure/web/atob.pure.test.ts rename to tests/type-definitions/pure/web/atob.test.ts diff --git a/tests/type-definitions/pure/web/btoa.test.ts b/tests/type-definitions/pure/web/btoa.test.ts new file mode 100644 index 000000000000..83238bb9a719 --- /dev/null +++ b/tests/type-definitions/pure/web/btoa.test.ts @@ -0,0 +1,10 @@ +import $btoa from '@core-js/pure/full/btoa'; + +const s: string = $btoa("SGVsbG8gd29ybGQ="); + +// @ts-expect-error +$btoa(); +// @ts-expect-error +$btoa(123); +// @ts-expect-error +$btoa({}); diff --git a/tests/type-definitions/pure/proposals/immediate.test.ts b/tests/type-definitions/pure/web/efficient-script-yielding.test.ts similarity index 100% rename from tests/type-definitions/pure/proposals/immediate.test.ts rename to tests/type-definitions/pure/web/efficient-script-yielding.test.ts diff --git a/tests/type-definitions/pure/web/queue-microtask.test.ts b/tests/type-definitions/pure/web/queue-microtask.test.ts new file mode 100644 index 000000000000..11455ee2f708 --- /dev/null +++ b/tests/type-definitions/pure/web/queue-microtask.test.ts @@ -0,0 +1,11 @@ +import $queueMicrotask from '@core-js/pure/full/queue-microtask'; + +$queueMicrotask((): void => {}); +$queueMicrotask(function (): void {}); + +// @ts-expect-error +$queueMicrotask(); +// @ts-expect-error +$queueMicrotask('not a function'); +// @ts-expect-error +$queueMicrotask((a) => {}); diff --git a/tests/type-definitions/pure/web/structured-clone.test.ts b/tests/type-definitions/pure/web/structured-clone.test.ts new file mode 100644 index 000000000000..6ce0bd06ed2f --- /dev/null +++ b/tests/type-definitions/pure/web/structured-clone.test.ts @@ -0,0 +1,15 @@ +import $structuredClone from '@core-js/pure/full/structured-clone'; + +const n: number = $structuredClone(5); +const s: string = $structuredClone('text'); + +declare const buffer: ArrayBuffer; +const obj = { buffer }; +const cloned: typeof obj = $structuredClone(obj, { transfer: [buffer] }); + +// @ts-expect-error +$structuredClone(); +// @ts-expect-error +$structuredClone('text', {}, 'extra'); +// @ts-expect-error +const n2: number = $structuredClone('1'); diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 9242f5b7799d..03cdebfe0deb 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -30,8 +30,8 @@ const types = [ 'pure', ]; const libs = [ - null, 'dom', + // null, // fails on web types ]; let tested = 0; @@ -46,17 +46,17 @@ const runTestsOnEnv = async function ({ typeScriptVersion, target, type, env, li $.verbose = false; const envLibName = env ? env.substring(0, env.lastIndexOf('@')) : ''; const command = `npx -p typescript@${ typeScriptVersion }${ env ? ` -p ${ env }` : '' } ` - + `tsc -p ${ type }/tsconfig.json --target ${ target }${ lib ? ` --lib ${ target },${ lib }` : '' }${ env ? ` --types @core-js/types,${ envLibName }` : '' }`; + + `tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target }${ lib ? `,${ lib }` : '' }${ env ? ` --types @core-js/types,${ envLibName }` : '' }`; echo(`$ ${ command }`); try { if (env && lib) { await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target },${ lib } --types @core-js/types,${ envLibName }`.quiet(); } else if (env) { - await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --types @core-js/types,${ envLibName }`.quiet(); + await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target } --types @core-js/types,${ envLibName }`.quiet(); } else if (lib) { await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target },${ lib }`.quiet(); } else { - await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig.json --target ${ target }`.quiet(); + await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target }`.quiet(); } echo(chalk.green(`$ ${ command }`)); tested++; From 73a46290fe760537980973d9952b9816b21028dc Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 19 Nov 2025 02:58:37 +0700 Subject: [PATCH 064/315] Fix empty lines --- scripts/build-types/index.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 1089afa71a69..ba718a7e1805 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -52,7 +52,7 @@ async function buildType(typeFilePath, entry, options) { const tpl = template({ ...options, modules, rawModules, level, entry, types, packageName: config.packageName }); - await outputFile(typeFilePath, `${ tpl.dts }\n\n`, { flag: 'a' }); + await outputFile(typeFilePath, `${ tpl.dts }${ tpl.dts ? '\n\n' : '' }`, { flag: 'a' }); } async function getVersions() { From 8cff15f118650bea6c8e5e1996b1e0e85fb9b2d5 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 20 Nov 2025 00:16:28 +0700 Subject: [PATCH 065/315] Fixes after rebase --- package-lock.json | 13 + packages/core-js-types/package.json | 3 +- .../src/56/proposals/iterator-join.d.ts | 6 + .../core-js/modules/esnext.iterator.join.js | 1 + scripts/build-entries/templates.mjs | 667 ++++++++++++------ tests/eslint/eslint.config.js | 1 + .../global/proposals/iterator-join.test.ts | 16 + .../pure/proposals/iterator-join.test.ts | 15 + 8 files changed, 496 insertions(+), 226 deletions(-) create mode 100644 packages/core-js-types/src/56/proposals/iterator-join.d.ts create mode 100644 tests/type-definitions/global/proposals/iterator-join.test.ts create mode 100644 tests/type-definitions/pure/proposals/iterator-join.test.ts diff --git a/package-lock.json b/package-lock.json index a5d00acb5286..199efc7fe28d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1006,6 +1006,10 @@ "resolved": "packages/core-js-pure", "link": true }, + "node_modules/@core-js/types": { + "resolved": "packages/core-js-types", + "link": true + }, "node_modules/@emnapi/core": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.8.1.tgz", @@ -2300,6 +2304,15 @@ "type": "opencollective", "url": "https://opencollective.com/core-js" } + }, + "packages/core-js-types": { + "name": "@core-js/types", + "version": "4.0.0-alpha.0", + "license": "SEE LICENSE IN LICENSE.md", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } } } } diff --git a/packages/core-js-types/package.json b/packages/core-js-types/package.json index 85213853ba35..3e1b72c600ca 100644 --- a/packages/core-js-types/package.json +++ b/packages/core-js-types/package.json @@ -36,5 +36,6 @@ ">=5.2": { "*": ["dist/core-js-types.52.d.ts"] } - } + }, + "sideEffects": false } diff --git a/packages/core-js-types/src/56/proposals/iterator-join.d.ts b/packages/core-js-types/src/56/proposals/iterator-join.d.ts new file mode 100644 index 000000000000..7f0151419bf2 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/iterator-join.d.ts @@ -0,0 +1,6 @@ +// proposal stage: 0 +// https://github.com/bakkot/proposal-iterator-join + +interface Iterator { + join(separator?: unknown): string; +} diff --git a/packages/core-js/modules/esnext.iterator.join.js b/packages/core-js/modules/esnext.iterator.join.js index d49bf3b1621e..685944885fe0 100644 --- a/packages/core-js/modules/esnext.iterator.join.js +++ b/packages/core-js/modules/esnext.iterator.join.js @@ -1,3 +1,4 @@ +// types: proposals/iterator-join 'use strict'; var $ = require('../internals/export'); var $toString = require('../internals/to-string'); diff --git a/scripts/build-entries/templates.mjs b/scripts/build-entries/templates.mjs index 01fe99a7a769..637de0873d2d 100644 --- a/scripts/build-entries/templates.mjs +++ b/scripts/build-entries/templates.mjs @@ -1,14 +1,14 @@ import { basename } from 'node:path'; import dedent from 'dedent'; -const t = template => params => `'use strict';\n${ template({ ...params }) }\n`; - const importInternal = (module, level) => `require('${ level ? '../'.repeat(level) : './' }internals/${ module }');`; const importModule = (module, level) => `require('${ level ? '../'.repeat(level) : './' }modules/${ module }');`; const importModules = ({ modules, level }) => modules.map(module => importModule(module, level)).join('\n'); +const buildTypeName = (namespace, name) => `CoreJS.${ namespace }${ String(name).charAt(0).toUpperCase() + String(name).slice(1) }`; + function isAllowedFunctionName(name) { try { // eslint-disable-next-line no-new-func -- safe @@ -19,229 +19,446 @@ function isAllowedFunctionName(name) { } } -export const $justImport = t(p => importModules(p)); - -export const $prototype = t(p => dedent` - ${ importModules(p) } - - var getBuiltInPrototypeMethod = ${ importInternal('get-built-in-prototype-method', p.level) } - - module.exports = getBuiltInPrototypeMethod('${ p.namespace }', '${ p.name }'); -`); - -export const $prototypeIterator = t(p => dedent` - ${ importModules(p) } - - var getIteratorMethod = ${ importInternal('get-iterator-method', p.level) } - - module.exports = getIteratorMethod(${ p.source }); -`); - -export const $uncurried = t(p => dedent` - ${ importModules(p) } - - var entryUnbind = ${ importInternal('entry-unbind', p.level) } - - module.exports = entryUnbind('${ p.namespace }', '${ p.name }'); -`); - -export const $uncurriedIterator = t(p => dedent` - ${ importModules(p) } - - var uncurryThis = ${ importInternal('function-uncurry-this', p.level) } - var getIteratorMethod = ${ importInternal('get-iterator-method', p.level) } - - module.exports = uncurryThis(getIteratorMethod(${ p.source })); -`); - -export const $static = t(p => dedent` - ${ importModules(p) } - - var getBuiltInStaticMethod = ${ importInternal('get-built-in-static-method', p.level) } - - module.exports = getBuiltInStaticMethod('${ p.namespace }', '${ p.name }'); -`); - -export const $staticWithContext = t(p => dedent` - ${ importModules(p) } - - var getBuiltIn = ${ importInternal('get-built-in', p.level) } - var getBuiltInStaticMethod = ${ importInternal('get-built-in-static-method', p.level) } - var isCallable = ${ importInternal('is-callable', p.level) } - var apply = ${ importInternal('function-apply', p.level) } - - var method = getBuiltInStaticMethod('${ p.namespace }', '${ p.name }'); - - module.exports = function ${ isAllowedFunctionName(p.name) ? p.name : '' }() { - return apply(method, isCallable(this) ? this : getBuiltIn('${ p.namespace }'), arguments); - }; -`); - -export const $patchableStatic = t(p => dedent` - ${ importModules(p) } - - var getBuiltInStaticMethod = ${ importInternal('get-built-in-static-method', p.level) } - var apply = ${ importInternal('function-apply', p.level) } - - module.exports = function ${ isAllowedFunctionName(p.name) ? p.name : '' }() { - return apply(getBuiltInStaticMethod('${ p.namespace }', '${ p.name }'), this, arguments); - }; -`); - -export const $namespace = t(p => dedent` - ${ importModules(p) } - - var path = ${ importInternal('path', p.level) } - - module.exports = path.${ p.name }; -`); - -export const $helper = t(p => dedent` - ${ importModules(p) } - - var $export = ${ importInternal(p.helper, p.level) } - - module.exports = $export; -`); - -export const $path = t(p => dedent` - ${ importModules(p) } - - var path = ${ importInternal('path', p.level) } - - module.exports = path; -`); - -export const $instanceArray = t(p => dedent` - var isPrototypeOf = require('../../internals/object-is-prototype-of'); - var arrayMethod = require('../array/prototype/${ basename(p.entry) }'); - - var ArrayPrototype = Array.prototype; - - module.exports = function (it) { - var ownProperty = it.${ p.name }; - if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && ownProperty === ArrayPrototype.${ p.name })) return arrayMethod; - return ownProperty; - }; -`); - -export const $instanceNumber = t(p => dedent` - var isPrototypeOf = require('../../internals/object-is-prototype-of'); - var numberMethod = require('../number/prototype/${ basename(p.entry) }'); - - var NumberPrototype = Number.prototype; - - module.exports = function (it) { - var ownProperty = it.${ p.name }; - if (typeof it == 'number' || it === NumberPrototype - || (isPrototypeOf(NumberPrototype, it) && ownProperty === NumberPrototype.${ p.name })) return numberMethod; - return ownProperty; - }; -`); - -export const $instanceString = t(p => dedent` - var isPrototypeOf = require('../../internals/object-is-prototype-of'); - var stringMethod = require('../string/prototype/${ basename(p.entry) }'); - - var StringPrototype = String.prototype; - - module.exports = function (it) { - var ownProperty = it.${ p.name }; - if (typeof it == 'string' || it === StringPrototype - || (isPrototypeOf(StringPrototype, it) && ownProperty === StringPrototype.${ p.name })) return stringMethod; - return ownProperty; - }; -`); - -export const $instanceFunction = t(p => dedent` - var isPrototypeOf = require('../../internals/object-is-prototype-of'); - var functionMethod = require('../function/prototype/${ basename(p.entry) }'); - - var FunctionPrototype = Function.prototype; - - module.exports = function (it) { - var ownProperty = it.${ p.name }; - if (it === FunctionPrototype || (isPrototypeOf(FunctionPrototype, it) && ownProperty === FunctionPrototype.${ p.name })) { - return functionMethod; - } return ownProperty; - }; -`); - -export const $instanceDOMIterables = t(p => dedent` - ${ importModules(p) } - - var classof = require('../../internals/classof'); - var hasOwn = require('../../internals/has-own-property'); - - var arrayMethod = Array.prototype.${ p.name }; +const namespacesWithTwoGeneric = [ + 'Map', + 'ReadonlyMap', + 'WeakMap', +]; + +const namespacesWithOneGeneric = [ + 'Array', + 'ReadonlyArray', + 'Set', + 'ReadonlySet', + 'WeakSet', + 'Promise', + 'Iterator', + 'AsyncIterator', +]; + +function getGenericsForNamespace(namespace) { + if (namespace === 'WeakMap') { + return ''; + } + if (namespacesWithTwoGeneric.includes(namespace)) { + return ''; + } + if (namespacesWithOneGeneric.includes(namespace)) { + return ''; + } + return ''; +} - var DOMIterables = { - DOMTokenList: true, - NodeList: true, - }; +function getCommonGenericsForNamespace(namespace) { + if (namespacesWithTwoGeneric.includes(namespace)) { + return ''; + } + if (namespacesWithOneGeneric.includes(namespace)) { + return ''; + } + return ''; +} - module.exports = function (it) { - var ownProperty = it.${ p.name }; - if (hasOwn(DOMIterables, classof(it))) return arrayMethod; - return ownProperty; - }; -`); +function getCustomGenerics(count) { + const names = ['T', 'R', 'U']; + return `<${ names.slice(0, count).join(', ') }>`; +} -export const $instanceArrayString = t(p => dedent` - var isPrototypeOf = require('../../internals/object-is-prototype-of'); - var arrayMethod = require('../array/prototype/${ basename(p.entry) }'); - var stringMethod = require('../string/prototype/${ basename(p.entry) }'); - - var ArrayPrototype = Array.prototype; - var StringPrototype = String.prototype; - - module.exports = function (it) { - var ownProperty = it.${ p.name }; - if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && ownProperty === ArrayPrototype.${ p.name })) return arrayMethod; - if (typeof it == 'string' || it === StringPrototype - || (isPrototypeOf(StringPrototype, it) && ownProperty === StringPrototype.${ p.name })) return stringMethod; - return ownProperty; - }; -`); - -export const $instanceArrayDOMIterables = t(p => dedent` - ${ importModules(p) } - - var classof = require('../../internals/classof'); - var hasOwn = require('../../internals/has-own-property'); - var isPrototypeOf = require('../../internals/object-is-prototype-of'); - var arrayMethod = require('../array/prototype/${ basename(p.entry) }'); - - var ArrayPrototype = Array.prototype; - - var DOMIterables = { - DOMTokenList: true, - NodeList: true, - }; - - module.exports = function (it) { - var ownProperty = it.${ p.name }; - if (it === ArrayPrototype || ((isPrototypeOf(ArrayPrototype, it) - || hasOwn(DOMIterables, classof(it))) && ownProperty === ArrayPrototype.${ p.name })) return arrayMethod; - return ownProperty; - }; -`); - -export const $instanceRegExpFlags = t(p => dedent` - ${ importModules(p) } - - var isPrototypeOf = require('../../internals/object-is-prototype-of'); - var flags = require('../regexp/flags'); - - var RegExpPrototype = RegExp.prototype; - - module.exports = function (it) { - return (it === RegExpPrototype || isPrototypeOf(RegExpPrototype, it)) ? flags(it) : it.flags; - }; -`); - -export const $proposal = t(p => dedent` - // proposal stage: ${ p.stage } - // ${ p.link } - ${ importModules(p) } -`); +export const wrapEntry = template => `'use strict';\n${ template }\n`; + +export const $justImport = p => ({ + entry: dedent` + ${ importModules(p) } + `, + dts: '', +}); + +export const $prototype = p => ({ + entry: dedent` + ${ importModules(p) } + + var getBuiltInPrototypeMethod = ${ importInternal('get-built-in-prototype-method', p.level) } + + module.exports = getBuiltInPrototypeMethod('${ p.namespace }', '${ p.name }'); + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + type method${ getGenericsForNamespace(p.namespace) } = ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; + export = method; + } + `, +}); + +export const $prototypeIterator = p => ({ + entry: dedent` + ${ importModules(p) } + + var getIteratorMethod = ${ importInternal('get-iterator-method', p.level) } + + module.exports = getIteratorMethod(${ p.source }); + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const method: typeof ${ p.namespace }.prototype[typeof Symbol.iterator]; + export = method; + } + `, +}); + +export const $uncurried = p => ({ + entry: dedent` + ${ importModules(p) } + + var entryUnbind = ${ importInternal('entry-unbind', p.level) } + + module.exports = entryUnbind('${ p.namespace }', '${ p.name }'); + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + type method${ getGenericsForNamespace(p.namespace) } = ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; + const resultMethod: ${ getGenericsForNamespace(p.namespace) }(self: ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters) => ReturnType; + export = resultMethod; + } + `, +}); + +export const $uncurriedWithCustomType = p => ({ + entry: dedent` + ${ importModules(p) } + + var entryUnbind = ${ importInternal('entry-unbind', p.level) } + + module.exports = entryUnbind('${ p.namespace }', '${ p.name }'); + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const resultMethod: ${ getCustomGenerics(p.genericsCount) }(self: ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters<${ buildTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>) => ReturnType<${ buildTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>; + export = resultMethod; + } + `, +}); + +export const $uncurriedIterator = p => ({ + entry: dedent` + ${ importModules(p) } + + var uncurryThis = ${ importInternal('function-uncurry-this', p.level) } + var getIteratorMethod = ${ importInternal('get-iterator-method', p.level) } + + module.exports = uncurryThis(getIteratorMethod(${ p.source })); + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + type method${ getGenericsForNamespace(p.namespace) } = ${ p.namespace }${ getGenericsForNamespace(p.namespace) }[typeof Symbol.iterator]; + const resultMethod: ${ getGenericsForNamespace(p.namespace) }(self: ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters) => ReturnType; + export = resultMethod; + } + `, +}); + +export const $static = p => ({ + entry: dedent` + ${ importModules(p) } + + var getBuiltInStaticMethod = ${ importInternal('get-built-in-static-method', p.level) } + + module.exports = getBuiltInStaticMethod('${ p.namespace }', '${ p.name }'); + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const method: typeof ${ p.namespace }.${ p.name }; + export = method; + } + `, +}); + +export const $staticWithContext = p => ({ + entry: dedent` + ${ importModules(p) } + + var getBuiltIn = ${ importInternal('get-built-in', p.level) } + var getBuiltInStaticMethod = ${ importInternal('get-built-in-static-method', p.level) } + var isCallable = ${ importInternal('is-callable', p.level) } + var apply = ${ importInternal('function-apply', p.level) } + + var method = getBuiltInStaticMethod('${ p.namespace }', '${ p.name }'); + + module.exports = function ${ isAllowedFunctionName(p.name) ? p.name : '' }() { + return apply(method, isCallable(this) ? this : getBuiltIn('${ p.namespace }'), arguments); + }; + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const method: typeof ${ p.namespace }.${ p.name }; + export = method; + } + `, +}); + +export const $patchableStatic = p => ({ + entry: dedent` + ${ importModules(p) } + + var getBuiltInStaticMethod = ${ importInternal('get-built-in-static-method', p.level) } + var apply = ${ importInternal('function-apply', p.level) } + + module.exports = function ${ isAllowedFunctionName(p.name) ? p.name : '' }() { + return apply(getBuiltInStaticMethod('${ p.namespace }', '${ p.name }'), this, arguments); + }; + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const method: typeof ${ p.namespace }.${ p.name }; + export = method; + } + `, +}); + +export const $namespace = p => ({ + entry: dedent` + ${ importModules(p) } + + var path = ${ importInternal('path', p.level) } + + module.exports = path.${ p.name }; + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const namespace: typeof ${ p.name }; + export = namespace; + } + `, +}); + +export const $helper = p => ({ + entry: dedent` + ${ importModules(p) } + + var $export = ${ importInternal(p.helper, p.level) } + + module.exports = $export; + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const helper: (arg: NonNullable) => any; + export = helper; + } + `, +}); + +export const $path = p => ({ + entry: dedent` + ${ importModules(p) } + + var path = ${ importInternal('path', p.level) } + + module.exports = path; + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const path: typeof globalThis; + export = path; + } + `, +}); + +export const $instanceArray = p => ({ + entry: dedent` + var isPrototypeOf = require('../../internals/object-is-prototype-of'); + var arrayMethod = require('../array/prototype/${ basename(p.entry) }'); + + var ArrayPrototype = Array.prototype; + + module.exports = function (it) { + var ownProperty = it.${ p.name }; + if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && ownProperty === ArrayPrototype.${ p.name })) return arrayMethod; + return ownProperty; + }; + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const method: (arg: NonNullable) => any; + export = method; + } + `, +}); + +export const $instanceNumber = p => ({ + entry: dedent` + var isPrototypeOf = require('../../internals/object-is-prototype-of'); + var numberMethod = require('../number/prototype/${ basename(p.entry) }'); + + var NumberPrototype = Number.prototype; + + module.exports = function (it) { + var ownProperty = it.${ p.name }; + if (typeof it == 'number' || it === NumberPrototype + || (isPrototypeOf(NumberPrototype, it) && ownProperty === NumberPrototype.${ p.name })) return numberMethod; + return ownProperty; + }; + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const method: (arg: NonNullable) => any; + export = method; + } + `, +}); + +export const $instanceString = p => ({ + entry: dedent` + var isPrototypeOf = require('../../internals/object-is-prototype-of'); + var stringMethod = require('../string/prototype/${ basename(p.entry) }'); + + var StringPrototype = String.prototype; + + module.exports = function (it) { + var ownProperty = it.${ p.name }; + if (typeof it == 'string' || it === StringPrototype + || (isPrototypeOf(StringPrototype, it) && ownProperty === StringPrototype.${ p.name })) return stringMethod; + return ownProperty; + }; + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const method: (arg: NonNullable) => any; + export = method; + } + `, +}); + +export const $instanceFunction = p => ({ + entry: dedent` + var isPrototypeOf = require('../../internals/object-is-prototype-of'); + var functionMethod = require('../function/prototype/${ basename(p.entry) }'); + + var FunctionPrototype = Function.prototype; + + module.exports = function (it) { + var ownProperty = it.${ p.name }; + if (it === FunctionPrototype || (isPrototypeOf(FunctionPrototype, it) && ownProperty === FunctionPrototype.${ p.name })) { + return functionMethod; + } return ownProperty; + }; + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const method: (arg: NonNullable) => any; + export = method; + } + `, +}); + +export const $instanceDOMIterables = p => ({ + entry: dedent` + ${ importModules(p) } + + var classof = require('../../internals/classof'); + var hasOwn = require('../../internals/has-own-property'); + + var arrayMethod = Array.prototype.${ p.name }; + + var DOMIterables = { + DOMTokenList: true, + NodeList: true, + }; + + module.exports = function (it) { + var ownProperty = it.${ p.name }; + if (hasOwn(DOMIterables, classof(it))) return arrayMethod; + return ownProperty; + }; + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const method: (arg: NonNullable) => any; + export = method; + } + `, +}); + +export const $instanceArrayString = p => ({ + entry: dedent` + var isPrototypeOf = require('../../internals/object-is-prototype-of'); + var arrayMethod = require('../array/prototype/${ basename(p.entry) }'); + var stringMethod = require('../string/prototype/${ basename(p.entry) }'); + + var ArrayPrototype = Array.prototype; + var StringPrototype = String.prototype; + + module.exports = function (it) { + var ownProperty = it.${ p.name }; + if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && ownProperty === ArrayPrototype.${ p.name })) return arrayMethod; + if (typeof it == 'string' || it === StringPrototype + || (isPrototypeOf(StringPrototype, it) && ownProperty === StringPrototype.${ p.name })) return stringMethod; + return ownProperty; + }; + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const method: (arg: NonNullable) => any; + export = method; + } + `, +}); + +export const $instanceArrayDOMIterables = p => ({ + entry: dedent` + ${ importModules(p) } + + var classof = require('../../internals/classof'); + var hasOwn = require('../../internals/has-own-property'); + var isPrototypeOf = require('../../internals/object-is-prototype-of'); + var arrayMethod = require('../array/prototype/${ basename(p.entry) }'); + + var ArrayPrototype = Array.prototype; + + var DOMIterables = { + DOMTokenList: true, + NodeList: true, + }; + + module.exports = function (it) { + var ownProperty = it.${ p.name }; + if (it === ArrayPrototype || ((isPrototypeOf(ArrayPrototype, it) + || hasOwn(DOMIterables, classof(it))) && ownProperty === ArrayPrototype.${ p.name })) return arrayMethod; + return ownProperty; + }; + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const method: (arg: NonNullable) => any; + export = method; + } + `, +}); + +export const $instanceRegExpFlags = p => ({ + entry: dedent` + ${ importModules(p) } + + var isPrototypeOf = require('../../internals/object-is-prototype-of'); + var flags = require('../regexp/flags'); + + var RegExpPrototype = RegExp.prototype; + + module.exports = function (it) { + return (it === RegExpPrototype || isPrototypeOf(RegExpPrototype, it)) ? flags(it) : it.flags; + }; + `, + dts: dedent` + declare module "${ p.packageName }${ p.entry }" { + const method: (arg: NonNullable) => any; + export = method; + } + `, +}); + +export const $proposal = p => ({ + entry: dedent` + // proposal stage: ${ p.stage } + // ${ p.link } + ${ importModules(p) } + `, + dts: '', +}); diff --git a/tests/eslint/eslint.config.js b/tests/eslint/eslint.config.js index 4b36d490dbab..a8f0243fba68 100644 --- a/tests/eslint/eslint.config.js +++ b/tests/eslint/eslint.config.js @@ -2180,6 +2180,7 @@ export default [ 'tests/**/bundles/**', 'tests/compat/compat-data.js', 'tests/unit-@(global|pure)/index.js', + 'tests/type-definitions/tmp/**', 'website/dist/**', 'website/src/public/*', 'website/templates/**', diff --git a/tests/type-definitions/global/proposals/iterator-join.test.ts b/tests/type-definitions/global/proposals/iterator-join.test.ts new file mode 100644 index 000000000000..3ca966b1a1e5 --- /dev/null +++ b/tests/type-definitions/global/proposals/iterator-join.test.ts @@ -0,0 +1,16 @@ +import 'core-js/full'; +import '@core-js/types'; + +declare const it: Iterator; + +const res1: string = it.join(); +const res2: string = it.join(' '); +const res3: string = it.join(5); +const res4: string = it.join(Symbol('x')); +const res5: string = it.join(undefined); +const res6: string = it.join(null); + +// @ts-expect-error +it.join('+', '_'); +// @ts-expect-error +const res7: number = it.join(); diff --git a/tests/type-definitions/pure/proposals/iterator-join.test.ts b/tests/type-definitions/pure/proposals/iterator-join.test.ts new file mode 100644 index 000000000000..abf2761b19d1 --- /dev/null +++ b/tests/type-definitions/pure/proposals/iterator-join.test.ts @@ -0,0 +1,15 @@ +import $join from '@core-js/pure/full/iterator/join'; + +declare const it: Iterator; + +const res1: string = $join(it, ); +const res2: string = $join(it, ' '); +const res3: string = $join(it, 5); +const res4: string = $join(it, Symbol('x')); +const res5: string = $join(it, undefined); +const res6: string = $join(it, null); + +// @ts-expect-error +$join(it, '+', '_'); +// @ts-expect-error +const res7: number = $join(it, ); From 2040ed92b319dc5547c2d757d48ab6e38013f390 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 20 Nov 2025 19:46:08 +0700 Subject: [PATCH 066/315] Types refactoring --- packages/core-js-types/package.json | 36 ++++++-- .../src/56/proposals/async-iteration.d.ts | 6 ++ .../src/56/proposals/error-cause.d.ts | 12 +++ scripts/build-types/config.mjs | 2 +- scripts/build-types/index.mjs | 89 +++++++++++-------- .../accessible-object-hasownproperty.test.ts | 1 - .../proposals/array-buffer-base64.test.ts | 1 - .../proposals/array-buffer-transfer.test.ts | 1 - .../global/proposals/array-filtering.test.ts | 1 - .../proposals/array-find-from-last.test.ts | 1 - .../global/proposals/array-flat-map.test.ts | 1 - .../global/proposals/array-from-async.test.ts | 1 - .../global/proposals/array-grouping.test.ts | 1 - .../global/proposals/array-includes.test.ts | 1 - .../array-is-template-object.test.ts | 1 - .../global/proposals/array-unique.test.ts | 1 - .../global/proposals/async-iteration.test.ts | 1 - .../proposals/async-iterator-helper.test.ts | 1 - .../global/proposals/await-dictionary.test.ts | 1 - .../proposals/change-array-by-copy.test.ts | 1 - .../proposals/collection-of-from.test.ts | 1 - .../data-view-get-set-uint8-clamped.test.ts | 1 - .../proposals/decorator-metadata.test.ts | 1 - .../global/proposals/error-cause.test.ts | 1 - .../explicit-resource-management.test.ts | 1 - .../global/proposals/extractors.test.ts | 1 - .../global/proposals/float16.test.ts | 1 - .../proposals/function-demethodize.test.ts | 1 - .../global/proposals/is-error.test.ts | 1 - .../proposals/iterator-chunking.test.ts | 1 - .../global/proposals/iterator-helpers.test.ts | 1 - .../global/proposals/iterator-join.test.ts | 1 - .../global/proposals/iterator-joint.test.ts | 1 - .../global/proposals/iterator-range.test.ts | 1 - .../proposals/iterator-sequencing.test.ts | 1 - .../proposals/json-parse-with-source.test.ts | 1 - .../global/proposals/map-upsert.test.ts | 1 - .../global/proposals/math-sum.test.ts | 1 - .../global/proposals/number-clamp.test.ts | 1 - .../proposals/object-from-entries.test.ts | 1 - ...bject-get-own-property-descriptors.test.ts | 1 - .../proposals/object-values-entries.test.ts | 1 - .../global/proposals/pattern-matching.test.ts | 1 - .../global/proposals/promise-any.test.ts | 1 - .../global/proposals/promise-finally.test.ts | 1 - .../global/proposals/promise-try.test.ts | 1 - .../proposals/promise-with-resolvers.test.ts | 1 - .../proposals/regexp-dotall-flag.test.ts | 1 - .../global/proposals/regexp-escaping.test.ts | 1 - .../proposals/regexp-named-groups.test.ts | 1 - .../relative-indexing-method.test.ts | 1 - .../global/proposals/set-methods.test.ts | 1 - .../global/proposals/string-cooked.test.ts | 1 - .../global/proposals/string-dedent.test.ts | 1 - .../proposals/string-left-right-trim.test.ts | 1 - .../global/proposals/string-match-all.test.ts | 1 - .../global/proposals/string-padding.test.ts | 1 - .../proposals/string-replace-all.test.ts | 1 - .../proposals/symbol-description.test.ts | 1 - .../proposals/symbol-predicates.test.ts | 1 - .../well-formed-unicode-strings.test.ts | 1 - tests/type-definitions/global/tsconfig.json | 7 +- tests/type-definitions/package-lock.json | 19 +++- tests/type-definitions/package.json | 5 +- .../proposals/change-array-by-copy.test.ts | 1 + .../pure/proposals/iterator-range.test.ts | 4 + tests/type-definitions/pure/tsconfig.json | 5 +- tests/type-definitions/runner.mjs | 6 +- tests/type-definitions/tsconfig.json | 2 +- 69 files changed, 142 insertions(+), 108 deletions(-) diff --git a/packages/core-js-types/package.json b/packages/core-js-types/package.json index 3e1b72c600ca..3a75561bb3f6 100644 --- a/packages/core-js-types/package.json +++ b/packages/core-js-types/package.json @@ -25,16 +25,40 @@ "email": "zloirock@zloirock.ru", "url": "http://zloirock.ru" }, - "types": "dist/core-js-types.56.d.ts", - "files": [ - "dist/core-js-types.56.d.ts" - ], + "types": "./actual.d.ts", "typesVersions": { ">=5.6": { - "*": ["dist/core-js-types.56.d.ts"] + "*": ["./dist/56/*"] }, ">=5.2": { - "*": ["dist/core-js-types.52.d.ts"] + "*": ["./dist/52/*"] + } + }, + "exports": { + ".": { + "types": "./dist/56/actual.d.ts", + "default": "./dist/56/actual.d.ts" + }, + "./actual": { + "types": "./dist/56/actual.d.ts", + "default": "./dist/56/actual.d.ts" + }, + "./es": { + "types": "./dist/56/es.d.ts", + "default": "./dist/56/es.d.ts" + }, + "./full": { + "types": "./dist/56/full.d.ts", + "default": "./dist/56/full.d.ts" + }, + "./pure": { + "types": "./dist/56/pure.d.ts", + "default": "./dist/56/pure.d.ts" + + }, + "./stable": { + "types": "./dist/56/stable.d.ts", + "default": "./dist/56/stable.d.ts" } }, "sideEffects": false diff --git a/packages/core-js-types/src/56/proposals/async-iteration.d.ts b/packages/core-js-types/src/56/proposals/async-iteration.d.ts index 98856336caf0..b822f489ab06 100644 --- a/packages/core-js-types/src/56/proposals/async-iteration.d.ts +++ b/packages/core-js-types/src/56/proposals/async-iteration.d.ts @@ -12,3 +12,9 @@ interface SymbolConstructor { */ readonly asyncIterator: unique symbol; } + +interface AsyncIteratorConstructor { + +} + +declare var AsyncIterator: AsyncIteratorConstructor; diff --git a/packages/core-js-types/src/56/proposals/error-cause.d.ts b/packages/core-js-types/src/56/proposals/error-cause.d.ts index 01bdbe8ef1d8..d10d80a6002f 100644 --- a/packages/core-js-types/src/56/proposals/error-cause.d.ts +++ b/packages/core-js-types/src/56/proposals/error-cause.d.ts @@ -55,6 +55,18 @@ declare global { (message?: string, options?: ErrorOptions): URIError; } + + interface AggregateError extends Error { + errors: any[]; + } + + interface AggregateErrorConstructor { + new (errors: Iterable, message?: string): AggregateError; + (errors: Iterable, message?: string): AggregateError; + readonly prototype: AggregateError; + } + + var AggregateError: AggregateErrorConstructor; } export {}; diff --git a/scripts/build-types/config.mjs b/scripts/build-types/config.mjs index fdaefbca84ce..12dd0bf274a2 100644 --- a/scripts/build-types/config.mjs +++ b/scripts/build-types/config.mjs @@ -2,6 +2,6 @@ export default { buildDir: 'packages/core-js-types/dist/', bundleName: 'core-js-types', latestTsVersion: 59, - packageName: '@core-js/pure/', + packageName: '@core-js/', srcDir: 'packages/core-js-types/src/', }; diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index ba718a7e1805..8969cda986f5 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -10,12 +10,20 @@ const { copy, outputFile, pathExists, readdir, remove } = fs; const versionArg = argv._.find(item => item.startsWith('version=')); const VERSION = versionArg ? versionArg.slice('version='.length) : undefined; - -async function buildType(typeFilePath, entry, options) { +const imports = { + es: new Set(), + stable: new Set(), + actual: new Set(), + full: new Set(), + pure: new Set(), +}; + +async function buildType(entry, options) { let { entryFromNamespace, subset = entryFromNamespace ?? 'full', template, templateStable, templateActual, templateFull, filter, modules, enforceEntryCreation, + customType, tsVersion, } = options; switch (subset) { @@ -50,9 +58,23 @@ async function buildType(typeFilePath, entry, options) { if (filter) modules = modules.filter(it => filter.has(it)); + const tplPure = template({ ...options, modules, rawModules, level, entry, types, packageName: `${ config.packageName }pure/` }); const tpl = template({ ...options, modules, rawModules, level, entry, types, packageName: config.packageName }); - await outputFile(typeFilePath, `${ tpl.dts }${ tpl.dts ? '\n\n' : '' }`, { flag: 'a' }); + types.forEach(type => { + imports[subset].add(type); + imports.pure.add(type); + }); + if (customType) { + imports[subset].add(customType); + imports.pure.add(customType); + } + + const filePath = buildFilePath(tsVersion, subset); + const filePathPure = buildFilePath(tsVersion, 'pure'); + + await outputFile(filePath, `${ tpl.dts }${ tpl.dts ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(filePathPure, `${ tplPure.dts }${ tplPure.dts ? '\n\n' : '' }`, { flag: 'a' }); } async function getVersions() { @@ -70,19 +92,7 @@ async function buildTypesDirForTSVersion(version) { const versions = await getVersions(); for (const v of versions) { if (v > version) break; - await copy(path.join(config.srcDir, v.toString()), path.join(config.buildDir, version.toString())); - } -} - -async function addImports(filePath, fromPath) { - const entries = await readdir(fromPath, { withFileTypes: true }); - for (const entry of entries) { - if (entry.isDirectory()) { - await addImports(filePath, path.join(fromPath, entry.name)); - } else { - const typePath = path.join(fromPath, entry.name).replace(config.buildDir, ''); - await outputFile(filePath, `/// \n`, { flag: 'a' }); - } + await copy(path.join(config.srcDir, v.toString()), path.join(config.buildDir, version.toString(), 'types')); } } @@ -96,38 +106,43 @@ const ESWithProposalsSet = new Set(ESWithProposalsModules); const StableSet = new Set(StableModules); const ActualSet = new Set(ActualModules); +function buildFilePath(tsVersion, subset) { + return path.join(config.buildDir, tsVersion.toString(), `${ subset }.d.ts`); +} + +async function prependImports(version) { + for (const subset of Object.keys(imports)) { + const filePath = buildFilePath(version, subset); + const importLines = Array.from(imports[subset], it => `/// `).join('\n'); + const originalContent = await fs.readFile(filePath, 'utf8'); + await outputFile(filePath, `${ importLines }\n\n${ originalContent }`); + } +} + async function buildTypesForTSVersion(tsVersion) { tsVersion = tsVersion.toString().replace('.', ''); - const bundleName = `${ config.bundleName }.${ tsVersion === config.latestTsVersion ? 'latest' : tsVersion }.d.ts`; - const bundlePath = path.join(config.buildDir, bundleName); - const typesPath = path.join(config.buildDir, tsVersion.toString()); + const bundlePath = path.join(config.buildDir, tsVersion); if (await pathExists(bundlePath)) await remove(bundlePath); - if (await pathExists(typesPath)) await remove(typesPath); await buildTypesDirForTSVersion(tsVersion); - await addImports(bundlePath, typesPath); for (const [entry, definition] of Object.entries(features)) { - await buildType(bundlePath, `es/${ entry }`, { ...definition, entryFromNamespace: 'es' }); - await buildType(bundlePath, `stable/${ entry }`, { ...definition, entryFromNamespace: 'stable' }); - await buildType(bundlePath, `actual/${ entry }`, { ...definition, entryFromNamespace: 'actual' }); - await buildType(bundlePath, `full/${ entry }`, { ...definition, entryFromNamespace: 'full' }); + await buildType(`es/${ entry }`, { ...definition, entryFromNamespace: 'es', tsVersion }); + await buildType(`stable/${ entry }`, { ...definition, entryFromNamespace: 'stable', tsVersion }); + await buildType(`actual/${ entry }`, { ...definition, entryFromNamespace: 'actual', tsVersion }); + await buildType(`full/${ entry }`, { ...definition, entryFromNamespace: 'full', tsVersion }); } for (const [name, definition] of Object.entries(proposals)) { - await buildType(bundlePath, `proposals/${ name }`, { ...definition, template: $proposal }); + await buildType(`proposals/${ name }`, { ...definition, template: $proposal, tsVersion }); } - await buildType(bundlePath, 'stage/3', { template: $path, modules: ActualModules, subset: 'es-stage' }); - await buildType(bundlePath, 'stage/2.7', { template: $path, modules: modulesToStage(StableModules, 2.7), subset: 'es-stage' }); - await buildType(bundlePath, 'stage/2', { template: $path, modules: modulesToStage(StableModules, 2), subset: 'es-stage' }); - await buildType(bundlePath, 'stage/1', { template: $path, modules: modulesToStage(StableModules, 1), subset: 'es-stage' }); - await buildType(bundlePath, 'stage/0', { template: $path, modules: AllModules, subset: 'es-stage' }); - - await buildType(bundlePath, 'es/index', { template: $path, modules: ESModules, subset: 'es' }); - await buildType(bundlePath, 'stable/index', { template: $path, modules: StableModules, subset: 'stable' }); - await buildType(bundlePath, 'actual/index', { template: $path, modules: ActualModules }); - await buildType(bundlePath, 'full/index', { template: $path, modules: AllModules }); - await buildType(bundlePath, 'index', { template: $path, modules: ActualModules }); + await buildType('es/index', { template: $path, modules: ESModules, subset: 'es', tsVersion }); + await buildType('stable/index', { template: $path, modules: StableModules, subset: 'stable', tsVersion }); + await buildType('actual/index', { template: $path, modules: ActualModules, tsVersion }); + await buildType('full/index', { template: $path, modules: AllModules, tsVersion }); + await buildType('index', { template: $path, modules: ActualModules, tsVersion }); + + await prependImports(tsVersion); } if (VERSION) { diff --git a/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts b/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts index 83fe9356c184..b01a6f0c1a06 100644 --- a/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts +++ b/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; Object.hasOwn({a: 1}, 'a'); Object.hasOwn([], 0); diff --git a/tests/type-definitions/global/proposals/array-buffer-base64.test.ts b/tests/type-definitions/global/proposals/array-buffer-base64.test.ts index 6f5741d2f42a..22d0162d6899 100644 --- a/tests/type-definitions/global/proposals/array-buffer-base64.test.ts +++ b/tests/type-definitions/global/proposals/array-buffer-base64.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; function acceptUint8Array(v: Uint8Array) {} function acceptProcessMetadata(v: { read: number; written: number }) {} diff --git a/tests/type-definitions/global/proposals/array-buffer-transfer.test.ts b/tests/type-definitions/global/proposals/array-buffer-transfer.test.ts index b8482003ca2f..7e4acf0eae5f 100644 --- a/tests/type-definitions/global/proposals/array-buffer-transfer.test.ts +++ b/tests/type-definitions/global/proposals/array-buffer-transfer.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const ab = new ArrayBuffer(16); // todo uncomment when fixed diff --git a/tests/type-definitions/global/proposals/array-filtering.test.ts b/tests/type-definitions/global/proposals/array-filtering.test.ts index 5092abf1edc1..68fcb38cec45 100644 --- a/tests/type-definitions/global/proposals/array-filtering.test.ts +++ b/tests/type-definitions/global/proposals/array-filtering.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; [1, 2, 3].filterReject((v, i, arr) => v > 1); ['a', 'b'].filterReject((v, i, arr) => v === 'a'); diff --git a/tests/type-definitions/global/proposals/array-find-from-last.test.ts b/tests/type-definitions/global/proposals/array-find-from-last.test.ts index d5e87481e5a9..2d3d90db1777 100644 --- a/tests/type-definitions/global/proposals/array-find-from-last.test.ts +++ b/tests/type-definitions/global/proposals/array-find-from-last.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const res: number | undefined = [1, 2, 3].findLast(v => v > 1); [1, 2, 3].findLast((v): v is 2 => v === 2); diff --git a/tests/type-definitions/global/proposals/array-flat-map.test.ts b/tests/type-definitions/global/proposals/array-flat-map.test.ts index f26911d88cb7..8ae7007f3a6d 100644 --- a/tests/type-definitions/global/proposals/array-flat-map.test.ts +++ b/tests/type-definitions/global/proposals/array-flat-map.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const flatMapped: number[] = [1, 2, 3].flatMap(x => [x, x * 2]); const flatMapped2: string[] = ['a', 'b', 'c'].flatMap(x => [x, x.toUpperCase()]); diff --git a/tests/type-definitions/global/proposals/array-from-async.test.ts b/tests/type-definitions/global/proposals/array-from-async.test.ts index 79a79405c088..fa8209bf9c1d 100644 --- a/tests/type-definitions/global/proposals/array-from-async.test.ts +++ b/tests/type-definitions/global/proposals/array-from-async.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; Array.fromAsync([1, 2, 3]); Array.fromAsync([Promise.resolve(1), 2, 3]); diff --git a/tests/type-definitions/global/proposals/array-grouping.test.ts b/tests/type-definitions/global/proposals/array-grouping.test.ts index 095a15355ba1..22380f95d21a 100644 --- a/tests/type-definitions/global/proposals/array-grouping.test.ts +++ b/tests/type-definitions/global/proposals/array-grouping.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const arr = [1, 2, 3, 4, 5]; const objGroup: Partial> = Object.groupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); diff --git a/tests/type-definitions/global/proposals/array-includes.test.ts b/tests/type-definitions/global/proposals/array-includes.test.ts index 176975fc64c0..5d8745599020 100644 --- a/tests/type-definitions/global/proposals/array-includes.test.ts +++ b/tests/type-definitions/global/proposals/array-includes.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const arr: number[] = [1, 2, 3]; const arrRes: boolean = arr.includes(2); diff --git a/tests/type-definitions/global/proposals/array-is-template-object.test.ts b/tests/type-definitions/global/proposals/array-is-template-object.test.ts index 4af57fba7d82..bc54ef0bd82d 100644 --- a/tests/type-definitions/global/proposals/array-is-template-object.test.ts +++ b/tests/type-definitions/global/proposals/array-is-template-object.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const t: boolean = Array.isTemplateObject([]); Array.isTemplateObject({}); diff --git a/tests/type-definitions/global/proposals/array-unique.test.ts b/tests/type-definitions/global/proposals/array-unique.test.ts index f547b5654aa5..d8501a6296a6 100644 --- a/tests/type-definitions/global/proposals/array-unique.test.ts +++ b/tests/type-definitions/global/proposals/array-unique.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; type Obj = { a: number; b: string }; const arr: Obj[] = [{ a: 1, b: 'x' }, { a: 2, b: 'y' }]; diff --git a/tests/type-definitions/global/proposals/async-iteration.test.ts b/tests/type-definitions/global/proposals/async-iteration.test.ts index 67de54f6c01c..b2989ab42dd2 100644 --- a/tests/type-definitions/global/proposals/async-iteration.test.ts +++ b/tests/type-definitions/global/proposals/async-iteration.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const sym: symbol = Symbol.asyncIterator; diff --git a/tests/type-definitions/global/proposals/async-iterator-helper.test.ts b/tests/type-definitions/global/proposals/async-iterator-helper.test.ts index 040653aebd31..a0e0048f9ba4 100644 --- a/tests/type-definitions/global/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/global/proposals/async-iterator-helper.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const res: AsyncIterator = AsyncIterator.from([1, 2, 3]); const res2: AsyncIterator = AsyncIterator.from(new Set([1, 2, 3])); diff --git a/tests/type-definitions/global/proposals/await-dictionary.test.ts b/tests/type-definitions/global/proposals/await-dictionary.test.ts index 66da7f658f20..563a3c46e9e6 100644 --- a/tests/type-definitions/global/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/global/proposals/await-dictionary.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const res: Promise<{ a: number, b: string, c: boolean }> = Promise.allKeyed({ a: Promise.resolve(1), diff --git a/tests/type-definitions/global/proposals/change-array-by-copy.test.ts b/tests/type-definitions/global/proposals/change-array-by-copy.test.ts index a8c94b79634c..70cb1e7971de 100644 --- a/tests/type-definitions/global/proposals/change-array-by-copy.test.ts +++ b/tests/type-definitions/global/proposals/change-array-by-copy.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const arr: number[] = [1, 2, 3]; const arrRev: number[] = arr.toReversed(); diff --git a/tests/type-definitions/global/proposals/collection-of-from.test.ts b/tests/type-definitions/global/proposals/collection-of-from.test.ts index 0873339ec620..e5ac9f57c86c 100644 --- a/tests/type-definitions/global/proposals/collection-of-from.test.ts +++ b/tests/type-definitions/global/proposals/collection-of-from.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const arrEntries: Array<[string, number]> = [['a', 1], ['b', 2]]; const mapFrom: Map = Map.from(arrEntries, v => String(v)); diff --git a/tests/type-definitions/global/proposals/data-view-get-set-uint8-clamped.test.ts b/tests/type-definitions/global/proposals/data-view-get-set-uint8-clamped.test.ts index 16ee58b80c98..da6e0703bfaa 100644 --- a/tests/type-definitions/global/proposals/data-view-get-set-uint8-clamped.test.ts +++ b/tests/type-definitions/global/proposals/data-view-get-set-uint8-clamped.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; declare const dv: DataView; diff --git a/tests/type-definitions/global/proposals/decorator-metadata.test.ts b/tests/type-definitions/global/proposals/decorator-metadata.test.ts index 8ccdc984a580..4abbf2decd7d 100644 --- a/tests/type-definitions/global/proposals/decorator-metadata.test.ts +++ b/tests/type-definitions/global/proposals/decorator-metadata.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const rsmd1: symbol = Symbol.metadata; const rsmd2: typeof Symbol.metadata = Symbol.metadata; diff --git a/tests/type-definitions/global/proposals/error-cause.test.ts b/tests/type-definitions/global/proposals/error-cause.test.ts index 37049a35f62b..099e6283e8da 100644 --- a/tests/type-definitions/global/proposals/error-cause.test.ts +++ b/tests/type-definitions/global/proposals/error-cause.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const prevError = new Error('Prev error'); diff --git a/tests/type-definitions/global/proposals/explicit-resource-management.test.ts b/tests/type-definitions/global/proposals/explicit-resource-management.test.ts index f2c99f328671..b0d4a58e75d4 100644 --- a/tests/type-definitions/global/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/global/proposals/explicit-resource-management.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const d: symbol = Symbol.dispose; const ad: symbol = Symbol.asyncDispose; diff --git a/tests/type-definitions/global/proposals/extractors.test.ts b/tests/type-definitions/global/proposals/extractors.test.ts index 826ff039b864..13ee20e150fe 100644 --- a/tests/type-definitions/global/proposals/extractors.test.ts +++ b/tests/type-definitions/global/proposals/extractors.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const rscs1: symbol = Symbol.customMatcher; const rscs2: typeof Symbol.customMatcher = Symbol.customMatcher; diff --git a/tests/type-definitions/global/proposals/float16.test.ts b/tests/type-definitions/global/proposals/float16.test.ts index 62097d9f483d..810fc9e2c788 100644 --- a/tests/type-definitions/global/proposals/float16.test.ts +++ b/tests/type-definitions/global/proposals/float16.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const res: number = Math.f16round(1); diff --git a/tests/type-definitions/global/proposals/function-demethodize.test.ts b/tests/type-definitions/global/proposals/function-demethodize.test.ts index 2fce02473635..be44d65caf70 100644 --- a/tests/type-definitions/global/proposals/function-demethodize.test.ts +++ b/tests/type-definitions/global/proposals/function-demethodize.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; function sumTo(this: { base: number }, a: number, b: number): number { return this.base + a + b; diff --git a/tests/type-definitions/global/proposals/is-error.test.ts b/tests/type-definitions/global/proposals/is-error.test.ts index 63aff9ef9b29..fde89158e17f 100644 --- a/tests/type-definitions/global/proposals/is-error.test.ts +++ b/tests/type-definitions/global/proposals/is-error.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const e = new Error(); const ne = { foo: 1 }; diff --git a/tests/type-definitions/global/proposals/iterator-chunking.test.ts b/tests/type-definitions/global/proposals/iterator-chunking.test.ts index 4c185307381e..533ad35aa7ea 100644 --- a/tests/type-definitions/global/proposals/iterator-chunking.test.ts +++ b/tests/type-definitions/global/proposals/iterator-chunking.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; declare function getNumberIterator(): Iterator; diff --git a/tests/type-definitions/global/proposals/iterator-helpers.test.ts b/tests/type-definitions/global/proposals/iterator-helpers.test.ts index 51cdafd16d15..1686ac2ab661 100644 --- a/tests/type-definitions/global/proposals/iterator-helpers.test.ts +++ b/tests/type-definitions/global/proposals/iterator-helpers.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; declare const it: Iterator; declare const itStr: Iterator; diff --git a/tests/type-definitions/global/proposals/iterator-join.test.ts b/tests/type-definitions/global/proposals/iterator-join.test.ts index 3ca966b1a1e5..9c21fbe3eaaf 100644 --- a/tests/type-definitions/global/proposals/iterator-join.test.ts +++ b/tests/type-definitions/global/proposals/iterator-join.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; declare const it: Iterator; diff --git a/tests/type-definitions/global/proposals/iterator-joint.test.ts b/tests/type-definitions/global/proposals/iterator-joint.test.ts index a714a7b52add..3701cbd40dcc 100644 --- a/tests/type-definitions/global/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/global/proposals/iterator-joint.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; Iterator.zip([[1, 2, 3], [4, 5, 6]]); Iterator.zip([['a', 'b', 'c'], ['d', 'e', 'f']]); diff --git a/tests/type-definitions/global/proposals/iterator-range.test.ts b/tests/type-definitions/global/proposals/iterator-range.test.ts index eb3421a5a1d8..599bde908a47 100644 --- a/tests/type-definitions/global/proposals/iterator-range.test.ts +++ b/tests/type-definitions/global/proposals/iterator-range.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const rir1: Iterator = Iterator.range(1, 10); Iterator.range(1, 10, 1); diff --git a/tests/type-definitions/global/proposals/iterator-sequencing.test.ts b/tests/type-definitions/global/proposals/iterator-sequencing.test.ts index 7615f724438e..21a342cca779 100644 --- a/tests/type-definitions/global/proposals/iterator-sequencing.test.ts +++ b/tests/type-definitions/global/proposals/iterator-sequencing.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; declare const its1: Iterable; declare const arrs: string[]; diff --git a/tests/type-definitions/global/proposals/json-parse-with-source.test.ts b/tests/type-definitions/global/proposals/json-parse-with-source.test.ts index 47b31e0d32a5..d8c9a4944fd8 100644 --- a/tests/type-definitions/global/proposals/json-parse-with-source.test.ts +++ b/tests/type-definitions/global/proposals/json-parse-with-source.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const r: CoreJSRawJSON = JSON.rawJSON('{"a":123}'); diff --git a/tests/type-definitions/global/proposals/map-upsert.test.ts b/tests/type-definitions/global/proposals/map-upsert.test.ts index f2dd06e4ea11..67e80f422712 100644 --- a/tests/type-definitions/global/proposals/map-upsert.test.ts +++ b/tests/type-definitions/global/proposals/map-upsert.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; declare const map: Map; diff --git a/tests/type-definitions/global/proposals/math-sum.test.ts b/tests/type-definitions/global/proposals/math-sum.test.ts index 07a5b5b873d2..2b48e4628c20 100644 --- a/tests/type-definitions/global/proposals/math-sum.test.ts +++ b/tests/type-definitions/global/proposals/math-sum.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; function acceptsNumber(x: number) {} diff --git a/tests/type-definitions/global/proposals/number-clamp.test.ts b/tests/type-definitions/global/proposals/number-clamp.test.ts index 8c6239425cc5..44617c511b3f 100644 --- a/tests/type-definitions/global/proposals/number-clamp.test.ts +++ b/tests/type-definitions/global/proposals/number-clamp.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; declare const num: number; const clamped: number = num.clamp(0, 100); diff --git a/tests/type-definitions/global/proposals/object-from-entries.test.ts b/tests/type-definitions/global/proposals/object-from-entries.test.ts index 346cea84cf8e..3a2c20009b15 100644 --- a/tests/type-definitions/global/proposals/object-from-entries.test.ts +++ b/tests/type-definitions/global/proposals/object-from-entries.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; declare const objEntries: Iterable; declare const mixedEntries: Iterable; diff --git a/tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts b/tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts index 0b4a1ddc7e95..b938ffbdf181 100644 --- a/tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts +++ b/tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const obj = { a: 1, b: 'x', c: true }; const objDescs: { a: TypedPropertyDescriptor; b: TypedPropertyDescriptor; c: TypedPropertyDescriptor } & diff --git a/tests/type-definitions/global/proposals/object-values-entries.test.ts b/tests/type-definitions/global/proposals/object-values-entries.test.ts index e4cd08a093db..08836ce7eb8e 100644 --- a/tests/type-definitions/global/proposals/object-values-entries.test.ts +++ b/tests/type-definitions/global/proposals/object-values-entries.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const obj = { a: 1, b: 2 }; const arr = [1, 2, 3]; diff --git a/tests/type-definitions/global/proposals/pattern-matching.test.ts b/tests/type-definitions/global/proposals/pattern-matching.test.ts index 1359b17fc624..7d7f8de721aa 100644 --- a/tests/type-definitions/global/proposals/pattern-matching.test.ts +++ b/tests/type-definitions/global/proposals/pattern-matching.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const sym: symbol = Symbol.customMatcher; diff --git a/tests/type-definitions/global/proposals/promise-any.test.ts b/tests/type-definitions/global/proposals/promise-any.test.ts index 7229fae7f45b..aa174df5ac4d 100644 --- a/tests/type-definitions/global/proposals/promise-any.test.ts +++ b/tests/type-definitions/global/proposals/promise-any.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const arr = [Promise.resolve(1), Promise.resolve("foo"), 3] as const; const justNumbers = [1, 2, 3]; diff --git a/tests/type-definitions/global/proposals/promise-finally.test.ts b/tests/type-definitions/global/proposals/promise-finally.test.ts index 5af0a95d6a6e..c0923cfa112f 100644 --- a/tests/type-definitions/global/proposals/promise-finally.test.ts +++ b/tests/type-definitions/global/proposals/promise-finally.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const p1 = Promise.resolve(42); const pf1: Promise = p1.finally(); diff --git a/tests/type-definitions/global/proposals/promise-try.test.ts b/tests/type-definitions/global/proposals/promise-try.test.ts index 39812e12574c..1268220ec85d 100644 --- a/tests/type-definitions/global/proposals/promise-try.test.ts +++ b/tests/type-definitions/global/proposals/promise-try.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const pt1: Promise = Promise.try(() => 42); const pt2: Promise = Promise.try(() => Promise.resolve("hi")); diff --git a/tests/type-definitions/global/proposals/promise-with-resolvers.test.ts b/tests/type-definitions/global/proposals/promise-with-resolvers.test.ts index 60aba896d2b2..a22face5a074 100644 --- a/tests/type-definitions/global/proposals/promise-with-resolvers.test.ts +++ b/tests/type-definitions/global/proposals/promise-with-resolvers.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const pr = Promise.withResolvers(); const pr2 = Promise.withResolvers(); diff --git a/tests/type-definitions/global/proposals/regexp-dotall-flag.test.ts b/tests/type-definitions/global/proposals/regexp-dotall-flag.test.ts index c11df9dd200f..286c56a36090 100644 --- a/tests/type-definitions/global/proposals/regexp-dotall-flag.test.ts +++ b/tests/type-definitions/global/proposals/regexp-dotall-flag.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const r1 = new RegExp('foo.bar', 's'); const dotAll: boolean = r1.dotAll; diff --git a/tests/type-definitions/global/proposals/regexp-escaping.test.ts b/tests/type-definitions/global/proposals/regexp-escaping.test.ts index 3361addbb13f..64bd78bca4dd 100644 --- a/tests/type-definitions/global/proposals/regexp-escaping.test.ts +++ b/tests/type-definitions/global/proposals/regexp-escaping.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const escaped1: string = RegExp.escape('foo.*+?^${}()|[]\\'); const escaped2: string = RegExp.escape(''); diff --git a/tests/type-definitions/global/proposals/regexp-named-groups.test.ts b/tests/type-definitions/global/proposals/regexp-named-groups.test.ts index 5b06452f2e22..8ae7eae0b1fa 100644 --- a/tests/type-definitions/global/proposals/regexp-named-groups.test.ts +++ b/tests/type-definitions/global/proposals/regexp-named-groups.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; declare const execArr: RegExpExecArray; declare const matchArr: RegExpMatchArray; diff --git a/tests/type-definitions/global/proposals/relative-indexing-method.test.ts b/tests/type-definitions/global/proposals/relative-indexing-method.test.ts index e1655396e16a..f024e486daae 100644 --- a/tests/type-definitions/global/proposals/relative-indexing-method.test.ts +++ b/tests/type-definitions/global/proposals/relative-indexing-method.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const str = 'hello'; const s1: string | undefined = str.at(0); diff --git a/tests/type-definitions/global/proposals/set-methods.test.ts b/tests/type-definitions/global/proposals/set-methods.test.ts index 07de09497a42..5b1f3313706d 100644 --- a/tests/type-definitions/global/proposals/set-methods.test.ts +++ b/tests/type-definitions/global/proposals/set-methods.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const setA = new Set([1, 2, 3]); const setB = new Set(['a', 'b', 'c']); diff --git a/tests/type-definitions/global/proposals/string-cooked.test.ts b/tests/type-definitions/global/proposals/string-cooked.test.ts index 2a852210bdf2..d2884ba55d55 100644 --- a/tests/type-definitions/global/proposals/string-cooked.test.ts +++ b/tests/type-definitions/global/proposals/string-cooked.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const rcooked1: string = String.cooked('foo', 1, 2, 3); String.cooked(['foo', 'bar'], 1, 2); diff --git a/tests/type-definitions/global/proposals/string-dedent.test.ts b/tests/type-definitions/global/proposals/string-dedent.test.ts index 31a74ee8d1f3..19d3004c1f13 100644 --- a/tests/type-definitions/global/proposals/string-dedent.test.ts +++ b/tests/type-definitions/global/proposals/string-dedent.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const rdedent1: string = String.dedent`foo\nbar`; const rdedent2: string = String.dedent`line1 diff --git a/tests/type-definitions/global/proposals/string-left-right-trim.test.ts b/tests/type-definitions/global/proposals/string-left-right-trim.test.ts index e791df02bf70..0da6d7ed51a7 100644 --- a/tests/type-definitions/global/proposals/string-left-right-trim.test.ts +++ b/tests/type-definitions/global/proposals/string-left-right-trim.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const s = 'abc'; const t1: string = s.trimEnd(); diff --git a/tests/type-definitions/global/proposals/string-match-all.test.ts b/tests/type-definitions/global/proposals/string-match-all.test.ts index 97cadde985b3..c7031ada18a1 100644 --- a/tests/type-definitions/global/proposals/string-match-all.test.ts +++ b/tests/type-definitions/global/proposals/string-match-all.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const s = 'abcabc'; const re = /abc/g; diff --git a/tests/type-definitions/global/proposals/string-padding.test.ts b/tests/type-definitions/global/proposals/string-padding.test.ts index 5bbbd5f8880c..42e5c44aeea5 100644 --- a/tests/type-definitions/global/proposals/string-padding.test.ts +++ b/tests/type-definitions/global/proposals/string-padding.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const s = 'foo'; const p1: string = s.padStart(5); diff --git a/tests/type-definitions/global/proposals/string-replace-all.test.ts b/tests/type-definitions/global/proposals/string-replace-all.test.ts index 045f65547cd3..c65e1000ebdc 100644 --- a/tests/type-definitions/global/proposals/string-replace-all.test.ts +++ b/tests/type-definitions/global/proposals/string-replace-all.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const s = 'foo bar foo'; diff --git a/tests/type-definitions/global/proposals/symbol-description.test.ts b/tests/type-definitions/global/proposals/symbol-description.test.ts index 8a55612203dd..94f52767ea83 100644 --- a/tests/type-definitions/global/proposals/symbol-description.test.ts +++ b/tests/type-definitions/global/proposals/symbol-description.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const sym1 = Symbol('foo'); const d1: string | undefined = sym1.description; diff --git a/tests/type-definitions/global/proposals/symbol-predicates.test.ts b/tests/type-definitions/global/proposals/symbol-predicates.test.ts index 54e49d4a1f63..5cad02b9fd39 100644 --- a/tests/type-definitions/global/proposals/symbol-predicates.test.ts +++ b/tests/type-definitions/global/proposals/symbol-predicates.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const rsymbol1: boolean = Symbol.isRegisteredSymbol(Symbol.for('foo')); const rsymbol2: boolean = Symbol.isRegisteredSymbol(undefined); diff --git a/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts b/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts index 0d18568b8ed5..e089e4857fa2 100644 --- a/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts +++ b/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const s = 'test'; const b: boolean = s.isWellFormed(); diff --git a/tests/type-definitions/global/tsconfig.json b/tests/type-definitions/global/tsconfig.json index 5197ce2769f4..efcadcbb61dc 100644 --- a/tests/type-definitions/global/tsconfig.json +++ b/tests/type-definitions/global/tsconfig.json @@ -1,4 +1,9 @@ { "extends": "../tsconfig.json", - "include": ["./**/*.ts"] + "include": ["./**/*.ts"], + "compilerOptions": { + "types": [ + "@core-js/types/full" + ] + } } diff --git a/tests/type-definitions/package-lock.json b/tests/type-definitions/package-lock.json index d36672ed25f6..467dd7d0c49d 100644 --- a/tests/type-definitions/package-lock.json +++ b/tests/type-definitions/package-lock.json @@ -4,7 +4,24 @@ "requires": true, "packages": { "": { - "name": "tests/type-definitions" + "name": "tests/type-definitions", + "devDependencies": { + "@core-js/types": "../../packages/core-js-types/" + } + }, + "../../packages/core-js-types": { + "name": "@core-js/types", + "version": "4.0.0-alpha.0", + "dev": true, + "license": "SEE LICENSE IN LICENSE.md", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, + "node_modules/@core-js/types": { + "resolved": "../../packages/core-js-types", + "link": true } } } diff --git a/tests/type-definitions/package.json b/tests/type-definitions/package.json index fcf49f09a0c2..ea12b3a8c99b 100644 --- a/tests/type-definitions/package.json +++ b/tests/type-definitions/package.json @@ -1,3 +1,6 @@ { - "name": "tests/type-definitions" + "name": "tests/type-definitions", + "devDependencies": { + "@core-js/types": "../../packages/core-js-types/" + } } diff --git a/tests/type-definitions/pure/proposals/change-array-by-copy.test.ts b/tests/type-definitions/pure/proposals/change-array-by-copy.test.ts index 6e2051155916..1fe02e6d7f55 100644 --- a/tests/type-definitions/pure/proposals/change-array-by-copy.test.ts +++ b/tests/type-definitions/pure/proposals/change-array-by-copy.test.ts @@ -2,6 +2,7 @@ import arrayToReversed from '@core-js/pure/full/array/to-reversed'; import arrayToSorted from '@core-js/pure/full/array/to-sorted'; import arrayToSpliced from '@core-js/pure/full/array/to-spliced'; import arrayWith from '@core-js/pure/full/array/with'; +import '@core-js/types/actual'; const arr: number[] = [1, 2, 3]; const arrRev: number[] = arrayToReversed(arr); diff --git a/tests/type-definitions/pure/proposals/iterator-range.test.ts b/tests/type-definitions/pure/proposals/iterator-range.test.ts index 247713a43dfc..0b2dcfd9c75b 100644 --- a/tests/type-definitions/pure/proposals/iterator-range.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-range.test.ts @@ -1,5 +1,9 @@ import range from '@core-js/pure/full/iterator/range'; +// import Promise from '@core-js/actual/promise/index'; +// import $iteratorFull from '@core-js/pure/full/promise/index'; +// import $iteratorActual from '@core-js/pure/actual/iterator/index'; + const rir1: Iterator = range(1, 10); range(1, 10, 1); range(1, 10, { step: 1 }); diff --git a/tests/type-definitions/pure/tsconfig.json b/tests/type-definitions/pure/tsconfig.json index 5197ce2769f4..3e633c7056c8 100644 --- a/tests/type-definitions/pure/tsconfig.json +++ b/tests/type-definitions/pure/tsconfig.json @@ -1,4 +1,7 @@ { "extends": "../tsconfig.json", - "include": ["./**/*.ts"] + "include": ["./**/*.ts"], + "compilerOptions": { + "types": ["@core-js/types/pure"] + } } diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 03cdebfe0deb..6d797901c6a9 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -46,13 +46,13 @@ const runTestsOnEnv = async function ({ typeScriptVersion, target, type, env, li $.verbose = false; const envLibName = env ? env.substring(0, env.lastIndexOf('@')) : ''; const command = `npx -p typescript@${ typeScriptVersion }${ env ? ` -p ${ env }` : '' } ` - + `tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target }${ lib ? `,${ lib }` : '' }${ env ? ` --types @core-js/types,${ envLibName }` : '' }`; + + `tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target }${ lib ? `,${ lib }` : '' }${ env ? ` --types @core-js/types${ type === 'pure' ? '/pure' : '/full' },${ envLibName }` : '' }`; echo(`$ ${ command }`); try { if (env && lib) { - await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target },${ lib } --types @core-js/types,${ envLibName }`.quiet(); + await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target },${ lib } --types @core-js/types${ type === 'pure' ? '/pure' : '/full' },${ envLibName }`.quiet(); } else if (env) { - await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target } --types @core-js/types,${ envLibName }`.quiet(); + await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target } --types @core-js/types${ type === 'pure' ? '/pure' : '/full' },${ envLibName }`.quiet(); } else if (lib) { await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target },${ lib }`.quiet(); } else { diff --git a/tests/type-definitions/tsconfig.json b/tests/type-definitions/tsconfig.json index 983fdac6373a..d0ba9a0cb6aa 100644 --- a/tests/type-definitions/tsconfig.json +++ b/tests/type-definitions/tsconfig.json @@ -7,7 +7,7 @@ "moduleResolution": "node", "noEmit": true, "types": [ - "@core-js/types" + "@core-js/types/pure" ] }, "include": [ From 4abe163983b8baa9d5390014bf53a7b012961271 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 21 Nov 2025 20:01:52 +0700 Subject: [PATCH 067/315] Split included types depending on TypeScript version --- packages/core-js-types/package.json | 6 ++++++ .../src/52/proposals/async-iteration.d.ts | 6 ++++++ .../src/52/proposals/iterator-join.d.ts | 6 ++++++ packages/core-js-types/src/52/web/atob.d.ts | 6 ++++++ packages/core-js-types/src/52/web/btoa.d.ts | 7 +++++++ .../core-js-types/src/52/web/queue-microtask.d.ts | 9 +++++++++ .../core-js-types/src/52/web/structured-clone.d.ts | 14 ++++++++++++++ packages/core-js-types/src/52/web/url-to-json.d.ts | 3 +++ 8 files changed, 57 insertions(+) create mode 100644 packages/core-js-types/src/52/proposals/iterator-join.d.ts create mode 100644 packages/core-js-types/src/52/web/atob.d.ts create mode 100644 packages/core-js-types/src/52/web/btoa.d.ts create mode 100644 packages/core-js-types/src/52/web/queue-microtask.d.ts create mode 100644 packages/core-js-types/src/52/web/structured-clone.d.ts create mode 100644 packages/core-js-types/src/52/web/url-to-json.d.ts diff --git a/packages/core-js-types/package.json b/packages/core-js-types/package.json index 3a75561bb3f6..d371a2447000 100644 --- a/packages/core-js-types/package.json +++ b/packages/core-js-types/package.json @@ -36,27 +36,33 @@ }, "exports": { ".": { + "types@>=5.6": "./dist/56/actual.d.ts", "types": "./dist/56/actual.d.ts", "default": "./dist/56/actual.d.ts" }, "./actual": { + "types@>=5.6": "./dist/56/actual.d.ts", "types": "./dist/56/actual.d.ts", "default": "./dist/56/actual.d.ts" }, "./es": { + "types@>=5.6": "./dist/56/es.d.ts", "types": "./dist/56/es.d.ts", "default": "./dist/56/es.d.ts" }, "./full": { + "types@>=5.6": "./dist/56/full.d.ts", "types": "./dist/56/full.d.ts", "default": "./dist/56/full.d.ts" }, "./pure": { + "types@>=5.6": "./dist/56/pure.d.ts", "types": "./dist/56/pure.d.ts", "default": "./dist/56/pure.d.ts" }, "./stable": { + "types@>=5.6": "./dist/56/stable.d.ts", "types": "./dist/56/stable.d.ts", "default": "./dist/56/stable.d.ts" } diff --git a/packages/core-js-types/src/52/proposals/async-iteration.d.ts b/packages/core-js-types/src/52/proposals/async-iteration.d.ts index 9fecd8b65641..abc7c772078d 100644 --- a/packages/core-js-types/src/52/proposals/async-iteration.d.ts +++ b/packages/core-js-types/src/52/proposals/async-iteration.d.ts @@ -8,3 +8,9 @@ interface SymbolConstructor { readonly asyncIterator: unique symbol; } + +interface AsyncIteratorConstructor { + +} + +declare var AsyncIterator: AsyncIteratorConstructor; diff --git a/packages/core-js-types/src/52/proposals/iterator-join.d.ts b/packages/core-js-types/src/52/proposals/iterator-join.d.ts new file mode 100644 index 000000000000..7f0151419bf2 --- /dev/null +++ b/packages/core-js-types/src/52/proposals/iterator-join.d.ts @@ -0,0 +1,6 @@ +// proposal stage: 0 +// https://github.com/bakkot/proposal-iterator-join + +interface Iterator { + join(separator?: unknown): string; +} diff --git a/packages/core-js-types/src/52/web/atob.d.ts b/packages/core-js-types/src/52/web/atob.d.ts new file mode 100644 index 000000000000..d08b3902da6c --- /dev/null +++ b/packages/core-js-types/src/52/web/atob.d.ts @@ -0,0 +1,6 @@ +/** + * Decodes a string of data which has been encoded using Base64 encoding. + * @param data A base64-encoded string, using the alphabet produced by btoa(). + * @returns A binary string containing raw bytes decoded from encodedData. + */ +declare function atob(data: string): string; diff --git a/packages/core-js-types/src/52/web/btoa.d.ts b/packages/core-js-types/src/52/web/btoa.d.ts new file mode 100644 index 000000000000..f4eac3d5ad11 --- /dev/null +++ b/packages/core-js-types/src/52/web/btoa.d.ts @@ -0,0 +1,7 @@ +/** + * Creates a Base64-encoded ASCII string from a binary string + * (i.e., a string in which each character in the string is treated as a byte of binary data) + * @param data The binary string to encode + * @returns An ASCII string containing the Base64 representation of data + */ +declare function btoa(data: string): string; diff --git a/packages/core-js-types/src/52/web/queue-microtask.d.ts b/packages/core-js-types/src/52/web/queue-microtask.d.ts new file mode 100644 index 000000000000..584b60656a64 --- /dev/null +++ b/packages/core-js-types/src/52/web/queue-microtask.d.ts @@ -0,0 +1,9 @@ +interface VoidFunction { + (): void; +} + +/** + * Queues a microtask to be executed at a later time. + * @param callback A function to be executed in the microtask. + */ +declare function queueMicrotask(callback: VoidFunction): void; diff --git a/packages/core-js-types/src/52/web/structured-clone.d.ts b/packages/core-js-types/src/52/web/structured-clone.d.ts new file mode 100644 index 000000000000..13f3367b9b3a --- /dev/null +++ b/packages/core-js-types/src/52/web/structured-clone.d.ts @@ -0,0 +1,14 @@ +interface CoreJSStructuredSerializeOptions { + readonly __brand?: unique symbol; + + transfer?: any[]; +} + +/** + * Creates a deep clone of a given value using the structured clone algorithm. + * @param value The value to be cloned. + * @param options An optional object that may contain a transfer property, + * which is an array of transferable objects to be transferred rather than cloned. + * @returns A deep clone of the provided value. + */ +declare function structuredClone(value: T, options?: CoreJSStructuredSerializeOptions): T; diff --git a/packages/core-js-types/src/52/web/url-to-json.d.ts b/packages/core-js-types/src/52/web/url-to-json.d.ts new file mode 100644 index 000000000000..6ecf69d921b0 --- /dev/null +++ b/packages/core-js-types/src/52/web/url-to-json.d.ts @@ -0,0 +1,3 @@ +interface URL { + toJSON(): string; +} From 532bdcc9b475e8e042d2e9eb31140534328b7f06 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 21 Nov 2025 23:45:21 +0700 Subject: [PATCH 068/315] Added proposal type entry-points & tests --- packages/core-js-types/package.json | 17 +++++++++++------ scripts/build-types/index.mjs | 16 +++++++++++++--- tests/type-definitions/entries.ts | 7 +++++++ tests/type-definitions/runner.mjs | 5 ++++- .../{entries.import.ts => templates.import.ts} | 0 ...{entries.require.ts => templates.require.ts} | 0 tests/type-definitions/tsconfig.entries.json | 13 +++++++++++++ tests/type-definitions/tsconfig.json | 11 +++-------- .../tsconfig.templates.import.json | 11 +++++++++++ ...ire.json => tsconfig.templates.require.json} | 7 +++---- 10 files changed, 65 insertions(+), 22 deletions(-) create mode 100644 tests/type-definitions/entries.ts rename tests/type-definitions/{entries.import.ts => templates.import.ts} (100%) rename tests/type-definitions/{entries.require.ts => templates.require.ts} (100%) create mode 100644 tests/type-definitions/tsconfig.entries.json create mode 100644 tests/type-definitions/tsconfig.templates.import.json rename tests/type-definitions/{tsconfig.require.json => tsconfig.templates.require.json} (62%) diff --git a/packages/core-js-types/package.json b/packages/core-js-types/package.json index d371a2447000..d2f1cc311aac 100644 --- a/packages/core-js-types/package.json +++ b/packages/core-js-types/package.json @@ -37,34 +37,39 @@ "exports": { ".": { "types@>=5.6": "./dist/56/actual.d.ts", - "types": "./dist/56/actual.d.ts", + "types": "./dist/52/actual.d.ts", "default": "./dist/56/actual.d.ts" }, "./actual": { "types@>=5.6": "./dist/56/actual.d.ts", - "types": "./dist/56/actual.d.ts", + "types": "./dist/52/actual.d.ts", "default": "./dist/56/actual.d.ts" }, "./es": { "types@>=5.6": "./dist/56/es.d.ts", - "types": "./dist/56/es.d.ts", + "types": "./dist/52/es.d.ts", "default": "./dist/56/es.d.ts" }, "./full": { "types@>=5.6": "./dist/56/full.d.ts", - "types": "./dist/56/full.d.ts", + "types": "./dist/52/full.d.ts", "default": "./dist/56/full.d.ts" }, "./pure": { "types@>=5.6": "./dist/56/pure.d.ts", - "types": "./dist/56/pure.d.ts", + "types": "./dist/52/pure.d.ts", "default": "./dist/56/pure.d.ts" }, "./stable": { "types@>=5.6": "./dist/56/stable.d.ts", - "types": "./dist/56/stable.d.ts", + "types": "./dist/52/stable.d.ts", "default": "./dist/56/stable.d.ts" + }, + "./proposals/*": { + "types@>=5.6": "./dist/56/proposals/*.d.ts", + "types": "./dist/52/proposals/*.d.ts", + "default": "./dist/56/proposals/*.d.ts" } }, "sideEffects": false diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 8969cda986f5..726f98825506 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -23,7 +23,7 @@ async function buildType(entry, options) { entryFromNamespace, subset = entryFromNamespace ?? 'full', template, templateStable, templateActual, templateFull, filter, modules, enforceEntryCreation, - customType, tsVersion, + customType, tsVersion, proposal, } = options; switch (subset) { @@ -75,6 +75,12 @@ async function buildType(entry, options) { await outputFile(filePath, `${ tpl.dts }${ tpl.dts ? '\n\n' : '' }`, { flag: 'a' }); await outputFile(filePathPure, `${ tplPure.dts }${ tplPure.dts ? '\n\n' : '' }`, { flag: 'a' }); + + if (proposal) { + const filePathProposal = buildFilePath(tsVersion, entry); + const proposalImports = buildImports(types, 1); + await outputFile(filePathProposal, `${ proposalImports }\n`, { flag: 'a' }); + } } async function getVersions() { @@ -110,10 +116,14 @@ function buildFilePath(tsVersion, subset) { return path.join(config.buildDir, tsVersion.toString(), `${ subset }.d.ts`); } +function buildImports(importsList, level = 0) { + return Array.from(importsList, it => `/// `).join('\n'); +} + async function prependImports(version) { for (const subset of Object.keys(imports)) { const filePath = buildFilePath(version, subset); - const importLines = Array.from(imports[subset], it => `/// `).join('\n'); + const importLines = buildImports(imports[subset]); const originalContent = await fs.readFile(filePath, 'utf8'); await outputFile(filePath, `${ importLines }\n\n${ originalContent }`); } @@ -133,7 +143,7 @@ async function buildTypesForTSVersion(tsVersion) { } for (const [name, definition] of Object.entries(proposals)) { - await buildType(`proposals/${ name }`, { ...definition, template: $proposal, tsVersion }); + await buildType(`proposals/${ name }`, { ...definition, template: $proposal, tsVersion, proposal: true }); } await buildType('es/index', { template: $path, modules: ESModules, subset: 'es', tsVersion }); diff --git a/tests/type-definitions/entries.ts b/tests/type-definitions/entries.ts new file mode 100644 index 000000000000..e144532cd934 --- /dev/null +++ b/tests/type-definitions/entries.ts @@ -0,0 +1,7 @@ +import '@core-js/types/stable'; +Iterator.concat([]); +// @ts-expect-error +Iterator.zipKeyed([]); + +import '@core-js/types/proposals/array-unique'; +const uniqueArr: number[] = [1, 2, 2, 3, 3, 3].uniqueBy(); diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 6d797901c6a9..25adce2f4b00 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -113,7 +113,10 @@ const prepareEnvironment = async function (environments, coreJsTypes) { }; await $`npx -p typescript@5.9 tsc`; -await $`npx -p typescript@5.9 -p @types/node@24 tsc -p tsconfig.require.json`; +await $`npx -p typescript@5.9 tsc -p tsconfig.templates.import.json`; +await $`npx -p typescript@5.9 tsc -p tsconfig.entries.json`; +await $`npx -p typescript@5.9 -p @types/node@24 tsc -p tsconfig.templates.require.json`; + const numCPUs = os.cpus().length; await prepareEnvironment(envs, types); await runLimited(taskConfigs, Math.max(numCPUs - 1, 1)); diff --git a/tests/type-definitions/entries.import.ts b/tests/type-definitions/templates.import.ts similarity index 100% rename from tests/type-definitions/entries.import.ts rename to tests/type-definitions/templates.import.ts diff --git a/tests/type-definitions/entries.require.ts b/tests/type-definitions/templates.require.ts similarity index 100% rename from tests/type-definitions/entries.require.ts rename to tests/type-definitions/templates.require.ts diff --git a/tests/type-definitions/tsconfig.entries.json b/tests/type-definitions/tsconfig.entries.json new file mode 100644 index 000000000000..020b54ec0ab8 --- /dev/null +++ b/tests/type-definitions/tsconfig.entries.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "strict": true, + "target": "esnext", + "module": "esnext", + "esModuleInterop": true, + "moduleResolution": "node", + "noEmit": true + }, + "include": [ + "./entries.ts" + ] +} diff --git a/tests/type-definitions/tsconfig.json b/tests/type-definitions/tsconfig.json index d0ba9a0cb6aa..773f34200e8d 100644 --- a/tests/type-definitions/tsconfig.json +++ b/tests/type-definitions/tsconfig.json @@ -5,15 +5,10 @@ "module": "esnext", "esModuleInterop": true, "moduleResolution": "node", - "noEmit": true, - "types": [ - "@core-js/types/pure" - ] + "noEmit": true }, "include": [ - "./*.ts" - ], - "exclude": [ - "./entries.require.ts" + "./builder.ts", + "./compat.ts" ] } diff --git a/tests/type-definitions/tsconfig.templates.import.json b/tests/type-definitions/tsconfig.templates.import.json new file mode 100644 index 000000000000..ab3afdcf0c25 --- /dev/null +++ b/tests/type-definitions/tsconfig.templates.import.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "types": [ + "@core-js/types/pure" + ] + }, + "include": [ + "./templates.import.ts" + ] +} diff --git a/tests/type-definitions/tsconfig.require.json b/tests/type-definitions/tsconfig.templates.require.json similarity index 62% rename from tests/type-definitions/tsconfig.require.json rename to tests/type-definitions/tsconfig.templates.require.json index 7bfad95eda4e..731c86753476 100644 --- a/tests/type-definitions/tsconfig.require.json +++ b/tests/type-definitions/tsconfig.templates.require.json @@ -2,12 +2,11 @@ "extends": "./tsconfig.json", "compilerOptions": { "types": [ - "@core-js/types", + "@core-js/types/pure", "@types/node" ] }, "include": [ - "./entries.require.ts" - ], - "exclude": [] + "./templates.require.ts" + ] } From ce74d2cb38d46e825bb31cbead18402bab57cf5f Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 3 Dec 2025 22:03:20 +0700 Subject: [PATCH 069/315] Pure types --- .../core-js-types/src/52/web/url-parse.d.ts | 2 +- .../src/56/common/pure/parse-float.d.ts | 3 + .../src/56/common/pure/parse-int.d.ts | 3 + .../src/56/core-js-types/core-js-types.d.ts | 19 +- .../56/core-js-types/core-js-types.pure.d.ts | 28 + .../accessible-object-hasownproperty.d.ts | 1 + .../src/56/proposals/array-buffer-base64.d.ts | 2 +- .../56/proposals/array-buffer-transfer.d.ts | 2 +- .../src/56/proposals/array-filtering.d.ts | 24 +- .../56/proposals/array-find-from-last.d.ts | 24 +- .../src/56/proposals/array-flat-map.d.ts | 4 +- .../src/56/proposals/array-includes.d.ts | 24 +- .../proposals/array-is-template-object.d.ts | 2 +- .../src/56/proposals/array-unique.d.ts | 24 +- .../src/56/proposals/async-iteration.d.ts | 6 - .../56/proposals/async-iterator-helpers.d.ts | 2 +- .../src/56/proposals/await-dictionary.d.ts | 2 + .../56/proposals/change-array-by-copy.d.ts | 704 +++++++++--------- .../src/56/proposals/collection-of-from.d.ts | 8 + .../data-view-get-set-uint8-clamped.d.ts | 2 +- .../explicit-resource-management.d.ts | 8 +- .../src/56/proposals/float16.d.ts | 4 +- .../56/proposals/function-demethodize.d.ts | 2 +- .../src/56/proposals/iterator-helpers.d.ts | 2 +- .../src/56/proposals/iterator-joint.d.ts | 2 +- .../src/56/proposals/iterator-range.d.ts | 4 +- .../src/56/proposals/iterator-sequencing.d.ts | 2 +- .../56/proposals/json-parse-with-source.d.ts | 6 +- .../src/56/proposals/map-upsert.d.ts | 4 +- .../src/56/proposals/math-sum.d.ts | 2 +- .../src/56/proposals/number-clamp.d.ts | 2 +- .../src/56/proposals/promise-any.d.ts | 2 +- .../56/proposals/promise-with-resolvers.d.ts | 2 +- .../proposals/pure/array-buffer-base64.d.ts | 0 .../proposals/pure/array-buffer-transfer.d.ts | 35 + .../56/proposals/pure/array-constructor.d.ts | 45 ++ .../56/proposals/pure/array-filtering.d.ts | 15 + .../proposals/pure/array-find-from-last.d.ts | 34 + .../src/56/proposals/pure/array-flat-map.d.ts | 33 + .../56/proposals/pure/array-from-async.d.ts | 0 .../src/56/proposals/pure/array-includes.d.ts | 17 + .../src/56/proposals/pure/array-unique.d.ts | 14 + .../56/proposals/pure/async-iteration.d.ts | 0 .../pure/async-iterator-helpers.d.ts | 98 +++ .../56/proposals/pure/await-dictionary.d.ts | 28 + .../proposals/pure/change-array-by-copy.d.ts | 54 ++ .../pure/data-view-get-set-uint8-clamped.d.ts | 24 + .../src/56/proposals/pure/date.d.ts | 5 + .../56/proposals/pure/decorator-metadata.d.ts | 12 + .../src/56/proposals/pure/dom-exception.d.ts | 71 ++ .../src/56/proposals/pure/error-cause.d.ts | 0 .../src/56/proposals/pure/error.d.ts | 49 ++ .../pure/explicit-resource-management.d.ts | 189 +++++ .../src/56/proposals/pure/float16.d.ts | 38 + .../src/56/proposals/pure/global-this.d.ts | 3 + .../src/56/proposals/pure/is-error.d.ts | 0 .../56/proposals/pure/iterator-chunking.d.ts | 0 .../56/proposals/pure/iterator-helpers.d.ts | 0 .../src/56/proposals/pure/iterator-join.d.ts | 0 .../src/56/proposals/pure/iterator-joint.d.ts | 0 .../src/56/proposals/pure/iterator-range.d.ts | 0 .../proposals/pure/iterator-sequencing.d.ts | 0 .../src/56/proposals/pure/iterator.d.ts | 242 ++++++ .../56/proposals/pure/pattern-matching.d.ts | 0 .../proposals/pure/promise-all-settled.d.ts | 31 + .../src/56/proposals/pure/promise-any.d.ts | 27 + .../src/56/proposals/pure/reflect.d.ts | 132 ++++ .../pure/relative-indexing-method.d.ts | 27 + .../src/56/proposals/pure/self.d.ts | 3 + .../pure/string-left-right-trim.d.ts | 28 + .../56/proposals/pure/string-match-all.d.ts | 33 + .../src/56/proposals/pure/string-padding.d.ts | 39 + .../56/proposals/pure/string-replace-all.d.ts | 27 + .../56/proposals/pure/symbol-description.d.ts | 0 .../56/proposals/pure/symbol-predicates.d.ts | 0 .../src/56/proposals/pure/symbol.d.ts | 87 +++ .../src/56/proposals/pure/typed-arrays.d.ts | 11 + .../56/proposals/pure/url-search-params.d.ts | 54 ++ .../src/56/proposals/pure/url.d.ts | 64 ++ .../pure/well-formed-unicode-strings.d.ts | 23 + .../proposals/relative-indexing-method.d.ts | 28 +- .../src/56/proposals/set-methods.d.ts | 180 +++-- .../56/proposals/string-left-right-trim.d.ts | 2 +- .../src/56/proposals/string-padding.d.ts | 2 +- .../src/56/proposals/string-replace-all.d.ts | 30 +- .../well-formed-unicode-strings.d.ts | 2 +- .../src/56/web/queue-microtask.d.ts | 2 +- .../src/56/web/structured-clone.d.ts | 2 +- .../core-js-types/src/56/web/url-to-json.d.ts | 2 +- scripts/build-entries/templates.mjs | 24 +- scripts/build-types/index.mjs | 164 +++- .../pure/common/parse-float.test.ts | 6 + .../pure/common/parse-int.test.ts | 6 + .../pure/proposals/array-from-async.test.ts | 37 + .../proposals/async-iterator-helper.test.ts | 46 +- .../pure/proposals/await-dictionary.test.ts | 11 - .../proposals/change-array-by-copy.test.ts | 1 - .../explicit-resource-management.test.ts | 41 +- .../pure/proposals/iterator-range.test.ts | 4 - .../proposals/json-parse-with-source.test.ts | 8 + .../proposals/promise-all-settled.test.ts | 20 +- .../pure/proposals/promise-finally.test.ts | 3 - .../proposals/promise-with-resolvers.test.ts | 5 - .../pure/proposals/set-methods.test.ts | 4 +- .../pure/proposals/string-match-all.test.ts | 5 +- tests/type-definitions/runner.mjs | 3 + 106 files changed, 2494 insertions(+), 664 deletions(-) create mode 100644 packages/core-js-types/src/56/common/pure/parse-float.d.ts create mode 100644 packages/core-js-types/src/56/common/pure/parse-int.d.ts create mode 100644 packages/core-js-types/src/56/core-js-types/core-js-types.pure.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/array-buffer-base64.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/array-buffer-transfer.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/array-constructor.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/array-filtering.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/array-find-from-last.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/array-flat-map.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/array-from-async.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/array-includes.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/array-unique.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/async-iteration.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/async-iterator-helpers.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/await-dictionary.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/change-array-by-copy.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/data-view-get-set-uint8-clamped.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/date.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/decorator-metadata.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/dom-exception.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/error-cause.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/error.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/explicit-resource-management.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/float16.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/global-this.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/is-error.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/iterator-chunking.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/iterator-helpers.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/iterator-join.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/iterator-joint.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/iterator-range.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/iterator-sequencing.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/iterator.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/pattern-matching.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/promise-all-settled.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/promise-any.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/reflect.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/relative-indexing-method.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/self.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/string-left-right-trim.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/string-match-all.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/string-padding.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/string-replace-all.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/symbol-description.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/symbol-predicates.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/symbol.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/typed-arrays.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/url-search-params.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/url.d.ts create mode 100644 packages/core-js-types/src/56/proposals/pure/well-formed-unicode-strings.d.ts create mode 100644 tests/type-definitions/pure/common/parse-float.test.ts create mode 100644 tests/type-definitions/pure/common/parse-int.test.ts create mode 100644 tests/type-definitions/pure/proposals/array-from-async.test.ts diff --git a/packages/core-js-types/src/52/web/url-parse.d.ts b/packages/core-js-types/src/52/web/url-parse.d.ts index a32d5e1ec937..8c998f44d99d 100644 --- a/packages/core-js-types/src/52/web/url-parse.d.ts +++ b/packages/core-js-types/src/52/web/url-parse.d.ts @@ -1,5 +1,5 @@ declare global { - interface URLConstructor { + interface URLConstructor extends URL { parse(url: string | URL, base?: string | URL): URL | null; } } diff --git a/packages/core-js-types/src/56/common/pure/parse-float.d.ts b/packages/core-js-types/src/56/common/pure/parse-float.d.ts new file mode 100644 index 000000000000..8e7a91a4e0a3 --- /dev/null +++ b/packages/core-js-types/src/56/common/pure/parse-float.d.ts @@ -0,0 +1,3 @@ +declare namespace CoreJS { + export function CoreJSparseFloat(string: string): number; +} diff --git a/packages/core-js-types/src/56/common/pure/parse-int.d.ts b/packages/core-js-types/src/56/common/pure/parse-int.d.ts new file mode 100644 index 000000000000..ade6b636890c --- /dev/null +++ b/packages/core-js-types/src/56/common/pure/parse-int.d.ts @@ -0,0 +1,3 @@ +declare namespace CoreJS { + export function CoreJSparseInt(string: string): number; +} diff --git a/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts index fbd7fdc9fe0d..26e17d519d24 100644 --- a/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts +++ b/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts @@ -17,6 +17,17 @@ declare global { interface PromiseRejectedResult { status: "rejected"; reason: any; } + interface AsyncIterator { + // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. + next(...[value]: [] | [TNext]): Promise>; + return?(value?: TReturn | PromiseLike): Promise>; + throw?(e?: any): Promise>; + } + + interface AsyncIteratorConstructor {} + + var AsyncIterator: AsyncIteratorConstructor; + interface AsyncIterable { [Symbol.asyncIterator](): AsyncIterator; } @@ -28,6 +39,10 @@ export type CoreJSDecoratorMetadataObject = typeof globalThis extends { Decorato export type CoreJSIteratorObject = IteratorObject; +export type CoreJSPromiseSettledResult = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020 + ? O + : PromiseFulfilledResult | PromiseRejectedResult; + export type CoreJSFlatArray = typeof globalThis extends { FlatArray: infer O } // from ts 4.4 ? O : { @@ -35,7 +50,3 @@ export type CoreJSFlatArray = typeof globalThis exten recur: Arr extends ReadonlyArray ? CoreJSFlatArray : Arr; }[Depth extends -1 ? "done" : "recur"]; - -export type CoreJSPromiseSettledResult = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020 - ? O - : PromiseFulfilledResult | PromiseRejectedResult; diff --git a/packages/core-js-types/src/56/core-js-types/core-js-types.pure.d.ts b/packages/core-js-types/src/56/core-js-types/core-js-types.pure.d.ts new file mode 100644 index 000000000000..69abef5c564a --- /dev/null +++ b/packages/core-js-types/src/56/core-js-types/core-js-types.pure.d.ts @@ -0,0 +1,28 @@ +/// +/// + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2019.array.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export type CoreJSDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } // from ts 5.2 + ? O + : Record & object; + + interface PromiseFulfilledResult { status: "fulfilled"; value: T; } + + interface PromiseRejectedResult { status: "rejected"; reason: any; } + + export type CoreJSPromiseSettledResult = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020 + ? O + : PromiseFulfilledResult | PromiseRejectedResult; + + export type CoreJSFlatArray = typeof globalThis extends { FlatArray: infer O } // from ts 4.4 + ? O + : { + done: Arr; + recur: Arr extends ReadonlyArray ? CoreJSFlatArray + : Arr; + }[Depth extends -1 ? "done" : "recur"]; +} diff --git a/packages/core-js-types/src/56/proposals/accessible-object-hasownproperty.d.ts b/packages/core-js-types/src/56/proposals/accessible-object-hasownproperty.d.ts index fa4e7515fd94..b4a26afff155 100644 --- a/packages/core-js-types/src/56/proposals/accessible-object-hasownproperty.d.ts +++ b/packages/core-js-types/src/56/proposals/accessible-object-hasownproperty.d.ts @@ -4,6 +4,7 @@ // For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2022.object.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + interface ObjectConstructor { /** * Determines whether an object has a property with the specified name. diff --git a/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts index dbc36f0df75f..34d3fbe44e8a 100644 --- a/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts +++ b/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts @@ -42,7 +42,7 @@ interface Uint8ArrayConstructor { fromHex(str: string): Uint8Array; } -interface Uint8Array { +interface Uint8Array { // @type-options no-redefine /** * Sets the `Uint8Array` from a base64-encoded string. * @param string The base64-encoded string. diff --git a/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts index b11b4866241c..973171b30030 100644 --- a/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts @@ -5,7 +5,7 @@ // https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/es2024.arraybuffer.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface ArrayBuffer { +interface ArrayBuffer { // @type-options export-base-constructor // todo hack for modern ts // get detached(): boolean; diff --git a/packages/core-js-types/src/56/proposals/array-filtering.d.ts b/packages/core-js-types/src/56/proposals/array-filtering.d.ts index 4b7353c68698..e0088e42d305 100644 --- a/packages/core-js-types/src/56/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/56/proposals/array-filtering.d.ts @@ -1,7 +1,7 @@ // proposal stage: 1 // https://github.com/tc39/proposal-array-filtering -interface Array { +interface Array { // @type-options no-redefine /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -12,7 +12,7 @@ interface Array { filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; } -interface Int8Array { +interface Int8Array { // @type-options no-redefine /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -23,7 +23,7 @@ interface Int8Array { filterReject(callbackFn: (value: number, index: number, target: Int8Array) => boolean, thisArg?: any): Int8Array; } -interface Uint8Array { +interface Uint8Array { // @type-options no-redefine /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -34,7 +34,7 @@ interface Uint8Array { filterReject(callbackFn: (value: number, index: number, target: Uint8Array) => boolean, thisArg?: any): Uint8Array; } -interface Uint8ClampedArray { +interface Uint8ClampedArray { // @type-options no-redefine /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -45,7 +45,7 @@ interface Uint8ClampedArray { filterReject(callbackFn: (value: number, index: number, target: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; } -interface Int16Array { +interface Int16Array { // @type-options no-redefine /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -56,7 +56,7 @@ interface Int16Array { filterReject(callbackFn: (value: number, index: number, target: Int16Array) => boolean, thisArg?: any): Int16Array; } -interface Uint16Array { +interface Uint16Array { // @type-options no-redefine /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -67,7 +67,7 @@ interface Uint16Array { filterReject(callbackFn: (value: number, index: number, target: Uint16Array) => boolean, thisArg?: any): Uint16Array; } -interface Int32Array { +interface Int32Array { // @type-options no-redefine /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -78,7 +78,7 @@ interface Int32Array { filterReject(callbackFn: (value: number, index: number, target: Int32Array) => boolean, thisArg?: any): Int32Array; } -interface Uint32Array { +interface Uint32Array { // @type-options no-redefine /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -89,7 +89,7 @@ interface Uint32Array { filterReject(callbackFn: (value: number, index: number, target: Uint32Array) => boolean, thisArg?: any): Uint32Array; } -interface Float32Array { +interface Float32Array { // @type-options no-redefine /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -100,11 +100,11 @@ interface Float32Array { filterReject(callbackFn: (value: number, index: number, target: Float32Array) => boolean, thisArg?: any): Float32Array; } -interface Float64Array { +interface Float64Array { // @type-options no-redefine filterReject(callbackFn: (value: number, index: number, target: Float64Array) => boolean, thisArg?: any): Float64Array; } -interface BigInt64Array { +interface BigInt64Array { // @type-options no-redefine /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -115,7 +115,7 @@ interface BigInt64Array { filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array; } -interface BigUint64Array { +interface BigUint64Array { // @type-options no-redefine /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the diff --git a/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts index 034e9f7304f4..7ef4f1daed51 100644 --- a/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts @@ -5,7 +5,7 @@ // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface Array { +interface Array { // @type-options no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -30,7 +30,7 @@ interface Array { findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; } -interface Int8Array { +interface Int8Array { // @type-options no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -55,7 +55,7 @@ interface Int8Array { findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Uint8Array { +interface Uint8Array { // @type-options no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -80,7 +80,7 @@ interface Uint8Array { findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Uint8ClampedArray { +interface Uint8ClampedArray { // @type-options no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -105,7 +105,7 @@ interface Uint8ClampedArray { findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Int16Array { +interface Int16Array { // @type-options no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -130,7 +130,7 @@ interface Int16Array { findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Uint16Array { +interface Uint16Array { // @type-options no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -155,7 +155,7 @@ interface Uint16Array { findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Int32Array { +interface Int32Array { // @type-options no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -180,7 +180,7 @@ interface Int32Array { findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Uint32Array { +interface Uint32Array { // @type-options no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -205,7 +205,7 @@ interface Uint32Array { findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Float32Array { +interface Float32Array { // @type-options no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -230,7 +230,7 @@ interface Float32Array { findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Float64Array { +interface Float64Array { // @type-options no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -246,7 +246,7 @@ interface Float64Array { findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface BigInt64Array { +interface BigInt64Array { // @type-options no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -271,7 +271,7 @@ interface BigInt64Array { findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; } -interface BigUint64Array { +interface BigUint64Array { // @type-options no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. diff --git a/packages/core-js-types/src/56/proposals/array-flat-map.d.ts b/packages/core-js-types/src/56/proposals/array-flat-map.d.ts index f861f0b25a6c..45a8cbf8acba 100644 --- a/packages/core-js-types/src/56/proposals/array-flat-map.d.ts +++ b/packages/core-js-types/src/56/proposals/array-flat-map.d.ts @@ -5,10 +5,10 @@ // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -import { CoreJSFlatArray } from '../core-js-types/core-js-types'; +import { CoreJSFlatArray } from "../core-js-types/core-js-types"; declare global { - interface Array { + interface Array { // @type-options no-redefine /** * Calls a defined callback function on each element of an array. Then, flattens the result into * a new array. diff --git a/packages/core-js-types/src/56/proposals/array-includes.d.ts b/packages/core-js-types/src/56/proposals/array-includes.d.ts index 55d17beeb3ee..0aa74e6ea6f6 100644 --- a/packages/core-js-types/src/56/proposals/array-includes.d.ts +++ b/packages/core-js-types/src/56/proposals/array-includes.d.ts @@ -5,7 +5,7 @@ // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2016.array.include.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface Array { +interface Array { // @type-options no-redefine /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -14,7 +14,7 @@ interface Array { includes(searchElement: T, fromIndex?: number): boolean; } -interface Int8Array { +interface Int8Array { // @type-options no-redefine /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -23,7 +23,7 @@ interface Int8Array { includes(searchElement: number, fromIndex?: number): boolean; } -interface Uint8Array { +interface Uint8Array { // @type-options no-redefine /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -32,7 +32,7 @@ interface Uint8Array { includes(searchElement: number, fromIndex?: number): boolean; } -interface Uint8ClampedArray { +interface Uint8ClampedArray { // @type-options no-redefine /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -41,7 +41,7 @@ interface Uint8ClampedArray { includes(searchElement: number, fromIndex?: number): boolean; } -interface Int16Array { +interface Int16Array { // @type-options no-redefine /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -50,7 +50,7 @@ interface Int16Array { includes(searchElement: number, fromIndex?: number): boolean; } -interface Uint16Array { +interface Uint16Array { // @type-options no-redefine /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -59,7 +59,7 @@ interface Uint16Array { includes(searchElement: number, fromIndex?: number): boolean; } -interface Int32Array { +interface Int32Array { // @type-options no-redefine /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -68,7 +68,7 @@ interface Int32Array { includes(searchElement: number, fromIndex?: number): boolean; } -interface Uint32Array { +interface Uint32Array { // @type-options no-redefine /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -77,7 +77,7 @@ interface Uint32Array { includes(searchElement: number, fromIndex?: number): boolean; } -interface Float32Array { +interface Float32Array { // @type-options no-redefine /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -86,7 +86,7 @@ interface Float32Array { includes(searchElement: number, fromIndex?: number): boolean; } -interface Float64Array { +interface Float64Array { // @type-options no-redefine /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -95,7 +95,7 @@ interface Float64Array { includes(searchElement: number, fromIndex?: number): boolean; } -interface BigInt64Array { +interface BigInt64Array { // @type-options no-redefine /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -104,7 +104,7 @@ interface BigInt64Array { includes(searchElement: bigint, fromIndex?: number): boolean; } -interface BigUint64Array { +interface BigUint64Array { // @type-options no-redefine /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. diff --git a/packages/core-js-types/src/56/proposals/array-is-template-object.d.ts b/packages/core-js-types/src/56/proposals/array-is-template-object.d.ts index 92ff3106613d..aa469688d346 100644 --- a/packages/core-js-types/src/56/proposals/array-is-template-object.d.ts +++ b/packages/core-js-types/src/56/proposals/array-is-template-object.d.ts @@ -1,7 +1,7 @@ // proposal stage: 2 // https://github.com/tc39/proposal-array-is-template-object -interface ArrayConstructor { +interface ArrayConstructor { // @type-options no-export /** * Determines whether an `value` is a `TemplateStringsArray` * @param value diff --git a/packages/core-js-types/src/56/proposals/array-unique.d.ts b/packages/core-js-types/src/56/proposals/array-unique.d.ts index d17ffc3d8d8b..8b1215717dc4 100644 --- a/packages/core-js-types/src/56/proposals/array-unique.d.ts +++ b/packages/core-js-types/src/56/proposals/array-unique.d.ts @@ -1,7 +1,7 @@ // proposal stage: 1 // https://github.com/tc39/proposal-array-unique -interface Array { +interface Array { // @type-options no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -11,7 +11,7 @@ interface Array { uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; } -interface Int8Array { +interface Int8Array { // @type-options no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -21,7 +21,7 @@ interface Int8Array { uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int8Array; } -interface Uint8Array { +interface Uint8Array { // @type-options no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -31,7 +31,7 @@ interface Uint8Array { uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8Array; } -interface Uint8ClampedArray { +interface Uint8ClampedArray { // @type-options no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -41,7 +41,7 @@ interface Uint8ClampedArray { uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8ClampedArray; } -interface Int16Array { +interface Int16Array { // @type-options no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -51,7 +51,7 @@ interface Int16Array { uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int16Array; } -interface Uint16Array { +interface Uint16Array { // @type-options no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -61,7 +61,7 @@ interface Uint16Array { uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint16Array; } -interface Int32Array { +interface Int32Array { // @type-options no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -71,7 +71,7 @@ interface Int32Array { uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int32Array; } -interface Uint32Array { +interface Uint32Array { // @type-options no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -81,7 +81,7 @@ interface Uint32Array { uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint32Array; } -interface Float32Array { +interface Float32Array { // @type-options no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -91,7 +91,7 @@ interface Float32Array { uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float32Array; } -interface Float64Array { +interface Float64Array { // @type-options no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -101,7 +101,7 @@ interface Float64Array { uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float64Array; } -interface BigInt64Array { +interface BigInt64Array { // @type-options no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -111,7 +111,7 @@ interface BigInt64Array { uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigInt64Array; } -interface BigUint64Array { +interface BigUint64Array { // @type-options no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, diff --git a/packages/core-js-types/src/56/proposals/async-iteration.d.ts b/packages/core-js-types/src/56/proposals/async-iteration.d.ts index b822f489ab06..98856336caf0 100644 --- a/packages/core-js-types/src/56/proposals/async-iteration.d.ts +++ b/packages/core-js-types/src/56/proposals/async-iteration.d.ts @@ -12,9 +12,3 @@ interface SymbolConstructor { */ readonly asyncIterator: unique symbol; } - -interface AsyncIteratorConstructor { - -} - -declare var AsyncIterator: AsyncIteratorConstructor; diff --git a/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts index 538421b74e27..9a83528bc579 100644 --- a/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts @@ -2,7 +2,7 @@ // https://github.com/tc39/proposal-async-iterator-helpers declare global { - interface AsyncIteratorConstructor { + interface AsyncIteratorConstructor { // @type-options no-extends /** * Creates an `AsyncIterator` from an iterable object * @param iterable An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` diff --git a/packages/core-js-types/src/56/proposals/await-dictionary.d.ts b/packages/core-js-types/src/56/proposals/await-dictionary.d.ts index c9741c3a1ded..d1e472598944 100644 --- a/packages/core-js-types/src/56/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/56/proposals/await-dictionary.d.ts @@ -22,6 +22,8 @@ declare global { */ allSettledKeyed>>(promises: D): Promise <{ [k in keyof D]: CoreJSPromiseSettledResult> }>; } + + var Promise: PromiseConstructor; } export {}; diff --git a/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts index 98e73b584f69..1652a7757cd5 100644 --- a/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts +++ b/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts @@ -5,359 +5,355 @@ // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -declare global { - interface Array { - /** - * @returns A copy of an array with its elements reversed. - */ - toReversed(): T[]; - - /** - * Returns a copy of an array with its elements sorted. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. - * ```ts - * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] - * ``` - */ - toSorted(compareFn?: (a: T, b: T) => number): T[]; - - /** - * Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. - * @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 copied array in place of the deleted elements. - * @returns The copied array. - */ - toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; - /** - * Copies an array and removes elements while returning the remaining 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 A copy of the original array with the remaining elements. - */ - toSpliced(start: number, deleteCount?: number): T[]; - - /** - * Copies an array, then overwrites the value at the provided index with the - * given value. If the index is negative, then it replaces from the end - * of the array. - * @param index The index of the value to overwrite. If the index is - * negative, then it replaces from the end of the array. - * @param value The value to write into the copied array. - * @returns The copied array with the updated value. - */ - with(index: number, value: T): T[]; - } - - interface Int8Array { - /** - * @returns A copy of an array with its elements reversed. - */ - toReversed(): Int8Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending order. - * ```ts - * const myNums = Int8Array.from([11, 2, 22, 1]); - * myNums.toSorted((a, b) => a - b) // Int8Array(4) [1, 2, 11, 22] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Int8Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is - * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Int8Array; - } - - interface Uint8Array { - /** - * @returns A copy of an array with its elements reversed. - */ - toReversed(): Uint8Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending order. - * ```ts - * const myNums = Uint8Array.from([11, 2, 22, 1]); - * myNums.toSorted((a, b) => a - b) // Uint8Array(4) [1, 2, 11, 22] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Uint8Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is - * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Uint8Array; - } - - interface Uint8ClampedArray { - /** - * @returns A copy of an array with its elements reversed. - */ - toReversed(): Uint8ClampedArray; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending order. - * ```ts - * const myNums = Uint8ClampedArray.from([11, 2, 22, 1]); - * myNums.toSorted((a, b) => a - b) // Uint8ClampedArray(4) [1, 2, 11, 22] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is - * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Uint8ClampedArray; - } - - interface Int16Array { - /** - * @returns A copy of an array with its elements reversed. - */ - toReversed(): Int16Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending order. - * ```ts - * const myNums = Int16Array.from([11, 2, -22, 1]); - * myNums.toSorted((a, b) => a - b) // Int16Array(4) [-22, 1, 2, 11] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Int16Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is - * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Int16Array; - } - - interface Uint16Array { - /** - * @returns A copy of an array with its elements reversed. - */ - toReversed(): Uint16Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending order. - * ```ts - * const myNums = Uint16Array.from([11, 2, 22, 1]); - * myNums.toSorted((a, b) => a - b) // Uint16Array(4) [1, 2, 11, 22] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Uint16Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is - * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Uint16Array; - } - - interface Int32Array { - /** - * @returns A copy of an array with its elements reversed. - */ - toReversed(): Int32Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending order. - * ```ts - * const myNums = Int32Array.from([11, 2, -22, 1]); - * myNums.toSorted((a, b) => a - b) // Int32Array(4) [-22, 1, 2, 11] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Int32Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is - * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Int32Array; - } - - interface Uint32Array { - /** - * @returns A copy of an array with its elements reversed. - */ - toReversed(): Uint32Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending order. - * ```ts - * const myNums = Int32Array.from([11, 2, -22, 1]); - * myNums.toSorted((a, b) => a - b) // Int32Array(4) [-22, 1, 2, 11] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is - * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Uint32Array; - } - - interface Float32Array { - /** - * @returns A copy of an array with its elements reversed. - */ - toReversed(): Float32Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending order. - * ```ts - * const myNums = Float32Array.from([11.25, 2, -22.5, 1]); - * myNums.toSorted((a, b) => a - b) // Float32Array(4) [-22.5, 1, 2, 11.5] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Float32Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is - * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Float32Array; - } - - interface Float64Array { - /** - * @returns A copy of an array with its elements reversed. - */ - toReversed(): Float64Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending order. - * ```ts - * const myNums = Float64Array.from([11.25, 2, -22.5, 1]); - * myNums.toSorted((a, b) => a - b) // Float64Array(4) [-22.5, 1, 2, 11.5] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Float64Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is - * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Float64Array; - } - - interface BigInt64Array { - /** - * @returns A copy of an array with its elements reversed. - */ - toReversed(): BigInt64Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending order. - * ```ts - * const myNums = BigInt64Array.from([11n, 2n, -22n, 1n]); - * myNums.toSorted((a, b) => Number(a - b)) // BigInt64Array(4) [-22n, 1n, 2n, 11n] - * ``` - */ - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; - - /** - * Copies the array and inserts the given bigint at the provided index. - * @param index The index of the value to overwrite. If the index is - * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: bigint): BigInt64Array; - } - - interface BigUint64Array { - /** - * @returns A copy of an array with its elements reversed. - */ - toReversed(): BigUint64Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending order. - * ```ts - * const myNums = BigUint64Array.from([11n, 2n, 22n, 1n]); - * myNums.toSorted((a, b) => Number(a - b)) // BigUint64Array(4) [1n, 2n, 11n, 22n] - * ``` - */ - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; - - /** - * Copies the array and inserts the given bigint at the provided index. - * @param index The index of the value to overwrite. If the index is - * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: bigint): BigUint64Array; - } +interface Array { // @type-options no-redefine + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): T[]; + + /** + * Returns a copy of an array with its elements sorted. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. + * ```ts + * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. + * @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 copied array in place of the deleted elements. + * @returns The copied array. + */ + toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; + /** + * Copies an array and removes elements while returning the remaining 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 A copy of the original array with the remaining elements. + */ + toSpliced(start: number, deleteCount?: number): T[]; + + /** + * Copies an array, then overwrites the value at the provided index with the + * given value. If the index is negative, then it replaces from the end + * of the array. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to write into the copied array. + * @returns The copied array with the updated value. + */ + with(index: number, value: T): T[]; } -export {}; +interface Int8Array { // @type-options export-base-constructor + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): Int8Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Int8Array.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Int8Array(4) [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Int8Array; +} + +interface Uint8Array { // @type-options no-redefine + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): Uint8Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Uint8Array.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint8Array(4) [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Uint8Array; +} + +interface Uint8ClampedArray { // @type-options export-base-constructor + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): Uint8ClampedArray; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Uint8ClampedArray.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint8ClampedArray(4) [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Uint8ClampedArray; +} + +interface Int16Array { // @type-options export-base-constructor + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): Int16Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Int16Array.from([11, 2, -22, 1]); + * myNums.toSorted((a, b) => a - b) // Int16Array(4) [-22, 1, 2, 11] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Int16Array; +} + +interface Uint16Array { // @type-options export-base-constructor + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): Uint16Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Uint16Array.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint16Array(4) [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Uint16Array; +} + +interface Int32Array { // @type-options export-base-constructor + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): Int32Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Int32Array.from([11, 2, -22, 1]); + * myNums.toSorted((a, b) => a - b) // Int32Array(4) [-22, 1, 2, 11] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Int32Array; +} + +interface Uint32Array { // @type-options export-base-constructor + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): Uint32Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Int32Array.from([11, 2, -22, 1]); + * myNums.toSorted((a, b) => a - b) // Int32Array(4) [-22, 1, 2, 11] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Uint32Array; +} + +interface Float32Array { // @type-options export-base-constructor + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): Float32Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Float32Array.from([11.25, 2, -22.5, 1]); + * myNums.toSorted((a, b) => a - b) // Float32Array(4) [-22.5, 1, 2, 11.5] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Float32Array; +} + +interface Float64Array { // @type-options export-base-constructor + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): Float64Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Float64Array.from([11.25, 2, -22.5, 1]); + * myNums.toSorted((a, b) => a - b) // Float64Array(4) [-22.5, 1, 2, 11.5] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Float64Array; +} + +interface BigInt64Array { // @type-options export-base-constructor + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): BigInt64Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = BigInt64Array.from([11n, 2n, -22n, 1n]); + * myNums.toSorted((a, b) => Number(a - b)) // BigInt64Array(4) [-22n, 1n, 2n, 11n] + * ``` + */ + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; + + /** + * Copies the array and inserts the given bigint at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: bigint): BigInt64Array; +} + +interface BigUint64Array { // @type-options export-base-constructor + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): BigUint64Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = BigUint64Array.from([11n, 2n, 22n, 1n]); + * myNums.toSorted((a, b) => Number(a - b)) // BigUint64Array(4) [1n, 2n, 11n, 22n] + * ``` + */ + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; + + /** + * Copies the array and inserts the given bigint at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: bigint): BigUint64Array; +} diff --git a/packages/core-js-types/src/56/proposals/collection-of-from.d.ts b/packages/core-js-types/src/56/proposals/collection-of-from.d.ts index 1e8b409b0182..b3b13d49e118 100644 --- a/packages/core-js-types/src/56/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/56/proposals/collection-of-from.d.ts @@ -21,6 +21,8 @@ interface MapConstructor { of(...items: [K, V][]): Map; } +declare var Map: MapConstructor; + interface SetConstructor { /** * Creates a new `Set` instance from an iterable or array-like object of [key, value] pairs. @@ -41,6 +43,8 @@ interface SetConstructor { of(...items: T[]): Set; } +declare var Set: SetConstructor; + interface WeakMapConstructor { /** * Creates a new `WeakMap` instance from an iterable or array-like object of [key, value] pairs. @@ -61,6 +65,8 @@ interface WeakMapConstructor { of(...items: [K, V][]): WeakMap; } +declare var WeakMap: WeakMapConstructor; + interface WeakSetConstructor { /** * Creates a new `WeakSet` instance from an iterable or array-like object of [key, value] pairs. @@ -80,3 +86,5 @@ interface WeakSetConstructor { */ of(...items: T[]): WeakSet; } + +declare var WeakSet: WeakSetConstructor; diff --git a/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts index e0b8c45ea1fd..401de46b5205 100644 --- a/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts +++ b/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts @@ -1,7 +1,7 @@ // proposal stage: 1 // https://github.com/tc39/proposal-dataview-get-set-uint8clamped -interface DataView { +interface DataView { // @type-options no-constructor /** * Reads an unsigned 8-bit integer at the specified byte offset from the DataView, * interpreting the byte as a clamped 8-bit unsigned value (same as Uint8ClampedArray). diff --git a/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts index 9fba6db4359d..ce4db09c578f 100644 --- a/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts @@ -17,11 +17,11 @@ interface SymbolConstructor { readonly asyncDispose: unique symbol; } -interface Disposable { +interface Disposable { // @type-options no-constructor [Symbol.dispose](): void; } -interface AsyncDisposable { +interface AsyncDisposable { // @type-options no-constructor [Symbol.asyncDispose](): PromiseLike; } @@ -192,6 +192,6 @@ interface AsyncDisposableStackConstructor { declare var AsyncDisposableStack: AsyncDisposableStackConstructor; -interface IteratorObject extends Disposable {} +interface IteratorObject extends Disposable {} // @type-options no-extends -interface AsyncIteratorObject extends AsyncDisposable {} +interface AsyncIteratorObject extends AsyncDisposable {} // @type-options no-extends diff --git a/packages/core-js-types/src/56/proposals/float16.d.ts b/packages/core-js-types/src/56/proposals/float16.d.ts index 5a667aeac6a3..e35d4f6e4515 100644 --- a/packages/core-js-types/src/56/proposals/float16.d.ts +++ b/packages/core-js-types/src/56/proposals/float16.d.ts @@ -5,7 +5,7 @@ // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.float16.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface Math { +interface Math { // @type-options no-constructor /** * Returns the nearest half precision float representation of a number. * @param x A numeric expression. @@ -13,7 +13,7 @@ interface Math { f16round(x: number): number; } -interface DataView { +interface DataView { // @type-options no-constructor /** * Gets the Float16 value at the specified byte offset from the start of the view. There is * no alignment constraint; multibyte values may be fetched from any offset. diff --git a/packages/core-js-types/src/56/proposals/function-demethodize.d.ts b/packages/core-js-types/src/56/proposals/function-demethodize.d.ts index ba2239788c1f..a5b013681862 100644 --- a/packages/core-js-types/src/56/proposals/function-demethodize.d.ts +++ b/packages/core-js-types/src/56/proposals/function-demethodize.d.ts @@ -1,6 +1,6 @@ // proposal stage: 0 // https://github.com/js-choi/proposal-function-demethodize -interface Function { +interface Function { // @type-options no-constructor /** * Creates a function that calls the original with its first argument as `this` and the rest as regular arguments. * @returns {Function} A new function that applies the original function with its `this` set to the first argument. diff --git a/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts index ad65d6bd6e6a..30e4d60d1975 100644 --- a/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts @@ -100,7 +100,7 @@ declare global { find(predicate: (value: T, index: number) => unknown): T | undefined; } - interface IteratorConstructor { + interface IteratorConstructor { // @type-options no-extends /** * Creates a native iterator from an iterator or iterable object. * Returns its input if the input already inherits from the built-in Iterator class. diff --git a/packages/core-js-types/src/56/proposals/iterator-joint.d.ts b/packages/core-js-types/src/56/proposals/iterator-joint.d.ts index 4e702cbaf437..2e6e18a25160 100644 --- a/packages/core-js-types/src/56/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-joint.d.ts @@ -10,7 +10,7 @@ declare global { padding?: object; }; - interface IteratorConstructor { + interface IteratorConstructor { // @type-options no-extends /** * Takes an iterable of iterables and produces an iterable of arrays where position corresponds * to position in the passed iterable. diff --git a/packages/core-js-types/src/56/proposals/iterator-range.d.ts b/packages/core-js-types/src/56/proposals/iterator-range.d.ts index 57a6a1602efd..90df48a404c7 100644 --- a/packages/core-js-types/src/56/proposals/iterator-range.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-range.d.ts @@ -1,5 +1,5 @@ // proposal stage: 2 -// https://github.com/tc39/proposal-Number.range +// https://github.com/tc39/proposal-iterator.range declare global { type IteratorRangeOptions = { @@ -8,7 +8,7 @@ declare global { inclusive?: boolean; }; - interface IteratorConstructor { + interface IteratorConstructor { // @type-options no-extends /** * Returns an iterator that generates a sequence of numbers or bigints within a range. * @param start The starting value of the sequence. diff --git a/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts index fbdd20b87752..9f327fd710e3 100644 --- a/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts +++ b/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts @@ -4,7 +4,7 @@ import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; declare global { - interface IteratorConstructor { + interface IteratorConstructor { // @type-options no-extends /** * Creates an iterator that sequentially yields values from the provided iterables. * @param iterators The iterables to concatenate. diff --git a/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts index 65d470bee47f..58c02930cf1e 100644 --- a/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts +++ b/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts @@ -1,19 +1,19 @@ // proposal stage: 3 // https://github.com/tc39/proposal-json-parse-with-source -interface CoreJSReviverContext { +interface CoreJSReviverContext { // @type-options no-extends,no-prefix readonly __brand: unique symbol; source: string; } -interface CoreJSRawJSON { +interface CoreJSRawJSON { // @type-options no-extends,no-prefix readonly __brand: unique symbol; rawJSON: string; } -interface JSON { +interface JSON { // @type-options no-constructor /** * Determines whether a value is a RawJSON object. * @param value diff --git a/packages/core-js-types/src/56/proposals/map-upsert.d.ts b/packages/core-js-types/src/56/proposals/map-upsert.d.ts index 987e9a9d7a2f..053128f0d551 100644 --- a/packages/core-js-types/src/56/proposals/map-upsert.d.ts +++ b/packages/core-js-types/src/56/proposals/map-upsert.d.ts @@ -1,7 +1,7 @@ // proposal stage: 2 // https://github.com/tc39/proposal-upsert -interface Map { +interface Map { // @type-options no-redefine /** * Gets the value for the given key. If the key does not exist, inserts the provided value and returns it. * @param key @@ -20,7 +20,7 @@ interface Map { getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } -interface WeakMap { +interface WeakMap { // @type-options no-redefine /** * Gets the value for the given key. If the key does not exist, inserts the provided value and returns it. * @param key diff --git a/packages/core-js-types/src/56/proposals/math-sum.d.ts b/packages/core-js-types/src/56/proposals/math-sum.d.ts index abad11a68bbc..3bbc0472db34 100644 --- a/packages/core-js-types/src/56/proposals/math-sum.d.ts +++ b/packages/core-js-types/src/56/proposals/math-sum.d.ts @@ -1,6 +1,6 @@ // proposal stage: 3 // https://github.com/tc39/proposal-math-sum -interface Math { +interface Math { // @type-options no-constructor /** * Returns the sum of all given values. * @param values diff --git a/packages/core-js-types/src/56/proposals/number-clamp.d.ts b/packages/core-js-types/src/56/proposals/number-clamp.d.ts index f57f14337100..2fb0e2388b03 100644 --- a/packages/core-js-types/src/56/proposals/number-clamp.d.ts +++ b/packages/core-js-types/src/56/proposals/number-clamp.d.ts @@ -1,7 +1,7 @@ // proposal stage: 2 // https://github.com/tc39/proposal-math-clamp -interface Number { +interface Number { // @type-options export-base-constructor /** * Clamps the number within the inclusive lower and upper bounds. * @param lower diff --git a/packages/core-js-types/src/56/proposals/promise-any.d.ts b/packages/core-js-types/src/56/proposals/promise-any.d.ts index 80b35c56fa4e..fb5d182ba8d2 100644 --- a/packages/core-js-types/src/56/proposals/promise-any.d.ts +++ b/packages/core-js-types/src/56/proposals/promise-any.d.ts @@ -25,7 +25,7 @@ interface AggregateError extends Error { errors: any[]; } -interface AggregateErrorConstructor { +interface AggregateErrorConstructor { // @type-options no-extends new (errors: Iterable, message?: string): AggregateError; (errors: Iterable, message?: string): AggregateError; readonly prototype: AggregateError; diff --git a/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts index 40f5a7088944..f59b720b151c 100644 --- a/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts +++ b/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts @@ -5,7 +5,7 @@ // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2024.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface PromiseWithResolvers { +interface PromiseWithResolvers { // @type-options no-extends, no-prefix promise: Promise; resolve: (value: T | PromiseLike) => void; diff --git a/packages/core-js-types/src/56/proposals/pure/array-buffer-base64.d.ts b/packages/core-js-types/src/56/proposals/pure/array-buffer-base64.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/array-buffer-transfer.d.ts b/packages/core-js-types/src/56/proposals/pure/array-buffer-transfer.d.ts new file mode 100644 index 000000000000..a7b1ea2e1681 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/array-buffer-transfer.d.ts @@ -0,0 +1,35 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-arraybuffer-transfer + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/es2024.arraybuffer.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export interface CoreJSArrayBuffer extends ArrayBuffer { + readonly detached: boolean; + + /** + * Creates a new `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. + * @param newByteLength If provided, specifies the `byteLength` of the new `ArrayBuffer` + * @throws {RangeError} If this `ArrayBuffer` is resizable and newByteLength is greater than the `maxByteLength` of this `ArrayBuffer` + * @throws {TypeError} If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @returns A new `ArrayBuffer` object + */ + transfer(newByteLength?: number): CoreJSArrayBuffer; + + /** + * Creates a new non-resizable `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. + * @param newByteLength If provided, specifies the `byteLength` of the new `ArrayBuffer` + * @throws {TypeError} If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @returns A new `ArrayBuffer` object + */ + transferToFixedLength(newByteLength?: number): CoreJSArrayBuffer; + } + + export interface CoreJSArrayBufferConstructor extends ArrayBufferConstructor { + new (byteLength: number, options?: { maxByteLength?: number; }): CoreJSArrayBuffer; + } + + var CoreJSArrayBuffer: CoreJSArrayBufferConstructor; +} diff --git a/packages/core-js-types/src/56/proposals/pure/array-constructor.d.ts b/packages/core-js-types/src/56/proposals/pure/array-constructor.d.ts new file mode 100644 index 000000000000..1637b9571622 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/array-constructor.d.ts @@ -0,0 +1,45 @@ +/// + +// proposal stage: 2 +// https://github.com/tc39/proposal-array-is-template-object + +// proposal stage: 3 +// https://github.com/tc39/proposal-array-from-async + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/esnext.array.d.ts#L6 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + type ArrayConstructorBase = Omit< + ArrayConstructor, + 'fromAsync' | 'isTemplateObject' + >; + + export interface CoreJSArrayConstructor extends ArrayConstructorBase { + /** + * Creates an array from an async iterator or iterable object. + * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. + */ + fromAsync(iterableOrArrayLike: CoreJSAsyncIterable | Iterable> | ArrayLike>): Promise; + + /** + * Creates an array from an async iterator or iterable object. + * + * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. + * @param mapFn A mapping function to call on every element of iterableOrArrayLike. + * Each return value is awaited before being added to result array. + * @param thisArg Value of 'this' used when executing mapFn. + */ + fromAsync(iterableOrArrayLike: CoreJSAsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; + + /** + * Determines whether an `value` is a `TemplateStringsArray` + * @param value + * @returns `true` if `value` is a `TemplateStringsArray`, otherwise `false` + */ + isTemplateObject(value: any): value is TemplateStringsArray; + } + + var CoreJSArray: CoreJSArrayConstructor; +} diff --git a/packages/core-js-types/src/56/proposals/pure/array-filtering.d.ts b/packages/core-js-types/src/56/proposals/pure/array-filtering.d.ts new file mode 100644 index 000000000000..a07733732064 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/array-filtering.d.ts @@ -0,0 +1,15 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-array-filtering + +declare namespace CoreJS { + interface CoreJSArray extends Array { + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/array-find-from-last.d.ts b/packages/core-js-types/src/56/proposals/pure/array-find-from-last.d.ts new file mode 100644 index 000000000000..641b35d5e45f --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/array-find-from-last.d.ts @@ -0,0 +1,34 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-array-find-from-last + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + interface CoreJSArray extends Array { + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; + + findLast(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T | undefined; + + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/array-flat-map.d.ts b/packages/core-js-types/src/56/proposals/pure/array-flat-map.d.ts new file mode 100644 index 000000000000..1adb5419d39e --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/array-flat-map.d.ts @@ -0,0 +1,33 @@ +/// + +// proposal stage: 4 +// https://github.com/tc39/proposal-flatMap + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export interface CoreJSArray extends Array { + + /** + * 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 callback 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 this keyword can refer in the callback function. If + * thisArg is omitted, undefined is used as this value. + */ + flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): 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(this: A, depth?: D): CoreJSFlatArray[]; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/array-from-async.d.ts b/packages/core-js-types/src/56/proposals/pure/array-from-async.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/array-includes.d.ts b/packages/core-js-types/src/56/proposals/pure/array-includes.d.ts new file mode 100644 index 000000000000..8e32b6cf5b26 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/array-includes.d.ts @@ -0,0 +1,17 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-Array.prototype.includes + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2016.array.include.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + interface CoreJSArray extends Array { + /** + * 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(searchElement: T, fromIndex?: number): boolean; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/array-unique.d.ts b/packages/core-js-types/src/56/proposals/pure/array-unique.d.ts new file mode 100644 index 000000000000..a855544e610a --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/array-unique.d.ts @@ -0,0 +1,14 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-array-unique + +declare namespace CoreJS { + interface CoreJSArray extends Array { + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ + uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/async-iteration.d.ts b/packages/core-js-types/src/56/proposals/pure/async-iteration.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/async-iterator-helpers.d.ts b/packages/core-js-types/src/56/proposals/pure/async-iterator-helpers.d.ts new file mode 100644 index 000000000000..077b25cf6c91 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/async-iterator-helpers.d.ts @@ -0,0 +1,98 @@ +/// +/// + +// proposal stage: 2 +// https://github.com/tc39/proposal-async-iterator-helpers + +declare namespace CoreJS { + export interface CoreJSAsyncIteratorConstructor { + /** + * Creates an `AsyncIterator` from an iterable object + * @param iterable An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` + * @returns A new `AsyncIterator` instance + */ + from(iterable: CoreJSAsyncIterable | Iterable | CoreJSAsyncIteratorObject): CoreJSAsyncIteratorObject; + } + + export interface CoreJSAsyncIterator { + + /** + * Drops elements from the iterator until the limit is reached + * @param limit The number of elements to drop + * @returns A new `AsyncIterator` + */ + drop(limit: number): CoreJSAsyncIteratorObject; + + /** + * Check if every value generated by the iterator passes the `predicate` function. + * @param predicate A function that tests each element of the iterator + * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` + */ + every(predicate: (value: T, index: number) => boolean): Promise; + + /** + * Creates a new `AsyncIterator` that contains only the elements that pass the `predicate` function. + * @param predicate A function that tests each element of the iterator + * @returns A new `AsyncIterator` + */ + filter(predicate: (value: T, index: number) => boolean): CoreJSAsyncIteratorObject; + + /** + * Finds the first element in the iterator that satisfies the `predicate` function. + * @param predicate A function that tests each element of the iterator + * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` + */ + find(predicate: (value: T, index: number) => boolean): Promise; + + /** + * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. + * @param mapper A function that transforms each element of the iterator + * @returns A new `AsyncIterator` + */ + flatMap(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorObject; + + /** + * Executes a provided function once for each element in the iterator. + * @param callbackFn A function that is called for each element of the iterator + * @returns A `Promise` that resolves when all elements have been processed + */ + forEach(callbackFn: (value: T, index: number) => void): Promise; + + /** + * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. + * @param mapper A function that transforms each element of the iterator + * @returns A new `AsyncIterator` + */ + map(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorObject; + + /** + * Reduces the elements of the iterator to a single value using the `reducer` function. + * @param reducer A function that combines two elements of the iterator + * @param initialValue An optional initial value to start the reduction + * @returns A `Promise` that resolves to the reduced value + */ + reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; + + /** + * Checks if any value in the iterator matches a given `predicate` + * @param predicate A function that tests each element of the iterator + * @returns A `Promise` that resolves to `true` if any element passes the `predicate`, otherwise `false` + */ + some(predicate: (value: T, index: number) => boolean): Promise; + + /** + * Creates a new `AsyncIterator` that yields only the first `limit` elements from the original iterator. + * @param limit The maximum number of elements to take + * @returns A new `AsyncIterator` + */ + take(limit: number): CoreJSAsyncIteratorObject; + + /** + * Collects all elements from the iterator into an array. + * @returns A `Promise` that resolves to an array containing all elements from the iterator + */ + toArray(): Promise; + } + + var CoreJSAsyncIterator: CoreJSAsyncIteratorConstructor; +} diff --git a/packages/core-js-types/src/56/proposals/pure/await-dictionary.d.ts b/packages/core-js-types/src/56/proposals/pure/await-dictionary.d.ts new file mode 100644 index 000000000000..351dc2b16fdb --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/await-dictionary.d.ts @@ -0,0 +1,28 @@ +/// + +// proposal stage: 1 +// https://github.com/tc39/proposal-await-dictionary + +declare namespace CoreJS { + export interface CoreJSPromiseConstructor extends PromiseConstructor { + + /** + * Takes an object of promises and returns a single Promise that resolves to an object + * with the same keys and fulfilled values, or rejects as soon as any of the input promises rejects. + * @param promises An object of promises + * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. + */ + allKeyed>>(promises: D): Promise<{ [k in keyof D]: Awaited }>; + + /** + * Takes an object whose values are promises and returns a single `Promise` that resolves + * to an object with the same keys, after all of the input promises have settled. + * @param promises An object of promises + * @returns A new Promise that resolves to an object with the same keys as the input object, + * where each key maps to the settlement result ({ status, value } or { status, reason }) of the corresponding promise. + */ + allSettledKeyed>>(promises: D): Promise<{ [k in keyof D]: CoreJSPromiseSettledResult> }>; + } + + var CoreJSPromise: CoreJSPromiseConstructor; +} diff --git a/packages/core-js-types/src/56/proposals/pure/change-array-by-copy.d.ts b/packages/core-js-types/src/56/proposals/pure/change-array-by-copy.d.ts new file mode 100644 index 000000000000..0ec42d1ba2b1 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/change-array-by-copy.d.ts @@ -0,0 +1,54 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-change-array-by-copy + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export interface CoreJSArray extends Array { + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): T[]; + + /** + * Returns a copy of an array with its elements sorted. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. + * ```ts + * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. + * @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 copied array in place of the deleted elements. + * @returns The copied array. + */ + toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; + + /** + * Copies an array and removes elements while returning the remaining 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 A copy of the original array with the remaining elements. + */ + toSpliced(start: number, deleteCount?: number): T[]; + + /** + * Copies an array, then overwrites the value at the provided index with the + * given value. If the index is negative, then it replaces from the end + * of the array. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to write into the copied array. + * @returns The copied array with the updated value. + */ + with(index: number, value: T): T[]; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/56/proposals/pure/data-view-get-set-uint8-clamped.d.ts new file mode 100644 index 000000000000..9b861be3b6f4 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/data-view-get-set-uint8-clamped.d.ts @@ -0,0 +1,24 @@ +// proposal stage: 1 +// https://github.com/tc39/proposal-dataview-get-set-uint8clamped + +declare namespace CoreJS { + var CoreJSDataView: CoreJSDataView; + + export interface CoreJSDataView extends DataView { + /** + * Reads an unsigned 8-bit integer at the specified byte offset from the DataView, + * interpreting the byte as a clamped 8-bit unsigned value (same as Uint8ClampedArray). + * @param byteOffset The offset, in bytes, from the start of the DataView. + * @returns The unsigned 8-bit integer at the given offset. + */ + getUint8Clamped(byteOffset: number): number; + + /** + * Stores a value as an unsigned 8-bit integer at the specified byte offset in the DataView, + * clamping the input to the 0–255 range and rounding to the nearest integer as per Uint8ClampedArray behavior. + * @param byteOffset The offset, in bytes, from the start of the DataView. + * @param value The value to store; it will be clamped to the range 0–255 and rounded to the nearest integer. + */ + setUint8Clamped(byteOffset: number, value: number): void; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/date.d.ts b/packages/core-js-types/src/56/proposals/pure/date.d.ts new file mode 100644 index 000000000000..ce1e532082ff --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/date.d.ts @@ -0,0 +1,5 @@ +declare namespace CoreJS { + export interface CoreJSDate extends Date {} + + var CoreJSDate: DateConstructor; +} diff --git a/packages/core-js-types/src/56/proposals/pure/decorator-metadata.d.ts b/packages/core-js-types/src/56/proposals/pure/decorator-metadata.d.ts new file mode 100644 index 000000000000..f30373dfff76 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/decorator-metadata.d.ts @@ -0,0 +1,12 @@ +/// + +// proposal stage: 3 +// https://github.com/tc39/proposal-decorator-metadata + +declare namespace CoreJS { + var CoreJSFunction: CoreJSFunction; + + export interface CoreJSFunction extends Function { + [CoreJS.CoreJSSymbol.metadata]: Record & object | null; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/dom-exception.d.ts b/packages/core-js-types/src/56/proposals/pure/dom-exception.d.ts new file mode 100644 index 000000000000..7b5f52d818c3 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/dom-exception.d.ts @@ -0,0 +1,71 @@ +declare namespace CoreJS { + interface CoreJSDOMException extends Error { + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code) + */ + readonly code: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) */ + readonly message: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) */ + readonly name: string; + readonly INDEX_SIZE_ERR: 1; + readonly DOMSTRING_SIZE_ERR: 2; + readonly HIERARCHY_REQUEST_ERR: 3; + readonly WRONG_DOCUMENT_ERR: 4; + readonly INVALID_CHARACTER_ERR: 5; + readonly NO_DATA_ALLOWED_ERR: 6; + readonly NO_MODIFICATION_ALLOWED_ERR: 7; + readonly NOT_FOUND_ERR: 8; + readonly NOT_SUPPORTED_ERR: 9; + readonly INUSE_ATTRIBUTE_ERR: 10; + readonly INVALID_STATE_ERR: 11; + readonly SYNTAX_ERR: 12; + readonly INVALID_MODIFICATION_ERR: 13; + readonly NAMESPACE_ERR: 14; + readonly INVALID_ACCESS_ERR: 15; + readonly VALIDATION_ERR: 16; + readonly TYPE_MISMATCH_ERR: 17; + readonly SECURITY_ERR: 18; + readonly NETWORK_ERR: 19; + readonly ABORT_ERR: 20; + readonly URL_MISMATCH_ERR: 21; + readonly QUOTA_EXCEEDED_ERR: 22; + readonly TIMEOUT_ERR: 23; + readonly INVALID_NODE_TYPE_ERR: 24; + readonly DATA_CLONE_ERR: 25; + } + + interface CoreJSDomExceptionConstructor { + prototype: CoreJSDOMException; + new(message?: string, name?: string): CoreJSDOMException; + readonly INDEX_SIZE_ERR: 1; + readonly DOMSTRING_SIZE_ERR: 2; + readonly HIERARCHY_REQUEST_ERR: 3; + readonly WRONG_DOCUMENT_ERR: 4; + readonly INVALID_CHARACTER_ERR: 5; + readonly NO_DATA_ALLOWED_ERR: 6; + readonly NO_MODIFICATION_ALLOWED_ERR: 7; + readonly NOT_FOUND_ERR: 8; + readonly NOT_SUPPORTED_ERR: 9; + readonly INUSE_ATTRIBUTE_ERR: 10; + readonly INVALID_STATE_ERR: 11; + readonly SYNTAX_ERR: 12; + readonly INVALID_MODIFICATION_ERR: 13; + readonly NAMESPACE_ERR: 14; + readonly INVALID_ACCESS_ERR: 15; + readonly VALIDATION_ERR: 16; + readonly TYPE_MISMATCH_ERR: 17; + readonly SECURITY_ERR: 18; + readonly NETWORK_ERR: 19; + readonly ABORT_ERR: 20; + readonly URL_MISMATCH_ERR: 21; + readonly QUOTA_EXCEEDED_ERR: 22; + readonly TIMEOUT_ERR: 23; + readonly INVALID_NODE_TYPE_ERR: 24; + readonly DATA_CLONE_ERR: 25; + } + + var CoreJSDOMException: CoreJSDOMException; +} diff --git a/packages/core-js-types/src/56/proposals/pure/error-cause.d.ts b/packages/core-js-types/src/56/proposals/pure/error-cause.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/error.d.ts b/packages/core-js-types/src/56/proposals/pure/error.d.ts new file mode 100644 index 000000000000..a27eb26b3d62 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/error.d.ts @@ -0,0 +1,49 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-error-cause + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/es2022.error.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +// proposal stage: 3 +// https://github.com/tc39/proposal-is-error + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/esnext.error.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export interface ErrorOptions { + cause?: unknown; + } + + export interface CoreJSError extends Error { + cause?: unknown; // ts <= 4.7 Error | undefined + } + + export interface CoreJSErrorConstructor extends ErrorConstructor { + new(message?: string, options?: ErrorOptions): CoreJSError; + + (message?: string, options?: ErrorOptions): CoreJSError; + + /** + * Indicates whether the argument provided is a built-in Error instance or not. + */ + isError(value: any): value is Error; + } + + export interface CoreJSAggregateError extends Error { + errors: any[]; + } + + export interface CoreJSAggregateErrorConstructor extends ErrorConstructor { + readonly prototype: CoreJSAggregateError; + + new(errors: Iterable, message?: string): CoreJSAggregateError; + + (errors: Iterable, message?: string): CoreJSAggregateError; + } + + export var CoreJSError: CoreJSErrorConstructor; + export var CoreJSAggregateError: CoreJSAggregateErrorConstructor; +} diff --git a/packages/core-js-types/src/56/proposals/pure/explicit-resource-management.d.ts b/packages/core-js-types/src/56/proposals/pure/explicit-resource-management.d.ts new file mode 100644 index 000000000000..d8b7c8952ba2 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/explicit-resource-management.d.ts @@ -0,0 +1,189 @@ +/// + +// proposal stage: 3 +// https://github.com/tc39/proposal-explicit-resource-management + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/0a1aa6d6ebdfa16b82f4a6aaf282089b1d484e05/src/lib/esnext.disposable.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export interface CoreJSDisposable { + [CoreJSSymbol.dispose](): void; + } + + var CoreJSDisposable: CoreJSDisposable; + + export interface CoreJSAsyncDisposable { + [CoreJSSymbol.asyncDispose](): PromiseLike; + } + + var CoreJSAsyncDisposable: CoreJSAsyncDisposable; + + export interface CoreJSSuppressedError extends Error { + error: any; + suppressed: any; + } + + export interface CoreJSSuppressedErrorConstructor { + readonly prototype: CoreJSSuppressedError; + + new(error: any, suppressed: any, message?: string): CoreJSSuppressedError; + + (error: any, suppressed: any, message?: string): CoreJSSuppressedError; + } + + var CoreJSSuppressedError: CoreJSSuppressedErrorConstructor; + + var CoreJSDisposableStack: CoreJSDisposableStackConstructor; + + export interface CoreJSDisposableStack { + /** + * Returns a value indicating whether this stack has been disposed. + */ + readonly disposed: boolean; + readonly [CoreJSSymbol.toStringTag]: string; + + /** + * Disposes each resource in the stack in the reverse order that they were added. + */ + dispose(): void; + + /** + * Adds a disposable resource to the stack, returning the resource. + * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @returns The provided {@link value}. + */ + use(value: T): T; + + /** + * Adds a value and associated disposal callback as a resource to the stack. + * @param value The value to add. + * @param onDispose The callback to use in place of a `[CoreJSSymbol.dispose]()` method. Will be invoked with `value` + * as the first parameter. + * @returns The provided {@link value}. + */ + adopt(value: T, onDispose: (value: T) => void): T; + + /** + * Adds a callback to be invoked when the stack is disposed. + */ + defer(onDispose: () => void): void; + + /** + * Move all resources out of this stack and into a new `DisposableStack`, and marks this stack as disposed. + * @example + * ```ts + * class C { + * #res1: Disposable; + * #res2: Disposable; + * #disposables: DisposableStack; + * constructor() { + * // stack will be disposed when exiting constructor for any reason + * using stack = new DisposableStack(); + * + * // get first resource + * this.#res1 = stack.use(getResource1()); + * + * // get second resource. If this fails, both `stack` and `#res1` will be disposed. + * this.#res2 = stack.use(getResource2()); + * + * // all operations succeeded, move resources out of `stack` so that they aren't disposed + * // when constructor exits + * this.#disposables = stack.move(); + * } + * + * [CoreJSSymbol.dispose]() { + * this.#disposables.dispose(); + * } + * } + * ``` + */ + move(): CoreJSDisposableStack; + + [CoreJSSymbol.dispose](): void; + } + + export interface CoreJSDisposableStackConstructor { + readonly prototype: CoreJSDisposableStack; + + new(): CoreJSDisposableStack; + } + + var CoreJSAsyncDisposableStack: CoreJSAsyncDisposableStackConstructor; + + export interface CoreJSAsyncDisposableStack { + + /** + * Returns a value indicating whether this stack has been disposed. + */ + readonly disposed: boolean; + readonly [CoreJSSymbol.toStringTag]: string; + + /** + * Disposes each resource in the stack in the reverse order that they were added. + */ + disposeAsync(): Promise; + + /** + * Adds a disposable resource to the stack, returning the resource. + * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @returns The provided {@link value}. + */ + use(value: T): T; + + /** + * Adds a value and associated disposal callback as a resource to the stack. + * @param value The value to add. + * @param onDisposeAsync The callback to use in place of a `[CoreJSSymbol.asyncDispose]()` method. Will be invoked with `value` + * as the first parameter. + * @returns The provided {@link value}. + */ + adopt(value: T, onDisposeAsync: (value: T) => PromiseLike | void): T; + + /** + * Adds a callback to be invoked when the stack is disposed. + */ + defer(onDisposeAsync: () => PromiseLike | void): void; + + /** + * Move all resources out of this stack and into a new `DisposableStack`, and marks this stack as disposed. + * @example + * ```ts + * class C { + * #res1: CoreJSDisposable; + * #res2: CoreJSDisposable; + * #disposables: CoreJSDisposableStack; + * constructor() { + * // stack will be disposed when exiting constructor for any reason + * using stack = new DisposableStack(); + * + * // get first resource + * this.#res1 = stack.use(getResource1()); + * + * // get second resource. If this fails, both `stack` and `#res1` will be disposed. + * this.#res2 = stack.use(getResource2()); + * + * // all operations succeeded, move resources out of `stack` so that they aren't disposed + * // when constructor exits + * this.#disposables = stack.move(); + * } + * + * [CoreJSSymbol.dispose]() { + * this.#disposables.dispose(); + * } + * } + * ``` + */ + move(): CoreJSAsyncDisposableStack; + + [CoreJSSymbol.asyncDispose](): Promise; + } + + export interface CoreJSAsyncDisposableStackConstructor { + + readonly prototype: CoreJSAsyncDisposableStack; + + new(): CoreJSAsyncDisposableStack; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/float16.d.ts b/packages/core-js-types/src/56/proposals/pure/float16.d.ts new file mode 100644 index 000000000000..230a3a96f8f5 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/float16.d.ts @@ -0,0 +1,38 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-float16array + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.float16.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + var CoreJSMath: CoreJSMath; + + export interface CoreJSMath extends Math { + /** + * Returns the nearest half precision float representation of a number. + * @param x A numeric expression. + */ + f16round(x: number): number; + } + + var CoreJSDataView: CoreJSDataView; + + export interface CoreJSDataView extends DataView { + /** + * Gets the Float16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multibyte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. + */ + getFloat16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Stores a Float16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written. + */ + setFloat16(byteOffset: number, value: number, littleEndian?: boolean): void; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/global-this.d.ts b/packages/core-js-types/src/56/proposals/pure/global-this.d.ts new file mode 100644 index 000000000000..fec053664a61 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/global-this.d.ts @@ -0,0 +1,3 @@ +declare namespace CoreJS { + var CoreJSglobalThis: typeof globalThis; +} diff --git a/packages/core-js-types/src/56/proposals/pure/is-error.d.ts b/packages/core-js-types/src/56/proposals/pure/is-error.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-chunking.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator-chunking.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-helpers.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator-helpers.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-join.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator-join.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-joint.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator-joint.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-range.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator-range.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-sequencing.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator-sequencing.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/iterator.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator.d.ts new file mode 100644 index 000000000000..6eb8f68bdb86 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/iterator.d.ts @@ -0,0 +1,242 @@ +/// + +// proposal stage: 2.7 +// https://github.com/tc39/proposal-iterator-chunking + +// proposal stage: 4 +// https://github.com/tc39/proposal-iterator-helpers + +// proposal stage: 0 +// https://github.com/bakkot/proposal-iterator-join + +// proposal stage: 2.7 +// https://github.com/tc39/proposal-joint-iteration + +// proposal stage: 2 +// https://github.com/tc39/proposal-iterator.range + +// proposal stage: 2.7 +// https://github.com/tc39/proposal-iterator-sequencing + +// proposal stage: 2 +// https://github.com/tc39/proposal-async-iterator-helpers + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + type ZipOptions = { + mode?: 'shortest' | 'longest' | 'strict'; + + padding?: object; + }; + + type IteratorRangeOptions = { + step?: T; + + inclusive?: boolean; + }; + + interface CoreJSPromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: ((value: T) => TResult1 | CoreJSPromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | CoreJSPromiseLike) | undefined | null): CoreJSPromiseLike; + } + + interface CoreJSAsyncIterator { + next(...[value]: [] | [TNext]): Promise>; + return?(value?: TReturn | CoreJSPromiseLike): Promise>; + throw?(e?: any): Promise>; + } + + export interface CoreJSAsyncIteratorObject extends CoreJSAsyncIterator {} + export interface CoreJSAsyncIteratorObject extends CoreJSAsyncDisposable {} + export interface CoreJSAsyncIterable { + [CoreJSSymbol.asyncIterator](): CoreJSAsyncIterator; + } + + export interface CoreJSIteratorObject extends Iterator {} + export interface CoreJSIteratorObject extends CoreJSDisposable {} + + export interface CoreJSIterator extends Iterator { + /** + * Yields arrays containing up to the specified number of elements + * chunked from the source iterator. + * @param chunkSize The maximum number of elements per chunk. Must be a positive integer. + * @returns An iterator yielding arrays of at most `chunkSize` elements from the source iterator. + */ + chunks(chunkSize: number): CoreJSIteratorObject; + + /** + * Yields overlapping arrays (windows) of the given size from the iterator. + * @param windowSize The size of each window. Must be a positive integer. + * @param undersized 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. + * @returns An iterator yielding arrays of the specified window size. + */ + windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJSIteratorObject; + + /** + * Creates an iterator whose values are the result of applying the callback to the values from this iterator. + * @param callbackfn A function that accepts up to two arguments to be used to transform values from the underlying iterator. + */ + map(callbackfn: (value: T, index: number) => U): CoreJSIteratorObject; + + /** + * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. + * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + */ + filter(predicate: (value: T, index: number) => value is S): CoreJSIteratorObject; + /** + * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. + * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + */ + filter(predicate: (value: T, index: number) => unknown): CoreJSIteratorObject; + + /** + * Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached. + * @param limit The maximum number of values to yield. + */ + take(limit: number): CoreJSIteratorObject; + + /** + * Creates an iterator whose values are the values from this iterator after skipping the provided count. + * @param count The number of values to drop. + */ + drop(count: number): CoreJSIteratorObject; + + /** + * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. + * @param callback A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. + */ + flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; // ts < 5.6 Iterable + + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; + + /** + * Creates a new array from the values yielded by this iterator. + */ + toArray(): T[]; + + /** + * Performs the specified action for each element in the iterator. + * @param callbackfn A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. + */ + forEach(callbackfn: (value: T, index: number) => void): void; + + /** + * Determines whether the specified callback function returns true for any element of this iterator. + * @param predicate A function that accepts up to two arguments. The `some` method calls + * the predicate function for each element in this iterator until the predicate returns a value + * true, or until the end of the iterator. + */ + some(predicate: (value: T, index: number) => unknown): boolean; + + /** + * Determines whether all the members of this iterator satisfy the specified test. + * @param predicate A function that accepts up to two arguments. The every method calls + * the predicate function for each element in this iterator until the predicate returns + * false, or until the end of this iterator. + */ + every(predicate: (value: T, index: number) => unknown): boolean; + + /** + * Returns the value of the first element in this iterator where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of this iterator, in + * 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. + */ + find(predicate: (value: T, index: number) => value is S): S | undefined; + find(predicate: (value: T, index: number) => unknown): T | undefined; + + join(separator?: unknown): string; + + /** + * Creates an `AsyncIterator` from the current `Iterator` + * @returns A new `AsyncIterator` instance + */ + toAsync(): CoreJSAsyncIteratorObject; + } + + export interface CoreJSIteratorConstructor { + /** + * Creates a native iterator from an iterator or iterable object. + * Returns its input if the input already inherits from the built-in Iterator class. + * @param value An iterator or iterable object to convert a native iterator. + */ + from(value: Iterator | Iterable): CoreJSIteratorObject; + + /** + * Takes an iterable of iterables and produces an iterable of arrays where position corresponds + * to position in the passed iterable. + * @param iterables An Iterable of iterables. + * @param options Optional object: + * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; + * - padding: an object specifying padding values for each key when mode is 'longest'. + * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. + */ + zip(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[T, U]>; + + /** + * takes an object whose values are iterables and produces an iterable of objects where keys. + * correspond to keys in the passed object. + * @param iterables An Iterable of iterables. + * @param options Optional object: + * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; + * - padding: an object specifying padding values for each key when mode is 'longest'. + * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. + */ + zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[number, T, U]>; + /** + * takes an object whose values are iterables and produces an iterable of objects where keys. + * correspond to keys in the passed object. + * @param record An object of iterables. + * @param options Optional object: + * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; + * - padding: an object specifying padding values for each key when mode is 'longest'. + * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. + */ + zipKeyed(record: Record>, options?: ZipOptions): CoreJSIteratorObject<[PropertyKey, T, U]>; + + /** + * Returns an iterator that generates a sequence of numbers or bigints within a range. + * @param start The starting value of the sequence. + * @param end The end value of the sequence (exclusive by default). + * @param options Optional object: + * - step: The difference between consecutive values (default is 1). + * - inclusive: If true, the end value is included in the range (default is false). + * @returns An iterator of numbers or bigints. + */ + range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): CoreJSIteratorObject + + /** + * Creates an iterator that sequentially yields values from the provided iterables. + * @param iterators The iterables to concatenate. + * @returns An iterator yielding values from each input iterable in sequence. + */ + concat(...iterators: Iterable[]): CoreJSIteratorObject; + } + + var CoreJSIterator: CoreJSIteratorConstructor; +} diff --git a/packages/core-js-types/src/56/proposals/pure/pattern-matching.d.ts b/packages/core-js-types/src/56/proposals/pure/pattern-matching.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/promise-all-settled.d.ts b/packages/core-js-types/src/56/proposals/pure/promise-all-settled.d.ts new file mode 100644 index 000000000000..53684ee5ad9f --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/promise-all-settled.d.ts @@ -0,0 +1,31 @@ +/// + +// proposal stage: 4 +// https://github.com/tc39/proposal-promise-allSettled + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2020.promise.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + var CoreJSPromise: CoreJSPromiseConstructor; + + export interface CoreJSPromiseConstructor extends PromiseConstructor { + + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJSPromiseSettledResult>; }>; + + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: Iterable>): Promise>[]>; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/promise-any.d.ts b/packages/core-js-types/src/56/proposals/pure/promise-any.d.ts new file mode 100644 index 000000000000..d73022d5540e --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/promise-any.d.ts @@ -0,0 +1,27 @@ +// proposal stage: 4 +// https://github.com/tc39/proposal-promise-any + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2021.promise.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export interface CoreJSPromiseConstructor extends PromiseConstructor { + + /** + * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. + * @param values An array or iterable of Promises. + * @returns A new Promise. + */ + any(values: T): Promise>; + + /** + * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. + * @param values An array or iterable of Promises. + * @returns A new Promise. + */ + any(values: Iterable>): Promise>; + } + + var CoreJSPromise: CoreJSPromiseConstructor; +} diff --git a/packages/core-js-types/src/56/proposals/pure/reflect.d.ts b/packages/core-js-types/src/56/proposals/pure/reflect.d.ts new file mode 100644 index 000000000000..980f9368b2ee --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/reflect.d.ts @@ -0,0 +1,132 @@ +declare namespace CoreJS { + interface Reflect { + /** + * Calls the function with the specified object as the this value + * and the elements of specified array as the arguments. + * @param target The function to call. + * @param thisArgument The object to be used as the this object. + * @param argumentsList An array of argument values to be passed to the function. + */ + apply( + target: (this: T, ...args: A) => R, + thisArgument: T, + argumentsList: Readonly, + ): R; + apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; + + /** + * Constructs the target with the elements of specified array as the arguments + * and the specified constructor as the `new.target` value. + * @param target The constructor to invoke. + * @param argumentsList An array of argument values to be passed to the constructor. + * @param newTarget The constructor to be used as the `new.target` object. + */ + construct( + target: new (...args: A) => R, + argumentsList: Readonly, + newTarget?: new (...args: any) => any, + ): R; + construct(target: Function, argumentsList: ArrayLike, newTarget?: Function): any; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param target 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 propertyKey The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ + defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor & ThisType): boolean; + + /** + * Removes a property from an object, equivalent to `delete target[propertyKey]`, + * except it won't throw if `target[propertyKey]` is non-configurable. + * @param target Object from which to remove the own property. + * @param propertyKey The property name. + */ + deleteProperty(target: object, propertyKey: PropertyKey): boolean; + + /** + * Gets the property of target, equivalent to `target[propertyKey]` when `receiver === target`. + * @param target Object that contains the property on itself or in its prototype chain. + * @param propertyKey The property name. + * @param receiver The reference to use as the `this` value in the getter function, + * if `target[propertyKey]` is an accessor property. + */ + get( + target: T, + propertyKey: P, + receiver?: unknown, + ): P extends keyof T ? T[P] : 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 target Object that contains the property. + * @param propertyKey The property name. + */ + getOwnPropertyDescriptor( + target: T, + propertyKey: P, + ): TypedPropertyDescriptor

| undefined; + + /** + * Returns the prototype of an object. + * @param target The object that references the prototype. + */ + getPrototypeOf(target: object): object | null; + + /** + * Equivalent to `propertyKey in target`. + * @param target Object that contains the property on itself or in its prototype chain. + * @param propertyKey Name of the property. + */ + has(target: object, propertyKey: PropertyKey): boolean; + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param target Object to test. + */ + isExtensible(target: object): boolean; + + /** + * Returns the string and symbol keys 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. + * @param target Object that contains the own properties. + */ + ownKeys(target: object): (string | symbol)[]; + + /** + * Prevents the addition of new properties to an object. + * @param target Object to make non-extensible. + * @return Whether the object has been made non-extensible. + */ + preventExtensions(target: object): boolean; + + /** + * Sets the property of target, equivalent to `target[propertyKey] = value` when `receiver === target`. + * @param target Object that contains the property on itself or in its prototype chain. + * @param propertyKey Name of the property. + * @param receiver The reference to use as the `this` value in the setter function, + * if `target[propertyKey]` is an accessor property. + */ + set( + target: T, + propertyKey: P, + value: P extends keyof T ? T[P] : any, + receiver?: any, + ): boolean; + set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + + /** + * Sets the prototype of a specified object o to object proto or null. + * @param target The object to change its prototype. + * @param proto The value of the new prototype or null. + * @return Whether setting the prototype was successful. + */ + setPrototypeOf(target: object, proto: object | null): boolean; + } + + interface CoreJSReflect extends Reflect {} + + var CoreJSReflect: CoreJSReflect; +} diff --git a/packages/core-js-types/src/56/proposals/pure/relative-indexing-method.d.ts b/packages/core-js-types/src/56/proposals/pure/relative-indexing-method.d.ts new file mode 100644 index 000000000000..e999824215cf --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/relative-indexing-method.d.ts @@ -0,0 +1,27 @@ +/// + +// proposal stage: 4 +// https://github.com/tc39/proposal-relative-indexing-method + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.array.d.ts +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + interface CoreJSString extends StringBase { + /** + * Returns a new String consisting of the single UTF-16 code unit located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ + at(index: number): string | undefined; + } + + interface CoreJSArray extends Array { + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ + at(index: number): T | undefined; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/self.d.ts b/packages/core-js-types/src/56/proposals/pure/self.d.ts new file mode 100644 index 000000000000..f07d845312aa --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/self.d.ts @@ -0,0 +1,3 @@ +declare namespace CoreJS { + var CoreJSself: typeof globalThis; +} diff --git a/packages/core-js-types/src/56/proposals/pure/string-left-right-trim.d.ts b/packages/core-js-types/src/56/proposals/pure/string-left-right-trim.d.ts new file mode 100644 index 000000000000..2cac498ddd43 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/string-left-right-trim.d.ts @@ -0,0 +1,28 @@ +/// + +// proposal stage: 4 +// https://github.com/tc39/proposal-string-left-right-trim + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export interface CoreJSString extends StringBase { + /** Removes the trailing white space and line terminator characters from a string. */ + trimEnd(): string; + + /** Removes the leading white space and line terminator characters from a string. */ + trimStart(): string; + + /** + * Removes the leading white space and line terminator characters from a string. + */ + trimLeft(): string; + + /** + * Removes the trailing white space and line terminator characters from a string. + */ + trimRight(): string; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/string-match-all.d.ts b/packages/core-js-types/src/56/proposals/pure/string-match-all.d.ts new file mode 100644 index 000000000000..8186dcaa0bce --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/string-match-all.d.ts @@ -0,0 +1,33 @@ +/// +/// + +// proposal stage: 4 +// https://github.com/tc39/proposal-string-matchall + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + interface CoreJSRegExpStringIterator extends CoreJSIteratorObject { + [Symbol.iterator](): CoreJSRegExpStringIterator; + } + + type StringBase = Omit; + + export interface CoreJSString extends StringBase { + + /** + * Matches a string with a regular expression, and returns an iterable of matches + * containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + matchAll(regexp: RegExp): CoreJSRegExpStringIterator; + } + + export interface CoreJSStringConstructor extends StringConstructor { + new(value?: any): CoreJSString; + } + + var CoreJSString: CoreJSStringConstructor; +} diff --git a/packages/core-js-types/src/56/proposals/pure/string-padding.d.ts b/packages/core-js-types/src/56/proposals/pure/string-padding.d.ts new file mode 100644 index 000000000000..f6c9a15a82e8 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/string-padding.d.ts @@ -0,0 +1,39 @@ +/// + +// proposal stage: 4 +// https://github.com/tc39/proposal-string-pad-start-end + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export interface CoreJSString extends StringBase { + + /** + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the start (left) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ + padStart(maxLength: number, fillString?: string): string; + + /** + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the end (right) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ + padEnd(maxLength: number, fillString?: string): string; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/string-replace-all.d.ts b/packages/core-js-types/src/56/proposals/pure/string-replace-all.d.ts new file mode 100644 index 000000000000..8d110b965291 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/string-replace-all.d.ts @@ -0,0 +1,27 @@ +/// + +// proposal stage: 4 +// https://github.com/tc39/proposal-string-replaceall + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/es2021.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export interface CoreJSString extends StringBase { + + /** + * Replace all instances of a substring in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replaceAll(searchValue: string | RegExp, replaceValue: string): string; + + /** + * Replace all instances of a substring in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replacer A function that returns the replacement text. + */ + replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/symbol-description.d.ts b/packages/core-js-types/src/56/proposals/pure/symbol-description.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/symbol-predicates.d.ts b/packages/core-js-types/src/56/proposals/pure/symbol-predicates.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/core-js-types/src/56/proposals/pure/symbol.d.ts b/packages/core-js-types/src/56/proposals/pure/symbol.d.ts new file mode 100644 index 000000000000..78ce50ea7a9c --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/symbol.d.ts @@ -0,0 +1,87 @@ +// proposal stage: 3 +// https://github.com/tc39/proposal-explicit-resource-management + +// proposal stage: 2 +// https://github.com/tc39/proposal-symbol-predicates + +// proposal stage: 4 +// https://github.com/tc39/proposal-async-iteration + +// proposal stage: 1 +// https://github.com/tc39/proposal-pattern-matching + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2018.asynciterable.d.ts#L4 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +// proposal stage: 3 +// https://github.com/tc39/proposal-decorator-metadata + +// proposal stage: 4 +// https://github.com/tc39/proposal-string-matchall + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +// proposal stage: 4 +// https://github.com/tc39/proposal-Symbol-description + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.symbol.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + type BaseSymbolConstructor = { + (description?: string | number | symbol): symbol; + new (description?: string | number | symbol): symbol; + } & Omit< + SymbolConstructor, + 'asyncIterator' | 'matchAll' | 'dispose' | 'asyncDispose' | 'customMatcher' | 'metadata' + >; + + export interface CoreJSSymbolConstructor extends BaseSymbolConstructor { + /** + * A method that is used to release resources held by an object. Called by the semantics of the `using` statement. + */ + readonly dispose: unique symbol; + + /** + * A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement. + */ + readonly asyncDispose: unique symbol; + + /** + * Determines whether the given value is a registered symbol. + * @param value + */ + isRegisteredSymbol(value: any): boolean; + + /** + * Determines whether the given value is a well-known symbol. + * @param value + */ + isWellKnownSymbol(value: any): boolean; + + /** + * A method that returns the default async iterator for an object. Called by the semantics of + * the for-await-of statement. + */ + readonly asyncIterator: unique symbol; + + readonly customMatcher: unique symbol; + + readonly metadata: unique symbol; + + readonly matchAll: unique symbol; + } + + export interface CoreJSSymbol extends Symbol { + /** + * Expose the [[Description]] internal slot of a symbol directly. + */ + readonly description: string | undefined; + } + + var CoreJSSymbol: CoreJSSymbolConstructor; +} diff --git a/packages/core-js-types/src/56/proposals/pure/typed-arrays.d.ts b/packages/core-js-types/src/56/proposals/pure/typed-arrays.d.ts new file mode 100644 index 000000000000..e6675dad3434 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/typed-arrays.d.ts @@ -0,0 +1,11 @@ +declare namespace CoreJS { + var CoreJSInt8Array: Int8ArrayConstructor; + var CoreJSUint8Array: Uint8ArrayConstructor; + var CoreJSUint8ClampedArray: Uint8ClampedArrayConstructor; + var CoreJSInt16Array: Int16ArrayConstructor; + var CoreJSUint16Array: Uint16ArrayConstructor; + var CoreJSInt32Array: Int32ArrayConstructor; + var CoreJSUint32Array: Uint32ArrayConstructor; + var CoreJSFloat32Array: Float32ArrayConstructor; + var CoreJSFloat64Array: Float64ArrayConstructor; +} diff --git a/packages/core-js-types/src/56/proposals/pure/url-search-params.d.ts b/packages/core-js-types/src/56/proposals/pure/url-search-params.d.ts new file mode 100644 index 000000000000..536d0b7109d5 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/url-search-params.d.ts @@ -0,0 +1,54 @@ +declare namespace CoreJS { + export interface CoreJSURLSearchParams { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size) */ + readonly size: number; + /** + * Appends a specified key/value pair as a new search parameter. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append) + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete) + */ + delete(name: string, value?: string): void; + /** + * Returns the first value associated to the given search parameter. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get) + */ + get(name: string): string | null; + /** + * Returns all the values association with a given search parameter. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll) + */ + getAll(name: string): string[]; + /** + * Returns a Boolean indicating if such a search parameter exists. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has) + */ + has(name: string, value?: string): boolean; + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set) + */ + set(name: string, value: string): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort) */ + sort(): void; + /** Returns a string containing a query string suitable for use in a URL. Does not include the question mark. */ + toString(): string; + forEach(callbackfn: (value: string, key: string, parent: CoreJSURLSearchParams) => void, thisArg?: any): void; + } + + export interface CoreJSURLSearchParamsConstructor { + prototype: CoreJSURLSearchParams; + new(init?: string[][] | Record | string | CoreJSURLSearchParams): CoreJSURLSearchParams; + } + + var CoreJSURLSearchParams: CoreJSURLSearchParamsConstructor; +} diff --git a/packages/core-js-types/src/56/proposals/pure/url.d.ts b/packages/core-js-types/src/56/proposals/pure/url.d.ts new file mode 100644 index 000000000000..b97a0234865e --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/url.d.ts @@ -0,0 +1,64 @@ +/// + +declare namespace CoreJS { + export interface CoreJSURL { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */ + hash: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */ + host: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */ + hostname: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */ + href: string; + + toString(): string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin) */ + readonly origin: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */ + password: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */ + pathname: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */ + port: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */ + protocol: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */ + search: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams) */ + readonly searchParams: CoreJSURLSearchParams; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */ + username: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON) */ + toJSON(): string; + } + + export interface CoreJSURLConstructor { + new(url: string, base?: string): CoreJSURL; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */ + canParse(url: string, base?: string): boolean; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) */ + createObjectURL(obj: any): string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static) */ + parse(url: string, base?: string): CoreJSURL | null; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) */ + revokeObjectURL(url: string): void; + } + + var CoreJSURL: CoreJSURLConstructor; +} diff --git a/packages/core-js-types/src/56/proposals/pure/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/56/proposals/pure/well-formed-unicode-strings.d.ts new file mode 100644 index 000000000000..24d3576a4021 --- /dev/null +++ b/packages/core-js-types/src/56/proposals/pure/well-formed-unicode-strings.d.ts @@ -0,0 +1,23 @@ +/// + +// proposal stage: 4 +// https://github.com/tc39/proposal-is-usv-string + +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2024.string.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export interface CoreJSString extends StringBase { + + /** + * Returns true if all leading surrogates and trailing surrogates appear paired and in order. + */ + isWellFormed(): boolean; + + /** + * Returns a string where all lone or out-of-order surrogates have been replaced by the Unicode replacement character (U+FFFD). + */ + toWellFormed(): string; + } +} diff --git a/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts index edffdc89fcc4..e773c772cfe8 100644 --- a/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts @@ -6,7 +6,7 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface String { +interface String { // @type-options no-redefine /** * Returns a new String consisting of the single UTF-16 code unit located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -14,7 +14,7 @@ interface String { at(index: number): string | undefined; } -interface Array { +interface Array { // @type-options no-redefine /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -22,7 +22,7 @@ interface Array { at(index: number): T | undefined; } -interface ReadonlyArray { +interface ReadonlyArray { // @type-options no-redefine /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -30,7 +30,7 @@ interface ReadonlyArray { at(index: number): T | undefined; } -interface Int8Array { +interface Int8Array { // @type-options no-redefine /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -38,7 +38,7 @@ interface Int8Array { at(index: number): number | undefined; } -interface Uint8Array { +interface Uint8Array { // @type-options no-redefine /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -46,7 +46,7 @@ interface Uint8Array { at(index: number): number | undefined; } -interface Uint8ClampedArray { +interface Uint8ClampedArray { // @type-options no-redefine /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -54,7 +54,7 @@ interface Uint8ClampedArray { at(index: number): number | undefined; } -interface Int16Array { +interface Int16Array { // @type-options no-redefine /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -62,7 +62,7 @@ interface Int16Array { at(index: number): number | undefined; } -interface Uint16Array { +interface Uint16Array { // @type-options no-redefine /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -70,7 +70,7 @@ interface Uint16Array { at(index: number): number | undefined; } -interface Int32Array { +interface Int32Array { // @type-options no-redefine /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -78,7 +78,7 @@ interface Int32Array { at(index: number): number | undefined; } -interface Uint32Array { +interface Uint32Array { // @type-options no-redefine /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -86,7 +86,7 @@ interface Uint32Array { at(index: number): number | undefined; } -interface Float32Array { +interface Float32Array { // @type-options no-redefine /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -94,7 +94,7 @@ interface Float32Array { at(index: number): number | undefined; } -interface Float64Array { +interface Float64Array { // @type-options no-redefine /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -102,7 +102,7 @@ interface Float64Array { at(index: number): number | undefined; } -interface BigInt64Array { +interface BigInt64Array { // @type-options no-redefine /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -110,7 +110,7 @@ interface BigInt64Array { at(index: number): bigint | undefined; } -interface BigUint64Array { +interface BigUint64Array { // @type-options no-redefine /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. diff --git a/packages/core-js-types/src/56/proposals/set-methods.d.ts b/packages/core-js-types/src/56/proposals/set-methods.d.ts index 6105faf431b6..c56a736a6182 100644 --- a/packages/core-js-types/src/56/proposals/set-methods.d.ts +++ b/packages/core-js-types/src/56/proposals/set-methods.d.ts @@ -5,97 +5,93 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -declare global { - interface ReadonlySetLike { - /** - * Despite its name, returns an iterator of the values in the set-like. - */ - keys(): Iterator; - - /** - * @returns a boolean indicating whether an element with the specified value exists in the set-like or not. - */ - has(value: T): boolean; - - /** - * @returns the number of (unique) elements in the set-like. - */ - readonly size: number; - } - - interface Set { - /** - * @returns a new Set containing all the elements in this Set and also all the elements in the argument. - */ - union(other: ReadonlySetLike): Set; - - /** - * @returns a new Set containing all the elements which are both in this Set and in the argument. - */ - intersection(other: ReadonlySetLike): Set; - - /** - * @returns a new Set containing all the elements in this Set which are not also in the argument. - */ - difference(other: ReadonlySetLike): Set; - - /** - * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. - */ - symmetricDifference(other: ReadonlySetLike): Set; - - /** - * @returns a boolean indicating whether all the elements in this Set are also in the argument. - */ - isSubsetOf(other: ReadonlySetLike): boolean; - - /** - * @returns a boolean indicating whether all the elements in the argument are also in this Set. - */ - isSupersetOf(other: ReadonlySetLike): boolean; - - /** - * @returns a boolean indicating whether this Set has no elements in common with the argument. - */ - isDisjointFrom(other: ReadonlySetLike): boolean; - } - - interface ReadonlySet { - /** - * @returns a new Set containing all the elements in this Set and also all the elements in the argument. - */ - union(other: ReadonlySetLike): Set; - - /** - * @returns a new Set containing all the elements which are both in this Set and in the argument. - */ - intersection(other: ReadonlySetLike): Set; - - /** - * @returns a new Set containing all the elements in this Set which are not also in the argument. - */ - difference(other: ReadonlySetLike): Set; - - /** - * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. - */ - symmetricDifference(other: ReadonlySetLike): Set; - - /** - * @returns a boolean indicating whether all the elements in this Set are also in the argument. - */ - isSubsetOf(other: ReadonlySetLike): boolean; - - /** - * @returns a boolean indicating whether all the elements in the argument are also in this Set. - */ - isSupersetOf(other: ReadonlySetLike): boolean; - - /** - * @returns a boolean indicating whether this Set has no elements in common with the argument. - */ - isDisjointFrom(other: ReadonlySetLike): boolean; - } +interface ReadonlySetLike { // @type-options no-extends, no-prefix + /** + * Despite its name, returns an iterator of the values in the set-like. + */ + keys(): Iterator; + + /** + * @returns a boolean indicating whether an element with the specified value exists in the set-like or not. + */ + has(value: T): boolean; + + /** + * @returns the number of (unique) elements in the set-like. + */ + readonly size: number; } -export {}; +interface Set { // @type-options no-redefine + /** + * @returns a new Set containing all the elements in this Set and also all the elements in the argument. + */ + union(other: ReadonlySetLike): Set; + + /** + * @returns a new Set containing all the elements which are both in this Set and in the argument. + */ + intersection(other: ReadonlySetLike): Set; + + /** + * @returns a new Set containing all the elements in this Set which are not also in the argument. + */ + difference(other: ReadonlySetLike): Set; + + /** + * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. + */ + symmetricDifference(other: ReadonlySetLike): Set; + + /** + * @returns a boolean indicating whether all the elements in this Set are also in the argument. + */ + isSubsetOf(other: ReadonlySetLike): boolean; + + /** + * @returns a boolean indicating whether all the elements in the argument are also in this Set. + */ + isSupersetOf(other: ReadonlySetLike): boolean; + + /** + * @returns a boolean indicating whether this Set has no elements in common with the argument. + */ + isDisjointFrom(other: ReadonlySetLike): boolean; +} + +interface ReadonlySet { // @type-options no-redefine + /** + * @returns a new Set containing all the elements in this Set and also all the elements in the argument. + */ + union(other: ReadonlySetLike): Set; + + /** + * @returns a new Set containing all the elements which are both in this Set and in the argument. + */ + intersection(other: ReadonlySetLike): Set; + + /** + * @returns a new Set containing all the elements in this Set which are not also in the argument. + */ + difference(other: ReadonlySetLike): Set; + + /** + * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. + */ + symmetricDifference(other: ReadonlySetLike): Set; + + /** + * @returns a boolean indicating whether all the elements in this Set are also in the argument. + */ + isSubsetOf(other: ReadonlySetLike): boolean; + + /** + * @returns a boolean indicating whether all the elements in the argument are also in this Set. + */ + isSupersetOf(other: ReadonlySetLike): boolean; + + /** + * @returns a boolean indicating whether this Set has no elements in common with the argument. + */ + isDisjointFrom(other: ReadonlySetLike): boolean; +} diff --git a/packages/core-js-types/src/56/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/56/proposals/string-left-right-trim.d.ts index d999e437c433..a815f0047cc7 100644 --- a/packages/core-js-types/src/56/proposals/string-left-right-trim.d.ts +++ b/packages/core-js-types/src/56/proposals/string-left-right-trim.d.ts @@ -5,7 +5,7 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface String { +interface String { // @type-options no-redefine /** Removes the trailing white space and line terminator characters from a string. */ trimEnd(): string; diff --git a/packages/core-js-types/src/56/proposals/string-padding.d.ts b/packages/core-js-types/src/56/proposals/string-padding.d.ts index 9fcb6eb5062f..b98201bba3ad 100644 --- a/packages/core-js-types/src/56/proposals/string-padding.d.ts +++ b/packages/core-js-types/src/56/proposals/string-padding.d.ts @@ -5,7 +5,7 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface String { +interface String { // @type-options no-redefine /** * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. * The padding is applied from the start (left) of the current string. diff --git a/packages/core-js-types/src/56/proposals/string-replace-all.d.ts b/packages/core-js-types/src/56/proposals/string-replace-all.d.ts index 3e39084839c9..0c9b44e3064d 100644 --- a/packages/core-js-types/src/56/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/56/proposals/string-replace-all.d.ts @@ -5,22 +5,18 @@ // https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/es2021.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -declare global { - interface String { - /** - * Replace all instances of a substring in a string, using a regular expression or search string. - * @param searchValue A string to search for. - * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. - */ - replaceAll(searchValue: string | RegExp, replaceValue: string): string; +interface String { // @type-options no-redefine + /** + * Replace all instances of a substring in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replaceAll(searchValue: string | RegExp, replaceValue: string): string; - /** - * Replace all instances of a substring in a string, using a regular expression or search string. - * @param searchValue A string to search for. - * @param replacer A function that returns the replacement text. - */ - replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; - } + /** + * Replace all instances of a substring in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replacer A function that returns the replacement text. + */ + replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } - -export {}; diff --git a/packages/core-js-types/src/56/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/56/proposals/well-formed-unicode-strings.d.ts index d8bd59d73d03..d4c697742d7b 100644 --- a/packages/core-js-types/src/56/proposals/well-formed-unicode-strings.d.ts +++ b/packages/core-js-types/src/56/proposals/well-formed-unicode-strings.d.ts @@ -5,7 +5,7 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2024.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface String { +interface String { // @type-options no-redefine /** * Returns true if all leading surrogates and trailing surrogates appear paired and in order. */ diff --git a/packages/core-js-types/src/56/web/queue-microtask.d.ts b/packages/core-js-types/src/56/web/queue-microtask.d.ts index 584b60656a64..1b8ce4e49683 100644 --- a/packages/core-js-types/src/56/web/queue-microtask.d.ts +++ b/packages/core-js-types/src/56/web/queue-microtask.d.ts @@ -1,4 +1,4 @@ -interface VoidFunction { +interface VoidFunction { // @type-options no-redefine no-prefix no-extends (): void; } diff --git a/packages/core-js-types/src/56/web/structured-clone.d.ts b/packages/core-js-types/src/56/web/structured-clone.d.ts index 13f3367b9b3a..4cecad3e499a 100644 --- a/packages/core-js-types/src/56/web/structured-clone.d.ts +++ b/packages/core-js-types/src/56/web/structured-clone.d.ts @@ -1,4 +1,4 @@ -interface CoreJSStructuredSerializeOptions { +interface CoreJSStructuredSerializeOptions { // @type-options no-extends, no-prefix readonly __brand?: unique symbol; transfer?: any[]; diff --git a/packages/core-js-types/src/56/web/url-to-json.d.ts b/packages/core-js-types/src/56/web/url-to-json.d.ts index 6ecf69d921b0..c1675d18bb5e 100644 --- a/packages/core-js-types/src/56/web/url-to-json.d.ts +++ b/packages/core-js-types/src/56/web/url-to-json.d.ts @@ -1,3 +1,3 @@ -interface URL { +interface URL { // @type-options no-extends toJSON(): string; } diff --git a/scripts/build-entries/templates.mjs b/scripts/build-entries/templates.mjs index 637de0873d2d..a4cf01a23e10 100644 --- a/scripts/build-entries/templates.mjs +++ b/scripts/build-entries/templates.mjs @@ -36,6 +36,14 @@ const namespacesWithOneGeneric = [ 'AsyncIterator', ]; +function existsInES6(namespace) { + const missingNamespacesInES6 = [ + 'AsyncIterator', + ]; + + return !missingNamespacesInES6.includes(namespace); +} + function getGenericsForNamespace(namespace) { if (namespace === 'WeakMap') { return ''; @@ -83,7 +91,7 @@ export const $prototype = p => ({ `, dts: dedent` declare module "${ p.packageName }${ p.entry }" { - type method${ getGenericsForNamespace(p.namespace) } = ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; + type method${ getGenericsForNamespace(p.namespace) } = ${ p.prefix ?? '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; export = method; } `, @@ -99,7 +107,7 @@ export const $prototypeIterator = p => ({ `, dts: dedent` declare module "${ p.packageName }${ p.entry }" { - const method: typeof ${ p.namespace }.prototype[typeof Symbol.iterator]; + const method: typeof ${ p.prefix ?? '' }${ p.namespace }.prototype[typeof Symbol.iterator]; export = method; } `, @@ -115,8 +123,8 @@ export const $uncurried = p => ({ `, dts: dedent` declare module "${ p.packageName }${ p.entry }" { - type method${ getGenericsForNamespace(p.namespace) } = ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; - const resultMethod: ${ getGenericsForNamespace(p.namespace) }(self: ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters) => ReturnType; + type method${ getGenericsForNamespace(p.namespace) } = ${ p.prefix ?? '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; + const resultMethod: ${ getGenericsForNamespace(p.namespace) }(self: ${ p.prefix && !existsInES6(p.namespace) ? p.prefix : '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters) => ReturnType; export = resultMethod; } `, @@ -166,7 +174,7 @@ export const $static = p => ({ `, dts: dedent` declare module "${ p.packageName }${ p.entry }" { - const method: typeof ${ p.namespace }.${ p.name }; + const method: typeof ${ p.prefix ?? '' }${ p.namespace }.${ p.name }; export = method; } `, @@ -189,7 +197,7 @@ export const $staticWithContext = p => ({ `, dts: dedent` declare module "${ p.packageName }${ p.entry }" { - const method: typeof ${ p.namespace }.${ p.name }; + const method: typeof ${ p.prefix ?? '' }${ p.namespace }.${ p.name }; export = method; } `, @@ -208,7 +216,7 @@ export const $patchableStatic = p => ({ `, dts: dedent` declare module "${ p.packageName }${ p.entry }" { - const method: typeof ${ p.namespace }.${ p.name }; + const method: typeof ${ p.prefix ?? '' }${ p.namespace }.${ p.name }; export = method; } `, @@ -224,7 +232,7 @@ export const $namespace = p => ({ `, dts: dedent` declare module "${ p.packageName }${ p.entry }" { - const namespace: typeof ${ p.name }; + const namespace: typeof ${ p.prefix ?? '' }${ p.name }; export = namespace; } `, diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 726f98825506..4ab45a875fc2 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -58,12 +58,13 @@ async function buildType(entry, options) { if (filter) modules = modules.filter(it => filter.has(it)); - const tplPure = template({ ...options, modules, rawModules, level, entry, types, packageName: `${ config.packageName }pure/` }); + const tplPure = template({ ...options, modules, rawModules, level, entry, types, packageName: `${ config.packageName }pure/`, prefix: 'CoreJS.CoreJS' }); const tpl = template({ ...options, modules, rawModules, level, entry, types, packageName: config.packageName }); types.forEach(type => { imports[subset].add(type); - imports.pure.add(type); + const fileName = path.basename(type); + imports.pure.add(type.replace(fileName, path.join('pure', fileName))); }); if (customType) { imports[subset].add(customType); @@ -129,11 +130,29 @@ async function prependImports(version) { } } +async function fillCustomImportsForPure(typesPath, initialPath) { + const entries = await readdir(typesPath, { withFileTypes: true }); + for (const entry of entries) { + if (entry.isDirectory()) { + await fillCustomImportsForPure(path.join(typesPath, entry.name), initialPath); + } else { + const dirName = path.basename(typesPath); + if (dirName !== 'pure') continue; + const filePath = path.join(typesPath, entry.name); + const fileStats = await fs.stat(filePath); + if (fileStats.size === 0) continue; + imports.pure.add(filePath.replace(`${ initialPath }/`, '').replace('.d.ts', '')); + } + } +} + async function buildTypesForTSVersion(tsVersion) { tsVersion = tsVersion.toString().replace('.', ''); const bundlePath = path.join(config.buildDir, tsVersion); if (await pathExists(bundlePath)) await remove(bundlePath); await buildTypesDirForTSVersion(tsVersion); + await fillCustomImportsForPure(bundlePath, path.join(bundlePath, 'types')); + await preparePureTypes(bundlePath); for (const [entry, definition] of Object.entries(features)) { await buildType(`es/${ entry }`, { ...definition, entryFromNamespace: 'es', tsVersion }); @@ -155,6 +174,147 @@ async function buildTypesForTSVersion(tsVersion) { await prependImports(tsVersion); } +function extractDeclareGlobalSections(lines) { + const sections = []; + const outside = []; + for (let i = 0; i < lines.length;) { + if (/^\s*declare\s+global\s*\{/.test(lines[i])) { + let depth = 1; + const section = []; + for (++i; i < lines.length && depth > 0; ++i) { + depth += (lines[i].match(/\{/g) || []).length; + depth -= (lines[i].match(/\}/g) || []).length; + if (depth === 0 && /^\s*\}\s*$/.test(lines[i])) break; + if (depth > 0) section.push(lines[i]); + } + ++i; + sections.push(section); + } else { + outside.push(lines[i++]); + } + } + return { sections, outside }; +} + +function processLines(lines, prefix) { + const prefixed = []; + let noExport = false; + return lines + .map(line => { + const hasOptions = line.includes('@type-options'); + const optionsStr = hasOptions ? line.match(/@type-options\s+(?[\s\w,-]+)/)?.groups?.options : ''; + const options = { + noExtends: !hasOptions ? false : optionsStr.includes('no-extends'), + noPrefix: !hasOptions ? false : optionsStr.includes('no-prefix'), + noConstructor: !hasOptions ? false : optionsStr.includes('no-constructor'), + exportBaseConstructor: !hasOptions ? false : optionsStr.includes('export-base-constructor'), + noExport: !hasOptions ? false : optionsStr.includes('no-export'), + noRedefine: !hasOptions ? false : optionsStr.includes('no-redefine'), + }; + if (noExport && /^[^{]*\}/.test(line)) { + noExport = false; + return null; + } + if (noExport) return null; + if (options.noExport) { + if (/^[^{]*$/.test(line) || /\{[^}]?\}/.test(line)) return null; + noExport = true; + return null; + } + if (/^\s*(?:declare\s+)?interface\s+\w+\s*extends/.test(line) || options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+\s*\{/.test(line)) { + if (!options.noPrefix) { + const m = line.match(/interface\s+(?\w+)/); + if (m && m.groups) { + prefixed.push(m.groups.name); + } + } + return line.replace(/^(?\s*)(?:declare\s+)?interface\s+(?[\s\w,<=>]+)/, `$export interface ${ !options.noPrefix ? prefix : '' }$`); + } + if (!options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+/.test(line)) { + const m = line.match(/^(?\s*)(?:declare\s+)?interface\s+(?\w+)(?<[^>]+>)?/); + const iIndent = m?.groups?.indent ?? ''; + const iName = m?.groups?.name ?? ''; + const iExtend = m?.groups?.extend ?? ''; + if (!options.noPrefix && iName !== '') { + prefixed.push(iName); + } + const genericsForExtends = iExtend.replace(/\sextends\s[^,>]+/g, '').replace(/\s?=\s?\w+/g, ''); + const entityName = `${ !options.noPrefix ? prefix : '' }${ iName }`; + const isConstructor = iName.includes('Constructor'); + let constructorDeclaration; + if (isConstructor) { + constructorDeclaration = !options.noRedefine ? `${ iIndent }var ${ entityName.replace('Constructor', '') }: ${ entityName };\n` : ''; + } else { + constructorDeclaration = !options.noRedefine ? `${ iIndent }var ${ entityName }: ${ options.exportBaseConstructor ? iName : entityName }${ options.noConstructor ? '' : 'Constructor' };\n` : ''; + } + return `${ constructorDeclaration }${ iIndent }export interface ${ entityName }${ iExtend } extends ${ iName }${ genericsForExtends } {\n`; + } + if (/^\s*(?:declare\s+)?function/.test(line)) { + return line.replace(/^(?\s*)(?:declare\s+)?function\s+(?\w+)/, `$export function ${ !options.noPrefix ? prefix : '' }$`); + } + if (/:\s*\w/.test(line)) { + const sortedPrefixed = prefixed.sort((a, b) => b.length - a.length); + sortedPrefixed.forEach(item => { + const reg = new RegExp(`: ${ item }([,;<)])`, 'g'); + line = line.replace(reg, `: ${ prefix }${ item }$1`); + }); + } + if (/^\s*(?:declare)?\svar/.test(line)) { + const m = line.match(/^(?\s*)(?:declare\s+)?var\s+(?\w+):\s+(?\w+)/); + return `${ m?.groups?.indent ?? '' }var ${ !options.noPrefix ? prefix : '' }${ m?.groups?.name ?? '' }: ${ m?.groups?.type };\n`; + } + return line; + }) + .filter(line => line !== null); +} + +function wrapDTSInNamespace(content, namespace = 'CoreJS') { + const lines = content.split('\n'); + const preamble = []; + let i = 0; + for (; i < lines.length; i++) { + const line = lines[i]; + if (/\/\/\/\s* `${ a }../${ b }${ c }`)); + } else if (/^\s*\/\//.test(line) || /^\s*$/.test(line)) { + preamble.push(line); + } else break; + } + const mainLines = lines.slice(i); + const { sections, outside } = extractDeclareGlobalSections(mainLines); + const nsBody = [...processLines(outside, namespace), ...sections.flatMap(s => processLines(s, namespace))] + .reduce((res, line) => { + if ((line && line.trim() !== '') || (res.at(-1) && res.at(-1).trim() !== '')) res.push(line); + return res; + }, []).map(line => line ? ` ${ line }` : '').join('\n'); + return `${ preamble.length ? `${ preamble.join('\n') }\n` : '' }declare namespace ${ namespace } {\n${ nsBody }}\n`; +} + +async function preparePureTypes(typesPath) { + const entries = await readdir(typesPath, { withFileTypes: true }); + for (const entry of entries) { + if (entry.name === 'pure') continue; + if (entry.isDirectory()) { + await preparePureTypes(path.join(typesPath, entry.name)); + } else { + if (entry.name.includes('core-js-types.d.ts')) continue; + const typePath = path.join(typesPath, entry.name); + const resultFilePath = typePath.replace(entry.name, `pure/${ entry.name }`); + if (await pathExists(resultFilePath)) continue; + const content = await fs.readFile(typePath, 'utf8'); + if (content.includes('declare namespace')) continue; + const result = wrapDTSInNamespace(content); + await outputFile(resultFilePath, result); + } + } +} + if (VERSION) { await buildTypesForTSVersion(VERSION); } else { diff --git a/tests/type-definitions/pure/common/parse-float.test.ts b/tests/type-definitions/pure/common/parse-float.test.ts new file mode 100644 index 000000000000..de75723fe936 --- /dev/null +++ b/tests/type-definitions/pure/common/parse-float.test.ts @@ -0,0 +1,6 @@ +import $parseFloat from '@core-js/pure/full/parse-float'; + +const res: number = $parseFloat('123.45'); + +// @ts-expect-error +$parseFloat(123); diff --git a/tests/type-definitions/pure/common/parse-int.test.ts b/tests/type-definitions/pure/common/parse-int.test.ts new file mode 100644 index 000000000000..ed8e39e43bec --- /dev/null +++ b/tests/type-definitions/pure/common/parse-int.test.ts @@ -0,0 +1,6 @@ +import $parseInt from '@core-js/pure/full/parse-int'; + +const res: number = $parseInt('123'); + +// @ts-expect-error +$parseInt(123); diff --git a/tests/type-definitions/pure/proposals/array-from-async.test.ts b/tests/type-definitions/pure/proposals/array-from-async.test.ts new file mode 100644 index 000000000000..2a3500bf22e5 --- /dev/null +++ b/tests/type-definitions/pure/proposals/array-from-async.test.ts @@ -0,0 +1,37 @@ +import arrayFromAsync from '@core-js/pure/full/array/from-async'; + +arrayFromAsync([1, 2, 3]); +arrayFromAsync([Promise.resolve(1), 2, 3]); +arrayFromAsync([1, 2, 3], (value: number, index: number) => value.toString()); +arrayFromAsync([Promise.resolve(1), 2, 3], (value: number) => value + 1); +arrayFromAsync([1, 2, 3], function (this: { foo: string }, value: number) { return value.toString(); }, {foo: 'str'}); + +async function t1() { + const n: number[] = await arrayFromAsync([1, 2, 3]); + const m: number[] = await arrayFromAsync([Promise.resolve(1), 2, 3]); + const s: string[] = await arrayFromAsync([1, 2, 3], (value: number) => value.toString()); +} + +async function t2() { + const bar: number[] = await arrayFromAsync([1, 2, 3], async (v: number) => v + 1); + const foo: string[] = await arrayFromAsync([Promise.resolve(1), 2], async (v: number) => String(v)); +} + +declare const arrLike: { [index: number]: PromiseLike; length: 2 }; +arrayFromAsync(arrLike); +arrayFromAsync(arrLike, (value: number) => value); + +// @ts-expect-error +arrayFromAsync([1, 2, 3], (value: string) => value); +// @ts-expect-error +arrayFromAsync([1, 2, 3], (value: string) => 1); +// @ts-expect-error +arrayFromAsync(['a', 'b', 'c'], (value: number) => value); +// @ts-expect-error +arrayFromAsync([Promise.resolve(1), 2, 3], (value: string) => value); +// // @ts-expect-error +// arrayFromAsync((async function* () { yield 'a'; })(), (value: number) => value); + +declare const strArrLike: { [index: number]: string; length: 3 }; +// @ts-expect-error +arrayFromAsync(strArrLike, (value: number) => value); diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 8dfca77ec5e6..58e06312a01a 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -11,24 +11,20 @@ import some from '@core-js/pure/full/async-iterator/some'; import take from '@core-js/pure/full/async-iterator/take'; import toArray from '@core-js/pure/full/async-iterator/to-array'; import toAsync from '@core-js/pure/full/iterator/to-async'; +import asyncIterator from '@core-js/pure/full/async-iterator/index'; -const res: AsyncIterator = from([1, 2, 3]); -const res2: AsyncIterator = from(new Set([1, 2, 3])); +const aiton = from([1, 2, 3]); +aiton.toArray(); +from(new Set([1, 2, 3])); from((function* () { yield 3; })()); -const res3: AsyncIterator = from('abc'); +const aitos = from('abc'); -declare const ain: AsyncIteratorObject; -declare const aio: AsyncIteratorObject<{ x: number }>; -declare const ais: AsyncIteratorObject; declare const ilb: Iterable; declare const is: Iterator; declare const itn: Iterator; -declare const ailb: AsyncIterable; -from(ain); +from(aiton); from(ilb); -from(ailb); -from(aio); // @ts-expect-error from(123); @@ -39,20 +35,20 @@ from(); // @ts-expect-error from({ next: () => 1 }); -const raits: AsyncIterator = toAsync(is); -const raitn: AsyncIterator = toAsync(itn); +toAsync(is); +toAsync(itn); -const r1: AsyncIterator = drop(ain, 3); -const r2: Promise = every(ain, (v: number, i: number) => v > 0); -const r3: AsyncIterator = filter(ain, (v: number, i: number) => v > 0); -const r4: Promise = find(ain, (v: number, i: number) => v > 0); -const r5: AsyncIterator = flatMap(ain, (v: number, i: number) => `${v}`); -const r6: Promise = forEach(ain, (v: number, i: number) => { }); -const r7: AsyncIterator = map(ain, (v: number, i: number) => v * 2); -const r8: Promise = reduce(ain, (acc: number, v: number, i: number) => acc + v, 0); -const r9: Promise = some(ain, (v: number, i: number) => v > 0); -const r10: AsyncIterator = take(ain, 10); -const r11: Promise = toArray(ain); +drop(aiton, 3); +const r2: Promise = every(aiton, (v: number, i: number) => v > 0); +filter(aiton, (v: number, i: number) => v > 0); +const r4: Promise = find(aiton, (v: number, i: number) => v > 0); +flatMap(aiton, (v: number, i: number) => `${v}`); +const r6: Promise = forEach(aiton, (v: number, i: number) => { }); +map(aiton, (v: number, i: number) => v * 2); +const r8: Promise = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); +const r9: Promise = some(aiton, (v: number, i: number) => v > 0); +take(aiton, 10); +const r11: Promise = toArray(aiton); // @ts-expect-error drop(ain); @@ -77,8 +73,8 @@ take(ain); // @ts-expect-error toArray(ain, 1); -const s0: Promise = toArray(ais); -const f0: Promise = find(ais, (v: string, i: number) => v.length === 1); +const s0: Promise = toArray(aiton); +const f0: Promise = find(aitos, (v: string, i: number) => v.length === 1); // @ts-expect-error map(ais, (v: string, i: number) => v.length === 1, 'extra'); diff --git a/tests/type-definitions/pure/proposals/await-dictionary.test.ts b/tests/type-definitions/pure/proposals/await-dictionary.test.ts index d0a6eda9302d..ba7752748b2b 100644 --- a/tests/type-definitions/pure/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/pure/proposals/await-dictionary.test.ts @@ -19,17 +19,6 @@ allKeyed({ a: 1, b: Promise.resolve(2) }); // @ts-expect-error allKeyed([ Promise.resolve(1), Promise.resolve(2) ]); -declare type AllSettledKeyedResult = PromiseFulfilledResult | PromiseRejectedResult; -const resASK: Promise<{ a: AllSettledKeyedResult, b: AllSettledKeyedResult, c: AllSettledKeyedResult }> = allSettledKeyed({ - a: Promise.resolve(1), - b: Promise.resolve('string'), - c: Promise.resolve(true), -}); - -const resASK2: Promise<{ [sym]: AllSettledKeyedResult }> = allSettledKeyed({ - [sym]: Promise.resolve(1) -}); - // @ts-expect-error allSettledKeyed(); // @ts-expect-error diff --git a/tests/type-definitions/pure/proposals/change-array-by-copy.test.ts b/tests/type-definitions/pure/proposals/change-array-by-copy.test.ts index 1fe02e6d7f55..6e2051155916 100644 --- a/tests/type-definitions/pure/proposals/change-array-by-copy.test.ts +++ b/tests/type-definitions/pure/proposals/change-array-by-copy.test.ts @@ -2,7 +2,6 @@ import arrayToReversed from '@core-js/pure/full/array/to-reversed'; import arrayToSorted from '@core-js/pure/full/array/to-sorted'; import arrayToSpliced from '@core-js/pure/full/array/to-spliced'; import arrayWith from '@core-js/pure/full/array/with'; -import '@core-js/types/actual'; const arr: number[] = [1, 2, 3]; const arrRev: number[] = arrayToReversed(arr); diff --git a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts index 09360157ba7a..f8ae808607d3 100644 --- a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts @@ -1,8 +1,11 @@ import symbolDispose from '@core-js/pure/full/symbol/dispose'; import symbolAsyncDispose from '@core-js/pure/full/symbol/async-dispose'; +import symbolToStringTag from '@core-js/pure/full/symbol/to-string-tag'; import suppressedError from '@core-js/pure/full/suppressed-error/constructor'; import disposableStack from '@core-js/pure/full/disposable-stack/constructor'; import asyncDisposableStack from '@core-js/pure/full/async-disposable-stack/constructor'; +import iteratorRange from '@core-js/pure/full/iterator/range'; +import asyncIteratorFrom from '@core-js/pure/full/async-iterator/from'; const d: symbol = symbolDispose; const ad: symbol = symbolAsyncDispose; @@ -10,12 +13,19 @@ const ad: symbol = symbolAsyncDispose; // @ts-expect-error const wrong: number = symbolDispose; -const objD: Disposable = { +declare type HasSymbolDispose = { + [symbolDispose]: () => void; +}; +declare type HasSymbolAsyncDispose = { + [symbolAsyncDispose]: () => void; +}; + +const objD = { [symbolDispose]() { /* empty */ } }; objD[symbolDispose](); -const objAD: AsyncDisposable = { +const objAD = { [symbolAsyncDispose]() { return Promise.resolve(); } } objAD[symbolAsyncDispose](); @@ -34,18 +44,17 @@ err2.message; // @ts-expect-error new suppressedError(1, 2, 3, 4); -const protoDS: DisposableStack = disposableStack.prototype; -const objDS: DisposableStack = new disposableStack(); +const objDS = new disposableStack(); const disposed: boolean = objDS.disposed; objDS.dispose(); -const ruse1: Disposable = objDS.use(objD); +objDS.use(objD); const ruse2: null = objDS.use(null); const ruse3: undefined = objDS.use(undefined); const radopt1: string = objDS.adopt('foo', (value: string) => { /* empty */ }); objDS.defer(() => { /* empty */ }); -const rmove1: DisposableStack = objDS.move(); +objDS.move(); objDS[symbolDispose](); -const rts1: string = objDS[Symbol.toStringTag]; +const rts1: string = objDS[symbolToStringTag]; // @ts-expect-error objDS.dispose(1); @@ -56,14 +65,14 @@ objDS.defer('bar'); // @ts-expect-error objDS.move(1); // @ts-expect-error -objDS[Symbol.toStringTag] = 'foo'; +objDS[symbolToStringTag] = 'foo'; -const protoADS: AsyncDisposableStack = asyncDisposableStack.prototype; -const objADS: AsyncDisposableStack = new asyncDisposableStack(); +asyncDisposableStack.prototype; +const objADS = new asyncDisposableStack(); const disposedASD: boolean = objDS.disposed; const rda: Promise = objADS.disposeAsync(); -const ruseASD1: AsyncDisposable = objADS.use(objAD); -const ruseASD2: Disposable = objADS.use(objD); +objADS.use(objAD); +objADS.use(objD); const ruseASD3: null = objADS.use(null); const ruseASD4: undefined = objADS.use(undefined); const radoptASD1: string = objADS.adopt('foo', (value: string) => { /* empty */ }); @@ -74,9 +83,9 @@ objADS.defer(() => { /* empty */ }); objADS.defer(async () => { /* empty */ }); objADS.defer(() => Promise.resolve()); objADS.defer(async () => Promise.resolve()); -const rmoveASD1: AsyncDisposableStack = objADS.move(); +objADS.move(); objADS[symbolAsyncDispose](); -const rtsASD1: string = objADS[Symbol.toStringTag]; +const rtsASD1: string = objADS[symbolToStringTag]; // @ts-expect-error objADS.disposeAsync(1).then(); @@ -89,8 +98,8 @@ objADS.move(1); // @ts-expect-error objADS[Symbol.toStringTag] = 'foo'; -declare const iter: IteratorObject; +const iter = iteratorRange(1, 3); iter[symbolDispose](); -declare const asyncIter: AsyncIteratorObject; +const asyncIter = asyncIteratorFrom([1, 2, 3]); asyncIter[symbolAsyncDispose](); diff --git a/tests/type-definitions/pure/proposals/iterator-range.test.ts b/tests/type-definitions/pure/proposals/iterator-range.test.ts index 0b2dcfd9c75b..247713a43dfc 100644 --- a/tests/type-definitions/pure/proposals/iterator-range.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-range.test.ts @@ -1,9 +1,5 @@ import range from '@core-js/pure/full/iterator/range'; -// import Promise from '@core-js/actual/promise/index'; -// import $iteratorFull from '@core-js/pure/full/promise/index'; -// import $iteratorActual from '@core-js/pure/actual/iterator/index'; - const rir1: Iterator = range(1, 10); range(1, 10, 1); range(1, 10, { step: 1 }); diff --git a/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts b/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts index 996c56e519bd..fc96ad78026c 100644 --- a/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts +++ b/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts @@ -2,6 +2,14 @@ import rawJSON from '@core-js/pure/full/json/raw-json'; import isRawJSON from '@core-js/pure/full/json/is-raw-json'; import parse from '@core-js/pure/full/json/parse'; +declare type CoreJSRawJSON = { + rawJSON: string; +} + +declare type CoreJSReviverContext = { + source: string; +} + const r: CoreJSRawJSON = rawJSON('{"a":123}'); const isr1: boolean = isRawJSON(r); diff --git a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts index 7690b72fa355..0269297a97cf 100644 --- a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts @@ -1,26 +1,20 @@ import promiseAllSettled from '@core-js/pure/full/promise/all-settled'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -const promises = [promiseResolve(1), promiseResolve("foo"), 3] as const; -const arr = [promiseResolve(1), promiseResolve(2)]; -const strArr = ["a", "b", "c"]; +promiseResolve(1); +promiseResolve('foo'); const promiseLike = { then: (cb: (val: number) => void) => cb(42) }; -type PromiseResult = PromiseFulfilledResult | PromiseRejectedResult; - -const settled2: Promise[]> = promiseAllSettled([promiseResolve(10), promiseResolve(20), 30]); -const settled3: Promise[]> = promiseAllSettled(strArr); -const settled4: Promise[]> = promiseAllSettled(new Set([1, 2, 3])); -const settled5: Promise[]> = promiseAllSettled([promiseLike]); +promiseAllSettled([promiseResolve(10), promiseResolve(20), 30]); +promiseAllSettled(['a', 'b', 'c']); +promiseAllSettled(new Set([1, 2, 3])); +promiseAllSettled([promiseLike]); const emptyTuple: [] = []; const settled6: Promise<[]> = promiseAllSettled(emptyTuple); const mixedTuple = [42, promiseResolve("bar")] as const; -const settled7: Promise<[ - PromiseResult, - PromiseResult -]> = promiseAllSettled(mixedTuple); +promiseAllSettled(mixedTuple); // @ts-expect-error promiseAllSettled(); diff --git a/tests/type-definitions/pure/proposals/promise-finally.test.ts b/tests/type-definitions/pure/proposals/promise-finally.test.ts index 36054651dcda..4a87a582bbb6 100644 --- a/tests/type-definitions/pure/proposals/promise-finally.test.ts +++ b/tests/type-definitions/pure/proposals/promise-finally.test.ts @@ -12,9 +12,6 @@ const p2 = Promise.reject("err"); const pf6: Promise = promiseFinally(p2); const pf7: Promise = promiseFinally(p2, () => {}); -declare function returnsPromise(): Promise; -const genericF: Promise = returnsPromise().finally(() => {}); - // @ts-expect-error promiseFinally(p1, 123); diff --git a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts index ce836a13308d..1099f757b7c7 100644 --- a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts +++ b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts @@ -23,11 +23,6 @@ pr3.reject(); const value: number | PromiseLike = 99; pr.resolve(value); -declare function agrees(): PromiseWithResolvers; -const gr: PromiseWithResolvers = agrees(); -gr.resolve(true); -gr.reject(); - // @ts-expect-error promiseWithResolvers(123); diff --git a/tests/type-definitions/pure/proposals/set-methods.test.ts b/tests/type-definitions/pure/proposals/set-methods.test.ts index 58819c79dd0a..6755602f7324 100644 --- a/tests/type-definitions/pure/proposals/set-methods.test.ts +++ b/tests/type-definitions/pure/proposals/set-methods.test.ts @@ -9,13 +9,13 @@ import setIsDisjointFrom from '@core-js/pure/full/set/is-disjoint-from'; const setA = new Set([1, 2, 3]); const setB = new Set(['a', 'b', 'c']); -const setLike: ReadonlySetLike = { +const setLike = { keys() { return [1, 2, 3][Symbol.iterator](); }, has(val: number): boolean { return val === 2; }, size: 3 }; -const setLikeStr: ReadonlySetLike = { +const setLikeStr = { keys() { return ['a', 'b'][Symbol.iterator](); }, has(val: string): boolean { return val === 'a'; }, size: 2 diff --git a/tests/type-definitions/pure/proposals/string-match-all.test.ts b/tests/type-definitions/pure/proposals/string-match-all.test.ts index cf699e29bb1e..232afb075d28 100644 --- a/tests/type-definitions/pure/proposals/string-match-all.test.ts +++ b/tests/type-definitions/pure/proposals/string-match-all.test.ts @@ -2,10 +2,7 @@ import stringMatchAll from '@core-js/pure/full/string/match-all'; const s = 'abcabc'; const re = /abc/g; -const matchIter: RegExpStringIterator = stringMatchAll(s, re); - -const result = stringMatchAll(s, re); -const assertType: RegExpStringIterator = result; +stringMatchAll(s, re); // @ts-expect-error stringMatchAll(s); diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 25adce2f4b00..cec9996bc01a 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -117,6 +117,9 @@ await $`npx -p typescript@5.9 tsc -p tsconfig.templates.import.json`; await $`npx -p typescript@5.9 tsc -p tsconfig.entries.json`; await $`npx -p typescript@5.9 -p @types/node@24 tsc -p tsconfig.templates.require.json`; +// await $`npx -p typescript@5.9 tsc -p pure/tsconfig.json --target es6 --lib es6`; +// await $`npx -p typescript@5.9 tsc -p global/tsconfig.json --target esnext --lib esnext,dom`; + const numCPUs = os.cpus().length; await prepareEnvironment(envs, types); await runLimited(taskConfigs, Math.max(numCPUs - 1, 1)); From f4db8b32d9b40c188e6fbe91fb1ddf80590767c5 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 4 Dec 2025 04:05:24 +0700 Subject: [PATCH 070/315] Refactoring & tests --- .../56/{proposals => common}/pure/date.d.ts | 0 .../src/56/web/pure/url-parse.d.ts | 7 + .../pure/url-search-params.d.ts | 0 .../src/56/{proposals => web}/pure/url.d.ts | 0 scripts/build-types/index.mjs | 163 +----------------- scripts/build-types/pure.mjs | 145 ++++++++++++++++ .../type-definitions/pure/common/date.test.ts | 4 + .../pure/web/url-can-parse.test.ts | 7 + .../pure/web/url-parse.test.ts | 19 ++ .../pure/web/url-search-params.test.ts | 36 ++++ tests/type-definitions/pure/web/url.test.ts | 15 ++ 11 files changed, 235 insertions(+), 161 deletions(-) rename packages/core-js-types/src/56/{proposals => common}/pure/date.d.ts (100%) create mode 100644 packages/core-js-types/src/56/web/pure/url-parse.d.ts rename packages/core-js-types/src/56/{proposals => web}/pure/url-search-params.d.ts (100%) rename packages/core-js-types/src/56/{proposals => web}/pure/url.d.ts (100%) create mode 100644 scripts/build-types/pure.mjs create mode 100644 tests/type-definitions/pure/common/date.test.ts create mode 100644 tests/type-definitions/pure/web/url-can-parse.test.ts create mode 100644 tests/type-definitions/pure/web/url-parse.test.ts create mode 100644 tests/type-definitions/pure/web/url-search-params.test.ts create mode 100644 tests/type-definitions/pure/web/url.test.ts diff --git a/packages/core-js-types/src/56/proposals/pure/date.d.ts b/packages/core-js-types/src/56/common/pure/date.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/date.d.ts rename to packages/core-js-types/src/56/common/pure/date.d.ts diff --git a/packages/core-js-types/src/56/web/pure/url-parse.d.ts b/packages/core-js-types/src/56/web/pure/url-parse.d.ts new file mode 100644 index 000000000000..53469fb170a6 --- /dev/null +++ b/packages/core-js-types/src/56/web/pure/url-parse.d.ts @@ -0,0 +1,7 @@ +/// + +declare namespace CoreJS { + export interface CoreJSURLConstructor { + parse(url: string | CoreJSURL, base?: string | CoreJSURL): CoreJSURL | null; + } +} diff --git a/packages/core-js-types/src/56/proposals/pure/url-search-params.d.ts b/packages/core-js-types/src/56/web/pure/url-search-params.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/url-search-params.d.ts rename to packages/core-js-types/src/56/web/pure/url-search-params.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/url.d.ts b/packages/core-js-types/src/56/web/pure/url.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/url.d.ts rename to packages/core-js-types/src/56/web/pure/url.d.ts diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 4ab45a875fc2..321bc74b65fc 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -5,6 +5,7 @@ import { getModulesMetadata } from '../build-entries/get-dependencies.mjs'; import config from './config.mjs'; import { argv, path, fs } from 'zx'; import { expandModules, modulesToStage } from '../build-entries/helpers.mjs'; +import { preparePureTypes } from './pure.mjs'; const { copy, outputFile, pathExists, readdir, remove } = fs; @@ -84,25 +85,6 @@ async function buildType(entry, options) { } } -async function getVersions() { - const versions = []; - const entries = await readdir(config.srcDir, { withFileTypes: true }); - for (const entry of entries) { - if (entry.isDirectory()) { - versions.push(parseInt(entry.name, 10)); - } - } - return versions.sort(); -} - -async function buildTypesDirForTSVersion(version) { - const versions = await getVersions(); - for (const v of versions) { - if (v > version) break; - await copy(path.join(config.srcDir, v.toString()), path.join(config.buildDir, version.toString(), 'types')); - } -} - const ESModules = AllModules.filter(it => it.startsWith('es.')); const ESWithProposalsModules = AllModules.filter(it => it.startsWith('es')); const StableModules = AllModules.filter(it => it.match(/^(?:es|web)\./)); @@ -150,7 +132,7 @@ async function buildTypesForTSVersion(tsVersion) { tsVersion = tsVersion.toString().replace('.', ''); const bundlePath = path.join(config.buildDir, tsVersion); if (await pathExists(bundlePath)) await remove(bundlePath); - await buildTypesDirForTSVersion(tsVersion); + await copy(path.join(config.srcDir, tsVersion), path.join(config.buildDir, tsVersion, 'types')); await fillCustomImportsForPure(bundlePath, path.join(bundlePath, 'types')); await preparePureTypes(bundlePath); @@ -174,147 +156,6 @@ async function buildTypesForTSVersion(tsVersion) { await prependImports(tsVersion); } -function extractDeclareGlobalSections(lines) { - const sections = []; - const outside = []; - for (let i = 0; i < lines.length;) { - if (/^\s*declare\s+global\s*\{/.test(lines[i])) { - let depth = 1; - const section = []; - for (++i; i < lines.length && depth > 0; ++i) { - depth += (lines[i].match(/\{/g) || []).length; - depth -= (lines[i].match(/\}/g) || []).length; - if (depth === 0 && /^\s*\}\s*$/.test(lines[i])) break; - if (depth > 0) section.push(lines[i]); - } - ++i; - sections.push(section); - } else { - outside.push(lines[i++]); - } - } - return { sections, outside }; -} - -function processLines(lines, prefix) { - const prefixed = []; - let noExport = false; - return lines - .map(line => { - const hasOptions = line.includes('@type-options'); - const optionsStr = hasOptions ? line.match(/@type-options\s+(?[\s\w,-]+)/)?.groups?.options : ''; - const options = { - noExtends: !hasOptions ? false : optionsStr.includes('no-extends'), - noPrefix: !hasOptions ? false : optionsStr.includes('no-prefix'), - noConstructor: !hasOptions ? false : optionsStr.includes('no-constructor'), - exportBaseConstructor: !hasOptions ? false : optionsStr.includes('export-base-constructor'), - noExport: !hasOptions ? false : optionsStr.includes('no-export'), - noRedefine: !hasOptions ? false : optionsStr.includes('no-redefine'), - }; - if (noExport && /^[^{]*\}/.test(line)) { - noExport = false; - return null; - } - if (noExport) return null; - if (options.noExport) { - if (/^[^{]*$/.test(line) || /\{[^}]?\}/.test(line)) return null; - noExport = true; - return null; - } - if (/^\s*(?:declare\s+)?interface\s+\w+\s*extends/.test(line) || options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+\s*\{/.test(line)) { - if (!options.noPrefix) { - const m = line.match(/interface\s+(?\w+)/); - if (m && m.groups) { - prefixed.push(m.groups.name); - } - } - return line.replace(/^(?\s*)(?:declare\s+)?interface\s+(?[\s\w,<=>]+)/, `$export interface ${ !options.noPrefix ? prefix : '' }$`); - } - if (!options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+/.test(line)) { - const m = line.match(/^(?\s*)(?:declare\s+)?interface\s+(?\w+)(?<[^>]+>)?/); - const iIndent = m?.groups?.indent ?? ''; - const iName = m?.groups?.name ?? ''; - const iExtend = m?.groups?.extend ?? ''; - if (!options.noPrefix && iName !== '') { - prefixed.push(iName); - } - const genericsForExtends = iExtend.replace(/\sextends\s[^,>]+/g, '').replace(/\s?=\s?\w+/g, ''); - const entityName = `${ !options.noPrefix ? prefix : '' }${ iName }`; - const isConstructor = iName.includes('Constructor'); - let constructorDeclaration; - if (isConstructor) { - constructorDeclaration = !options.noRedefine ? `${ iIndent }var ${ entityName.replace('Constructor', '') }: ${ entityName };\n` : ''; - } else { - constructorDeclaration = !options.noRedefine ? `${ iIndent }var ${ entityName }: ${ options.exportBaseConstructor ? iName : entityName }${ options.noConstructor ? '' : 'Constructor' };\n` : ''; - } - return `${ constructorDeclaration }${ iIndent }export interface ${ entityName }${ iExtend } extends ${ iName }${ genericsForExtends } {\n`; - } - if (/^\s*(?:declare\s+)?function/.test(line)) { - return line.replace(/^(?\s*)(?:declare\s+)?function\s+(?\w+)/, `$export function ${ !options.noPrefix ? prefix : '' }$`); - } - if (/:\s*\w/.test(line)) { - const sortedPrefixed = prefixed.sort((a, b) => b.length - a.length); - sortedPrefixed.forEach(item => { - const reg = new RegExp(`: ${ item }([,;<)])`, 'g'); - line = line.replace(reg, `: ${ prefix }${ item }$1`); - }); - } - if (/^\s*(?:declare)?\svar/.test(line)) { - const m = line.match(/^(?\s*)(?:declare\s+)?var\s+(?\w+):\s+(?\w+)/); - return `${ m?.groups?.indent ?? '' }var ${ !options.noPrefix ? prefix : '' }${ m?.groups?.name ?? '' }: ${ m?.groups?.type };\n`; - } - return line; - }) - .filter(line => line !== null); -} - -function wrapDTSInNamespace(content, namespace = 'CoreJS') { - const lines = content.split('\n'); - const preamble = []; - let i = 0; - for (; i < lines.length; i++) { - const line = lines[i]; - if (/\/\/\/\s* `${ a }../${ b }${ c }`)); - } else if (/^\s*\/\//.test(line) || /^\s*$/.test(line)) { - preamble.push(line); - } else break; - } - const mainLines = lines.slice(i); - const { sections, outside } = extractDeclareGlobalSections(mainLines); - const nsBody = [...processLines(outside, namespace), ...sections.flatMap(s => processLines(s, namespace))] - .reduce((res, line) => { - if ((line && line.trim() !== '') || (res.at(-1) && res.at(-1).trim() !== '')) res.push(line); - return res; - }, []).map(line => line ? ` ${ line }` : '').join('\n'); - return `${ preamble.length ? `${ preamble.join('\n') }\n` : '' }declare namespace ${ namespace } {\n${ nsBody }}\n`; -} - -async function preparePureTypes(typesPath) { - const entries = await readdir(typesPath, { withFileTypes: true }); - for (const entry of entries) { - if (entry.name === 'pure') continue; - if (entry.isDirectory()) { - await preparePureTypes(path.join(typesPath, entry.name)); - } else { - if (entry.name.includes('core-js-types.d.ts')) continue; - const typePath = path.join(typesPath, entry.name); - const resultFilePath = typePath.replace(entry.name, `pure/${ entry.name }`); - if (await pathExists(resultFilePath)) continue; - const content = await fs.readFile(typePath, 'utf8'); - if (content.includes('declare namespace')) continue; - const result = wrapDTSInNamespace(content); - await outputFile(resultFilePath, result); - } - } -} - if (VERSION) { await buildTypesForTSVersion(VERSION); } else { diff --git a/scripts/build-types/pure.mjs b/scripts/build-types/pure.mjs new file mode 100644 index 000000000000..b908fc6da712 --- /dev/null +++ b/scripts/build-types/pure.mjs @@ -0,0 +1,145 @@ +import { path, fs } from 'zx'; + +const { outputFile, pathExists, readdir } = fs; + +function extractDeclareGlobalSections(lines) { + const sections = []; + const outside = []; + for (let i = 0; i < lines.length;) { + if (/^\s*declare\s+global\s*\{/.test(lines[i])) { + let depth = 1; + const section = []; + for (++i; i < lines.length && depth > 0; ++i) { + depth += (lines[i].match(/\{/g) || []).length; + depth -= (lines[i].match(/\}/g) || []).length; + if (depth === 0 && /^\s*\}\s*$/.test(lines[i])) break; + if (depth > 0) section.push(lines[i]); + } + ++i; + sections.push(section); + } else { + outside.push(lines[i++]); + } + } + return { sections, outside }; +} + +function processLines(lines, prefix) { + const prefixed = []; + let noExport = false; + return lines + .map(line => { + const hasOptions = line.includes('@type-options'); + const optionsStr = hasOptions ? line.match(/@type-options\s+(?[\s\w,-]+)/)?.groups?.options : ''; + const options = { + noExtends: !hasOptions ? false : optionsStr.includes('no-extends'), + noPrefix: !hasOptions ? false : optionsStr.includes('no-prefix'), + noConstructor: !hasOptions ? false : optionsStr.includes('no-constructor'), + exportBaseConstructor: !hasOptions ? false : optionsStr.includes('export-base-constructor'), + noExport: !hasOptions ? false : optionsStr.includes('no-export'), + noRedefine: !hasOptions ? false : optionsStr.includes('no-redefine'), + }; + if (noExport && /^[^{]*\}/.test(line)) { + noExport = false; + return null; + } + if (noExport) return null; + if (options.noExport) { + if (/^[^{]*$/.test(line) || /\{[^}]?\}/.test(line)) return null; + noExport = true; + return null; + } + if (line.includes('export {')) return null; + if (/^\s*(?:declare\s+)?interface\s+\w+\s*extends/.test(line) || options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+\s*\{/.test(line)) { + if (!options.noPrefix) { + const m = line.match(/interface\s+(?\w+)/); + if (m && m.groups) { + prefixed.push(m.groups.name); + } + } + return line.replace(/^(?\s*)(?:declare\s+)?interface\s+(?[\s\w,<=>]+)/, `$export interface ${ !options.noPrefix ? prefix : '' }$`); + } + if (!options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+/.test(line)) { + const m = line.match(/^(?\s*)(?:declare\s+)?interface\s+(?\w+)(?<[^>]+>)?/); + const iIndent = m?.groups?.indent ?? ''; + const iName = m?.groups?.name ?? ''; + const iExtend = m?.groups?.extend ?? ''; + if (!options.noPrefix && iName !== '') { + prefixed.push(iName); + } + const genericsForExtends = iExtend.replace(/\sextends\s[^,>]+/g, '').replace(/\s?=\s?\w+/g, ''); + const entityName = `${ !options.noPrefix ? prefix : '' }${ iName }`; + const isConstructor = iName.includes('Constructor'); + let constructorDeclaration; + if (isConstructor) { + constructorDeclaration = !options.noRedefine ? `${ iIndent }var ${ entityName.replace('Constructor', '') }: ${ entityName };\n` : ''; + } else { + constructorDeclaration = !options.noRedefine ? `${ iIndent }var ${ entityName }: ${ options.exportBaseConstructor ? iName : entityName }${ options.noConstructor ? '' : 'Constructor' };\n` : ''; + } + return `${ constructorDeclaration }${ iIndent }export interface ${ entityName }${ iExtend } extends ${ iName }${ genericsForExtends } {\n`; + } + if (/^\s*(?:declare\s+)?function/.test(line)) { + return line.replace(/^(?\s*)(?:declare\s+)?function\s+(?\w+)/, `$export function ${ !options.noPrefix ? prefix : '' }$`); + } + if (/:\s*\w/.test(line)) { + const sortedPrefixed = prefixed.sort((a, b) => b.length - a.length); + sortedPrefixed.forEach(item => { + const reg = new RegExp(`: ${ item }([,;<)])`, 'g'); + line = line.replace(reg, `: ${ prefix }${ item }$1`); + }); + } + if (/^\s*(?:declare)?\svar/.test(line)) { + const m = line.match(/^(?\s*)(?:declare\s+)?var\s+(?\w+):\s+(?\w+)/); + return `${ m?.groups?.indent ?? '' }var ${ !options.noPrefix ? prefix : '' }${ m?.groups?.name ?? '' }: ${ m?.groups?.type };\n`; + } + return line; + }) + .filter(line => line !== null); +} + +function wrapDTSInNamespace(content, namespace = 'CoreJS') { + const lines = content.split('\n'); + const preamble = []; + let i = 0; + for (; i < lines.length; i++) { + const line = lines[i]; + if (/\/\/\/\s* `${ a }../${ b }${ c }`)); + } else if (/^\s*\/\//.test(line) || /^\s*$/.test(line)) { + preamble.push(line); + } else break; + } + const mainLines = lines.slice(i); + const { sections, outside } = extractDeclareGlobalSections(mainLines); + const nsBody = [...processLines(outside, namespace), ...sections.flatMap(s => processLines(s, namespace))] + .reduce((res, line) => { + if ((line && line.trim() !== '') || (res.at(-1) && res.at(-1).trim() !== '')) res.push(line); + return res; + }, []).map(line => line ? ` ${ line }` : '').join('\n'); + return `${ preamble.length ? `${ preamble.join('\n') }\n` : '' }declare namespace ${ namespace } {\n${ nsBody }\n}\n`; +} + +export async function preparePureTypes(typesPath) { + const entries = await readdir(typesPath, { withFileTypes: true }); + for (const entry of entries) { + if (entry.name === 'pure') continue; + if (entry.isDirectory()) { + await preparePureTypes(path.join(typesPath, entry.name)); + } else { + if (entry.name.includes('core-js-types.d.ts')) continue; + const typePath = path.join(typesPath, entry.name); + const resultFilePath = typePath.replace(entry.name, `pure/${ entry.name }`); + if (await pathExists(resultFilePath)) continue; + const content = await fs.readFile(typePath, 'utf8'); + if (content.includes('declare namespace')) continue; + const result = wrapDTSInNamespace(content); + await outputFile(resultFilePath, result); + } + } +} diff --git a/tests/type-definitions/pure/common/date.test.ts b/tests/type-definitions/pure/common/date.test.ts new file mode 100644 index 000000000000..c797e6a0b5f0 --- /dev/null +++ b/tests/type-definitions/pure/common/date.test.ts @@ -0,0 +1,4 @@ +import $date from '@core-js/pure/full/date/index'; + +new $date(); +new $date('2020-01-01'); diff --git a/tests/type-definitions/pure/web/url-can-parse.test.ts b/tests/type-definitions/pure/web/url-can-parse.test.ts new file mode 100644 index 000000000000..a3f7ae842c7b --- /dev/null +++ b/tests/type-definitions/pure/web/url-can-parse.test.ts @@ -0,0 +1,7 @@ +import $canParse from '@core-js/pure/full/url/can-parse'; + +const u1: boolean = $canParse('https://example.com/path?name=value#hash'); +const u2: boolean = $canParse('/path', 'https://example.com'); + +// @ts-expect-error +$canParse(null); diff --git a/tests/type-definitions/pure/web/url-parse.test.ts b/tests/type-definitions/pure/web/url-parse.test.ts new file mode 100644 index 000000000000..d1a0a98ad037 --- /dev/null +++ b/tests/type-definitions/pure/web/url-parse.test.ts @@ -0,0 +1,19 @@ +import $parse from '@core-js/pure/full/url/parse'; + +const u1 = $parse('https://example.com/path?name=value#hash'); +$parse('/path', 'https://example.com'); + +if (u1) { + $parse(u1); + + let str: string; + str = u1.pathname; + str = u1.hostname; + str = u1.pathname; + + str = u1.toJSON(); + str = u1.toString(); +} + +// @ts-expect-error +$parse(null); diff --git a/tests/type-definitions/pure/web/url-search-params.test.ts b/tests/type-definitions/pure/web/url-search-params.test.ts new file mode 100644 index 000000000000..a51cdccea1e3 --- /dev/null +++ b/tests/type-definitions/pure/web/url-search-params.test.ts @@ -0,0 +1,36 @@ +import $urlSearchParams from '@core-js/pure/full/url-search-params/index'; + +const ps1 = new $urlSearchParams(); +new $urlSearchParams('a=1&b=2'); +new $urlSearchParams([['a', '1'], ['b', '2']]); +new $urlSearchParams(ps1); +new $urlSearchParams({ foo: "bar" }); + +// @ts-expect-error +new $urlSearchParams(42); + +ps1.append('k', 'v'); +// @ts-expect-error +ps1.append(); +// @ts-expect-error +ps1.append('a', 5); + +ps1.delete('k'); +// @ts-expect-error +ps1.delete(); + +const getResult: string | null = ps1.get('foo'); + +const allResult: string[] = ps1.getAll('foo'); + +const hasResult: boolean = ps1.has('foo'); + +ps1.set('foo', 'bar'); +// @ts-expect-error +ps1.set('foo', 1); +// @ts-expect-error +ps1.set('foo'); + +ps1.sort(); + +const str: string = ps1.toString(); diff --git a/tests/type-definitions/pure/web/url.test.ts b/tests/type-definitions/pure/web/url.test.ts new file mode 100644 index 000000000000..0e95cd550a5e --- /dev/null +++ b/tests/type-definitions/pure/web/url.test.ts @@ -0,0 +1,15 @@ +import $url from '@core-js/pure/full/url/index'; + +const u1 = new $url('https://example.com/path?name=value#hash'); +new $url('/path', 'https://example.com'); + +let str: string; +str = u1.pathname; +str = u1.hostname; +str = u1.pathname; + +str = u1.toJSON(); +str = u1.toString(); + +// @ts-expect-error +new $url(null); From f7d7253b6be9c169028e4fcd9260060dff9f2a2a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 6 Dec 2025 03:13:12 +0700 Subject: [PATCH 071/315] Pure types refactoring & some improvements --- packages/core-js-types/package.json | 1 - .../pure/global-this.d.ts | 0 .../{proposals => common}/pure/reflect.d.ts | 4 + .../56/{proposals => common}/pure/self.d.ts | 0 .../src/56/core-js-types/async-iterable.d.ts | 3 + .../core-js-types/async-iterator-object.d.ts | 3 + .../src/56/core-js-types/core-js-types.d.ts | 12 -- .../56/core-js-types/core-js-types.pure.d.ts | 16 -- .../decorator-metadata-object.d.ts | 5 + .../src/56/core-js-types/flat-array.d.ts | 13 ++ .../src/56/core-js-types/iterator-object.d.ts | 3 + .../core-js-types/promise-settled-result.d.ts | 9 + .../src/56/core-js-types/string-base.d.ts | 3 + .../src/56/proposals/array-buffer-base64.d.ts | 2 +- .../56/proposals/array-buffer-transfer.d.ts | 2 +- .../src/56/proposals/array-filtering.d.ts | 22 +-- .../56/proposals/array-find-from-last.d.ts | 22 +-- .../src/56/proposals/array-flat-map.d.ts | 46 +++-- .../src/56/proposals/array-from-async.d.ts | 34 ++-- .../src/56/proposals/array-includes.d.ts | 22 +-- .../src/56/proposals/array-unique.d.ts | 22 +-- .../56/proposals/async-iterator-helpers.d.ts | 170 +++++++++--------- .../src/56/proposals/await-dictionary.d.ts | 42 ++--- .../56/proposals/change-array-by-copy.d.ts | 22 +-- .../data-view-get-set-uint8-clamped.d.ts | 2 +- .../src/56/proposals/decorator-metadata.d.ts | 18 +- .../src/56/proposals/error-cause.d.ts | 88 +++++---- .../src/56/proposals/float16.d.ts | 2 +- .../src/56/proposals/is-error.d.ts | 2 +- .../src/56/proposals/promise-all-settled.d.ts | 38 ++-- .../src/56/proposals/promise-any.d.ts | 4 +- .../proposals/pure/array-buffer-base64.d.ts | 2 + .../proposals/pure/array-buffer-transfer.d.ts | 3 + .../56/proposals/pure/array-constructor.d.ts | 7 +- .../56/proposals/pure/array-filtering.d.ts | 15 -- .../proposals/pure/array-find-from-last.d.ts | 34 ---- .../src/56/proposals/pure/array-flat-map.d.ts | 33 ---- .../56/proposals/pure/array-from-async.d.ts | 2 + .../src/56/proposals/pure/array-includes.d.ts | 17 -- .../src/56/proposals/pure/array-unique.d.ts | 14 -- .../56/proposals/pure/async-iteration.d.ts | 2 + .../pure/async-iterator-helpers.d.ts | 14 +- .../56/proposals/pure/await-dictionary.d.ts | 28 --- .../proposals/pure/change-array-by-copy.d.ts | 54 ------ .../pure/data-view-get-set-uint8-clamped.d.ts | 24 --- .../56/proposals/pure/decorator-metadata.d.ts | 4 + .../src/56/proposals/pure/error-cause.d.ts | 0 .../src/56/proposals/pure/error.d.ts | 49 ----- .../pure/explicit-resource-management.d.ts | 2 + .../src/56/proposals/pure/float16.d.ts | 38 ---- .../src/56/proposals/pure/is-error.d.ts | 0 .../56/proposals/pure/iterator-chunking.d.ts | 2 + .../56/proposals/pure/iterator-helpers.d.ts | 2 + .../src/56/proposals/pure/iterator-join.d.ts | 2 + .../src/56/proposals/pure/iterator-joint.d.ts | 2 + .../src/56/proposals/pure/iterator-range.d.ts | 2 + .../proposals/pure/iterator-sequencing.d.ts | 2 + .../src/56/proposals/pure/iterator.d.ts | 12 +- .../56/proposals/pure/pattern-matching.d.ts | 2 + .../proposals/pure/promise-all-settled.d.ts | 31 ---- .../src/56/proposals/pure/promise-any.d.ts | 27 --- .../pure/relative-indexing-method.d.ts | 4 +- .../pure/string-left-right-trim.d.ts | 4 +- .../56/proposals/pure/string-match-all.d.ts | 8 +- .../src/56/proposals/pure/string-padding.d.ts | 4 +- .../56/proposals/pure/string-replace-all.d.ts | 4 +- .../56/proposals/pure/symbol-description.d.ts | 2 + .../56/proposals/pure/symbol-predicates.d.ts | 2 + .../src/56/proposals/pure/symbol.d.ts | 5 +- .../pure/well-formed-unicode-strings.d.ts | 4 +- .../proposals/relative-indexing-method.d.ts | 28 +-- .../src/56/web/{btoa.d.ts => atob-btoa.d.ts} | 7 + packages/core-js-types/src/56/web/atob.d.ts | 6 - .../pure/dom-exception.d.ts | 0 packages/core-js/modules/web.atob.js | 2 +- packages/core-js/modules/web.btoa.js | 2 +- scripts/build-types/pure.mjs | 8 +- tests/eslint/package-lock.json | 9 +- tests/type-definitions/package-lock.json | 11 +- tests/type-definitions/package.json | 5 +- tests/type-definitions/runner.mjs | 20 +-- 81 files changed, 430 insertions(+), 763 deletions(-) rename packages/core-js-types/src/56/{proposals => common}/pure/global-this.d.ts (100%) rename packages/core-js-types/src/56/{proposals => common}/pure/reflect.d.ts (95%) rename packages/core-js-types/src/56/{proposals => common}/pure/self.d.ts (100%) create mode 100644 packages/core-js-types/src/56/core-js-types/async-iterable.d.ts create mode 100644 packages/core-js-types/src/56/core-js-types/async-iterator-object.d.ts create mode 100644 packages/core-js-types/src/56/core-js-types/decorator-metadata-object.d.ts create mode 100644 packages/core-js-types/src/56/core-js-types/flat-array.d.ts create mode 100644 packages/core-js-types/src/56/core-js-types/iterator-object.d.ts create mode 100644 packages/core-js-types/src/56/core-js-types/promise-settled-result.d.ts create mode 100644 packages/core-js-types/src/56/core-js-types/string-base.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/array-filtering.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/array-find-from-last.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/array-flat-map.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/array-includes.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/array-unique.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/await-dictionary.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/change-array-by-copy.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/data-view-get-set-uint8-clamped.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/error-cause.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/error.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/float16.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/is-error.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/promise-all-settled.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/pure/promise-any.d.ts rename packages/core-js-types/src/56/web/{btoa.d.ts => atob-btoa.d.ts} (53%) delete mode 100644 packages/core-js-types/src/56/web/atob.d.ts rename packages/core-js-types/src/56/{proposals => web}/pure/dom-exception.d.ts (100%) diff --git a/packages/core-js-types/package.json b/packages/core-js-types/package.json index d2f1cc311aac..77493dc29d2b 100644 --- a/packages/core-js-types/package.json +++ b/packages/core-js-types/package.json @@ -59,7 +59,6 @@ "types@>=5.6": "./dist/56/pure.d.ts", "types": "./dist/52/pure.d.ts", "default": "./dist/56/pure.d.ts" - }, "./stable": { "types@>=5.6": "./dist/56/stable.d.ts", diff --git a/packages/core-js-types/src/56/proposals/pure/global-this.d.ts b/packages/core-js-types/src/56/common/pure/global-this.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/global-this.d.ts rename to packages/core-js-types/src/56/common/pure/global-this.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/reflect.d.ts b/packages/core-js-types/src/56/common/pure/reflect.d.ts similarity index 95% rename from packages/core-js-types/src/56/proposals/pure/reflect.d.ts rename to packages/core-js-types/src/56/common/pure/reflect.d.ts index 980f9368b2ee..00f78e5bcff4 100644 --- a/packages/core-js-types/src/56/proposals/pure/reflect.d.ts +++ b/packages/core-js-types/src/56/common/pure/reflect.d.ts @@ -1,3 +1,7 @@ +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/38d95c8001300f525fd601dd0ce6d0ff5f12baee/src/lib/es2015.reflect.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + declare namespace CoreJS { interface Reflect { /** diff --git a/packages/core-js-types/src/56/proposals/pure/self.d.ts b/packages/core-js-types/src/56/common/pure/self.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/self.d.ts rename to packages/core-js-types/src/56/common/pure/self.d.ts diff --git a/packages/core-js-types/src/56/core-js-types/async-iterable.d.ts b/packages/core-js-types/src/56/core-js-types/async-iterable.d.ts new file mode 100644 index 000000000000..aa9d7adf12f9 --- /dev/null +++ b/packages/core-js-types/src/56/core-js-types/async-iterable.d.ts @@ -0,0 +1,3 @@ +declare namespace CoreJS { + export interface CoreJSAsyncIterable {} +} diff --git a/packages/core-js-types/src/56/core-js-types/async-iterator-object.d.ts b/packages/core-js-types/src/56/core-js-types/async-iterator-object.d.ts new file mode 100644 index 000000000000..f25d309513f5 --- /dev/null +++ b/packages/core-js-types/src/56/core-js-types/async-iterator-object.d.ts @@ -0,0 +1,3 @@ +declare namespace CoreJS { + export interface CoreJSAsyncIteratorObject {} +} diff --git a/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts index 26e17d519d24..b3dc9bf74b41 100644 --- a/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts +++ b/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts @@ -38,15 +38,3 @@ export type CoreJSDecoratorMetadataObject = typeof globalThis extends { Decorato : Record & object; export type CoreJSIteratorObject = IteratorObject; - -export type CoreJSPromiseSettledResult = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020 - ? O - : PromiseFulfilledResult | PromiseRejectedResult; - -export type CoreJSFlatArray = typeof globalThis extends { FlatArray: infer O } // from ts 4.4 - ? O - : { - done: Arr; - recur: Arr extends ReadonlyArray ? CoreJSFlatArray - : Arr; - }[Depth extends -1 ? "done" : "recur"]; diff --git a/packages/core-js-types/src/56/core-js-types/core-js-types.pure.d.ts b/packages/core-js-types/src/56/core-js-types/core-js-types.pure.d.ts index 69abef5c564a..bffa05d090d7 100644 --- a/packages/core-js-types/src/56/core-js-types/core-js-types.pure.d.ts +++ b/packages/core-js-types/src/56/core-js-types/core-js-types.pure.d.ts @@ -9,20 +9,4 @@ declare namespace CoreJS { export type CoreJSDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } // from ts 5.2 ? O : Record & object; - - interface PromiseFulfilledResult { status: "fulfilled"; value: T; } - - interface PromiseRejectedResult { status: "rejected"; reason: any; } - - export type CoreJSPromiseSettledResult = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020 - ? O - : PromiseFulfilledResult | PromiseRejectedResult; - - export type CoreJSFlatArray = typeof globalThis extends { FlatArray: infer O } // from ts 4.4 - ? O - : { - done: Arr; - recur: Arr extends ReadonlyArray ? CoreJSFlatArray - : Arr; - }[Depth extends -1 ? "done" : "recur"]; } diff --git a/packages/core-js-types/src/56/core-js-types/decorator-metadata-object.d.ts b/packages/core-js-types/src/56/core-js-types/decorator-metadata-object.d.ts new file mode 100644 index 000000000000..178fc4e739a0 --- /dev/null +++ b/packages/core-js-types/src/56/core-js-types/decorator-metadata-object.d.ts @@ -0,0 +1,5 @@ +declare namespace CoreJS { + export type CoreJSDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } // from ts 5.2 + ? O + : Record & object; +} diff --git a/packages/core-js-types/src/56/core-js-types/flat-array.d.ts b/packages/core-js-types/src/56/core-js-types/flat-array.d.ts new file mode 100644 index 000000000000..072ded56f28e --- /dev/null +++ b/packages/core-js-types/src/56/core-js-types/flat-array.d.ts @@ -0,0 +1,13 @@ +// For ensuring compatibility with TypeScript standard types, this code is based on: +// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2019.array.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export type CoreJSFlatArray = typeof globalThis extends { FlatArray: infer O } // from ts 4.4 + ? O + : { + done: Arr; + recur: Arr extends ReadonlyArray ? CoreJSFlatArray + : Arr; + }[Depth extends -1 ? "done" : "recur"]; +} diff --git a/packages/core-js-types/src/56/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/56/core-js-types/iterator-object.d.ts new file mode 100644 index 000000000000..a6252f8dfbb2 --- /dev/null +++ b/packages/core-js-types/src/56/core-js-types/iterator-object.d.ts @@ -0,0 +1,3 @@ +declare namespace CoreJS { + export interface CoreJSIteratorObject extends Iterator {} +} diff --git a/packages/core-js-types/src/56/core-js-types/promise-settled-result.d.ts b/packages/core-js-types/src/56/core-js-types/promise-settled-result.d.ts new file mode 100644 index 000000000000..7289ee8035cf --- /dev/null +++ b/packages/core-js-types/src/56/core-js-types/promise-settled-result.d.ts @@ -0,0 +1,9 @@ +declare namespace CoreJS { + interface PromiseFulfilledResult { status: "fulfilled"; value: T; } + + interface PromiseRejectedResult { status: "rejected"; reason: any; } + + export type CoreJSPromiseSettledResult = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020 + ? O + : PromiseFulfilledResult | PromiseRejectedResult; +} diff --git a/packages/core-js-types/src/56/core-js-types/string-base.d.ts b/packages/core-js-types/src/56/core-js-types/string-base.d.ts new file mode 100644 index 000000000000..26f8c1c4948e --- /dev/null +++ b/packages/core-js-types/src/56/core-js-types/string-base.d.ts @@ -0,0 +1,3 @@ +declare namespace CoreJS { + export type StringBase = Omit; +} diff --git a/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts index 34d3fbe44e8a..dbc36f0df75f 100644 --- a/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts +++ b/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts @@ -42,7 +42,7 @@ interface Uint8ArrayConstructor { fromHex(str: string): Uint8Array; } -interface Uint8Array { // @type-options no-redefine +interface Uint8Array { /** * Sets the `Uint8Array` from a base64-encoded string. * @param string The base64-encoded string. diff --git a/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts index 973171b30030..b11b4866241c 100644 --- a/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts @@ -5,7 +5,7 @@ // https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/es2024.arraybuffer.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface ArrayBuffer { // @type-options export-base-constructor +interface ArrayBuffer { // todo hack for modern ts // get detached(): boolean; diff --git a/packages/core-js-types/src/56/proposals/array-filtering.d.ts b/packages/core-js-types/src/56/proposals/array-filtering.d.ts index e0088e42d305..6df245b62c9c 100644 --- a/packages/core-js-types/src/56/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/56/proposals/array-filtering.d.ts @@ -12,7 +12,7 @@ interface Array { // @type-options no-redefine filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; } -interface Int8Array { // @type-options no-redefine +interface Int8Array { // @type-options no-export /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -23,7 +23,7 @@ interface Int8Array { // @type-options no-redefine filterReject(callbackFn: (value: number, index: number, target: Int8Array) => boolean, thisArg?: any): Int8Array; } -interface Uint8Array { // @type-options no-redefine +interface Uint8Array { // @type-options no-export /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -34,7 +34,7 @@ interface Uint8Array { // @type-options no-redefine filterReject(callbackFn: (value: number, index: number, target: Uint8Array) => boolean, thisArg?: any): Uint8Array; } -interface Uint8ClampedArray { // @type-options no-redefine +interface Uint8ClampedArray { // @type-options no-export /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -45,7 +45,7 @@ interface Uint8ClampedArray { // @type-options no-redefine filterReject(callbackFn: (value: number, index: number, target: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; } -interface Int16Array { // @type-options no-redefine +interface Int16Array { // @type-options no-export /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -56,7 +56,7 @@ interface Int16Array { // @type-options no-redefine filterReject(callbackFn: (value: number, index: number, target: Int16Array) => boolean, thisArg?: any): Int16Array; } -interface Uint16Array { // @type-options no-redefine +interface Uint16Array { // @type-options no-export /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -67,7 +67,7 @@ interface Uint16Array { // @type-options no-redefine filterReject(callbackFn: (value: number, index: number, target: Uint16Array) => boolean, thisArg?: any): Uint16Array; } -interface Int32Array { // @type-options no-redefine +interface Int32Array { // @type-options no-export /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -78,7 +78,7 @@ interface Int32Array { // @type-options no-redefine filterReject(callbackFn: (value: number, index: number, target: Int32Array) => boolean, thisArg?: any): Int32Array; } -interface Uint32Array { // @type-options no-redefine +interface Uint32Array { // @type-options no-export /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -89,7 +89,7 @@ interface Uint32Array { // @type-options no-redefine filterReject(callbackFn: (value: number, index: number, target: Uint32Array) => boolean, thisArg?: any): Uint32Array; } -interface Float32Array { // @type-options no-redefine +interface Float32Array { // @type-options no-export /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -100,11 +100,11 @@ interface Float32Array { // @type-options no-redefine filterReject(callbackFn: (value: number, index: number, target: Float32Array) => boolean, thisArg?: any): Float32Array; } -interface Float64Array { // @type-options no-redefine +interface Float64Array { // @type-options no-export filterReject(callbackFn: (value: number, index: number, target: Float64Array) => boolean, thisArg?: any): Float64Array; } -interface BigInt64Array { // @type-options no-redefine +interface BigInt64Array { // @type-options no-export /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the @@ -115,7 +115,7 @@ interface BigInt64Array { // @type-options no-redefine filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array; } -interface BigUint64Array { // @type-options no-redefine +interface BigUint64Array { // @type-options no-export /** * Removes the items that return true * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the diff --git a/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts index 7ef4f1daed51..8bc13e148613 100644 --- a/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts @@ -30,7 +30,7 @@ interface Array { // @type-options no-redefine findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; } -interface Int8Array { // @type-options no-redefine +interface Int8Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -55,7 +55,7 @@ interface Int8Array { // @type-options no-redefine findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Uint8Array { // @type-options no-redefine +interface Uint8Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -80,7 +80,7 @@ interface Uint8Array { // @type-options no-redefine findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Uint8ClampedArray { // @type-options no-redefine +interface Uint8ClampedArray { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -105,7 +105,7 @@ interface Uint8ClampedArray { // @type-options no-redefine findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Int16Array { // @type-options no-redefine +interface Int16Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -130,7 +130,7 @@ interface Int16Array { // @type-options no-redefine findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Uint16Array { // @type-options no-redefine +interface Uint16Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -155,7 +155,7 @@ interface Uint16Array { // @type-options no-redefine findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Int32Array { // @type-options no-redefine +interface Int32Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -180,7 +180,7 @@ interface Int32Array { // @type-options no-redefine findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Uint32Array { // @type-options no-redefine +interface Uint32Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -205,7 +205,7 @@ interface Uint32Array { // @type-options no-redefine findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Float32Array { // @type-options no-redefine +interface Float32Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -230,7 +230,7 @@ interface Float32Array { // @type-options no-redefine findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Float64Array { // @type-options no-redefine +interface Float64Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -246,7 +246,7 @@ interface Float64Array { // @type-options no-redefine findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface BigInt64Array { // @type-options no-redefine +interface BigInt64Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -271,7 +271,7 @@ interface BigInt64Array { // @type-options no-redefine findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; } -interface BigUint64Array { // @type-options no-redefine +interface BigUint64Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. diff --git a/packages/core-js-types/src/56/proposals/array-flat-map.d.ts b/packages/core-js-types/src/56/proposals/array-flat-map.d.ts index 45a8cbf8acba..dead291ff4da 100644 --- a/packages/core-js-types/src/56/proposals/array-flat-map.d.ts +++ b/packages/core-js-types/src/56/proposals/array-flat-map.d.ts @@ -1,3 +1,5 @@ +/// + // proposal stage: 4 // https://github.com/tc39/proposal-flatMap @@ -5,30 +7,24 @@ // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -import { CoreJSFlatArray } from "../core-js-types/core-js-types"; - -declare global { - interface Array { // @type-options no-redefine - /** - * 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 callback 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 this keyword can refer in the callback function. If - * thisArg is omitted, undefined is used as this value. - */ - flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): U[]; +interface Array { // @type-options no-redefine + /** + * 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 callback 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 this keyword can refer in the callback function. If + * thisArg is omitted, undefined is used as this value. + */ + flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): 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(this: A, depth?: D): CoreJSFlatArray[]; - } + /** + * 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(this: A, depth?: D): CoreJS.CoreJSFlatArray[]; } - -export {}; diff --git a/packages/core-js-types/src/56/proposals/array-from-async.d.ts b/packages/core-js-types/src/56/proposals/array-from-async.d.ts index 8dfef687701c..acd4ffe22961 100644 --- a/packages/core-js-types/src/56/proposals/array-from-async.d.ts +++ b/packages/core-js-types/src/56/proposals/array-from-async.d.ts @@ -5,24 +5,20 @@ // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/esnext.array.d.ts#L6 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -declare global { - interface ArrayConstructor { - /** - * Creates an array from an async iterator or iterable object. - * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. - */ - fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; +interface ArrayConstructor { + /** + * Creates an array from an async iterator or iterable object. + * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. + */ + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; - /** - * Creates an array from an async iterator or iterable object. - * - * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. - * @param mapFn A mapping function to call on every element of iterableOrArrayLike. - * Each return value is awaited before being added to result array. - * @param thisArg Value of 'this' used when executing mapFn. - */ - fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; - } + /** + * Creates an array from an async iterator or iterable object. + * + * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. + * @param mapFn A mapping function to call on every element of iterableOrArrayLike. + * Each return value is awaited before being added to result array. + * @param thisArg Value of 'this' used when executing mapFn. + */ + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; } - -export {}; diff --git a/packages/core-js-types/src/56/proposals/array-includes.d.ts b/packages/core-js-types/src/56/proposals/array-includes.d.ts index 0aa74e6ea6f6..9618c4cf1762 100644 --- a/packages/core-js-types/src/56/proposals/array-includes.d.ts +++ b/packages/core-js-types/src/56/proposals/array-includes.d.ts @@ -14,7 +14,7 @@ interface Array { // @type-options no-redefine includes(searchElement: T, fromIndex?: number): boolean; } -interface Int8Array { // @type-options no-redefine +interface Int8Array { // @type-options no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -23,7 +23,7 @@ interface Int8Array { // @type-options no-redefine includes(searchElement: number, fromIndex?: number): boolean; } -interface Uint8Array { // @type-options no-redefine +interface Uint8Array { // @type-options no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -32,7 +32,7 @@ interface Uint8Array { // @type-options no-redefine includes(searchElement: number, fromIndex?: number): boolean; } -interface Uint8ClampedArray { // @type-options no-redefine +interface Uint8ClampedArray { // @type-options no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -41,7 +41,7 @@ interface Uint8ClampedArray { // @type-options no-redefine includes(searchElement: number, fromIndex?: number): boolean; } -interface Int16Array { // @type-options no-redefine +interface Int16Array { // @type-options no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -50,7 +50,7 @@ interface Int16Array { // @type-options no-redefine includes(searchElement: number, fromIndex?: number): boolean; } -interface Uint16Array { // @type-options no-redefine +interface Uint16Array { // @type-options no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -59,7 +59,7 @@ interface Uint16Array { // @type-options no-redefine includes(searchElement: number, fromIndex?: number): boolean; } -interface Int32Array { // @type-options no-redefine +interface Int32Array { // @type-options no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -68,7 +68,7 @@ interface Int32Array { // @type-options no-redefine includes(searchElement: number, fromIndex?: number): boolean; } -interface Uint32Array { // @type-options no-redefine +interface Uint32Array { // @type-options no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -77,7 +77,7 @@ interface Uint32Array { // @type-options no-redefine includes(searchElement: number, fromIndex?: number): boolean; } -interface Float32Array { // @type-options no-redefine +interface Float32Array { // @type-options no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -86,7 +86,7 @@ interface Float32Array { // @type-options no-redefine includes(searchElement: number, fromIndex?: number): boolean; } -interface Float64Array { // @type-options no-redefine +interface Float64Array { // @type-options no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -95,7 +95,7 @@ interface Float64Array { // @type-options no-redefine includes(searchElement: number, fromIndex?: number): boolean; } -interface BigInt64Array { // @type-options no-redefine +interface BigInt64Array { // @type-options no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -104,7 +104,7 @@ interface BigInt64Array { // @type-options no-redefine includes(searchElement: bigint, fromIndex?: number): boolean; } -interface BigUint64Array { // @type-options no-redefine +interface BigUint64Array { // @type-options no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. diff --git a/packages/core-js-types/src/56/proposals/array-unique.d.ts b/packages/core-js-types/src/56/proposals/array-unique.d.ts index 8b1215717dc4..3d22faa36462 100644 --- a/packages/core-js-types/src/56/proposals/array-unique.d.ts +++ b/packages/core-js-types/src/56/proposals/array-unique.d.ts @@ -11,7 +11,7 @@ interface Array { // @type-options no-redefine uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; } -interface Int8Array { // @type-options no-redefine +interface Int8Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -21,7 +21,7 @@ interface Int8Array { // @type-options no-redefine uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int8Array; } -interface Uint8Array { // @type-options no-redefine +interface Uint8Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -31,7 +31,7 @@ interface Uint8Array { // @type-options no-redefine uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8Array; } -interface Uint8ClampedArray { // @type-options no-redefine +interface Uint8ClampedArray { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -41,7 +41,7 @@ interface Uint8ClampedArray { // @type-options no-redefine uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8ClampedArray; } -interface Int16Array { // @type-options no-redefine +interface Int16Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -51,7 +51,7 @@ interface Int16Array { // @type-options no-redefine uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int16Array; } -interface Uint16Array { // @type-options no-redefine +interface Uint16Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -61,7 +61,7 @@ interface Uint16Array { // @type-options no-redefine uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint16Array; } -interface Int32Array { // @type-options no-redefine +interface Int32Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -71,7 +71,7 @@ interface Int32Array { // @type-options no-redefine uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int32Array; } -interface Uint32Array { // @type-options no-redefine +interface Uint32Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -81,7 +81,7 @@ interface Uint32Array { // @type-options no-redefine uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint32Array; } -interface Float32Array { // @type-options no-redefine +interface Float32Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -91,7 +91,7 @@ interface Float32Array { // @type-options no-redefine uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float32Array; } -interface Float64Array { // @type-options no-redefine +interface Float64Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -101,7 +101,7 @@ interface Float64Array { // @type-options no-redefine uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float64Array; } -interface BigInt64Array { // @type-options no-redefine +interface BigInt64Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, @@ -111,7 +111,7 @@ interface BigInt64Array { // @type-options no-redefine uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigInt64Array; } -interface BigUint64Array { // @type-options no-redefine +interface BigUint64Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver A function that resolves the value to check uniqueness against, diff --git a/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts index 9a83528bc579..0567377a00e7 100644 --- a/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts @@ -1,104 +1,100 @@ // proposal stage: 2 // https://github.com/tc39/proposal-async-iterator-helpers -declare global { - interface AsyncIteratorConstructor { // @type-options no-extends - /** - * Creates an `AsyncIterator` from an iterable object - * @param iterable An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` - * @returns A new `AsyncIterator` instance - */ - from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; - } - - var AsyncIterator: AsyncIteratorConstructor; +interface AsyncIteratorConstructor { + /** + * Creates an `AsyncIterator` from an iterable object + * @param iterable An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` + * @returns A new `AsyncIterator` instance + */ + from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; +} - interface AsyncIterator { - /** - * Drops elements from the iterator until the limit is reached - * @param limit The number of elements to drop - * @returns A new `AsyncIterator` - */ - drop(limit: number): AsyncIteratorObject; +declare var AsyncIterator: AsyncIteratorConstructor; - /** - * Check if every value generated by the iterator passes the `predicate` function. - * @param predicate A function that tests each element of the iterator - * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` - */ - every(predicate: (value: T, index: number) => boolean): Promise; +interface AsyncIterator { + /** + * Drops elements from the iterator until the limit is reached + * @param limit The number of elements to drop + * @returns A new `AsyncIterator` + */ + drop(limit: number): AsyncIteratorObject; - /** - * Creates a new `AsyncIterator` that contains only the elements that pass the `predicate` function. - * @param predicate A function that tests each element of the iterator - * @returns A new `AsyncIterator` - */ - filter(predicate: (value: T, index: number) => boolean): AsyncIteratorObject; + /** + * Check if every value generated by the iterator passes the `predicate` function. + * @param predicate A function that tests each element of the iterator + * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` + */ + every(predicate: (value: T, index: number) => boolean): Promise; - /** - * Finds the first element in the iterator that satisfies the `predicate` function. - * @param predicate A function that tests each element of the iterator - * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` - */ - find(predicate: (value: T, index: number) => boolean): Promise; + /** + * Creates a new `AsyncIterator` that contains only the elements that pass the `predicate` function. + * @param predicate A function that tests each element of the iterator + * @returns A new `AsyncIterator` + */ + filter(predicate: (value: T, index: number) => boolean): AsyncIteratorObject; - /** - * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. - * @param mapper A function that transforms each element of the iterator - * @returns A new `AsyncIterator` - */ - flatMap(mapper: (value: T, index: number) => any): AsyncIteratorObject; + /** + * Finds the first element in the iterator that satisfies the `predicate` function. + * @param predicate A function that tests each element of the iterator + * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` + */ + find(predicate: (value: T, index: number) => boolean): Promise; - /** - * Executes a provided function once for each element in the iterator. - * @param callbackFn A function that is called for each element of the iterator - * @returns A `Promise` that resolves when all elements have been processed - */ - forEach(callbackFn: (value: T, index: number) => void): Promise; + /** + * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. + * @param mapper A function that transforms each element of the iterator + * @returns A new `AsyncIterator` + */ + flatMap(mapper: (value: T, index: number) => any): AsyncIteratorObject; - /** - * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. - * @param mapper A function that transforms each element of the iterator - * @returns A new `AsyncIterator` - */ - map(mapper: (value: T, index: number) => any): AsyncIteratorObject; + /** + * Executes a provided function once for each element in the iterator. + * @param callbackFn A function that is called for each element of the iterator + * @returns A `Promise` that resolves when all elements have been processed + */ + forEach(callbackFn: (value: T, index: number) => void): Promise; - /** - * Reduces the elements of the iterator to a single value using the `reducer` function. - * @param reducer A function that combines two elements of the iterator - * @param initialValue An optional initial value to start the reduction - * @returns A `Promise` that resolves to the reduced value - */ - reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; + /** + * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. + * @param mapper A function that transforms each element of the iterator + * @returns A new `AsyncIterator` + */ + map(mapper: (value: T, index: number) => any): AsyncIteratorObject; - /** - * Checks if any value in the iterator matches a given `predicate` - * @param predicate A function that tests each element of the iterator - * @returns A `Promise` that resolves to `true` if any element passes the `predicate`, otherwise `false` - */ - some(predicate: (value: T, index: number) => boolean): Promise; + /** + * Reduces the elements of the iterator to a single value using the `reducer` function. + * @param reducer A function that combines two elements of the iterator + * @param initialValue An optional initial value to start the reduction + * @returns A `Promise` that resolves to the reduced value + */ + reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; - /** - * Creates a new `AsyncIterator` that yields only the first `limit` elements from the original iterator. - * @param limit The maximum number of elements to take - * @returns A new `AsyncIterator` - */ - take(limit: number): AsyncIteratorObject; + /** + * Checks if any value in the iterator matches a given `predicate` + * @param predicate A function that tests each element of the iterator + * @returns A `Promise` that resolves to `true` if any element passes the `predicate`, otherwise `false` + */ + some(predicate: (value: T, index: number) => boolean): Promise; - /** - * Collects all elements from the iterator into an array. - * @returns A `Promise` that resolves to an array containing all elements from the iterator - */ - toArray(): Promise; - } + /** + * Creates a new `AsyncIterator` that yields only the first `limit` elements from the original iterator. + * @param limit The maximum number of elements to take + * @returns A new `AsyncIterator` + */ + take(limit: number): AsyncIteratorObject; - interface Iterator { - /** - * Creates an `AsyncIterator` from the current `Iterator` - * @returns A new `AsyncIterator` instance - */ - toAsync(): AsyncIteratorObject; - } + /** + * Collects all elements from the iterator into an array. + * @returns A `Promise` that resolves to an array containing all elements from the iterator + */ + toArray(): Promise; } -export {}; +interface Iterator { + /** + * Creates an `AsyncIterator` from the current `Iterator` + * @returns A new `AsyncIterator` instance + */ + toAsync(): AsyncIteratorObject; +} diff --git a/packages/core-js-types/src/56/proposals/await-dictionary.d.ts b/packages/core-js-types/src/56/proposals/await-dictionary.d.ts index d1e472598944..354548a45777 100644 --- a/packages/core-js-types/src/56/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/56/proposals/await-dictionary.d.ts @@ -1,29 +1,25 @@ +/// + // proposal stage: 1 // https://github.com/tc39/proposal-await-dictionary -import { CoreJSPromiseSettledResult } from '../core-js-types/core-js-types'; - -declare global { - interface PromiseConstructor { - /** - * Takes an object of promises and returns a single Promise that resolves to an object - * with the same keys and fulfilled values, or rejects as soon as any of the input promises rejects. - * @param promises An object of promises - * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. - */ - allKeyed>>(promises: D): Promise <{ [k in keyof D]: Awaited }>; - - /** - * Takes an object whose values are promises and returns a single `Promise` that resolves - * to an object with the same keys, after all of the input promises have settled. - * @param promises An object of promises - * @returns A new Promise that resolves to an object with the same keys as the input object, - * where each key maps to the settlement result ({ status, value } or { status, reason }) of the corresponding promise. - */ - allSettledKeyed>>(promises: D): Promise <{ [k in keyof D]: CoreJSPromiseSettledResult> }>; - } +interface PromiseConstructor { // @type-options no-redefine + /** + * Takes an object of promises and returns a single Promise that resolves to an object + * with the same keys and fulfilled values, or rejects as soon as any of the input promises rejects. + * @param promises An object of promises + * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. + */ + allKeyed>>(promises: D): Promise <{ [k in keyof D]: Awaited }>; - var Promise: PromiseConstructor; + /** + * Takes an object whose values are promises and returns a single `Promise` that resolves + * to an object with the same keys, after all of the input promises have settled. + * @param promises An object of promises + * @returns A new Promise that resolves to an object with the same keys as the input object, + * where each key maps to the settlement result ({ status, value } or { status, reason }) of the corresponding promise. + */ + allSettledKeyed>>(promises: D): Promise <{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; } -export {}; +declare var Promise: PromiseConstructor; diff --git a/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts index 1652a7757cd5..265350ff2e09 100644 --- a/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts +++ b/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts @@ -50,7 +50,7 @@ interface Array { // @type-options no-redefine with(index: number, value: T): T[]; } -interface Int8Array { // @type-options export-base-constructor +interface Int8Array { // @type-options no-export /** * @returns A copy of an array with its elements reversed. */ @@ -78,7 +78,7 @@ interface Int8Array { // @type-options export-base-constructor with(index: number, value: number): Int8Array; } -interface Uint8Array { // @type-options no-redefine +interface Uint8Array { // @type-options no-export /** * @returns A copy of an array with its elements reversed. */ @@ -106,7 +106,7 @@ interface Uint8Array { // @type-options no-redefine with(index: number, value: number): Uint8Array; } -interface Uint8ClampedArray { // @type-options export-base-constructor +interface Uint8ClampedArray { // @type-options no-export /** * @returns A copy of an array with its elements reversed. */ @@ -134,7 +134,7 @@ interface Uint8ClampedArray { // @type-options export-base-constructor with(index: number, value: number): Uint8ClampedArray; } -interface Int16Array { // @type-options export-base-constructor +interface Int16Array { // @type-options no-export /** * @returns A copy of an array with its elements reversed. */ @@ -162,7 +162,7 @@ interface Int16Array { // @type-options export-base-constructor with(index: number, value: number): Int16Array; } -interface Uint16Array { // @type-options export-base-constructor +interface Uint16Array { // @type-options no-export /** * @returns A copy of an array with its elements reversed. */ @@ -190,7 +190,7 @@ interface Uint16Array { // @type-options export-base-constructor with(index: number, value: number): Uint16Array; } -interface Int32Array { // @type-options export-base-constructor +interface Int32Array { // @type-options no-export /** * @returns A copy of an array with its elements reversed. */ @@ -218,7 +218,7 @@ interface Int32Array { // @type-options export-base-constructor with(index: number, value: number): Int32Array; } -interface Uint32Array { // @type-options export-base-constructor +interface Uint32Array { // @type-options no-export /** * @returns A copy of an array with its elements reversed. */ @@ -246,7 +246,7 @@ interface Uint32Array { // @type-options export-base-constructor with(index: number, value: number): Uint32Array; } -interface Float32Array { // @type-options export-base-constructor +interface Float32Array { // @type-options no-export /** * @returns A copy of an array with its elements reversed. */ @@ -274,7 +274,7 @@ interface Float32Array { // @type-options export-base-constructor with(index: number, value: number): Float32Array; } -interface Float64Array { // @type-options export-base-constructor +interface Float64Array { // @type-options no-export /** * @returns A copy of an array with its elements reversed. */ @@ -302,7 +302,7 @@ interface Float64Array { // @type-options export-base-constructor with(index: number, value: number): Float64Array; } -interface BigInt64Array { // @type-options export-base-constructor +interface BigInt64Array { // @type-options no-export /** * @returns A copy of an array with its elements reversed. */ @@ -330,7 +330,7 @@ interface BigInt64Array { // @type-options export-base-constructor with(index: number, value: bigint): BigInt64Array; } -interface BigUint64Array { // @type-options export-base-constructor +interface BigUint64Array { // @type-options no-export /** * @returns A copy of an array with its elements reversed. */ diff --git a/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts index 401de46b5205..05fb7154b5e8 100644 --- a/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts +++ b/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts @@ -1,7 +1,7 @@ // proposal stage: 1 // https://github.com/tc39/proposal-dataview-get-set-uint8clamped -interface DataView { // @type-options no-constructor +interface DataView { // @type-options no-constructor /** * Reads an unsigned 8-bit integer at the specified byte offset from the DataView, * interpreting the byte as a clamped 8-bit unsigned value (same as Uint8ClampedArray). diff --git a/packages/core-js-types/src/56/proposals/decorator-metadata.d.ts b/packages/core-js-types/src/56/proposals/decorator-metadata.d.ts index 2c2e21069a55..82908a331f64 100644 --- a/packages/core-js-types/src/56/proposals/decorator-metadata.d.ts +++ b/packages/core-js-types/src/56/proposals/decorator-metadata.d.ts @@ -1,16 +1,12 @@ +/// + // proposal stage: 3 // https://github.com/tc39/proposal-decorator-metadata -import { CoreJSDecoratorMetadataObject } from '../core-js-types/core-js-types.js'; - -declare global { - interface SymbolConstructor { - readonly metadata: unique symbol; - } - - interface Function { - [Symbol.metadata]: CoreJSDecoratorMetadataObject | null; - } +interface SymbolConstructor { + readonly metadata: unique symbol; } -export {}; +interface Function { + [Symbol.metadata]: CoreJS.CoreJSDecoratorMetadataObject | null; +} diff --git a/packages/core-js-types/src/56/proposals/error-cause.d.ts b/packages/core-js-types/src/56/proposals/error-cause.d.ts index d10d80a6002f..bcb796408ecb 100644 --- a/packages/core-js-types/src/56/proposals/error-cause.d.ts +++ b/packages/core-js-types/src/56/proposals/error-cause.d.ts @@ -5,68 +5,66 @@ // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/es2022.error.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -declare global { - interface ErrorOptions { - cause?: unknown; - } +interface ErrorOptions { // @type-options no-extends no-prefix no-redefine + cause?: unknown; +} - interface Error { - cause?: unknown; // ts <= 4.7 Error | undefined - } +interface Error { + cause?: unknown; // ts <= 4.7 Error | undefined +} - interface ErrorConstructor { - new(message?: string, options?: ErrorOptions): Error; +interface ErrorConstructor { // @type-options no-redefine + new(message?: string, options?: ErrorOptions): Error; - (message?: string, options?: ErrorOptions): Error; - } + (message?: string, options?: ErrorOptions): Error; +} - interface EvalErrorConstructor { - new(message?: string, options?: ErrorOptions): EvalError; +interface EvalErrorConstructor { // @type-options no-export + new(message?: string, options?: ErrorOptions): EvalError; - (message?: string, options?: ErrorOptions): EvalError; - } + (message?: string, options?: ErrorOptions): EvalError; +} - interface RangeErrorConstructor { - new(message?: string, options?: ErrorOptions): RangeError; +interface RangeErrorConstructor { // @type-options no-export + new(message?: string, options?: ErrorOptions): RangeError; - (message?: string, options?: ErrorOptions): RangeError; - } + (message?: string, options?: ErrorOptions): RangeError; +} - interface ReferenceErrorConstructor { - new(message?: string, options?: ErrorOptions): ReferenceError; +interface ReferenceErrorConstructor { // @type-options no-export + new(message?: string, options?: ErrorOptions): ReferenceError; - (message?: string, options?: ErrorOptions): ReferenceError; - } + (message?: string, options?: ErrorOptions): ReferenceError; +} - interface SyntaxErrorConstructor { - new(message?: string, options?: ErrorOptions): SyntaxError; +interface SyntaxErrorConstructor { // @type-options no-export + new(message?: string, options?: ErrorOptions): SyntaxError; - (message?: string, options?: ErrorOptions): SyntaxError; - } + (message?: string, options?: ErrorOptions): SyntaxError; +} - interface TypeErrorConstructor { - new(message?: string, options?: ErrorOptions): TypeError; +interface TypeErrorConstructor { // @type-options no-export + new(message?: string, options?: ErrorOptions): TypeError; - (message?: string, options?: ErrorOptions): TypeError; - } + (message?: string, options?: ErrorOptions): TypeError; +} - interface URIErrorConstructor { - new(message?: string, options?: ErrorOptions): URIError; +interface URIErrorConstructor { // @type-options no-export + new(message?: string, options?: ErrorOptions): URIError; - (message?: string, options?: ErrorOptions): URIError; - } + (message?: string, options?: ErrorOptions): URIError; +} - interface AggregateError extends Error { - errors: any[]; - } +interface AggregateError extends Error { // @type-options no-redefine + errors: any[]; - interface AggregateErrorConstructor { - new (errors: Iterable, message?: string): AggregateError; - (errors: Iterable, message?: string): AggregateError; - readonly prototype: AggregateError; - } + cause?: unknown; +} - var AggregateError: AggregateErrorConstructor; +interface AggregateErrorConstructor extends ErrorConstructor { + new (errors: Iterable, message?: string): AggregateError; + (errors: Iterable, message?: string): AggregateError; + readonly prototype: AggregateError; } -export {}; +declare var AggregateError: AggregateErrorConstructor; diff --git a/packages/core-js-types/src/56/proposals/float16.d.ts b/packages/core-js-types/src/56/proposals/float16.d.ts index e35d4f6e4515..5a2aad50513b 100644 --- a/packages/core-js-types/src/56/proposals/float16.d.ts +++ b/packages/core-js-types/src/56/proposals/float16.d.ts @@ -13,7 +13,7 @@ interface Math { // @type-options no-constructor f16round(x: number): number; } -interface DataView { // @type-options no-constructor +interface DataView { // @type-options no-constructor /** * Gets the Float16 value at the specified byte offset from the start of the view. There is * no alignment constraint; multibyte values may be fetched from any offset. diff --git a/packages/core-js-types/src/56/proposals/is-error.d.ts b/packages/core-js-types/src/56/proposals/is-error.d.ts index 6d4ca1586cd3..6532a3c237eb 100644 --- a/packages/core-js-types/src/56/proposals/is-error.d.ts +++ b/packages/core-js-types/src/56/proposals/is-error.d.ts @@ -5,7 +5,7 @@ // https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/esnext.error.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface ErrorConstructor { +interface ErrorConstructor { // @type-options no-redefine /** * Indicates whether the argument provided is a built-in Error instance or not. */ diff --git a/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts index 5b6994315aac..bd6c4e8f1e92 100644 --- a/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts +++ b/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts @@ -1,3 +1,5 @@ +/// + // proposal stage: 4 // https://github.com/tc39/proposal-promise-allSettled @@ -5,26 +7,20 @@ // https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2020.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -import { CoreJSPromiseSettledResult } from '../core-js-types/core-js-types'; - -declare global { - interface PromiseConstructor { - /** - * Creates a Promise that is resolved with an array of results when all - * of the provided Promises resolve or reject. - * @param values An array of Promises. - * @returns A new Promise. - */ - allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJSPromiseSettledResult>; }>; +interface PromiseConstructor { + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJS.CoreJSPromiseSettledResult>; }>; - /** - * Creates a Promise that is resolved with an array of results when all - * of the provided Promises resolve or reject. - * @param values An array of Promises. - * @returns A new Promise. - */ - allSettled(values: Iterable>): Promise>[]>; - } + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: Iterable>): Promise>[]>; } - -export {}; diff --git a/packages/core-js-types/src/56/proposals/promise-any.d.ts b/packages/core-js-types/src/56/proposals/promise-any.d.ts index fb5d182ba8d2..33e106534b71 100644 --- a/packages/core-js-types/src/56/proposals/promise-any.d.ts +++ b/packages/core-js-types/src/56/proposals/promise-any.d.ts @@ -21,11 +21,11 @@ interface PromiseConstructor { any(values: Iterable>): Promise>; } -interface AggregateError extends Error { +interface AggregateError extends Error { // @type-options no-redefine errors: any[]; } -interface AggregateErrorConstructor { // @type-options no-extends +interface AggregateErrorConstructor { // @type-options no-extends no-redefine new (errors: Iterable, message?: string): AggregateError; (errors: Iterable, message?: string): AggregateError; readonly prototype: AggregateError; diff --git a/packages/core-js-types/src/56/proposals/pure/array-buffer-base64.d.ts b/packages/core-js-types/src/56/proposals/pure/array-buffer-base64.d.ts index e69de29bb2d1..078b40cbed27 100644 --- a/packages/core-js-types/src/56/proposals/pure/array-buffer-base64.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/array-buffer-base64.d.ts @@ -0,0 +1,2 @@ +// empty +// Uint8Array isn't used in pure version diff --git a/packages/core-js-types/src/56/proposals/pure/array-buffer-transfer.d.ts b/packages/core-js-types/src/56/proposals/pure/array-buffer-transfer.d.ts index a7b1ea2e1681..d4ae08e3315e 100644 --- a/packages/core-js-types/src/56/proposals/pure/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/array-buffer-transfer.d.ts @@ -1,3 +1,6 @@ +// Motivation: We can use a readonly properties in the pure version, e.g. ArrayBuffer.detached. +// Motivation: We must create a constructor interface to allow creating our own ArrayBuffer implementation. + // proposal stage: 4 // https://github.com/tc39/proposal-arraybuffer-transfer diff --git a/packages/core-js-types/src/56/proposals/pure/array-constructor.d.ts b/packages/core-js-types/src/56/proposals/pure/array-constructor.d.ts index 1637b9571622..92a9617c8ad5 100644 --- a/packages/core-js-types/src/56/proposals/pure/array-constructor.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/array-constructor.d.ts @@ -1,5 +1,7 @@ /// +// Motivation: We must omit methods `fromAsync` and `isTemplateObject` because they cause a signature mismatch error. + // proposal stage: 2 // https://github.com/tc39/proposal-array-is-template-object @@ -11,10 +13,7 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt declare namespace CoreJS { - type ArrayConstructorBase = Omit< - ArrayConstructor, - 'fromAsync' | 'isTemplateObject' - >; + type ArrayConstructorBase = Omit; export interface CoreJSArrayConstructor extends ArrayConstructorBase { /** diff --git a/packages/core-js-types/src/56/proposals/pure/array-filtering.d.ts b/packages/core-js-types/src/56/proposals/pure/array-filtering.d.ts deleted file mode 100644 index a07733732064..000000000000 --- a/packages/core-js-types/src/56/proposals/pure/array-filtering.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -// proposal stage: 1 -// https://github.com/tc39/proposal-array-filtering - -declare namespace CoreJS { - interface CoreJSArray extends Array { - /** - * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the - * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; - } -} diff --git a/packages/core-js-types/src/56/proposals/pure/array-find-from-last.d.ts b/packages/core-js-types/src/56/proposals/pure/array-find-from-last.d.ts deleted file mode 100644 index 641b35d5e45f..000000000000 --- a/packages/core-js-types/src/56/proposals/pure/array-find-from-last.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-array-find-from-last - -// For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - interface CoreJSArray extends Array { - /** - * Returns the value of the last element in the array where predicate is true, and undefined - * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending - * order, until it finds one where predicate returns true. If such an element is found, findLast - * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T | undefined; - - /** - * Returns the index of the last element in the array where predicate is true, and -1 - * otherwise. - * @param predicate findLastIndex calls predicate once for each element of the array, in descending - * 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 this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; - } -} diff --git a/packages/core-js-types/src/56/proposals/pure/array-flat-map.d.ts b/packages/core-js-types/src/56/proposals/pure/array-flat-map.d.ts deleted file mode 100644 index 1adb5419d39e..000000000000 --- a/packages/core-js-types/src/56/proposals/pure/array-flat-map.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -/// - -// proposal stage: 4 -// https://github.com/tc39/proposal-flatMap - -// For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - export interface CoreJSArray extends Array { - - /** - * 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 callback 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 this keyword can refer in the callback function. If - * thisArg is omitted, undefined is used as this value. - */ - flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): 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(this: A, depth?: D): CoreJSFlatArray[]; - } -} diff --git a/packages/core-js-types/src/56/proposals/pure/array-from-async.d.ts b/packages/core-js-types/src/56/proposals/pure/array-from-async.d.ts index e69de29bb2d1..e1c84e60cb71 100644 --- a/packages/core-js-types/src/56/proposals/pure/array-from-async.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/array-from-async.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ./array-constructor.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/array-includes.d.ts b/packages/core-js-types/src/56/proposals/pure/array-includes.d.ts deleted file mode 100644 index 8e32b6cf5b26..000000000000 --- a/packages/core-js-types/src/56/proposals/pure/array-includes.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-Array.prototype.includes - -// For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2016.array.include.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - interface CoreJSArray extends Array { - /** - * 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(searchElement: T, fromIndex?: number): boolean; - } -} diff --git a/packages/core-js-types/src/56/proposals/pure/array-unique.d.ts b/packages/core-js-types/src/56/proposals/pure/array-unique.d.ts deleted file mode 100644 index a855544e610a..000000000000 --- a/packages/core-js-types/src/56/proposals/pure/array-unique.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -// proposal stage: 1 -// https://github.com/tc39/proposal-array-unique - -declare namespace CoreJS { - interface CoreJSArray extends Array { - /** - * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, - * or a property key to compare the value from each item - * @returns A new `Array` with unique items - */ - uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; - } -} diff --git a/packages/core-js-types/src/56/proposals/pure/async-iteration.d.ts b/packages/core-js-types/src/56/proposals/pure/async-iteration.d.ts index e69de29bb2d1..3d883ae22930 100644 --- a/packages/core-js-types/src/56/proposals/pure/async-iteration.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/async-iteration.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ./symbol.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/async-iterator-helpers.d.ts b/packages/core-js-types/src/56/proposals/pure/async-iterator-helpers.d.ts index 077b25cf6c91..fe09cca81e44 100644 --- a/packages/core-js-types/src/56/proposals/pure/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/async-iterator-helpers.d.ts @@ -1,5 +1,7 @@ -/// -/// +/// +/// + +// Motivation: Has dependencies on internal types, e.g. AsyncIterable, AsyncIteratorObject // proposal stage: 2 // https://github.com/tc39/proposal-async-iterator-helpers @@ -95,4 +97,12 @@ declare namespace CoreJS { } var CoreJSAsyncIterator: CoreJSAsyncIteratorConstructor; + + interface CoreJSIterator extends Iterator { + /** + * Creates an `AsyncIterator` from the current `Iterator` + * @returns A new `AsyncIterator` instance + */ + toAsync(): CoreJSAsyncIteratorObject; + } } diff --git a/packages/core-js-types/src/56/proposals/pure/await-dictionary.d.ts b/packages/core-js-types/src/56/proposals/pure/await-dictionary.d.ts deleted file mode 100644 index 351dc2b16fdb..000000000000 --- a/packages/core-js-types/src/56/proposals/pure/await-dictionary.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -// proposal stage: 1 -// https://github.com/tc39/proposal-await-dictionary - -declare namespace CoreJS { - export interface CoreJSPromiseConstructor extends PromiseConstructor { - - /** - * Takes an object of promises and returns a single Promise that resolves to an object - * with the same keys and fulfilled values, or rejects as soon as any of the input promises rejects. - * @param promises An object of promises - * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. - */ - allKeyed>>(promises: D): Promise<{ [k in keyof D]: Awaited }>; - - /** - * Takes an object whose values are promises and returns a single `Promise` that resolves - * to an object with the same keys, after all of the input promises have settled. - * @param promises An object of promises - * @returns A new Promise that resolves to an object with the same keys as the input object, - * where each key maps to the settlement result ({ status, value } or { status, reason }) of the corresponding promise. - */ - allSettledKeyed>>(promises: D): Promise<{ [k in keyof D]: CoreJSPromiseSettledResult> }>; - } - - var CoreJSPromise: CoreJSPromiseConstructor; -} diff --git a/packages/core-js-types/src/56/proposals/pure/change-array-by-copy.d.ts b/packages/core-js-types/src/56/proposals/pure/change-array-by-copy.d.ts deleted file mode 100644 index 0ec42d1ba2b1..000000000000 --- a/packages/core-js-types/src/56/proposals/pure/change-array-by-copy.d.ts +++ /dev/null @@ -1,54 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-change-array-by-copy - -// For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - export interface CoreJSArray extends Array { - /** - * @returns A copy of an array with its elements reversed. - */ - toReversed(): T[]; - - /** - * Returns a copy of an array with its elements sorted. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. - * ```ts - * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] - * ``` - */ - toSorted(compareFn?: (a: T, b: T) => number): T[]; - - /** - * Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. - * @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 copied array in place of the deleted elements. - * @returns The copied array. - */ - toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; - - /** - * Copies an array and removes elements while returning the remaining 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 A copy of the original array with the remaining elements. - */ - toSpliced(start: number, deleteCount?: number): T[]; - - /** - * Copies an array, then overwrites the value at the provided index with the - * given value. If the index is negative, then it replaces from the end - * of the array. - * @param index The index of the value to overwrite. If the index is - * negative, then it replaces from the end of the array. - * @param value The value to write into the copied array. - * @returns The copied array with the updated value. - */ - with(index: number, value: T): T[]; - } -} diff --git a/packages/core-js-types/src/56/proposals/pure/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/56/proposals/pure/data-view-get-set-uint8-clamped.d.ts deleted file mode 100644 index 9b861be3b6f4..000000000000 --- a/packages/core-js-types/src/56/proposals/pure/data-view-get-set-uint8-clamped.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -// proposal stage: 1 -// https://github.com/tc39/proposal-dataview-get-set-uint8clamped - -declare namespace CoreJS { - var CoreJSDataView: CoreJSDataView; - - export interface CoreJSDataView extends DataView { - /** - * Reads an unsigned 8-bit integer at the specified byte offset from the DataView, - * interpreting the byte as a clamped 8-bit unsigned value (same as Uint8ClampedArray). - * @param byteOffset The offset, in bytes, from the start of the DataView. - * @returns The unsigned 8-bit integer at the given offset. - */ - getUint8Clamped(byteOffset: number): number; - - /** - * Stores a value as an unsigned 8-bit integer at the specified byte offset in the DataView, - * clamping the input to the 0–255 range and rounding to the nearest integer as per Uint8ClampedArray behavior. - * @param byteOffset The offset, in bytes, from the start of the DataView. - * @param value The value to store; it will be clamped to the range 0–255 and rounded to the nearest integer. - */ - setUint8Clamped(byteOffset: number, value: number): void; - } -} diff --git a/packages/core-js-types/src/56/proposals/pure/decorator-metadata.d.ts b/packages/core-js-types/src/56/proposals/pure/decorator-metadata.d.ts index f30373dfff76..4228026c7e05 100644 --- a/packages/core-js-types/src/56/proposals/pure/decorator-metadata.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/decorator-metadata.d.ts @@ -1,9 +1,13 @@ /// +// Motivation: Symbol is replaced with our own + // proposal stage: 3 // https://github.com/tc39/proposal-decorator-metadata declare namespace CoreJS { + // Symbol.metadata is moved to ./symbol.d.ts + var CoreJSFunction: CoreJSFunction; export interface CoreJSFunction extends Function { diff --git a/packages/core-js-types/src/56/proposals/pure/error-cause.d.ts b/packages/core-js-types/src/56/proposals/pure/error-cause.d.ts deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/core-js-types/src/56/proposals/pure/error.d.ts b/packages/core-js-types/src/56/proposals/pure/error.d.ts deleted file mode 100644 index a27eb26b3d62..000000000000 --- a/packages/core-js-types/src/56/proposals/pure/error.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-error-cause - -// For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/es2022.error.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -// proposal stage: 3 -// https://github.com/tc39/proposal-is-error - -// For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/esnext.error.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - export interface ErrorOptions { - cause?: unknown; - } - - export interface CoreJSError extends Error { - cause?: unknown; // ts <= 4.7 Error | undefined - } - - export interface CoreJSErrorConstructor extends ErrorConstructor { - new(message?: string, options?: ErrorOptions): CoreJSError; - - (message?: string, options?: ErrorOptions): CoreJSError; - - /** - * Indicates whether the argument provided is a built-in Error instance or not. - */ - isError(value: any): value is Error; - } - - export interface CoreJSAggregateError extends Error { - errors: any[]; - } - - export interface CoreJSAggregateErrorConstructor extends ErrorConstructor { - readonly prototype: CoreJSAggregateError; - - new(errors: Iterable, message?: string): CoreJSAggregateError; - - (errors: Iterable, message?: string): CoreJSAggregateError; - } - - export var CoreJSError: CoreJSErrorConstructor; - export var CoreJSAggregateError: CoreJSAggregateErrorConstructor; -} diff --git a/packages/core-js-types/src/56/proposals/pure/explicit-resource-management.d.ts b/packages/core-js-types/src/56/proposals/pure/explicit-resource-management.d.ts index d8b7c8952ba2..d3dfc48cebae 100644 --- a/packages/core-js-types/src/56/proposals/pure/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/explicit-resource-management.d.ts @@ -1,5 +1,7 @@ /// +// Motivation: Symbol is replaced with our own + // proposal stage: 3 // https://github.com/tc39/proposal-explicit-resource-management diff --git a/packages/core-js-types/src/56/proposals/pure/float16.d.ts b/packages/core-js-types/src/56/proposals/pure/float16.d.ts deleted file mode 100644 index 230a3a96f8f5..000000000000 --- a/packages/core-js-types/src/56/proposals/pure/float16.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-float16array - -// For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.float16.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - var CoreJSMath: CoreJSMath; - - export interface CoreJSMath extends Math { - /** - * Returns the nearest half precision float representation of a number. - * @param x A numeric expression. - */ - f16round(x: number): number; - } - - var CoreJSDataView: CoreJSDataView; - - export interface CoreJSDataView extends DataView { - /** - * Gets the Float16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multibyte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - * @param littleEndian If false or undefined, a big-endian value should be read. - */ - getFloat16(byteOffset: number, littleEndian?: boolean): number; - - /** - * Stores a Float16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written. - */ - setFloat16(byteOffset: number, value: number, littleEndian?: boolean): void; - } -} diff --git a/packages/core-js-types/src/56/proposals/pure/is-error.d.ts b/packages/core-js-types/src/56/proposals/pure/is-error.d.ts deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-chunking.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator-chunking.d.ts index e69de29bb2d1..7da4b2567937 100644 --- a/packages/core-js-types/src/56/proposals/pure/iterator-chunking.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/iterator-chunking.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ./iterator.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-helpers.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator-helpers.d.ts index e69de29bb2d1..7da4b2567937 100644 --- a/packages/core-js-types/src/56/proposals/pure/iterator-helpers.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/iterator-helpers.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ./iterator.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-join.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator-join.d.ts index e69de29bb2d1..7da4b2567937 100644 --- a/packages/core-js-types/src/56/proposals/pure/iterator-join.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/iterator-join.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ./iterator.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-joint.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator-joint.d.ts index e69de29bb2d1..7da4b2567937 100644 --- a/packages/core-js-types/src/56/proposals/pure/iterator-joint.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/iterator-joint.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ./iterator.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-range.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator-range.d.ts index e69de29bb2d1..7da4b2567937 100644 --- a/packages/core-js-types/src/56/proposals/pure/iterator-range.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/iterator-range.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ./iterator.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-sequencing.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator-sequencing.d.ts index e69de29bb2d1..7da4b2567937 100644 --- a/packages/core-js-types/src/56/proposals/pure/iterator-sequencing.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/iterator-sequencing.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ./iterator.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/iterator.d.ts b/packages/core-js-types/src/56/proposals/pure/iterator.d.ts index 6eb8f68bdb86..83a7ce12f56d 100644 --- a/packages/core-js-types/src/56/proposals/pure/iterator.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/iterator.d.ts @@ -1,5 +1,7 @@ /// +// Motivation: Has dependencies on internal types + // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-chunking @@ -18,9 +20,6 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-sequencing -// proposal stage: 2 -// https://github.com/tc39/proposal-async-iterator-helpers - // For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt @@ -60,7 +59,6 @@ declare namespace CoreJS { [CoreJSSymbol.asyncIterator](): CoreJSAsyncIterator; } - export interface CoreJSIteratorObject extends Iterator {} export interface CoreJSIteratorObject extends CoreJSDisposable {} export interface CoreJSIterator extends Iterator { @@ -171,12 +169,6 @@ declare namespace CoreJS { find(predicate: (value: T, index: number) => unknown): T | undefined; join(separator?: unknown): string; - - /** - * Creates an `AsyncIterator` from the current `Iterator` - * @returns A new `AsyncIterator` instance - */ - toAsync(): CoreJSAsyncIteratorObject; } export interface CoreJSIteratorConstructor { diff --git a/packages/core-js-types/src/56/proposals/pure/pattern-matching.d.ts b/packages/core-js-types/src/56/proposals/pure/pattern-matching.d.ts index e69de29bb2d1..3d883ae22930 100644 --- a/packages/core-js-types/src/56/proposals/pure/pattern-matching.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/pattern-matching.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ./symbol.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/promise-all-settled.d.ts b/packages/core-js-types/src/56/proposals/pure/promise-all-settled.d.ts deleted file mode 100644 index 53684ee5ad9f..000000000000 --- a/packages/core-js-types/src/56/proposals/pure/promise-all-settled.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/// - -// proposal stage: 4 -// https://github.com/tc39/proposal-promise-allSettled - -// For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2020.promise.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - var CoreJSPromise: CoreJSPromiseConstructor; - - export interface CoreJSPromiseConstructor extends PromiseConstructor { - - /** - * Creates a Promise that is resolved with an array of results when all - * of the provided Promises resolve or reject. - * @param values An array of Promises. - * @returns A new Promise. - */ - allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJSPromiseSettledResult>; }>; - - /** - * Creates a Promise that is resolved with an array of results when all - * of the provided Promises resolve or reject. - * @param values An array of Promises. - * @returns A new Promise. - */ - allSettled(values: Iterable>): Promise>[]>; - } -} diff --git a/packages/core-js-types/src/56/proposals/pure/promise-any.d.ts b/packages/core-js-types/src/56/proposals/pure/promise-any.d.ts deleted file mode 100644 index d73022d5540e..000000000000 --- a/packages/core-js-types/src/56/proposals/pure/promise-any.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-promise-any - -// For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2021.promise.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - export interface CoreJSPromiseConstructor extends PromiseConstructor { - - /** - * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. - * @param values An array or iterable of Promises. - * @returns A new Promise. - */ - any(values: T): Promise>; - - /** - * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. - * @param values An array or iterable of Promises. - * @returns A new Promise. - */ - any(values: Iterable>): Promise>; - } - - var CoreJSPromise: CoreJSPromiseConstructor; -} diff --git a/packages/core-js-types/src/56/proposals/pure/relative-indexing-method.d.ts b/packages/core-js-types/src/56/proposals/pure/relative-indexing-method.d.ts index e999824215cf..87acb99280b7 100644 --- a/packages/core-js-types/src/56/proposals/pure/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/relative-indexing-method.d.ts @@ -1,4 +1,6 @@ -/// +/// + +// Motivation: We should use String without the matchAll method to avoid signature conflicts // proposal stage: 4 // https://github.com/tc39/proposal-relative-indexing-method diff --git a/packages/core-js-types/src/56/proposals/pure/string-left-right-trim.d.ts b/packages/core-js-types/src/56/proposals/pure/string-left-right-trim.d.ts index 2cac498ddd43..65ab4d4bf97f 100644 --- a/packages/core-js-types/src/56/proposals/pure/string-left-right-trim.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/string-left-right-trim.d.ts @@ -1,4 +1,6 @@ -/// +/// + +// Motivation: We should use String without the matchAll method to avoid signature conflicts // proposal stage: 4 // https://github.com/tc39/proposal-string-left-right-trim diff --git a/packages/core-js-types/src/56/proposals/pure/string-match-all.d.ts b/packages/core-js-types/src/56/proposals/pure/string-match-all.d.ts index 8186dcaa0bce..193d192071d5 100644 --- a/packages/core-js-types/src/56/proposals/pure/string-match-all.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/string-match-all.d.ts @@ -1,5 +1,7 @@ -/// -/// +/// +/// + +// Motivation: We should use String without the matchAll method to avoid signature conflicts // proposal stage: 4 // https://github.com/tc39/proposal-string-matchall @@ -13,8 +15,6 @@ declare namespace CoreJS { [Symbol.iterator](): CoreJSRegExpStringIterator; } - type StringBase = Omit; - export interface CoreJSString extends StringBase { /** diff --git a/packages/core-js-types/src/56/proposals/pure/string-padding.d.ts b/packages/core-js-types/src/56/proposals/pure/string-padding.d.ts index f6c9a15a82e8..7ea6e2d94fba 100644 --- a/packages/core-js-types/src/56/proposals/pure/string-padding.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/string-padding.d.ts @@ -1,4 +1,6 @@ -/// +/// + +// Motivation: We should use String without the matchAll method to avoid signature conflicts // proposal stage: 4 // https://github.com/tc39/proposal-string-pad-start-end diff --git a/packages/core-js-types/src/56/proposals/pure/string-replace-all.d.ts b/packages/core-js-types/src/56/proposals/pure/string-replace-all.d.ts index 8d110b965291..3c216b0f4ce4 100644 --- a/packages/core-js-types/src/56/proposals/pure/string-replace-all.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/string-replace-all.d.ts @@ -1,4 +1,6 @@ -/// +/// + +// Motivation: We should use String without the matchAll method to avoid signature conflicts // proposal stage: 4 // https://github.com/tc39/proposal-string-replaceall diff --git a/packages/core-js-types/src/56/proposals/pure/symbol-description.d.ts b/packages/core-js-types/src/56/proposals/pure/symbol-description.d.ts index e69de29bb2d1..3d883ae22930 100644 --- a/packages/core-js-types/src/56/proposals/pure/symbol-description.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/symbol-description.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ./symbol.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/symbol-predicates.d.ts b/packages/core-js-types/src/56/proposals/pure/symbol-predicates.d.ts index e69de29bb2d1..3d883ae22930 100644 --- a/packages/core-js-types/src/56/proposals/pure/symbol-predicates.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/symbol-predicates.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ./symbol.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/symbol.d.ts b/packages/core-js-types/src/56/proposals/pure/symbol.d.ts index 78ce50ea7a9c..bc1c3124efda 100644 --- a/packages/core-js-types/src/56/proposals/pure/symbol.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/symbol.d.ts @@ -1,3 +1,6 @@ +// Motivation: We should use SymbolConstructor without asyncIterator, matchAll, dispose, asyncDispose, +// customMatcher, metadata properties to avoid signature conflicts + // proposal stage: 3 // https://github.com/tc39/proposal-explicit-resource-management @@ -12,7 +15,6 @@ // For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2018.asynciterable.d.ts#L4 -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt // proposal stage: 3 // https://github.com/tc39/proposal-decorator-metadata @@ -22,7 +24,6 @@ // For ensuring compatibility with TypeScript standard types, this code is based on: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt // proposal stage: 4 // https://github.com/tc39/proposal-Symbol-description diff --git a/packages/core-js-types/src/56/proposals/pure/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/56/proposals/pure/well-formed-unicode-strings.d.ts index 24d3576a4021..4b186440f9d0 100644 --- a/packages/core-js-types/src/56/proposals/pure/well-formed-unicode-strings.d.ts +++ b/packages/core-js-types/src/56/proposals/pure/well-formed-unicode-strings.d.ts @@ -1,4 +1,6 @@ -/// +/// + +// Motivation: We should use String without the matchAll method to avoid signature conflicts // proposal stage: 4 // https://github.com/tc39/proposal-is-usv-string diff --git a/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts index e773c772cfe8..a1cb809ec54c 100644 --- a/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts @@ -6,7 +6,7 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface String { // @type-options no-redefine +interface String { // @type-options no-export /** * Returns a new String consisting of the single UTF-16 code unit located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -14,7 +14,7 @@ interface String { // @type-options no-redefine at(index: number): string | undefined; } -interface Array { // @type-options no-redefine +interface Array { // @type-options no-export /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -22,7 +22,7 @@ interface Array { // @type-options no-redefine at(index: number): T | undefined; } -interface ReadonlyArray { // @type-options no-redefine +interface ReadonlyArray { // @type-options no-export /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -30,7 +30,7 @@ interface ReadonlyArray { // @type-options no-redefine at(index: number): T | undefined; } -interface Int8Array { // @type-options no-redefine +interface Int8Array { // @type-options no-export /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -38,7 +38,7 @@ interface Int8Array { // @type-options no-redefine at(index: number): number | undefined; } -interface Uint8Array { // @type-options no-redefine +interface Uint8Array { // @type-options no-export /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -46,7 +46,7 @@ interface Uint8Array { // @type-options no-redefine at(index: number): number | undefined; } -interface Uint8ClampedArray { // @type-options no-redefine +interface Uint8ClampedArray { // @type-options no-export /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -54,7 +54,7 @@ interface Uint8ClampedArray { // @type-options no-redefine at(index: number): number | undefined; } -interface Int16Array { // @type-options no-redefine +interface Int16Array { // @type-options no-export /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -62,7 +62,7 @@ interface Int16Array { // @type-options no-redefine at(index: number): number | undefined; } -interface Uint16Array { // @type-options no-redefine +interface Uint16Array { // @type-options no-export /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -70,7 +70,7 @@ interface Uint16Array { // @type-options no-redefine at(index: number): number | undefined; } -interface Int32Array { // @type-options no-redefine +interface Int32Array { // @type-options no-export /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -78,7 +78,7 @@ interface Int32Array { // @type-options no-redefine at(index: number): number | undefined; } -interface Uint32Array { // @type-options no-redefine +interface Uint32Array { // @type-options no-export /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -86,7 +86,7 @@ interface Uint32Array { // @type-options no-redefine at(index: number): number | undefined; } -interface Float32Array { // @type-options no-redefine +interface Float32Array { // @type-options no-export /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -94,7 +94,7 @@ interface Float32Array { // @type-options no-redefine at(index: number): number | undefined; } -interface Float64Array { // @type-options no-redefine +interface Float64Array { // @type-options no-export /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -102,7 +102,7 @@ interface Float64Array { // @type-options no-redefine at(index: number): number | undefined; } -interface BigInt64Array { // @type-options no-redefine +interface BigInt64Array { // @type-options no-export /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -110,7 +110,7 @@ interface BigInt64Array { // @type-options no-redefine at(index: number): bigint | undefined; } -interface BigUint64Array { // @type-options no-redefine +interface BigUint64Array { // @type-options no-export /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. diff --git a/packages/core-js-types/src/56/web/btoa.d.ts b/packages/core-js-types/src/56/web/atob-btoa.d.ts similarity index 53% rename from packages/core-js-types/src/56/web/btoa.d.ts rename to packages/core-js-types/src/56/web/atob-btoa.d.ts index f4eac3d5ad11..e4fc647b51a0 100644 --- a/packages/core-js-types/src/56/web/btoa.d.ts +++ b/packages/core-js-types/src/56/web/atob-btoa.d.ts @@ -1,3 +1,10 @@ +/** + * Decodes a string of data which has been encoded using Base64 encoding. + * @param data A base64-encoded string, using the alphabet produced by btoa(). + * @returns A binary string containing raw bytes decoded from encodedData. + */ +declare function atob(data: string): string; + /** * Creates a Base64-encoded ASCII string from a binary string * (i.e., a string in which each character in the string is treated as a byte of binary data) diff --git a/packages/core-js-types/src/56/web/atob.d.ts b/packages/core-js-types/src/56/web/atob.d.ts deleted file mode 100644 index d08b3902da6c..000000000000 --- a/packages/core-js-types/src/56/web/atob.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Decodes a string of data which has been encoded using Base64 encoding. - * @param data A base64-encoded string, using the alphabet produced by btoa(). - * @returns A binary string containing raw bytes decoded from encodedData. - */ -declare function atob(data: string): string; diff --git a/packages/core-js-types/src/56/proposals/pure/dom-exception.d.ts b/packages/core-js-types/src/56/web/pure/dom-exception.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/dom-exception.d.ts rename to packages/core-js-types/src/56/web/pure/dom-exception.d.ts diff --git a/packages/core-js/modules/web.atob.js b/packages/core-js/modules/web.atob.js index 10da7c1c0097..b8954e7464ed 100644 --- a/packages/core-js/modules/web.atob.js +++ b/packages/core-js/modules/web.atob.js @@ -1,4 +1,4 @@ -// types: web/atob +// types: web/atob-btoa 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.btoa.js b/packages/core-js/modules/web.btoa.js index 127020dc1058..4989240f341c 100644 --- a/packages/core-js/modules/web.btoa.js +++ b/packages/core-js/modules/web.btoa.js @@ -1,4 +1,4 @@ -// types: web/btoa +// types: web/atob-btoa 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/scripts/build-types/pure.mjs b/scripts/build-types/pure.mjs index b908fc6da712..aa82162c9b7e 100644 --- a/scripts/build-types/pure.mjs +++ b/scripts/build-types/pure.mjs @@ -50,7 +50,7 @@ function processLines(lines, prefix) { return null; } if (line.includes('export {')) return null; - if (/^\s*(?:declare\s+)?interface\s+\w+\s*extends/.test(line) || options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+\s*\{/.test(line)) { + if (/^\s*(?:declare\s+)?interface\s+\w+\s*extends/.test(line) || options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+(?:<[^>]+>)?\s*\{/.test(line)) { if (!options.noPrefix) { const m = line.match(/interface\s+(?\w+)/); if (m && m.groups) { @@ -81,11 +81,11 @@ function processLines(lines, prefix) { if (/^\s*(?:declare\s+)?function/.test(line)) { return line.replace(/^(?\s*)(?:declare\s+)?function\s+(?\w+)/, `$export function ${ !options.noPrefix ? prefix : '' }$`); } - if (/:\s*\w/.test(line)) { + if (/(?::|\|)\s*\w/.test(line)) { const sortedPrefixed = prefixed.sort((a, b) => b.length - a.length); sortedPrefixed.forEach(item => { - const reg = new RegExp(`: ${ item }([,;<)])`, 'g'); - line = line.replace(reg, `: ${ prefix }${ item }$1`); + const reg = new RegExp(`(?:||) ${ item }(?[,;<)])`, 'g'); + line = line.replace(reg, `$ ${ prefix }${ item }$`); }); } if (/^\s*(?:declare)?\svar/.test(line)) { diff --git a/tests/eslint/package-lock.json b/tests/eslint/package-lock.json index f17ad719c99f..e1a94fcb1653 100644 --- a/tests/eslint/package-lock.json +++ b/tests/eslint/package-lock.json @@ -439,7 +439,8 @@ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", "dev": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/@types/json-schema": { "version": "7.0.15", @@ -761,6 +762,7 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -877,6 +879,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -1251,6 +1254,7 @@ "integrity": "sha512-20MV9SUdeN6Jd84xESsKhRly+/vxI+hwvpBMA93s+9dAcjdCuCojn4IqUGS3lvVaqjVYGYHSRMCpeFtF2rQYxQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", @@ -2482,6 +2486,7 @@ "integrity": "sha512-75EA7EWZExL/j+MDKQrRbdzcRI2HOkRlmUw8fZJc1ioqFEOvBsq7Rt+A6yCxOt9w/TYNpkt52gC6nm/g5tFIng==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "acorn": "^8.5.0", "eslint-visitor-keys": "^5.0.0", @@ -4244,6 +4249,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -4328,6 +4334,7 @@ "dev": true, "hasInstallScript": true, "license": "MIT", + "peer": true, "dependencies": { "napi-postinstall": "^0.3.0" }, diff --git a/tests/type-definitions/package-lock.json b/tests/type-definitions/package-lock.json index 467dd7d0c49d..ddede5c1dd20 100644 --- a/tests/type-definitions/package-lock.json +++ b/tests/type-definitions/package-lock.json @@ -4,24 +4,17 @@ "requires": true, "packages": { "": { - "name": "tests/type-definitions", - "devDependencies": { - "@core-js/types": "../../packages/core-js-types/" - } + "name": "tests/type-definitions" }, "../../packages/core-js-types": { "name": "@core-js/types", "version": "4.0.0-alpha.0", - "dev": true, + "extraneous": true, "license": "SEE LICENSE IN LICENSE.md", "funding": { "type": "opencollective", "url": "https://opencollective.com/core-js" } - }, - "node_modules/@core-js/types": { - "resolved": "../../packages/core-js-types", - "link": true } } } diff --git a/tests/type-definitions/package.json b/tests/type-definitions/package.json index ea12b3a8c99b..fcf49f09a0c2 100644 --- a/tests/type-definitions/package.json +++ b/tests/type-definitions/package.json @@ -1,6 +1,3 @@ { - "name": "tests/type-definitions", - "devDependencies": { - "@core-js/types": "../../packages/core-js-types/" - } + "name": "tests/type-definitions" } diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index cec9996bc01a..aedce35c38ad 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -37,12 +37,12 @@ const libs = [ let tested = 0; let failed = 0; -const getEnvPath = function (env) { +function getEnvPath(env) { if (!env) return null; return path.join(TMP_DIR, env.replaceAll('/', '-').replaceAll('@', '')); -}; +} -const runTestsOnEnv = async function ({ typeScriptVersion, target, type, env, lib }) { +async function runTestsOnEnv({ typeScriptVersion, target, type, env, lib }) { $.verbose = false; const envLibName = env ? env.substring(0, env.lastIndexOf('@')) : ''; const command = `npx -p typescript@${ typeScriptVersion }${ env ? ` -p ${ env }` : '' } ` @@ -65,9 +65,9 @@ const runTestsOnEnv = async function ({ typeScriptVersion, target, type, env, li failed++; echo(`$ ${ chalk.red(command) }\n ${ error }`); } -}; +} -const runLimited = async function (configs, limit) { +async function runLimited(configs, limit) { let i = 0; async function worker() { while (i < configs.length) { @@ -76,7 +76,7 @@ const runLimited = async function (configs, limit) { } } await Promise.all(Array.from({ length: limit }, worker)); -}; +} const taskConfigs = []; for (const type of types) { @@ -91,11 +91,11 @@ for (const type of types) { } } -const clearTmpDir = async function () { +async function clearTmpDir() { await $`rm -rf ${ TMP_DIR }`; -}; +} -const prepareEnvironment = async function (environments, coreJsTypes) { +async function prepareEnvironment(environments, coreJsTypes) { await clearTmpDir(); for (const env of environments) { if (!env) continue; @@ -110,7 +110,7 @@ const prepareEnvironment = async function (environments, coreJsTypes) { }); } } -}; +} await $`npx -p typescript@5.9 tsc`; await $`npx -p typescript@5.9 tsc -p tsconfig.templates.import.json`; From 38dd1b172ca56560b9957ca28e76f49c52289b17 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 8 Dec 2025 19:52:38 +0700 Subject: [PATCH 072/315] All & partial type definitions test commands --- package.json | 1 + tests/type-definitions/runner.mjs | 31 +++++++++++++++---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index d79f09be86b9..8a207e258622 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "test-compat-tools": "npm run zxi tests/compat-tools/index.mjs", "test-templates": "npm run zxi tests/templates/templates.mjs", "test-type-definitions": "npm run zxi time cd tests/type-definitions/runner.mjs", + "test-type-definitions-all": "ALL_TYPE_DEFINITIONS_TESTS=1 npm run zxi time cd tests/type-definitions/runner.mjs", "test262": "npm run zxi time cd tests/test262/runner.mjs", "refresh": "UPDATE_DEPENDENCIES=1 npm run prepare-monorepo && npm run test-raw", "refresh-safe": "npm run prepare-monorepo && npm run test-raw", diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index aedce35c38ad..61457ea762f3 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -3,6 +3,7 @@ import { fs } from 'zx'; const { mkdir, writeJson } = fs; const TMP_DIR = './tmp/'; +const ALL_TESTS = process.env.ALL_TYPE_DEFINITIONS_TESTS === '1'; const targets = [ 'esnext', @@ -117,19 +118,17 @@ await $`npx -p typescript@5.9 tsc -p tsconfig.templates.import.json`; await $`npx -p typescript@5.9 tsc -p tsconfig.entries.json`; await $`npx -p typescript@5.9 -p @types/node@24 tsc -p tsconfig.templates.require.json`; -// await $`npx -p typescript@5.9 tsc -p pure/tsconfig.json --target es6 --lib es6`; -// await $`npx -p typescript@5.9 tsc -p global/tsconfig.json --target esnext --lib esnext,dom`; - -const numCPUs = os.cpus().length; -await prepareEnvironment(envs, types); -await runLimited(taskConfigs, Math.max(numCPUs - 1, 1)); -await clearTmpDir(); -echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); - -// await $`tsc -p proposals/global/tsconfig.esnext.json`; -// await $`tsc -p proposals/global/tsconfig.es2023.json`; -// await $`tsc -p proposals/global/tsconfig.es6.json`; -// -// await $`tsc -p proposals/pure/tsconfig.esnext.json`; -// await $`tsc -p proposals/pure/tsconfig.es2023.json`; -// await $`tsc -p proposals/pure/tsconfig.es6.node.json`; +if (!ALL_TESTS) { + await $`npx -p typescript@5.9 tsc -p pure/tsconfig.json --target es6 --lib es6`; + await $`npx -p typescript@5.9 tsc -p pure/tsconfig.json --target es2023 --lib es2023`; + await $`npx -p typescript@5.9 tsc -p pure/tsconfig.json --target esnext --lib esnext`; + await $`npx -p typescript@5.9 tsc -p global/tsconfig.json --target es6 --lib es6,dom`; + await $`npx -p typescript@5.9 tsc -p global/tsconfig.json --target es2023 --lib es2023,dom`; + await $`npx -p typescript@5.9 tsc -p global/tsconfig.json --target esnext --lib esnext,dom`; +} else { + const numCPUs = os.cpus().length; + await prepareEnvironment(envs, types); + await runLimited(taskConfigs, Math.max(numCPUs - 1, 1)); + await clearTmpDir(); + echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); +} From ee0a1c1b6d1c09b1df33dfe63b73a0963defd81a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 9 Dec 2025 00:23:53 +0700 Subject: [PATCH 073/315] package.json builder for types --- packages/core-js-types/package.json | 36 ++++++++++++----------- scripts/build-types/config.mjs | 2 ++ scripts/build-types/index.mjs | 43 ++++++++++++++++++++++++---- scripts/build-types/package.tpl.json | 30 +++++++++++++++++++ 4 files changed, 90 insertions(+), 21 deletions(-) create mode 100644 scripts/build-types/package.tpl.json diff --git a/packages/core-js-types/package.json b/packages/core-js-types/package.json index 77493dc29d2b..2190413151cf 100644 --- a/packages/core-js-types/package.json +++ b/packages/core-js-types/package.json @@ -26,30 +26,40 @@ "url": "http://zloirock.ru" }, "types": "./actual.d.ts", + "sideEffects": false, "typesVersions": { ">=5.6": { - "*": ["./dist/56/*"] + "*": [ + "./dist/56/*" + ] }, ">=5.2": { - "*": ["./dist/52/*"] + "*": [ + "./dist/52/*" + ] } }, "exports": { - ".": { + "./es": { + "types@>=5.6": "./dist/56/es.d.ts", + "types": "./dist/52/es.d.ts", + "default": "./dist/56/es.d.ts" + }, + "./stable": { + "types@>=5.6": "./dist/56/stable.d.ts", + "types": "./dist/52/stable.d.ts", + "default": "./dist/56/stable.d.ts" + }, + "./actual": { "types@>=5.6": "./dist/56/actual.d.ts", "types": "./dist/52/actual.d.ts", "default": "./dist/56/actual.d.ts" }, - "./actual": { + ".": { "types@>=5.6": "./dist/56/actual.d.ts", "types": "./dist/52/actual.d.ts", "default": "./dist/56/actual.d.ts" }, - "./es": { - "types@>=5.6": "./dist/56/es.d.ts", - "types": "./dist/52/es.d.ts", - "default": "./dist/56/es.d.ts" - }, "./full": { "types@>=5.6": "./dist/56/full.d.ts", "types": "./dist/52/full.d.ts", @@ -60,16 +70,10 @@ "types": "./dist/52/pure.d.ts", "default": "./dist/56/pure.d.ts" }, - "./stable": { - "types@>=5.6": "./dist/56/stable.d.ts", - "types": "./dist/52/stable.d.ts", - "default": "./dist/56/stable.d.ts" - }, "./proposals/*": { "types@>=5.6": "./dist/56/proposals/*.d.ts", "types": "./dist/52/proposals/*.d.ts", "default": "./dist/56/proposals/*.d.ts" } - }, - "sideEffects": false + } } diff --git a/scripts/build-types/config.mjs b/scripts/build-types/config.mjs index 12dd0bf274a2..70d25b071c78 100644 --- a/scripts/build-types/config.mjs +++ b/scripts/build-types/config.mjs @@ -3,5 +3,7 @@ export default { bundleName: 'core-js-types', latestTsVersion: 59, packageName: '@core-js/', + packageTemplate: 'scripts/build-types/package.tpl.json', + packageDir: 'packages/core-js-types/', srcDir: 'packages/core-js-types/src/', }; diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 321bc74b65fc..777afa8170af 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -7,7 +7,7 @@ import { argv, path, fs } from 'zx'; import { expandModules, modulesToStage } from '../build-entries/helpers.mjs'; import { preparePureTypes } from './pure.mjs'; -const { copy, outputFile, pathExists, readdir, remove } = fs; +const { copy, outputFile, pathExists, readdir, readJson, remove, writeJson } = fs; const versionArg = argv._.find(item => item.startsWith('version=')); const VERSION = versionArg ? versionArg.slice('version='.length) : undefined; @@ -156,13 +156,46 @@ async function buildTypesForTSVersion(tsVersion) { await prependImports(tsVersion); } +async function buildPackageJson(breakpoints, namespaces) { + breakpoints = breakpoints.sort().reverse(); + const packageJson = await readJson(config.packageTemplate); + const defaultBreakpoint = Math.max(...breakpoints); + packageJson.typesVersions = {}; + breakpoints.forEach(breakpoint => { + packageJson.typesVersions[`>=${ breakpoint }`] = { + '*': [`./dist/${ breakpoint.toString().replace('.', '') }/*`], + }; + }); + packageJson.exports = {}; + Object.entries(namespaces).forEach(([namespace, options]) => { + const namespaceKey = namespace ? `./${ namespace }${ options.isDir ? '/*' : '' }` : '.'; + packageJson.exports[namespaceKey] = {}; + breakpoints.forEach((breakpoint, index) => { + const isLast = index === breakpoints.length - 1; + const breakpointString = breakpoint.toString().replace('.', ''); + packageJson.exports[namespaceKey][`types${ isLast ? '' : `@>=${ breakpoint }` }`] = `./dist/${ breakpointString }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; + }); + packageJson.exports[namespaceKey].default = `./dist/${ defaultBreakpoint.toString().replace('.', '') }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; + if (options.default) { + packageJson.exports['.'] = packageJson.exports[namespaceKey]; + } + }); + writeJson(path.join(config.packageDir, 'package.json'), packageJson, { spaces: 2 }); +} + if (VERSION) { await buildTypesForTSVersion(VERSION); } else { - const tsVersionBreakpoints = [ - 5.2, - 5.6, - ]; + const tsVersionBreakpoints = [5.2, 5.6]; await remove(config.buildDir); tsVersionBreakpoints.forEach(async version => await buildTypesForTSVersion(version)); + const namespaces = { + es: { isDir: false, default: false }, + stable: { isDir: false, default: false }, + actual: { isDir: false, default: true }, + full: { isDir: false, default: false }, + pure: { isDir: false, default: false }, + proposals: { isDir: true, default: false }, + }; + await buildPackageJson(tsVersionBreakpoints, namespaces); } diff --git a/scripts/build-types/package.tpl.json b/scripts/build-types/package.tpl.json new file mode 100644 index 000000000000..efb86b0b587d --- /dev/null +++ b/scripts/build-types/package.tpl.json @@ -0,0 +1,30 @@ +{ + "name": "@core-js/types", + "version": "4.0.0-alpha.0", + "publishConfig": { + "access": "public" + }, + "type": "commonjs", + "description": "TypeScript types for core-js", + "repository": { + "type": "git", + "url": "git+https://github.com/zloirock/core-js.git", + "directory": "packages/core-js-types" + }, + "homepage": "https://core-js.io", + "bugs": { + "url": "https://github.com/zloirock/core-js/issues" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + }, + "license": "SEE LICENSE IN LICENSE.md", + "author": { + "name": "Denis Pushkarev", + "email": "zloirock@zloirock.ru", + "url": "http://zloirock.ru" + }, + "types": "./actual.d.ts", + "sideEffects": false +} From f7e913faea28fc0281c207e85efa812278928f00 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 9 Dec 2025 00:24:21 +0700 Subject: [PATCH 074/315] Run all type definition tests in CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa61ded969c3..456ef5c58d68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: python-version: 3.14 - run: npm run prepare-monorepo - run: pip install codespell - - run: npx run-s lint-raw codespell + - run: ALL_TYPE_DEFINITIONS_TESTS=1 npx run-s lint-raw codespell karma: runs-on: windows-2022 From 2f99da5678f04e366ed8a21903f63d27db5b80db Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 9 Dec 2025 01:51:19 +0700 Subject: [PATCH 075/315] Sort exports --- packages/core-js-types/package.json | 32 ++++++++++++++--------------- scripts/build-types/index.mjs | 6 ++++++ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/packages/core-js-types/package.json b/packages/core-js-types/package.json index 2190413151cf..5cc48dbcaa87 100644 --- a/packages/core-js-types/package.json +++ b/packages/core-js-types/package.json @@ -40,40 +40,40 @@ } }, "exports": { - "./es": { - "types@>=5.6": "./dist/56/es.d.ts", - "types": "./dist/52/es.d.ts", - "default": "./dist/56/es.d.ts" - }, - "./stable": { - "types@>=5.6": "./dist/56/stable.d.ts", - "types": "./dist/52/stable.d.ts", - "default": "./dist/56/stable.d.ts" - }, - "./actual": { + ".": { "types@>=5.6": "./dist/56/actual.d.ts", "types": "./dist/52/actual.d.ts", "default": "./dist/56/actual.d.ts" }, - ".": { + "./actual": { "types@>=5.6": "./dist/56/actual.d.ts", "types": "./dist/52/actual.d.ts", "default": "./dist/56/actual.d.ts" }, + "./es": { + "types@>=5.6": "./dist/56/es.d.ts", + "types": "./dist/52/es.d.ts", + "default": "./dist/56/es.d.ts" + }, "./full": { "types@>=5.6": "./dist/56/full.d.ts", "types": "./dist/52/full.d.ts", "default": "./dist/56/full.d.ts" }, + "./proposals/*": { + "types@>=5.6": "./dist/56/proposals/*.d.ts", + "types": "./dist/52/proposals/*.d.ts", + "default": "./dist/56/proposals/*.d.ts" + }, "./pure": { "types@>=5.6": "./dist/56/pure.d.ts", "types": "./dist/52/pure.d.ts", "default": "./dist/56/pure.d.ts" }, - "./proposals/*": { - "types@>=5.6": "./dist/56/proposals/*.d.ts", - "types": "./dist/52/proposals/*.d.ts", - "default": "./dist/56/proposals/*.d.ts" + "./stable": { + "types@>=5.6": "./dist/56/stable.d.ts", + "types": "./dist/52/stable.d.ts", + "default": "./dist/56/stable.d.ts" } } } diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 777afa8170af..fb0ef1edfaba 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -180,6 +180,12 @@ async function buildPackageJson(breakpoints, namespaces) { packageJson.exports['.'] = packageJson.exports[namespaceKey]; } }); + const exportsKeys = Object.keys(packageJson.exports).sort(); + const exports = {}; + exportsKeys.forEach(key => { + exports[key] = packageJson.exports[key]; + }); + packageJson.exports = exports; writeJson(path.join(config.packageDir, 'package.json'), packageJson, { spaces: 2 }); } From 595bfdcc822cbda14b6bde9809e369fbc24e2b57 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 9 Dec 2025 14:13:42 +0700 Subject: [PATCH 076/315] Types dir refactoring & some fixes & some improvements --- packages/core-js-types/package.json | 46 ++++++++--------- packages/core-js-types/src/52/web/atob.d.ts | 6 --- packages/core-js-types/src/52/web/btoa.d.ts | 7 --- .../src/52/web/efficient-script-yielding.d.ts | 5 -- .../src/52/web/queue-microtask.d.ts | 9 ---- .../src/52/web/structured-clone.d.ts | 14 ------ .../core-js-types/src/52/web/url-parse.d.ts | 7 --- .../core-js-types/src/52/web/url-to-json.d.ts | 3 -- .../object-prototype-accessor-methods.d.ts | 9 ---- .../src/56/core-js-types/string-base.d.ts | 3 -- .../src/56/proposals/iterator-chunking.d.ts | 26 ---------- .../src/56/proposals/iterator-joint.d.ts | 50 ------------------- .../src/56/proposals/iterator-sequencing.d.ts | 19 ------- .../object-prototype-accessor-methods.d.ts | 0 .../core-js-types/async-iterable.d.ts | 0 .../core-js-types/async-iterator-object.d.ts | 0 .../core-js-types/core-js-types.d.ts | 4 -- .../core-js-types/core-js-types.pure.d.ts | 0 .../decorator-metadata-object.d.ts | 0 .../core-js-types/flat-array.d.ts | 0 .../core-js-types/iterator-object.d.ts | 0 .../core-js-types/promise-settled-result.d.ts | 0 .../src/base/core-js-types/string-base.d.ts | 4 ++ .../accessible-object-hasownproperty.d.ts | 0 .../proposals/array-buffer-base64.d.ts | 0 .../proposals/array-buffer-transfer.d.ts | 0 .../proposals/array-filtering.d.ts | 0 .../proposals/array-find-from-last.d.ts | 0 .../proposals/array-flat-map-custom.d.ts | 2 + .../proposals/array-flat-map.d.ts | 0 .../proposals/array-from-async.d.ts | 0 .../proposals/array-grouping.d.ts | 0 .../proposals/array-includes.d.ts | 0 .../proposals/array-is-template-object.d.ts | 0 .../{56 => base}/proposals/array-unique.d.ts | 0 .../proposals/async-iteration.d.ts | 0 .../proposals/async-iterator-helpers.d.ts | 0 .../proposals/await-dictionary.d.ts | 0 .../change-array-by-copy-custom.d.ts | 2 + .../proposals/change-array-by-copy.d.ts | 0 .../proposals/collection-of-from.d.ts | 0 .../data-view-get-set-uint8-clamped.d.ts | 0 .../proposals/decorator-metadata.d.ts | 0 .../{56 => base}/proposals/error-cause.d.ts | 0 .../explicit-resource-management.d.ts | 6 +++ .../src/{56 => base}/proposals/float16.d.ts | 0 .../proposals/function-demethodize.d.ts | 0 .../src/{56 => base}/proposals/is-error.d.ts | 0 .../src/base/proposals/iterator-chunking.d.ts | 22 ++++++++ .../proposals/iterator-helpers-custom.d.ts | 2 + .../proposals/iterator-helpers.d.ts | 0 .../{52 => base}/proposals/iterator-join.d.ts | 0 .../src/base/proposals/iterator-joint.d.ts | 46 +++++++++++++++++ .../proposals/iterator-range.d.ts | 0 .../base/proposals/iterator-sequencing.d.ts | 15 ++++++ .../proposals/json-parse-with-source.d.ts | 0 .../{56 => base}/proposals/map-upsert.d.ts | 0 .../src/{56 => base}/proposals/math-sum.d.ts | 0 .../{56 => base}/proposals/number-clamp.d.ts | 0 .../proposals/object-from-entries.d.ts | 0 .../object-get-own-property-descriptors.d.ts | 0 .../proposals/object-values-entries.d.ts | 0 .../proposals/pattern-matching.d.ts | 0 .../proposals/promise-all-settled.d.ts | 0 .../{56 => base}/proposals/promise-any.d.ts | 0 .../proposals/promise-finally.d.ts | 0 .../{56 => base}/proposals/promise-try.d.ts | 0 .../proposals/promise-with-resolvers.d.ts | 2 - .../proposals/regexp-dotall-flag.d.ts | 0 .../proposals/regexp-escaping.d.ts | 0 .../proposals/regexp-named-groups.d.ts | 0 .../proposals/relative-indexing-method.d.ts | 0 .../proposals/set-methods-custom.d.ts | 2 + .../{56 => base}/proposals/set-methods.d.ts | 0 .../{56 => base}/proposals/string-cooked.d.ts | 0 .../{56 => base}/proposals/string-dedent.d.ts | 0 .../proposals/string-left-right-trim.d.ts | 0 .../proposals/string-match-all.d.ts | 0 .../proposals/string-padding.d.ts | 0 .../proposals/string-replace-all-custom.d.ts | 2 + .../proposals/string-replace-all.d.ts | 0 .../proposals/symbol-description.d.ts | 0 .../proposals/symbol-predicates.d.ts | 0 .../well-formed-unicode-strings.d.ts | 0 .../pure => base/pure/common}/date.d.ts | 0 .../pure/common}/global-this.d.ts | 0 .../pure/common}/parse-float.d.ts | 0 .../pure => base/pure/common}/parse-int.d.ts | 0 .../pure => base/pure/common}/reflect.d.ts | 0 .../pure => base/pure/common}/self.d.ts | 0 .../pure/proposals}/array-buffer-base64.d.ts | 0 .../proposals}/array-buffer-transfer.d.ts | 0 .../pure/proposals}/array-constructor.d.ts | 0 .../pure/proposals}/array-from-async.d.ts | 0 .../pure/proposals}/async-iteration.d.ts | 0 .../proposals}/async-iterator-helpers.d.ts | 0 .../pure/proposals}/decorator-metadata.d.ts | 0 .../explicit-resource-management.d.ts | 0 .../pure/proposals}/iterator-chunking.d.ts | 0 .../pure/proposals}/iterator-helpers.d.ts | 0 .../pure/proposals}/iterator-join.d.ts | 0 .../pure/proposals}/iterator-joint.d.ts | 0 .../pure/proposals}/iterator-range.d.ts | 0 .../pure/proposals}/iterator-sequencing.d.ts | 0 .../pure/proposals}/iterator.d.ts | 0 .../pure/proposals}/pattern-matching.d.ts | 0 .../proposals}/relative-indexing-method.d.ts | 0 .../proposals}/string-left-right-trim.d.ts | 0 .../pure/proposals}/string-match-all.d.ts | 0 .../pure/proposals}/string-padding.d.ts | 0 .../pure/proposals}/string-replace-all.d.ts | 0 .../pure/proposals}/symbol-description.d.ts | 0 .../pure/proposals}/symbol-predicates.d.ts | 0 .../pure => base/pure/proposals}/symbol.d.ts | 0 .../pure/proposals}/typed-arrays.d.ts | 0 .../well-formed-unicode-strings.d.ts | 0 .../pure => base/pure/web}/dom-exception.d.ts | 0 .../web/pure => base/pure/web}/url-parse.d.ts | 0 .../pure/web}/url-search-params.d.ts | 0 .../{56/web/pure => base/pure/web}/url.d.ts | 0 .../src/{56 => base}/web/atob-btoa.d.ts | 0 .../web/efficient-script-yielding.d.ts | 0 .../src/{56 => base}/web/queue-microtask.d.ts | 0 .../{56 => base}/web/structured-clone.d.ts | 0 .../src/{56 => base}/web/url-to-json.d.ts | 0 .../core-js-types/core-js-types.d.ts | 0 .../accessible-object-hasownproperty.d.ts | 0 .../proposals/array-buffer-base64.d.ts | 0 .../proposals/array-buffer-transfer.d.ts | 0 .../proposals/array-filtering.d.ts | 0 .../proposals/array-find-from-last.d.ts | 0 .../proposals/array-flat-map-custom.d.ts | 0 .../proposals/array-flat-map.d.ts | 0 .../proposals/array-from-async.d.ts | 0 .../proposals/array-grouping.d.ts | 0 .../proposals/array-includes.d.ts | 0 .../proposals/array-is-template-object.d.ts | 0 .../{52 => ts5-2}/proposals/array-unique.d.ts | 0 .../proposals/async-iteration.d.ts | 0 .../proposals/async-iterator-helpers.d.ts | 0 .../proposals/await-dictionary.d.ts | 0 .../change-array-by-copy-custom.d.ts | 0 .../proposals/change-array-by-copy.d.ts | 0 .../proposals/collection-of-from.d.ts | 0 .../data-view-get-set-uint8-clamped.d.ts | 0 .../proposals/decorator-metadata.d.ts | 0 .../{52 => ts5-2}/proposals/error-cause.d.ts | 0 .../explicit-resource-management.d.ts | 0 .../src/{52 => ts5-2}/proposals/float16.d.ts | 0 .../proposals/function-demethodize.d.ts | 0 .../src/{52 => ts5-2}/proposals/is-error.d.ts | 0 .../proposals/iterator-chunking.d.ts | 0 .../proposals/iterator-helpers-custom.d.ts | 0 .../proposals/iterator-helpers.d.ts | 0 .../proposals/iterator-join.d.ts | 0 .../proposals/iterator-joint.d.ts | 0 .../proposals/iterator-range.d.ts | 0 .../proposals/iterator-sequencing.d.ts | 0 .../proposals/json-parse-with-source.d.ts | 0 .../{52 => ts5-2}/proposals/map-upsert.d.ts | 0 .../src/{52 => ts5-2}/proposals/math-sum.d.ts | 0 .../{52 => ts5-2}/proposals/number-clamp.d.ts | 0 .../proposals/object-from-entries.d.ts | 0 .../object-get-own-property-descriptors.d.ts | 0 .../proposals/object-values-entries.d.ts | 0 .../proposals/pattern-matching.d.ts | 0 .../proposals/promise-all-settled.d.ts | 0 .../{52 => ts5-2}/proposals/promise-any.d.ts | 0 .../proposals/promise-finally.d.ts | 0 .../{52 => ts5-2}/proposals/promise-try.d.ts | 0 .../proposals/promise-with-resolvers.d.ts | 0 .../proposals/regexp-dotall-flag.d.ts | 0 .../proposals/regexp-escaping.d.ts | 0 .../proposals/regexp-named-groups.d.ts | 0 .../proposals/relative-indexing-method.d.ts | 0 .../proposals/set-methods-custom.d.ts | 0 .../{52 => ts5-2}/proposals/set-methods.d.ts | 0 .../proposals/string-cooked.d.ts | 0 .../proposals/string-dedent.d.ts | 0 .../proposals/string-left-right-trim.d.ts | 0 .../proposals/string-match-all.d.ts | 0 .../proposals/string-padding.d.ts | 0 .../proposals/string-replace-all-custom.d.ts | 0 .../proposals/string-replace-all.d.ts | 0 .../proposals/symbol-description.d.ts | 0 .../proposals/symbol-predicates.d.ts | 0 .../well-formed-unicode-strings.d.ts | 0 scripts/build-entries/templates.mjs | 38 +++++++------- scripts/build-types/config.mjs | 1 + scripts/build-types/index.mjs | 25 +++++----- scripts/build-types/pure.mjs | 6 +-- 191 files changed, 161 insertions(+), 222 deletions(-) delete mode 100644 packages/core-js-types/src/52/web/atob.d.ts delete mode 100644 packages/core-js-types/src/52/web/btoa.d.ts delete mode 100644 packages/core-js-types/src/52/web/efficient-script-yielding.d.ts delete mode 100644 packages/core-js-types/src/52/web/queue-microtask.d.ts delete mode 100644 packages/core-js-types/src/52/web/structured-clone.d.ts delete mode 100644 packages/core-js-types/src/52/web/url-parse.d.ts delete mode 100644 packages/core-js-types/src/52/web/url-to-json.d.ts delete mode 100644 packages/core-js-types/src/56/common/object-prototype-accessor-methods.d.ts delete mode 100644 packages/core-js-types/src/56/core-js-types/string-base.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/iterator-chunking.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/iterator-joint.d.ts delete mode 100644 packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts rename packages/core-js-types/src/{52 => base}/common/object-prototype-accessor-methods.d.ts (100%) rename packages/core-js-types/src/{56 => base}/core-js-types/async-iterable.d.ts (100%) rename packages/core-js-types/src/{56 => base}/core-js-types/async-iterator-object.d.ts (100%) rename packages/core-js-types/src/{56 => base}/core-js-types/core-js-types.d.ts (90%) rename packages/core-js-types/src/{56 => base}/core-js-types/core-js-types.pure.d.ts (100%) rename packages/core-js-types/src/{56 => base}/core-js-types/decorator-metadata-object.d.ts (100%) rename packages/core-js-types/src/{56 => base}/core-js-types/flat-array.d.ts (100%) rename packages/core-js-types/src/{56 => base}/core-js-types/iterator-object.d.ts (100%) rename packages/core-js-types/src/{56 => base}/core-js-types/promise-settled-result.d.ts (100%) create mode 100644 packages/core-js-types/src/base/core-js-types/string-base.d.ts rename packages/core-js-types/src/{56 => base}/proposals/accessible-object-hasownproperty.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/array-buffer-base64.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/array-buffer-transfer.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/array-filtering.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/array-find-from-last.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/array-flat-map-custom.d.ts (90%) rename packages/core-js-types/src/{56 => base}/proposals/array-flat-map.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/array-from-async.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/array-grouping.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/array-includes.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/array-is-template-object.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/array-unique.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/async-iteration.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/async-iterator-helpers.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/await-dictionary.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/change-array-by-copy-custom.d.ts (89%) rename packages/core-js-types/src/{56 => base}/proposals/change-array-by-copy.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/collection-of-from.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/data-view-get-set-uint8-clamped.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/decorator-metadata.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/error-cause.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/explicit-resource-management.d.ts (97%) rename packages/core-js-types/src/{56 => base}/proposals/float16.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/function-demethodize.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/is-error.d.ts (100%) create mode 100644 packages/core-js-types/src/base/proposals/iterator-chunking.d.ts rename packages/core-js-types/src/{56 => base}/proposals/iterator-helpers-custom.d.ts (94%) rename packages/core-js-types/src/{56 => base}/proposals/iterator-helpers.d.ts (100%) rename packages/core-js-types/src/{52 => base}/proposals/iterator-join.d.ts (100%) create mode 100644 packages/core-js-types/src/base/proposals/iterator-joint.d.ts rename packages/core-js-types/src/{56 => base}/proposals/iterator-range.d.ts (100%) create mode 100644 packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts rename packages/core-js-types/src/{56 => base}/proposals/json-parse-with-source.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/map-upsert.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/math-sum.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/number-clamp.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/object-from-entries.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/object-get-own-property-descriptors.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/object-values-entries.d.ts (100%) rename packages/core-js-types/src/{52 => base}/proposals/pattern-matching.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/promise-all-settled.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/promise-any.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/promise-finally.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/promise-try.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/promise-with-resolvers.d.ts (99%) rename packages/core-js-types/src/{56 => base}/proposals/regexp-dotall-flag.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/regexp-escaping.d.ts (100%) rename packages/core-js-types/src/{52 => base}/proposals/regexp-named-groups.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/relative-indexing-method.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/set-methods-custom.d.ts (91%) rename packages/core-js-types/src/{56 => base}/proposals/set-methods.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/string-cooked.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/string-dedent.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/string-left-right-trim.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/string-match-all.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/string-padding.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/string-replace-all-custom.d.ts (90%) rename packages/core-js-types/src/{56 => base}/proposals/string-replace-all.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/symbol-description.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/symbol-predicates.d.ts (100%) rename packages/core-js-types/src/{56 => base}/proposals/well-formed-unicode-strings.d.ts (100%) rename packages/core-js-types/src/{56/common/pure => base/pure/common}/date.d.ts (100%) rename packages/core-js-types/src/{56/common/pure => base/pure/common}/global-this.d.ts (100%) rename packages/core-js-types/src/{56/common/pure => base/pure/common}/parse-float.d.ts (100%) rename packages/core-js-types/src/{56/common/pure => base/pure/common}/parse-int.d.ts (100%) rename packages/core-js-types/src/{56/common/pure => base/pure/common}/reflect.d.ts (100%) rename packages/core-js-types/src/{56/common/pure => base/pure/common}/self.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/array-buffer-base64.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/array-buffer-transfer.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/array-constructor.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/array-from-async.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/async-iteration.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/async-iterator-helpers.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/decorator-metadata.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/explicit-resource-management.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/iterator-chunking.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/iterator-helpers.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/iterator-join.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/iterator-joint.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/iterator-range.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/iterator-sequencing.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/iterator.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/pattern-matching.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/relative-indexing-method.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/string-left-right-trim.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/string-match-all.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/string-padding.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/string-replace-all.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/symbol-description.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/symbol-predicates.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/symbol.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/typed-arrays.d.ts (100%) rename packages/core-js-types/src/{56/proposals/pure => base/pure/proposals}/well-formed-unicode-strings.d.ts (100%) rename packages/core-js-types/src/{56/web/pure => base/pure/web}/dom-exception.d.ts (100%) rename packages/core-js-types/src/{56/web/pure => base/pure/web}/url-parse.d.ts (100%) rename packages/core-js-types/src/{56/web/pure => base/pure/web}/url-search-params.d.ts (100%) rename packages/core-js-types/src/{56/web/pure => base/pure/web}/url.d.ts (100%) rename packages/core-js-types/src/{56 => base}/web/atob-btoa.d.ts (100%) rename packages/core-js-types/src/{56 => base}/web/efficient-script-yielding.d.ts (100%) rename packages/core-js-types/src/{56 => base}/web/queue-microtask.d.ts (100%) rename packages/core-js-types/src/{56 => base}/web/structured-clone.d.ts (100%) rename packages/core-js-types/src/{56 => base}/web/url-to-json.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/core-js-types/core-js-types.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/accessible-object-hasownproperty.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/array-buffer-base64.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/array-buffer-transfer.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/array-filtering.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/array-find-from-last.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/array-flat-map-custom.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/array-flat-map.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/array-from-async.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/array-grouping.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/array-includes.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/array-is-template-object.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/array-unique.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/async-iteration.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/async-iterator-helpers.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/await-dictionary.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/change-array-by-copy-custom.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/change-array-by-copy.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/collection-of-from.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/data-view-get-set-uint8-clamped.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/decorator-metadata.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/error-cause.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/explicit-resource-management.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/float16.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/function-demethodize.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/is-error.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/iterator-chunking.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/iterator-helpers-custom.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/iterator-helpers.d.ts (100%) rename packages/core-js-types/src/{56 => ts5-2}/proposals/iterator-join.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/iterator-joint.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/iterator-range.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/iterator-sequencing.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/json-parse-with-source.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/map-upsert.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/math-sum.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/number-clamp.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/object-from-entries.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/object-get-own-property-descriptors.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/object-values-entries.d.ts (100%) rename packages/core-js-types/src/{56 => ts5-2}/proposals/pattern-matching.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/promise-all-settled.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/promise-any.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/promise-finally.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/promise-try.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/promise-with-resolvers.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/regexp-dotall-flag.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/regexp-escaping.d.ts (100%) rename packages/core-js-types/src/{56 => ts5-2}/proposals/regexp-named-groups.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/relative-indexing-method.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/set-methods-custom.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/set-methods.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/string-cooked.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/string-dedent.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/string-left-right-trim.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/string-match-all.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/string-padding.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/string-replace-all-custom.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/string-replace-all.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/symbol-description.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/symbol-predicates.d.ts (100%) rename packages/core-js-types/src/{52 => ts5-2}/proposals/well-formed-unicode-strings.d.ts (100%) diff --git a/packages/core-js-types/package.json b/packages/core-js-types/package.json index 5cc48dbcaa87..a38dcfbdef4f 100644 --- a/packages/core-js-types/package.json +++ b/packages/core-js-types/package.json @@ -30,50 +30,50 @@ "typesVersions": { ">=5.6": { "*": [ - "./dist/56/*" + "./dist/ts5-6/*" ] }, ">=5.2": { "*": [ - "./dist/52/*" + "./dist/ts5-2/*" ] } }, "exports": { ".": { - "types@>=5.6": "./dist/56/actual.d.ts", - "types": "./dist/52/actual.d.ts", - "default": "./dist/56/actual.d.ts" + "types@>=5.6": "./dist/ts5-6/actual.d.ts", + "types": "./dist/ts5-2/actual.d.ts", + "default": "./dist/ts5-6/actual.d.ts" }, "./actual": { - "types@>=5.6": "./dist/56/actual.d.ts", - "types": "./dist/52/actual.d.ts", - "default": "./dist/56/actual.d.ts" + "types@>=5.6": "./dist/ts5-6/actual.d.ts", + "types": "./dist/ts5-2/actual.d.ts", + "default": "./dist/ts5-6/actual.d.ts" }, "./es": { - "types@>=5.6": "./dist/56/es.d.ts", - "types": "./dist/52/es.d.ts", - "default": "./dist/56/es.d.ts" + "types@>=5.6": "./dist/ts5-6/es.d.ts", + "types": "./dist/ts5-2/es.d.ts", + "default": "./dist/ts5-6/es.d.ts" }, "./full": { - "types@>=5.6": "./dist/56/full.d.ts", - "types": "./dist/52/full.d.ts", - "default": "./dist/56/full.d.ts" + "types@>=5.6": "./dist/ts5-6/full.d.ts", + "types": "./dist/ts5-2/full.d.ts", + "default": "./dist/ts5-6/full.d.ts" }, "./proposals/*": { - "types@>=5.6": "./dist/56/proposals/*.d.ts", - "types": "./dist/52/proposals/*.d.ts", - "default": "./dist/56/proposals/*.d.ts" + "types@>=5.6": "./dist/ts5-6/proposals/*.d.ts", + "types": "./dist/ts5-2/proposals/*.d.ts", + "default": "./dist/ts5-6/proposals/*.d.ts" }, "./pure": { - "types@>=5.6": "./dist/56/pure.d.ts", - "types": "./dist/52/pure.d.ts", - "default": "./dist/56/pure.d.ts" + "types@>=5.6": "./dist/ts5-6/pure.d.ts", + "types": "./dist/ts5-2/pure.d.ts", + "default": "./dist/ts5-6/pure.d.ts" }, "./stable": { - "types@>=5.6": "./dist/56/stable.d.ts", - "types": "./dist/52/stable.d.ts", - "default": "./dist/56/stable.d.ts" + "types@>=5.6": "./dist/ts5-6/stable.d.ts", + "types": "./dist/ts5-2/stable.d.ts", + "default": "./dist/ts5-6/stable.d.ts" } } } diff --git a/packages/core-js-types/src/52/web/atob.d.ts b/packages/core-js-types/src/52/web/atob.d.ts deleted file mode 100644 index d08b3902da6c..000000000000 --- a/packages/core-js-types/src/52/web/atob.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Decodes a string of data which has been encoded using Base64 encoding. - * @param data A base64-encoded string, using the alphabet produced by btoa(). - * @returns A binary string containing raw bytes decoded from encodedData. - */ -declare function atob(data: string): string; diff --git a/packages/core-js-types/src/52/web/btoa.d.ts b/packages/core-js-types/src/52/web/btoa.d.ts deleted file mode 100644 index f4eac3d5ad11..000000000000 --- a/packages/core-js-types/src/52/web/btoa.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Creates a Base64-encoded ASCII string from a binary string - * (i.e., a string in which each character in the string is treated as a byte of binary data) - * @param data The binary string to encode - * @returns An ASCII string containing the Base64 representation of data - */ -declare function btoa(data: string): string; diff --git a/packages/core-js-types/src/52/web/efficient-script-yielding.d.ts b/packages/core-js-types/src/52/web/efficient-script-yielding.d.ts deleted file mode 100644 index 9e077b1e4a8d..000000000000 --- a/packages/core-js-types/src/52/web/efficient-script-yielding.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -type Immediate = number | object; - -declare function setImmediate(handler: (...args: any[]) => void, ...args: any[]): Immediate; - -declare function clearImmediate(immediate: Immediate): void; diff --git a/packages/core-js-types/src/52/web/queue-microtask.d.ts b/packages/core-js-types/src/52/web/queue-microtask.d.ts deleted file mode 100644 index 584b60656a64..000000000000 --- a/packages/core-js-types/src/52/web/queue-microtask.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -interface VoidFunction { - (): void; -} - -/** - * Queues a microtask to be executed at a later time. - * @param callback A function to be executed in the microtask. - */ -declare function queueMicrotask(callback: VoidFunction): void; diff --git a/packages/core-js-types/src/52/web/structured-clone.d.ts b/packages/core-js-types/src/52/web/structured-clone.d.ts deleted file mode 100644 index 13f3367b9b3a..000000000000 --- a/packages/core-js-types/src/52/web/structured-clone.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -interface CoreJSStructuredSerializeOptions { - readonly __brand?: unique symbol; - - transfer?: any[]; -} - -/** - * Creates a deep clone of a given value using the structured clone algorithm. - * @param value The value to be cloned. - * @param options An optional object that may contain a transfer property, - * which is an array of transferable objects to be transferred rather than cloned. - * @returns A deep clone of the provided value. - */ -declare function structuredClone(value: T, options?: CoreJSStructuredSerializeOptions): T; diff --git a/packages/core-js-types/src/52/web/url-parse.d.ts b/packages/core-js-types/src/52/web/url-parse.d.ts deleted file mode 100644 index 8c998f44d99d..000000000000 --- a/packages/core-js-types/src/52/web/url-parse.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare global { - interface URLConstructor extends URL { - parse(url: string | URL, base?: string | URL): URL | null; - } -} - -export {}; diff --git a/packages/core-js-types/src/52/web/url-to-json.d.ts b/packages/core-js-types/src/52/web/url-to-json.d.ts deleted file mode 100644 index 6ecf69d921b0..000000000000 --- a/packages/core-js-types/src/52/web/url-to-json.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -interface URL { - toJSON(): string; -} diff --git a/packages/core-js-types/src/56/common/object-prototype-accessor-methods.d.ts b/packages/core-js-types/src/56/common/object-prototype-accessor-methods.d.ts deleted file mode 100644 index cf148f00e65a..000000000000 --- a/packages/core-js-types/src/56/common/object-prototype-accessor-methods.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -interface Object { - __defineGetter__(prop: PropertyKey, getter: () => any): void; - - __defineSetter__(prop: PropertyKey, setter: (val: any) => void): void; - - __lookupGetter__(prop: PropertyKey): (() => any) | undefined; - - __lookupSetter__(prop: PropertyKey): ((val: any) => void) | undefined; -} diff --git a/packages/core-js-types/src/56/core-js-types/string-base.d.ts b/packages/core-js-types/src/56/core-js-types/string-base.d.ts deleted file mode 100644 index 26f8c1c4948e..000000000000 --- a/packages/core-js-types/src/56/core-js-types/string-base.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare namespace CoreJS { - export type StringBase = Omit; -} diff --git a/packages/core-js-types/src/56/proposals/iterator-chunking.d.ts b/packages/core-js-types/src/56/proposals/iterator-chunking.d.ts deleted file mode 100644 index f43c557491b5..000000000000 --- a/packages/core-js-types/src/56/proposals/iterator-chunking.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -// proposal stage: 2.7 -// https://github.com/tc39/proposal-iterator-chunking - -import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; - -declare global { - interface Iterator { - /** - * Yields arrays containing up to the specified number of elements - * chunked from the source iterator. - * @param chunkSize The maximum number of elements per chunk. Must be a positive integer. - * @returns An iterator yielding arrays of at most `chunkSize` elements from the source iterator. - */ - chunks(chunkSize: number): CoreJSIteratorObject; - - /** - * Yields overlapping arrays (windows) of the given size from the iterator. - * @param windowSize The size of each window. Must be a positive integer. - * @param undersized 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. - * @returns An iterator yielding arrays of the specified window size. - */ - windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJSIteratorObject; - } -} - -export {}; diff --git a/packages/core-js-types/src/56/proposals/iterator-joint.d.ts b/packages/core-js-types/src/56/proposals/iterator-joint.d.ts deleted file mode 100644 index 2e6e18a25160..000000000000 --- a/packages/core-js-types/src/56/proposals/iterator-joint.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -// proposal stage: 2.7 -// https://github.com/tc39/proposal-joint-iteration - -import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; - -declare global { - type ZipOptions = { - mode?: 'shortest' | 'longest' | 'strict'; - - padding?: object; - }; - - interface IteratorConstructor { // @type-options no-extends - /** - * Takes an iterable of iterables and produces an iterable of arrays where position corresponds - * to position in the passed iterable. - * @param iterables An Iterable of iterables. - * @param options Optional object: - * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; - * - padding: an object specifying padding values for each key when mode is 'longest'. - * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. - */ - zip(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[T, U]>; - - /** - * takes an object whose values are iterables and produces an iterable of objects where keys. - * correspond to keys in the passed object. - * @param iterables An Iterable of iterables. - * @param options Optional object: - * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; - * - padding: an object specifying padding values for each key when mode is 'longest'. - * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. - */ - zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[number, T, U]>; - /** - * takes an object whose values are iterables and produces an iterable of objects where keys. - * correspond to keys in the passed object. - * @param record An object of iterables. - * @param options Optional object: - * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; - * - padding: an object specifying padding values for each key when mode is 'longest'. - * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. - */ - zipKeyed(record: Record>, options?: ZipOptions): CoreJSIteratorObject<[PropertyKey, T, U]>; - } - - var Iterator: IteratorConstructor; -} - -export {}; diff --git a/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts deleted file mode 100644 index 9f327fd710e3..000000000000 --- a/packages/core-js-types/src/56/proposals/iterator-sequencing.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -// proposal stage: 2.7 -// https://github.com/tc39/proposal-iterator-sequencing - -import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; - -declare global { - interface IteratorConstructor { // @type-options no-extends - /** - * Creates an iterator that sequentially yields values from the provided iterables. - * @param iterators The iterables to concatenate. - * @returns An iterator yielding values from each input iterable in sequence. - */ - concat(...iterators: Iterable[]): CoreJSIteratorObject; - } - - var Iterator: IteratorConstructor; -} - -export {}; diff --git a/packages/core-js-types/src/52/common/object-prototype-accessor-methods.d.ts b/packages/core-js-types/src/base/common/object-prototype-accessor-methods.d.ts similarity index 100% rename from packages/core-js-types/src/52/common/object-prototype-accessor-methods.d.ts rename to packages/core-js-types/src/base/common/object-prototype-accessor-methods.d.ts diff --git a/packages/core-js-types/src/56/core-js-types/async-iterable.d.ts b/packages/core-js-types/src/base/core-js-types/async-iterable.d.ts similarity index 100% rename from packages/core-js-types/src/56/core-js-types/async-iterable.d.ts rename to packages/core-js-types/src/base/core-js-types/async-iterable.d.ts diff --git a/packages/core-js-types/src/56/core-js-types/async-iterator-object.d.ts b/packages/core-js-types/src/base/core-js-types/async-iterator-object.d.ts similarity index 100% rename from packages/core-js-types/src/56/core-js-types/async-iterator-object.d.ts rename to packages/core-js-types/src/base/core-js-types/async-iterator-object.d.ts diff --git a/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts similarity index 90% rename from packages/core-js-types/src/56/core-js-types/core-js-types.d.ts rename to packages/core-js-types/src/base/core-js-types/core-js-types.d.ts index b3dc9bf74b41..1cc8655176fe 100644 --- a/packages/core-js-types/src/56/core-js-types/core-js-types.d.ts +++ b/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts @@ -33,8 +33,4 @@ declare global { } } -export type CoreJSDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } // from ts 5.2 - ? O - : Record & object; - export type CoreJSIteratorObject = IteratorObject; diff --git a/packages/core-js-types/src/56/core-js-types/core-js-types.pure.d.ts b/packages/core-js-types/src/base/core-js-types/core-js-types.pure.d.ts similarity index 100% rename from packages/core-js-types/src/56/core-js-types/core-js-types.pure.d.ts rename to packages/core-js-types/src/base/core-js-types/core-js-types.pure.d.ts diff --git a/packages/core-js-types/src/56/core-js-types/decorator-metadata-object.d.ts b/packages/core-js-types/src/base/core-js-types/decorator-metadata-object.d.ts similarity index 100% rename from packages/core-js-types/src/56/core-js-types/decorator-metadata-object.d.ts rename to packages/core-js-types/src/base/core-js-types/decorator-metadata-object.d.ts diff --git a/packages/core-js-types/src/56/core-js-types/flat-array.d.ts b/packages/core-js-types/src/base/core-js-types/flat-array.d.ts similarity index 100% rename from packages/core-js-types/src/56/core-js-types/flat-array.d.ts rename to packages/core-js-types/src/base/core-js-types/flat-array.d.ts diff --git a/packages/core-js-types/src/56/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/base/core-js-types/iterator-object.d.ts similarity index 100% rename from packages/core-js-types/src/56/core-js-types/iterator-object.d.ts rename to packages/core-js-types/src/base/core-js-types/iterator-object.d.ts diff --git a/packages/core-js-types/src/56/core-js-types/promise-settled-result.d.ts b/packages/core-js-types/src/base/core-js-types/promise-settled-result.d.ts similarity index 100% rename from packages/core-js-types/src/56/core-js-types/promise-settled-result.d.ts rename to packages/core-js-types/src/base/core-js-types/promise-settled-result.d.ts diff --git a/packages/core-js-types/src/base/core-js-types/string-base.d.ts b/packages/core-js-types/src/base/core-js-types/string-base.d.ts new file mode 100644 index 000000000000..1e688110e864 --- /dev/null +++ b/packages/core-js-types/src/base/core-js-types/string-base.d.ts @@ -0,0 +1,4 @@ +declare namespace CoreJS { + // We should use String without the matchAll method to avoid signature conflicts + export type StringBase = Omit; +} diff --git a/packages/core-js-types/src/56/proposals/accessible-object-hasownproperty.d.ts b/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/accessible-object-hasownproperty.d.ts rename to packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts diff --git a/packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts rename to packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts diff --git a/packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts rename to packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts diff --git a/packages/core-js-types/src/56/proposals/array-filtering.d.ts b/packages/core-js-types/src/base/proposals/array-filtering.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/array-filtering.d.ts rename to packages/core-js-types/src/base/proposals/array-filtering.d.ts diff --git a/packages/core-js-types/src/56/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/array-find-from-last.d.ts rename to packages/core-js-types/src/base/proposals/array-find-from-last.d.ts diff --git a/packages/core-js-types/src/56/proposals/array-flat-map-custom.d.ts b/packages/core-js-types/src/base/proposals/array-flat-map-custom.d.ts similarity index 90% rename from packages/core-js-types/src/56/proposals/array-flat-map-custom.d.ts rename to packages/core-js-types/src/base/proposals/array-flat-map-custom.d.ts index f54e8b3b212e..93687e7aa9a8 100644 --- a/packages/core-js-types/src/56/proposals/array-flat-map-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/array-flat-map-custom.d.ts @@ -1,3 +1,5 @@ +// Motivation: Custom type needed to keep generics strict + // proposal stage: 4 // https://github.com/tc39/proposal-flatMap diff --git a/packages/core-js-types/src/56/proposals/array-flat-map.d.ts b/packages/core-js-types/src/base/proposals/array-flat-map.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/array-flat-map.d.ts rename to packages/core-js-types/src/base/proposals/array-flat-map.d.ts diff --git a/packages/core-js-types/src/56/proposals/array-from-async.d.ts b/packages/core-js-types/src/base/proposals/array-from-async.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/array-from-async.d.ts rename to packages/core-js-types/src/base/proposals/array-from-async.d.ts diff --git a/packages/core-js-types/src/56/proposals/array-grouping.d.ts b/packages/core-js-types/src/base/proposals/array-grouping.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/array-grouping.d.ts rename to packages/core-js-types/src/base/proposals/array-grouping.d.ts diff --git a/packages/core-js-types/src/56/proposals/array-includes.d.ts b/packages/core-js-types/src/base/proposals/array-includes.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/array-includes.d.ts rename to packages/core-js-types/src/base/proposals/array-includes.d.ts diff --git a/packages/core-js-types/src/56/proposals/array-is-template-object.d.ts b/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/array-is-template-object.d.ts rename to packages/core-js-types/src/base/proposals/array-is-template-object.d.ts diff --git a/packages/core-js-types/src/56/proposals/array-unique.d.ts b/packages/core-js-types/src/base/proposals/array-unique.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/array-unique.d.ts rename to packages/core-js-types/src/base/proposals/array-unique.d.ts diff --git a/packages/core-js-types/src/56/proposals/async-iteration.d.ts b/packages/core-js-types/src/base/proposals/async-iteration.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/async-iteration.d.ts rename to packages/core-js-types/src/base/proposals/async-iteration.d.ts diff --git a/packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/async-iterator-helpers.d.ts rename to packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts diff --git a/packages/core-js-types/src/56/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/await-dictionary.d.ts rename to packages/core-js-types/src/base/proposals/await-dictionary.d.ts diff --git a/packages/core-js-types/src/56/proposals/change-array-by-copy-custom.d.ts b/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts similarity index 89% rename from packages/core-js-types/src/56/proposals/change-array-by-copy-custom.d.ts rename to packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts index a40c18137eaf..fa55974c73c8 100644 --- a/packages/core-js-types/src/56/proposals/change-array-by-copy-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts @@ -1,3 +1,5 @@ +// Motivation: Custom type needed to keep generics strict + // proposal stage: 4 // https://github.com/tc39/proposal-change-array-by-copy diff --git a/packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/change-array-by-copy.d.ts rename to packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts diff --git a/packages/core-js-types/src/56/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/collection-of-from.d.ts rename to packages/core-js-types/src/base/proposals/collection-of-from.d.ts diff --git a/packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/data-view-get-set-uint8-clamped.d.ts rename to packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts diff --git a/packages/core-js-types/src/56/proposals/decorator-metadata.d.ts b/packages/core-js-types/src/base/proposals/decorator-metadata.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/decorator-metadata.d.ts rename to packages/core-js-types/src/base/proposals/decorator-metadata.d.ts diff --git a/packages/core-js-types/src/56/proposals/error-cause.d.ts b/packages/core-js-types/src/base/proposals/error-cause.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/error-cause.d.ts rename to packages/core-js-types/src/base/proposals/error-cause.d.ts diff --git a/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts similarity index 97% rename from packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts rename to packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts index ce4db09c578f..e40893c0b489 100644 --- a/packages/core-js-types/src/56/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts @@ -195,3 +195,9 @@ declare var AsyncDisposableStack: AsyncDisposableStackConstructor; interface IteratorObject extends Disposable {} // @type-options no-extends interface AsyncIteratorObject extends AsyncDisposable {} // @type-options no-extends + +interface AsyncIteratorConstructor {} + +declare var AsyncIterator: AsyncIteratorConstructor; + +interface AsyncIterator {} diff --git a/packages/core-js-types/src/56/proposals/float16.d.ts b/packages/core-js-types/src/base/proposals/float16.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/float16.d.ts rename to packages/core-js-types/src/base/proposals/float16.d.ts diff --git a/packages/core-js-types/src/56/proposals/function-demethodize.d.ts b/packages/core-js-types/src/base/proposals/function-demethodize.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/function-demethodize.d.ts rename to packages/core-js-types/src/base/proposals/function-demethodize.d.ts diff --git a/packages/core-js-types/src/56/proposals/is-error.d.ts b/packages/core-js-types/src/base/proposals/is-error.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/is-error.d.ts rename to packages/core-js-types/src/base/proposals/is-error.d.ts diff --git a/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts b/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts new file mode 100644 index 000000000000..6e44eb0c468b --- /dev/null +++ b/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts @@ -0,0 +1,22 @@ +/// + +// proposal stage: 2.7 +// https://github.com/tc39/proposal-iterator-chunking + +interface Iterator { + /** + * Yields arrays containing up to the specified number of elements + * chunked from the source iterator. + * @param chunkSize The maximum number of elements per chunk. Must be a positive integer. + * @returns An iterator yielding arrays of at most `chunkSize` elements from the source iterator. + */ + chunks(chunkSize: number): CoreJS.CoreJSIteratorObject; + + /** + * Yields overlapping arrays (windows) of the given size from the iterator. + * @param windowSize The size of each window. Must be a positive integer. + * @param undersized 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. + * @returns An iterator yielding arrays of the specified window size. + */ + windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJS.CoreJSIteratorObject; +} diff --git a/packages/core-js-types/src/56/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts similarity index 94% rename from packages/core-js-types/src/56/proposals/iterator-helpers-custom.d.ts rename to packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts index 29c5f9fa425a..d7f7c64b5d3a 100644 --- a/packages/core-js-types/src/56/proposals/iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts @@ -1,3 +1,5 @@ +// Motivation: Custom type needed to keep generics strict + // proposal stage: 4 // https://github.com/tc39/proposal-iterator-helpers diff --git a/packages/core-js-types/src/56/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/iterator-helpers.d.ts rename to packages/core-js-types/src/base/proposals/iterator-helpers.d.ts diff --git a/packages/core-js-types/src/52/proposals/iterator-join.d.ts b/packages/core-js-types/src/base/proposals/iterator-join.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/iterator-join.d.ts rename to packages/core-js-types/src/base/proposals/iterator-join.d.ts diff --git a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts new file mode 100644 index 000000000000..c49a5953a859 --- /dev/null +++ b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts @@ -0,0 +1,46 @@ +/// + +// proposal stage: 2.7 +// https://github.com/tc39/proposal-joint-iteration + +type ZipOptions = { + mode?: 'shortest' | 'longest' | 'strict'; + + padding?: object; +}; + +interface IteratorConstructor { // @type-options no-extends + /** + * Takes an iterable of iterables and produces an iterable of arrays where position corresponds + * to position in the passed iterable. + * @param iterables An Iterable of iterables. + * @param options Optional object: + * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; + * - padding: an object specifying padding values for each key when mode is 'longest'. + * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. + */ + zip(iterables: Iterable, options?: ZipOptions): CoreJS.CoreJSIteratorObject<[T, U]>; + + /** + * takes an object whose values are iterables and produces an iterable of objects where keys. + * correspond to keys in the passed object. + * @param iterables An Iterable of iterables. + * @param options Optional object: + * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; + * - padding: an object specifying padding values for each key when mode is 'longest'. + * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. + */ + zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJS.CoreJSIteratorObject<[number, T, U]>; + /** + * takes an object whose values are iterables and produces an iterable of objects where keys. + * correspond to keys in the passed object. + * @param record An object of iterables. + * @param options Optional object: + * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; + * - padding: an object specifying padding values for each key when mode is 'longest'. + * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. + */ + zipKeyed(record: Record>, options?: ZipOptions): CoreJS.CoreJSIteratorObject<[PropertyKey, T, U]>; +} + +declare var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/56/proposals/iterator-range.d.ts b/packages/core-js-types/src/base/proposals/iterator-range.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/iterator-range.d.ts rename to packages/core-js-types/src/base/proposals/iterator-range.d.ts diff --git a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts new file mode 100644 index 000000000000..8a3ad0958ace --- /dev/null +++ b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts @@ -0,0 +1,15 @@ +/// + +// proposal stage: 2.7 +// https://github.com/tc39/proposal-iterator-sequencing + +interface IteratorConstructor { // @type-options no-extends + /** + * Creates an iterator that sequentially yields values from the provided iterables. + * @param iterators The iterables to concatenate. + * @returns An iterator yielding values from each input iterable in sequence. + */ + concat(...iterators: Iterable[]): CoreJS.CoreJSIteratorObject; +} + +declare var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/json-parse-with-source.d.ts rename to packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts diff --git a/packages/core-js-types/src/56/proposals/map-upsert.d.ts b/packages/core-js-types/src/base/proposals/map-upsert.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/map-upsert.d.ts rename to packages/core-js-types/src/base/proposals/map-upsert.d.ts diff --git a/packages/core-js-types/src/56/proposals/math-sum.d.ts b/packages/core-js-types/src/base/proposals/math-sum.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/math-sum.d.ts rename to packages/core-js-types/src/base/proposals/math-sum.d.ts diff --git a/packages/core-js-types/src/56/proposals/number-clamp.d.ts b/packages/core-js-types/src/base/proposals/number-clamp.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/number-clamp.d.ts rename to packages/core-js-types/src/base/proposals/number-clamp.d.ts diff --git a/packages/core-js-types/src/56/proposals/object-from-entries.d.ts b/packages/core-js-types/src/base/proposals/object-from-entries.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/object-from-entries.d.ts rename to packages/core-js-types/src/base/proposals/object-from-entries.d.ts diff --git a/packages/core-js-types/src/56/proposals/object-get-own-property-descriptors.d.ts b/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/object-get-own-property-descriptors.d.ts rename to packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts diff --git a/packages/core-js-types/src/56/proposals/object-values-entries.d.ts b/packages/core-js-types/src/base/proposals/object-values-entries.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/object-values-entries.d.ts rename to packages/core-js-types/src/base/proposals/object-values-entries.d.ts diff --git a/packages/core-js-types/src/52/proposals/pattern-matching.d.ts b/packages/core-js-types/src/base/proposals/pattern-matching.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/pattern-matching.d.ts rename to packages/core-js-types/src/base/proposals/pattern-matching.d.ts diff --git a/packages/core-js-types/src/56/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/promise-all-settled.d.ts rename to packages/core-js-types/src/base/proposals/promise-all-settled.d.ts diff --git a/packages/core-js-types/src/56/proposals/promise-any.d.ts b/packages/core-js-types/src/base/proposals/promise-any.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/promise-any.d.ts rename to packages/core-js-types/src/base/proposals/promise-any.d.ts diff --git a/packages/core-js-types/src/56/proposals/promise-finally.d.ts b/packages/core-js-types/src/base/proposals/promise-finally.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/promise-finally.d.ts rename to packages/core-js-types/src/base/proposals/promise-finally.d.ts diff --git a/packages/core-js-types/src/56/proposals/promise-try.d.ts b/packages/core-js-types/src/base/proposals/promise-try.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/promise-try.d.ts rename to packages/core-js-types/src/base/proposals/promise-try.d.ts diff --git a/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts similarity index 99% rename from packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts rename to packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts index f59b720b151c..3478f3d1a778 100644 --- a/packages/core-js-types/src/56/proposals/promise-with-resolvers.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts @@ -24,5 +24,3 @@ interface PromiseConstructor { */ withResolvers(): PromiseWithResolvers; } - - diff --git a/packages/core-js-types/src/56/proposals/regexp-dotall-flag.d.ts b/packages/core-js-types/src/base/proposals/regexp-dotall-flag.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/regexp-dotall-flag.d.ts rename to packages/core-js-types/src/base/proposals/regexp-dotall-flag.d.ts diff --git a/packages/core-js-types/src/56/proposals/regexp-escaping.d.ts b/packages/core-js-types/src/base/proposals/regexp-escaping.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/regexp-escaping.d.ts rename to packages/core-js-types/src/base/proposals/regexp-escaping.d.ts diff --git a/packages/core-js-types/src/52/proposals/regexp-named-groups.d.ts b/packages/core-js-types/src/base/proposals/regexp-named-groups.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/regexp-named-groups.d.ts rename to packages/core-js-types/src/base/proposals/regexp-named-groups.d.ts diff --git a/packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/relative-indexing-method.d.ts rename to packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts diff --git a/packages/core-js-types/src/56/proposals/set-methods-custom.d.ts b/packages/core-js-types/src/base/proposals/set-methods-custom.d.ts similarity index 91% rename from packages/core-js-types/src/56/proposals/set-methods-custom.d.ts rename to packages/core-js-types/src/base/proposals/set-methods-custom.d.ts index 6e5e628e8ba2..a99087996264 100644 --- a/packages/core-js-types/src/56/proposals/set-methods-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/set-methods-custom.d.ts @@ -1,3 +1,5 @@ +// Motivation: Custom type needed to keep generics strict + // proposal stage: 4 // https://github.com/tc39/proposal-set-methods diff --git a/packages/core-js-types/src/56/proposals/set-methods.d.ts b/packages/core-js-types/src/base/proposals/set-methods.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/set-methods.d.ts rename to packages/core-js-types/src/base/proposals/set-methods.d.ts diff --git a/packages/core-js-types/src/56/proposals/string-cooked.d.ts b/packages/core-js-types/src/base/proposals/string-cooked.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/string-cooked.d.ts rename to packages/core-js-types/src/base/proposals/string-cooked.d.ts diff --git a/packages/core-js-types/src/56/proposals/string-dedent.d.ts b/packages/core-js-types/src/base/proposals/string-dedent.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/string-dedent.d.ts rename to packages/core-js-types/src/base/proposals/string-dedent.d.ts diff --git a/packages/core-js-types/src/56/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/string-left-right-trim.d.ts rename to packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts diff --git a/packages/core-js-types/src/56/proposals/string-match-all.d.ts b/packages/core-js-types/src/base/proposals/string-match-all.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/string-match-all.d.ts rename to packages/core-js-types/src/base/proposals/string-match-all.d.ts diff --git a/packages/core-js-types/src/56/proposals/string-padding.d.ts b/packages/core-js-types/src/base/proposals/string-padding.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/string-padding.d.ts rename to packages/core-js-types/src/base/proposals/string-padding.d.ts diff --git a/packages/core-js-types/src/56/proposals/string-replace-all-custom.d.ts b/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts similarity index 90% rename from packages/core-js-types/src/56/proposals/string-replace-all-custom.d.ts rename to packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts index 928f0d7dc10e..d456ad35fb2f 100644 --- a/packages/core-js-types/src/56/proposals/string-replace-all-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts @@ -1,3 +1,5 @@ +// Motivation: Custom type needed to keep generics strict + // proposal stage: 4 // https://github.com/tc39/proposal-string-replaceall diff --git a/packages/core-js-types/src/56/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/proposals/string-replace-all.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/string-replace-all.d.ts rename to packages/core-js-types/src/base/proposals/string-replace-all.d.ts diff --git a/packages/core-js-types/src/56/proposals/symbol-description.d.ts b/packages/core-js-types/src/base/proposals/symbol-description.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/symbol-description.d.ts rename to packages/core-js-types/src/base/proposals/symbol-description.d.ts diff --git a/packages/core-js-types/src/56/proposals/symbol-predicates.d.ts b/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/symbol-predicates.d.ts rename to packages/core-js-types/src/base/proposals/symbol-predicates.d.ts diff --git a/packages/core-js-types/src/56/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/well-formed-unicode-strings.d.ts rename to packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts diff --git a/packages/core-js-types/src/56/common/pure/date.d.ts b/packages/core-js-types/src/base/pure/common/date.d.ts similarity index 100% rename from packages/core-js-types/src/56/common/pure/date.d.ts rename to packages/core-js-types/src/base/pure/common/date.d.ts diff --git a/packages/core-js-types/src/56/common/pure/global-this.d.ts b/packages/core-js-types/src/base/pure/common/global-this.d.ts similarity index 100% rename from packages/core-js-types/src/56/common/pure/global-this.d.ts rename to packages/core-js-types/src/base/pure/common/global-this.d.ts diff --git a/packages/core-js-types/src/56/common/pure/parse-float.d.ts b/packages/core-js-types/src/base/pure/common/parse-float.d.ts similarity index 100% rename from packages/core-js-types/src/56/common/pure/parse-float.d.ts rename to packages/core-js-types/src/base/pure/common/parse-float.d.ts diff --git a/packages/core-js-types/src/56/common/pure/parse-int.d.ts b/packages/core-js-types/src/base/pure/common/parse-int.d.ts similarity index 100% rename from packages/core-js-types/src/56/common/pure/parse-int.d.ts rename to packages/core-js-types/src/base/pure/common/parse-int.d.ts diff --git a/packages/core-js-types/src/56/common/pure/reflect.d.ts b/packages/core-js-types/src/base/pure/common/reflect.d.ts similarity index 100% rename from packages/core-js-types/src/56/common/pure/reflect.d.ts rename to packages/core-js-types/src/base/pure/common/reflect.d.ts diff --git a/packages/core-js-types/src/56/common/pure/self.d.ts b/packages/core-js-types/src/base/pure/common/self.d.ts similarity index 100% rename from packages/core-js-types/src/56/common/pure/self.d.ts rename to packages/core-js-types/src/base/pure/common/self.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/array-buffer-base64.d.ts b/packages/core-js-types/src/base/pure/proposals/array-buffer-base64.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/array-buffer-base64.d.ts rename to packages/core-js-types/src/base/pure/proposals/array-buffer-base64.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/array-buffer-transfer.d.ts rename to packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/array-constructor.d.ts b/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/array-constructor.d.ts rename to packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/array-from-async.d.ts b/packages/core-js-types/src/base/pure/proposals/array-from-async.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/array-from-async.d.ts rename to packages/core-js-types/src/base/pure/proposals/array-from-async.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/async-iteration.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iteration.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/async-iteration.d.ts rename to packages/core-js-types/src/base/pure/proposals/async-iteration.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/async-iterator-helpers.d.ts rename to packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/decorator-metadata.d.ts b/packages/core-js-types/src/base/pure/proposals/decorator-metadata.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/decorator-metadata.d.ts rename to packages/core-js-types/src/base/pure/proposals/decorator-metadata.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/explicit-resource-management.d.ts b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/explicit-resource-management.d.ts rename to packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-chunking.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator-chunking.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/iterator-chunking.d.ts rename to packages/core-js-types/src/base/pure/proposals/iterator-chunking.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator-helpers.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/iterator-helpers.d.ts rename to packages/core-js-types/src/base/pure/proposals/iterator-helpers.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-join.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator-join.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/iterator-join.d.ts rename to packages/core-js-types/src/base/pure/proposals/iterator-join.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-joint.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator-joint.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/iterator-joint.d.ts rename to packages/core-js-types/src/base/pure/proposals/iterator-joint.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-range.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator-range.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/iterator-range.d.ts rename to packages/core-js-types/src/base/pure/proposals/iterator-range.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/iterator-sequencing.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator-sequencing.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/iterator-sequencing.d.ts rename to packages/core-js-types/src/base/pure/proposals/iterator-sequencing.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/iterator.d.ts rename to packages/core-js-types/src/base/pure/proposals/iterator.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/pattern-matching.d.ts b/packages/core-js-types/src/base/pure/proposals/pattern-matching.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/pattern-matching.d.ts rename to packages/core-js-types/src/base/pure/proposals/pattern-matching.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/relative-indexing-method.d.ts b/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/relative-indexing-method.d.ts rename to packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/string-left-right-trim.d.ts b/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/string-left-right-trim.d.ts rename to packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/string-match-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/string-match-all.d.ts rename to packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/string-padding.d.ts b/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/string-padding.d.ts rename to packages/core-js-types/src/base/pure/proposals/string-padding.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/string-replace-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/string-replace-all.d.ts rename to packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/symbol-description.d.ts b/packages/core-js-types/src/base/pure/proposals/symbol-description.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/symbol-description.d.ts rename to packages/core-js-types/src/base/pure/proposals/symbol-description.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/symbol-predicates.d.ts b/packages/core-js-types/src/base/pure/proposals/symbol-predicates.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/symbol-predicates.d.ts rename to packages/core-js-types/src/base/pure/proposals/symbol-predicates.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/symbol.d.ts b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/symbol.d.ts rename to packages/core-js-types/src/base/pure/proposals/symbol.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/typed-arrays.d.ts b/packages/core-js-types/src/base/pure/proposals/typed-arrays.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/typed-arrays.d.ts rename to packages/core-js-types/src/base/pure/proposals/typed-arrays.d.ts diff --git a/packages/core-js-types/src/56/proposals/pure/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pure/well-formed-unicode-strings.d.ts rename to packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts diff --git a/packages/core-js-types/src/56/web/pure/dom-exception.d.ts b/packages/core-js-types/src/base/pure/web/dom-exception.d.ts similarity index 100% rename from packages/core-js-types/src/56/web/pure/dom-exception.d.ts rename to packages/core-js-types/src/base/pure/web/dom-exception.d.ts diff --git a/packages/core-js-types/src/56/web/pure/url-parse.d.ts b/packages/core-js-types/src/base/pure/web/url-parse.d.ts similarity index 100% rename from packages/core-js-types/src/56/web/pure/url-parse.d.ts rename to packages/core-js-types/src/base/pure/web/url-parse.d.ts diff --git a/packages/core-js-types/src/56/web/pure/url-search-params.d.ts b/packages/core-js-types/src/base/pure/web/url-search-params.d.ts similarity index 100% rename from packages/core-js-types/src/56/web/pure/url-search-params.d.ts rename to packages/core-js-types/src/base/pure/web/url-search-params.d.ts diff --git a/packages/core-js-types/src/56/web/pure/url.d.ts b/packages/core-js-types/src/base/pure/web/url.d.ts similarity index 100% rename from packages/core-js-types/src/56/web/pure/url.d.ts rename to packages/core-js-types/src/base/pure/web/url.d.ts diff --git a/packages/core-js-types/src/56/web/atob-btoa.d.ts b/packages/core-js-types/src/base/web/atob-btoa.d.ts similarity index 100% rename from packages/core-js-types/src/56/web/atob-btoa.d.ts rename to packages/core-js-types/src/base/web/atob-btoa.d.ts diff --git a/packages/core-js-types/src/56/web/efficient-script-yielding.d.ts b/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts similarity index 100% rename from packages/core-js-types/src/56/web/efficient-script-yielding.d.ts rename to packages/core-js-types/src/base/web/efficient-script-yielding.d.ts diff --git a/packages/core-js-types/src/56/web/queue-microtask.d.ts b/packages/core-js-types/src/base/web/queue-microtask.d.ts similarity index 100% rename from packages/core-js-types/src/56/web/queue-microtask.d.ts rename to packages/core-js-types/src/base/web/queue-microtask.d.ts diff --git a/packages/core-js-types/src/56/web/structured-clone.d.ts b/packages/core-js-types/src/base/web/structured-clone.d.ts similarity index 100% rename from packages/core-js-types/src/56/web/structured-clone.d.ts rename to packages/core-js-types/src/base/web/structured-clone.d.ts diff --git a/packages/core-js-types/src/56/web/url-to-json.d.ts b/packages/core-js-types/src/base/web/url-to-json.d.ts similarity index 100% rename from packages/core-js-types/src/56/web/url-to-json.d.ts rename to packages/core-js-types/src/base/web/url-to-json.d.ts diff --git a/packages/core-js-types/src/52/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts similarity index 100% rename from packages/core-js-types/src/52/core-js-types/core-js-types.d.ts rename to packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts diff --git a/packages/core-js-types/src/52/proposals/accessible-object-hasownproperty.d.ts b/packages/core-js-types/src/ts5-2/proposals/accessible-object-hasownproperty.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/accessible-object-hasownproperty.d.ts rename to packages/core-js-types/src/ts5-2/proposals/accessible-object-hasownproperty.d.ts diff --git a/packages/core-js-types/src/52/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-buffer-base64.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/array-buffer-base64.d.ts rename to packages/core-js-types/src/ts5-2/proposals/array-buffer-base64.d.ts diff --git a/packages/core-js-types/src/52/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-buffer-transfer.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/array-buffer-transfer.d.ts rename to packages/core-js-types/src/ts5-2/proposals/array-buffer-transfer.d.ts diff --git a/packages/core-js-types/src/52/proposals/array-filtering.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-filtering.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/array-filtering.d.ts rename to packages/core-js-types/src/ts5-2/proposals/array-filtering.d.ts diff --git a/packages/core-js-types/src/52/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-find-from-last.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/array-find-from-last.d.ts rename to packages/core-js-types/src/ts5-2/proposals/array-find-from-last.d.ts diff --git a/packages/core-js-types/src/52/proposals/array-flat-map-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-flat-map-custom.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/array-flat-map-custom.d.ts rename to packages/core-js-types/src/ts5-2/proposals/array-flat-map-custom.d.ts diff --git a/packages/core-js-types/src/52/proposals/array-flat-map.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-flat-map.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/array-flat-map.d.ts rename to packages/core-js-types/src/ts5-2/proposals/array-flat-map.d.ts diff --git a/packages/core-js-types/src/52/proposals/array-from-async.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-from-async.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/array-from-async.d.ts rename to packages/core-js-types/src/ts5-2/proposals/array-from-async.d.ts diff --git a/packages/core-js-types/src/52/proposals/array-grouping.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-grouping.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/array-grouping.d.ts rename to packages/core-js-types/src/ts5-2/proposals/array-grouping.d.ts diff --git a/packages/core-js-types/src/52/proposals/array-includes.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-includes.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/array-includes.d.ts rename to packages/core-js-types/src/ts5-2/proposals/array-includes.d.ts diff --git a/packages/core-js-types/src/52/proposals/array-is-template-object.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-is-template-object.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/array-is-template-object.d.ts rename to packages/core-js-types/src/ts5-2/proposals/array-is-template-object.d.ts diff --git a/packages/core-js-types/src/52/proposals/array-unique.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-unique.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/array-unique.d.ts rename to packages/core-js-types/src/ts5-2/proposals/array-unique.d.ts diff --git a/packages/core-js-types/src/52/proposals/async-iteration.d.ts b/packages/core-js-types/src/ts5-2/proposals/async-iteration.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/async-iteration.d.ts rename to packages/core-js-types/src/ts5-2/proposals/async-iteration.d.ts diff --git a/packages/core-js-types/src/52/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/async-iterator-helpers.d.ts rename to packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts diff --git a/packages/core-js-types/src/52/proposals/await-dictionary.d.ts b/packages/core-js-types/src/ts5-2/proposals/await-dictionary.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/await-dictionary.d.ts rename to packages/core-js-types/src/ts5-2/proposals/await-dictionary.d.ts diff --git a/packages/core-js-types/src/52/proposals/change-array-by-copy-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy-custom.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/change-array-by-copy-custom.d.ts rename to packages/core-js-types/src/ts5-2/proposals/change-array-by-copy-custom.d.ts diff --git a/packages/core-js-types/src/52/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/change-array-by-copy.d.ts rename to packages/core-js-types/src/ts5-2/proposals/change-array-by-copy.d.ts diff --git a/packages/core-js-types/src/52/proposals/collection-of-from.d.ts b/packages/core-js-types/src/ts5-2/proposals/collection-of-from.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/collection-of-from.d.ts rename to packages/core-js-types/src/ts5-2/proposals/collection-of-from.d.ts diff --git a/packages/core-js-types/src/52/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/ts5-2/proposals/data-view-get-set-uint8-clamped.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/data-view-get-set-uint8-clamped.d.ts rename to packages/core-js-types/src/ts5-2/proposals/data-view-get-set-uint8-clamped.d.ts diff --git a/packages/core-js-types/src/52/proposals/decorator-metadata.d.ts b/packages/core-js-types/src/ts5-2/proposals/decorator-metadata.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/decorator-metadata.d.ts rename to packages/core-js-types/src/ts5-2/proposals/decorator-metadata.d.ts diff --git a/packages/core-js-types/src/52/proposals/error-cause.d.ts b/packages/core-js-types/src/ts5-2/proposals/error-cause.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/error-cause.d.ts rename to packages/core-js-types/src/ts5-2/proposals/error-cause.d.ts diff --git a/packages/core-js-types/src/52/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/explicit-resource-management.d.ts rename to packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts diff --git a/packages/core-js-types/src/52/proposals/float16.d.ts b/packages/core-js-types/src/ts5-2/proposals/float16.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/float16.d.ts rename to packages/core-js-types/src/ts5-2/proposals/float16.d.ts diff --git a/packages/core-js-types/src/52/proposals/function-demethodize.d.ts b/packages/core-js-types/src/ts5-2/proposals/function-demethodize.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/function-demethodize.d.ts rename to packages/core-js-types/src/ts5-2/proposals/function-demethodize.d.ts diff --git a/packages/core-js-types/src/52/proposals/is-error.d.ts b/packages/core-js-types/src/ts5-2/proposals/is-error.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/is-error.d.ts rename to packages/core-js-types/src/ts5-2/proposals/is-error.d.ts diff --git a/packages/core-js-types/src/52/proposals/iterator-chunking.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-chunking.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/iterator-chunking.d.ts rename to packages/core-js-types/src/ts5-2/proposals/iterator-chunking.d.ts diff --git a/packages/core-js-types/src/52/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers-custom.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/iterator-helpers-custom.d.ts rename to packages/core-js-types/src/ts5-2/proposals/iterator-helpers-custom.d.ts diff --git a/packages/core-js-types/src/52/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/iterator-helpers.d.ts rename to packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts diff --git a/packages/core-js-types/src/56/proposals/iterator-join.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-join.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/iterator-join.d.ts rename to packages/core-js-types/src/ts5-2/proposals/iterator-join.d.ts diff --git a/packages/core-js-types/src/52/proposals/iterator-joint.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-joint.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/iterator-joint.d.ts rename to packages/core-js-types/src/ts5-2/proposals/iterator-joint.d.ts diff --git a/packages/core-js-types/src/52/proposals/iterator-range.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-range.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/iterator-range.d.ts rename to packages/core-js-types/src/ts5-2/proposals/iterator-range.d.ts diff --git a/packages/core-js-types/src/52/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-sequencing.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/iterator-sequencing.d.ts rename to packages/core-js-types/src/ts5-2/proposals/iterator-sequencing.d.ts diff --git a/packages/core-js-types/src/52/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/ts5-2/proposals/json-parse-with-source.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/json-parse-with-source.d.ts rename to packages/core-js-types/src/ts5-2/proposals/json-parse-with-source.d.ts diff --git a/packages/core-js-types/src/52/proposals/map-upsert.d.ts b/packages/core-js-types/src/ts5-2/proposals/map-upsert.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/map-upsert.d.ts rename to packages/core-js-types/src/ts5-2/proposals/map-upsert.d.ts diff --git a/packages/core-js-types/src/52/proposals/math-sum.d.ts b/packages/core-js-types/src/ts5-2/proposals/math-sum.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/math-sum.d.ts rename to packages/core-js-types/src/ts5-2/proposals/math-sum.d.ts diff --git a/packages/core-js-types/src/52/proposals/number-clamp.d.ts b/packages/core-js-types/src/ts5-2/proposals/number-clamp.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/number-clamp.d.ts rename to packages/core-js-types/src/ts5-2/proposals/number-clamp.d.ts diff --git a/packages/core-js-types/src/52/proposals/object-from-entries.d.ts b/packages/core-js-types/src/ts5-2/proposals/object-from-entries.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/object-from-entries.d.ts rename to packages/core-js-types/src/ts5-2/proposals/object-from-entries.d.ts diff --git a/packages/core-js-types/src/52/proposals/object-get-own-property-descriptors.d.ts b/packages/core-js-types/src/ts5-2/proposals/object-get-own-property-descriptors.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/object-get-own-property-descriptors.d.ts rename to packages/core-js-types/src/ts5-2/proposals/object-get-own-property-descriptors.d.ts diff --git a/packages/core-js-types/src/52/proposals/object-values-entries.d.ts b/packages/core-js-types/src/ts5-2/proposals/object-values-entries.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/object-values-entries.d.ts rename to packages/core-js-types/src/ts5-2/proposals/object-values-entries.d.ts diff --git a/packages/core-js-types/src/56/proposals/pattern-matching.d.ts b/packages/core-js-types/src/ts5-2/proposals/pattern-matching.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/pattern-matching.d.ts rename to packages/core-js-types/src/ts5-2/proposals/pattern-matching.d.ts diff --git a/packages/core-js-types/src/52/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-all-settled.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/promise-all-settled.d.ts rename to packages/core-js-types/src/ts5-2/proposals/promise-all-settled.d.ts diff --git a/packages/core-js-types/src/52/proposals/promise-any.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-any.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/promise-any.d.ts rename to packages/core-js-types/src/ts5-2/proposals/promise-any.d.ts diff --git a/packages/core-js-types/src/52/proposals/promise-finally.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-finally.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/promise-finally.d.ts rename to packages/core-js-types/src/ts5-2/proposals/promise-finally.d.ts diff --git a/packages/core-js-types/src/52/proposals/promise-try.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-try.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/promise-try.d.ts rename to packages/core-js-types/src/ts5-2/proposals/promise-try.d.ts diff --git a/packages/core-js-types/src/52/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-with-resolvers.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/promise-with-resolvers.d.ts rename to packages/core-js-types/src/ts5-2/proposals/promise-with-resolvers.d.ts diff --git a/packages/core-js-types/src/52/proposals/regexp-dotall-flag.d.ts b/packages/core-js-types/src/ts5-2/proposals/regexp-dotall-flag.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/regexp-dotall-flag.d.ts rename to packages/core-js-types/src/ts5-2/proposals/regexp-dotall-flag.d.ts diff --git a/packages/core-js-types/src/52/proposals/regexp-escaping.d.ts b/packages/core-js-types/src/ts5-2/proposals/regexp-escaping.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/regexp-escaping.d.ts rename to packages/core-js-types/src/ts5-2/proposals/regexp-escaping.d.ts diff --git a/packages/core-js-types/src/56/proposals/regexp-named-groups.d.ts b/packages/core-js-types/src/ts5-2/proposals/regexp-named-groups.d.ts similarity index 100% rename from packages/core-js-types/src/56/proposals/regexp-named-groups.d.ts rename to packages/core-js-types/src/ts5-2/proposals/regexp-named-groups.d.ts diff --git a/packages/core-js-types/src/52/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/ts5-2/proposals/relative-indexing-method.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/relative-indexing-method.d.ts rename to packages/core-js-types/src/ts5-2/proposals/relative-indexing-method.d.ts diff --git a/packages/core-js-types/src/52/proposals/set-methods-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/set-methods-custom.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/set-methods-custom.d.ts rename to packages/core-js-types/src/ts5-2/proposals/set-methods-custom.d.ts diff --git a/packages/core-js-types/src/52/proposals/set-methods.d.ts b/packages/core-js-types/src/ts5-2/proposals/set-methods.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/set-methods.d.ts rename to packages/core-js-types/src/ts5-2/proposals/set-methods.d.ts diff --git a/packages/core-js-types/src/52/proposals/string-cooked.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-cooked.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/string-cooked.d.ts rename to packages/core-js-types/src/ts5-2/proposals/string-cooked.d.ts diff --git a/packages/core-js-types/src/52/proposals/string-dedent.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-dedent.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/string-dedent.d.ts rename to packages/core-js-types/src/ts5-2/proposals/string-dedent.d.ts diff --git a/packages/core-js-types/src/52/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-left-right-trim.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/string-left-right-trim.d.ts rename to packages/core-js-types/src/ts5-2/proposals/string-left-right-trim.d.ts diff --git a/packages/core-js-types/src/52/proposals/string-match-all.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/string-match-all.d.ts rename to packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts diff --git a/packages/core-js-types/src/52/proposals/string-padding.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-padding.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/string-padding.d.ts rename to packages/core-js-types/src/ts5-2/proposals/string-padding.d.ts diff --git a/packages/core-js-types/src/52/proposals/string-replace-all-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-replace-all-custom.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/string-replace-all-custom.d.ts rename to packages/core-js-types/src/ts5-2/proposals/string-replace-all-custom.d.ts diff --git a/packages/core-js-types/src/52/proposals/string-replace-all.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-replace-all.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/string-replace-all.d.ts rename to packages/core-js-types/src/ts5-2/proposals/string-replace-all.d.ts diff --git a/packages/core-js-types/src/52/proposals/symbol-description.d.ts b/packages/core-js-types/src/ts5-2/proposals/symbol-description.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/symbol-description.d.ts rename to packages/core-js-types/src/ts5-2/proposals/symbol-description.d.ts diff --git a/packages/core-js-types/src/52/proposals/symbol-predicates.d.ts b/packages/core-js-types/src/ts5-2/proposals/symbol-predicates.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/symbol-predicates.d.ts rename to packages/core-js-types/src/ts5-2/proposals/symbol-predicates.d.ts diff --git a/packages/core-js-types/src/52/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/ts5-2/proposals/well-formed-unicode-strings.d.ts similarity index 100% rename from packages/core-js-types/src/52/proposals/well-formed-unicode-strings.d.ts rename to packages/core-js-types/src/ts5-2/proposals/well-formed-unicode-strings.d.ts diff --git a/scripts/build-entries/templates.mjs b/scripts/build-entries/templates.mjs index a4cf01a23e10..f07d89bad9a3 100644 --- a/scripts/build-entries/templates.mjs +++ b/scripts/build-entries/templates.mjs @@ -90,7 +90,7 @@ export const $prototype = p => ({ module.exports = getBuiltInPrototypeMethod('${ p.namespace }', '${ p.name }'); `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { type method${ getGenericsForNamespace(p.namespace) } = ${ p.prefix ?? '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; export = method; } @@ -106,7 +106,7 @@ export const $prototypeIterator = p => ({ module.exports = getIteratorMethod(${ p.source }); `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const method: typeof ${ p.prefix ?? '' }${ p.namespace }.prototype[typeof Symbol.iterator]; export = method; } @@ -122,7 +122,7 @@ export const $uncurried = p => ({ module.exports = entryUnbind('${ p.namespace }', '${ p.name }'); `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { type method${ getGenericsForNamespace(p.namespace) } = ${ p.prefix ?? '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; const resultMethod: ${ getGenericsForNamespace(p.namespace) }(self: ${ p.prefix && !existsInES6(p.namespace) ? p.prefix : '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters) => ReturnType; export = resultMethod; @@ -139,7 +139,7 @@ export const $uncurriedWithCustomType = p => ({ module.exports = entryUnbind('${ p.namespace }', '${ p.name }'); `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const resultMethod: ${ getCustomGenerics(p.genericsCount) }(self: ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters<${ buildTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>) => ReturnType<${ buildTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>; export = resultMethod; } @@ -156,7 +156,7 @@ export const $uncurriedIterator = p => ({ module.exports = uncurryThis(getIteratorMethod(${ p.source })); `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { type method${ getGenericsForNamespace(p.namespace) } = ${ p.namespace }${ getGenericsForNamespace(p.namespace) }[typeof Symbol.iterator]; const resultMethod: ${ getGenericsForNamespace(p.namespace) }(self: ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters) => ReturnType; export = resultMethod; @@ -173,7 +173,7 @@ export const $static = p => ({ module.exports = getBuiltInStaticMethod('${ p.namespace }', '${ p.name }'); `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const method: typeof ${ p.prefix ?? '' }${ p.namespace }.${ p.name }; export = method; } @@ -196,7 +196,7 @@ export const $staticWithContext = p => ({ }; `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const method: typeof ${ p.prefix ?? '' }${ p.namespace }.${ p.name }; export = method; } @@ -215,7 +215,7 @@ export const $patchableStatic = p => ({ }; `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const method: typeof ${ p.prefix ?? '' }${ p.namespace }.${ p.name }; export = method; } @@ -231,7 +231,7 @@ export const $namespace = p => ({ module.exports = path.${ p.name }; `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const namespace: typeof ${ p.prefix ?? '' }${ p.name }; export = namespace; } @@ -247,7 +247,7 @@ export const $helper = p => ({ module.exports = $export; `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const helper: (arg: NonNullable) => any; export = helper; } @@ -263,7 +263,7 @@ export const $path = p => ({ module.exports = path; `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const path: typeof globalThis; export = path; } @@ -284,7 +284,7 @@ export const $instanceArray = p => ({ }; `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; } @@ -306,7 +306,7 @@ export const $instanceNumber = p => ({ }; `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; } @@ -328,7 +328,7 @@ export const $instanceString = p => ({ }; `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; } @@ -350,7 +350,7 @@ export const $instanceFunction = p => ({ }; `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; } @@ -378,7 +378,7 @@ export const $instanceDOMIterables = p => ({ }; `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; } @@ -403,7 +403,7 @@ export const $instanceArrayString = p => ({ }; `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; } @@ -434,7 +434,7 @@ export const $instanceArrayDOMIterables = p => ({ }; `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; } @@ -455,7 +455,7 @@ export const $instanceRegExpFlags = p => ({ }; `, dts: dedent` - declare module "${ p.packageName }${ p.entry }" { + declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; } diff --git a/scripts/build-types/config.mjs b/scripts/build-types/config.mjs index 70d25b071c78..db92f43b9541 100644 --- a/scripts/build-types/config.mjs +++ b/scripts/build-types/config.mjs @@ -6,4 +6,5 @@ export default { packageTemplate: 'scripts/build-types/package.tpl.json', packageDir: 'packages/core-js-types/', srcDir: 'packages/core-js-types/src/', + srcBase: 'base', }; diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index fb0ef1edfaba..1c35a8744f3a 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -7,7 +7,7 @@ import { argv, path, fs } from 'zx'; import { expandModules, modulesToStage } from '../build-entries/helpers.mjs'; import { preparePureTypes } from './pure.mjs'; -const { copy, outputFile, pathExists, readdir, readJson, remove, writeJson } = fs; +const { copy, outputFile, pathExists, readdir, readFile, readJson, remove, writeJson } = fs; const versionArg = argv._.find(item => item.startsWith('version=')); const VERSION = versionArg ? versionArg.slice('version='.length) : undefined; @@ -64,8 +64,7 @@ async function buildType(entry, options) { types.forEach(type => { imports[subset].add(type); - const fileName = path.basename(type); - imports.pure.add(type.replace(fileName, path.join('pure', fileName))); + imports.pure.add(path.join('pure', type)); }); if (customType) { imports[subset].add(customType); @@ -118,23 +117,23 @@ async function fillCustomImportsForPure(typesPath, initialPath) { if (entry.isDirectory()) { await fillCustomImportsForPure(path.join(typesPath, entry.name), initialPath); } else { - const dirName = path.basename(typesPath); - if (dirName !== 'pure') continue; const filePath = path.join(typesPath, entry.name); - const fileStats = await fs.stat(filePath); - if (fileStats.size === 0) continue; + const fileContent = await readFile(filePath).toString(); + if (fileContent.startsWith('// empty')) continue; imports.pure.add(filePath.replace(`${ initialPath }/`, '').replace('.d.ts', '')); } } } async function buildTypesForTSVersion(tsVersion) { - tsVersion = tsVersion.toString().replace('.', ''); + tsVersion = `ts${ tsVersion.toString().replace('.', '-') }`; const bundlePath = path.join(config.buildDir, tsVersion); + const distTypesPath = path.join(bundlePath, 'types'); if (await pathExists(bundlePath)) await remove(bundlePath); + await copy(path.join(config.srcDir, config.srcBase), path.join(config.buildDir, tsVersion, 'types')); await copy(path.join(config.srcDir, tsVersion), path.join(config.buildDir, tsVersion, 'types')); - await fillCustomImportsForPure(bundlePath, path.join(bundlePath, 'types')); - await preparePureTypes(bundlePath); + await fillCustomImportsForPure(path.join(bundlePath, 'types', 'pure'), distTypesPath); + await preparePureTypes(bundlePath, distTypesPath); for (const [entry, definition] of Object.entries(features)) { await buildType(`es/${ entry }`, { ...definition, entryFromNamespace: 'es', tsVersion }); @@ -163,7 +162,7 @@ async function buildPackageJson(breakpoints, namespaces) { packageJson.typesVersions = {}; breakpoints.forEach(breakpoint => { packageJson.typesVersions[`>=${ breakpoint }`] = { - '*': [`./dist/${ breakpoint.toString().replace('.', '') }/*`], + '*': [`./dist/ts${ breakpoint.toString().replace('.', '-') }/*`], }; }); packageJson.exports = {}; @@ -172,10 +171,10 @@ async function buildPackageJson(breakpoints, namespaces) { packageJson.exports[namespaceKey] = {}; breakpoints.forEach((breakpoint, index) => { const isLast = index === breakpoints.length - 1; - const breakpointString = breakpoint.toString().replace('.', ''); + const breakpointString = `ts${ breakpoint.toString().replace('.', '-') }`; packageJson.exports[namespaceKey][`types${ isLast ? '' : `@>=${ breakpoint }` }`] = `./dist/${ breakpointString }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; }); - packageJson.exports[namespaceKey].default = `./dist/${ defaultBreakpoint.toString().replace('.', '') }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; + packageJson.exports[namespaceKey].default = `./dist/ts${ defaultBreakpoint.toString().replace('.', '-') }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; if (options.default) { packageJson.exports['.'] = packageJson.exports[namespaceKey]; } diff --git a/scripts/build-types/pure.mjs b/scripts/build-types/pure.mjs index aa82162c9b7e..ec4a99df9df2 100644 --- a/scripts/build-types/pure.mjs +++ b/scripts/build-types/pure.mjs @@ -125,16 +125,16 @@ function wrapDTSInNamespace(content, namespace = 'CoreJS') { return `${ preamble.length ? `${ preamble.join('\n') }\n` : '' }declare namespace ${ namespace } {\n${ nsBody }\n}\n`; } -export async function preparePureTypes(typesPath) { +export async function preparePureTypes(typesPath, initialPath) { const entries = await readdir(typesPath, { withFileTypes: true }); for (const entry of entries) { if (entry.name === 'pure') continue; if (entry.isDirectory()) { - await preparePureTypes(path.join(typesPath, entry.name)); + await preparePureTypes(path.join(typesPath, entry.name), initialPath); } else { if (entry.name.includes('core-js-types.d.ts')) continue; const typePath = path.join(typesPath, entry.name); - const resultFilePath = typePath.replace(entry.name, `pure/${ entry.name }`); + const resultFilePath = typePath.replace(initialPath, `${ initialPath }/pure/`); if (await pathExists(resultFilePath)) continue; const content = await fs.readFile(typePath, 'utf8'); if (content.includes('declare namespace')) continue; From 8fb3711f4437a52d8b06d6e621c15eee41933ec0 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 9 Dec 2025 14:31:18 +0700 Subject: [PATCH 077/315] Fix not existing src path --- scripts/build-types/index.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 1c35a8744f3a..aca90f771435 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -131,7 +131,10 @@ async function buildTypesForTSVersion(tsVersion) { const distTypesPath = path.join(bundlePath, 'types'); if (await pathExists(bundlePath)) await remove(bundlePath); await copy(path.join(config.srcDir, config.srcBase), path.join(config.buildDir, tsVersion, 'types')); - await copy(path.join(config.srcDir, tsVersion), path.join(config.buildDir, tsVersion, 'types')); + const srcPath = path.join(config.srcDir, tsVersion); + if (await pathExists(srcPath)) { + await copy(srcPath, distTypesPath); + } await fillCustomImportsForPure(path.join(bundlePath, 'types', 'pure'), distTypesPath); await preparePureTypes(bundlePath, distTypesPath); From 264b470997d0ffe0f318758fb6d3214f5e277f84 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 9 Dec 2025 23:40:27 +0700 Subject: [PATCH 078/315] Fix lib paths & add module name variations & remove config --- scripts/build-types/config.mjs | 10 ---- scripts/build-types/index.mjs | 54 ++++++++++++++----- tests/type-definitions/entries.pure.ts | 8 +++ .../type-definitions/global/web/atob.test.ts | 3 +- .../type-definitions/global/web/btoa.test.ts | 3 +- .../web/efficient-script-yielding.test.ts | 1 - .../global/web/queue-microtask.test.ts | 3 +- .../global/web/structured-clone.test.ts | 3 +- .../global/web/url-to-json.test.ts | 3 +- tests/type-definitions/runner.mjs | 1 + .../tsconfig.entries.pure.json | 14 +++++ 11 files changed, 70 insertions(+), 33 deletions(-) delete mode 100644 scripts/build-types/config.mjs create mode 100644 tests/type-definitions/entries.pure.ts create mode 100644 tests/type-definitions/tsconfig.entries.pure.json diff --git a/scripts/build-types/config.mjs b/scripts/build-types/config.mjs deleted file mode 100644 index db92f43b9541..000000000000 --- a/scripts/build-types/config.mjs +++ /dev/null @@ -1,10 +0,0 @@ -export default { - buildDir: 'packages/core-js-types/dist/', - bundleName: 'core-js-types', - latestTsVersion: 59, - packageName: '@core-js/', - packageTemplate: 'scripts/build-types/package.tpl.json', - packageDir: 'packages/core-js-types/', - srcDir: 'packages/core-js-types/src/', - srcBase: 'base', -}; diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index aca90f771435..265c69d95a99 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -2,13 +2,21 @@ import { features, proposals } from '../build-entries/entries-definitions.mjs'; import { $path, $proposal } from '../build-entries/templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; import { getModulesMetadata } from '../build-entries/get-dependencies.mjs'; -import config from './config.mjs'; import { argv, path, fs } from 'zx'; import { expandModules, modulesToStage } from '../build-entries/helpers.mjs'; import { preparePureTypes } from './pure.mjs'; const { copy, outputFile, pathExists, readdir, readFile, readJson, remove, writeJson } = fs; +const BUILD_DIR = 'packages/core-js-types/dist/'; +const PACKAGE_JSON_DIR = 'packages/core-js-types/'; +const PACKAGE_NAME = 'core-js/'; +const PACKAGE_NAME_PURE = '@core-js/pure/'; +const PACKAGE_TEMPLATE = 'scripts/build-types/package.tpl.json'; +const SRC_DIR = 'packages/core-js-types/src/'; +const SRC_BASE = 'base'; +const TYPE_PREFIX = 'CoreJS.CoreJS'; + const versionArg = argv._.find(item => item.startsWith('version=')); const VERSION = versionArg ? versionArg.slice('version='.length) : undefined; const imports = { @@ -59,9 +67,6 @@ async function buildType(entry, options) { if (filter) modules = modules.filter(it => filter.has(it)); - const tplPure = template({ ...options, modules, rawModules, level, entry, types, packageName: `${ config.packageName }pure/`, prefix: 'CoreJS.CoreJS' }); - const tpl = template({ ...options, modules, rawModules, level, entry, types, packageName: config.packageName }); - types.forEach(type => { imports[subset].add(type); imports.pure.add(path.join('pure', type)); @@ -74,8 +79,33 @@ async function buildType(entry, options) { const filePath = buildFilePath(tsVersion, subset); const filePathPure = buildFilePath(tsVersion, 'pure'); - await outputFile(filePath, `${ tpl.dts }${ tpl.dts ? '\n\n' : '' }`, { flag: 'a' }); + const tplPure = template({ ...options, modules, rawModules, level, entry, types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); + const tpl = template({ ...options, modules, rawModules, level, entry, types, packageName: PACKAGE_NAME }); + await outputFile(filePathPure, `${ tplPure.dts }${ tplPure.dts ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(filePath, `${ tpl.dts }${ tpl.dts ? '\n\n' : '' }`, { flag: 'a' }); + + if (!entry.endsWith('/')) { + const entryWithExt = `${ entry }.js`; + const tplPureWithExt = template({ ...options, modules, rawModules, level, entry: entryWithExt, + types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); + const tplWithExt = template({ ...options, modules, rawModules, level, types, entry: entryWithExt, + packageName: PACKAGE_NAME }); + + await outputFile(filePathPure, `${ tplPureWithExt.dts }${ tplPureWithExt.dts ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(filePath, `${ tplWithExt.dts }${ tplWithExt.dts ? '\n\n' : '' }`, { flag: 'a' }); + } + + if (entry.endsWith('/index')) { + const entryWithoutIndex = entry.replace(/index$/, ''); + const tplPureWithoutIndex = template({ ...options, modules, rawModules, level, entry: entryWithoutIndex, types, + packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); + const tplWithoutIndex = template({ ...options, modules, rawModules, level, types, entry: entryWithoutIndex, + packageName: PACKAGE_NAME }); + + await outputFile(filePathPure, `${ tplPureWithoutIndex.dts }${ tplPureWithoutIndex.dts ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(filePath, `${ tplWithoutIndex.dts }${ tplWithoutIndex.dts ? '\n\n' : '' }`, { flag: 'a' }); + } if (proposal) { const filePathProposal = buildFilePath(tsVersion, entry); @@ -95,7 +125,7 @@ const StableSet = new Set(StableModules); const ActualSet = new Set(ActualModules); function buildFilePath(tsVersion, subset) { - return path.join(config.buildDir, tsVersion.toString(), `${ subset }.d.ts`); + return path.join(BUILD_DIR, tsVersion.toString(), `${ subset }.d.ts`); } function buildImports(importsList, level = 0) { @@ -127,11 +157,11 @@ async function fillCustomImportsForPure(typesPath, initialPath) { async function buildTypesForTSVersion(tsVersion) { tsVersion = `ts${ tsVersion.toString().replace('.', '-') }`; - const bundlePath = path.join(config.buildDir, tsVersion); + const bundlePath = path.join(BUILD_DIR, tsVersion); const distTypesPath = path.join(bundlePath, 'types'); if (await pathExists(bundlePath)) await remove(bundlePath); - await copy(path.join(config.srcDir, config.srcBase), path.join(config.buildDir, tsVersion, 'types')); - const srcPath = path.join(config.srcDir, tsVersion); + await copy(path.join(SRC_DIR, SRC_BASE), path.join(BUILD_DIR, tsVersion, 'types')); + const srcPath = path.join(SRC_DIR, tsVersion); if (await pathExists(srcPath)) { await copy(srcPath, distTypesPath); } @@ -160,7 +190,7 @@ async function buildTypesForTSVersion(tsVersion) { async function buildPackageJson(breakpoints, namespaces) { breakpoints = breakpoints.sort().reverse(); - const packageJson = await readJson(config.packageTemplate); + const packageJson = await readJson(PACKAGE_TEMPLATE); const defaultBreakpoint = Math.max(...breakpoints); packageJson.typesVersions = {}; breakpoints.forEach(breakpoint => { @@ -188,14 +218,14 @@ async function buildPackageJson(breakpoints, namespaces) { exports[key] = packageJson.exports[key]; }); packageJson.exports = exports; - writeJson(path.join(config.packageDir, 'package.json'), packageJson, { spaces: 2 }); + writeJson(path.join(PACKAGE_JSON_DIR, 'package.json'), packageJson, { spaces: 2 }); } if (VERSION) { await buildTypesForTSVersion(VERSION); } else { const tsVersionBreakpoints = [5.2, 5.6]; - await remove(config.buildDir); + await remove(BUILD_DIR); tsVersionBreakpoints.forEach(async version => await buildTypesForTSVersion(version)); const namespaces = { es: { isDir: false, default: false }, diff --git a/tests/type-definitions/entries.pure.ts b/tests/type-definitions/entries.pure.ts new file mode 100644 index 000000000000..4fd12a8f45b0 --- /dev/null +++ b/tests/type-definitions/entries.pure.ts @@ -0,0 +1,8 @@ +import $date from '@core-js/pure/full/date/index'; +new $date(); + +import $date2 from '@core-js/pure/full/date/index.js'; +new $date2(); + +import $date3 from '@core-js/pure/full/date/'; +new $date3(); diff --git a/tests/type-definitions/global/web/atob.test.ts b/tests/type-definitions/global/web/atob.test.ts index 3da270552c11..e5095168eddf 100644 --- a/tests/type-definitions/global/web/atob.test.ts +++ b/tests/type-definitions/global/web/atob.test.ts @@ -1,5 +1,4 @@ -import '@core-js/full'; -import '@core-js/types'; +import 'core-js/full'; const s: string = atob("SGVsbG8gd29ybGQ="); diff --git a/tests/type-definitions/global/web/btoa.test.ts b/tests/type-definitions/global/web/btoa.test.ts index 2a4539a0d733..f461a900aa8b 100644 --- a/tests/type-definitions/global/web/btoa.test.ts +++ b/tests/type-definitions/global/web/btoa.test.ts @@ -1,5 +1,4 @@ -import '@core-js/full'; -import '@core-js/types'; +import 'core-js/full'; const s: string = btoa("SGVsbG8gd29ybGQ="); diff --git a/tests/type-definitions/global/web/efficient-script-yielding.test.ts b/tests/type-definitions/global/web/efficient-script-yielding.test.ts index 601a567bbdf4..4478f70abacd 100644 --- a/tests/type-definitions/global/web/efficient-script-yielding.test.ts +++ b/tests/type-definitions/global/web/efficient-script-yielding.test.ts @@ -1,5 +1,4 @@ import 'core-js/full'; -import '@core-js/types'; const res: number | object = setImmediate(() => 42); clearImmediate(res); diff --git a/tests/type-definitions/global/web/queue-microtask.test.ts b/tests/type-definitions/global/web/queue-microtask.test.ts index 886d1616da5c..4203071aaf68 100644 --- a/tests/type-definitions/global/web/queue-microtask.test.ts +++ b/tests/type-definitions/global/web/queue-microtask.test.ts @@ -1,5 +1,4 @@ -import '@core-js/full'; -import '@core-js/types'; +import 'core-js/full'; queueMicrotask((): void => {}); queueMicrotask(function (): void {}); diff --git a/tests/type-definitions/global/web/structured-clone.test.ts b/tests/type-definitions/global/web/structured-clone.test.ts index c8cb11a33986..45225ae242cb 100644 --- a/tests/type-definitions/global/web/structured-clone.test.ts +++ b/tests/type-definitions/global/web/structured-clone.test.ts @@ -1,5 +1,4 @@ -import '@core-js/full'; -import '@core-js/types'; +import 'core-js/full'; const n: number = structuredClone(5); const s: string = structuredClone('text'); diff --git a/tests/type-definitions/global/web/url-to-json.test.ts b/tests/type-definitions/global/web/url-to-json.test.ts index e4180029132e..4bbbec16a6b0 100644 --- a/tests/type-definitions/global/web/url-to-json.test.ts +++ b/tests/type-definitions/global/web/url-to-json.test.ts @@ -1,5 +1,4 @@ -import '@core-js/full'; -import '@core-js/types'; +import 'core-js/full'; declare const urlLike: URL; const str: string = urlLike.toJSON(); diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 61457ea762f3..e60b0ef323b8 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -116,6 +116,7 @@ async function prepareEnvironment(environments, coreJsTypes) { await $`npx -p typescript@5.9 tsc`; await $`npx -p typescript@5.9 tsc -p tsconfig.templates.import.json`; await $`npx -p typescript@5.9 tsc -p tsconfig.entries.json`; +await $`npx -p typescript@5.9 tsc -p tsconfig.entries.pure.json`; await $`npx -p typescript@5.9 -p @types/node@24 tsc -p tsconfig.templates.require.json`; if (!ALL_TESTS) { diff --git a/tests/type-definitions/tsconfig.entries.pure.json b/tests/type-definitions/tsconfig.entries.pure.json new file mode 100644 index 000000000000..3eadb96fea85 --- /dev/null +++ b/tests/type-definitions/tsconfig.entries.pure.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "strict": true, + "target": "esnext", + "module": "esnext", + "esModuleInterop": true, + "moduleResolution": "node", + "noEmit": true, + "types": ["@core-js/types/pure"] + }, + "include": [ + "./entries.pure.ts" + ] +} From c4bec53f9e9211338f86be1a651dd12457b928ea Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 9 Dec 2025 23:52:51 +0700 Subject: [PATCH 079/315] Move test type definitions to own CI job --- .github/workflows/ci.yml | 13 ++++++++++++- package.json | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 456ef5c58d68..e6722016c36b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,18 @@ jobs: python-version: 3.14 - run: npm run prepare-monorepo - run: pip install codespell - - run: ALL_TYPE_DEFINITIONS_TESTS=1 npx run-s lint-raw codespell + - run: npx run-s lint-raw codespell + + type-definitions: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 + with: + node-version: 25 + cache: npm + - run: npm ci + - run: npx run-s build-types test-type-definitions-all karma: runs-on: windows-2022 diff --git a/package.json b/package.json index 8a207e258622..015d959ef7cd 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ "compat-rhino": "npm run zxi tests/compat/rhino-adapter.mjs", "debug-get-dependencies": "npm run zxi time tests/debug-get-dependencies/debug-get-dependencies.mjs", "lint": "run-s prepare lint-raw", - "lint-raw": "run-s build-types test-eslint test-type-definitions bundle-package test-publint", - "test": "run-s prepare test-raw", + "lint-raw": "run-s build-types test-eslint bundle-package test-publint", + "test": "run-s prepare test-raw test-type-definitions", "test-raw": "run-s lint-raw bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check", "test-eslint": "npm run zxi time tests/eslint/runner.mjs", "test-publint": "npm run zxi time tests/publint/runner.mjs", From 68e2fa76ba4376f1dfaff79489950348a79421f5 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 10 Dec 2025 20:01:59 +0700 Subject: [PATCH 080/315] Add index.d.ts & rebuild all type entry points & move test-type-definitions to test-raw command --- package.json | 4 +- packages/core-js-types/package.json | 8 ++-- scripts/build-types/index.mjs | 46 ++++++++++--------- scripts/build-types/package.tpl.json | 2 +- tests/type-definitions/entries.pure.ts | 2 +- tests/type-definitions/global/tsconfig.json | 2 +- .../global/web/dom-exception.test.ts | 3 +- .../type-definitions/global/web/self.test.ts | 3 +- .../global/web/url-search-params.test.ts | 3 +- 9 files changed, 37 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index 015d959ef7cd..d0f9df981a64 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,8 @@ "debug-get-dependencies": "npm run zxi time tests/debug-get-dependencies/debug-get-dependencies.mjs", "lint": "run-s prepare lint-raw", "lint-raw": "run-s build-types test-eslint bundle-package test-publint", - "test": "run-s prepare test-raw test-type-definitions", - "test-raw": "run-s lint-raw bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check", + "test": "run-s prepare test-raw", + "test-raw": "run-s lint-raw test-type-definitions bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check", "test-eslint": "npm run zxi time tests/eslint/runner.mjs", "test-publint": "npm run zxi time tests/publint/runner.mjs", "test-unit": "run-s test-unit-karma test-unit-node test-unit-bun", diff --git a/packages/core-js-types/package.json b/packages/core-js-types/package.json index a38dcfbdef4f..66a24001f6b8 100644 --- a/packages/core-js-types/package.json +++ b/packages/core-js-types/package.json @@ -25,7 +25,7 @@ "email": "zloirock@zloirock.ru", "url": "http://zloirock.ru" }, - "types": "./actual.d.ts", + "types": "./index.d.ts", "sideEffects": false, "typesVersions": { ">=5.6": { @@ -41,9 +41,9 @@ }, "exports": { ".": { - "types@>=5.6": "./dist/ts5-6/actual.d.ts", - "types": "./dist/ts5-2/actual.d.ts", - "default": "./dist/ts5-6/actual.d.ts" + "types@>=5.6": "./dist/ts5-6/index.d.ts", + "types": "./dist/ts5-2/index.d.ts", + "default": "./dist/ts5-6/index.d.ts" }, "./actual": { "types@>=5.6": "./dist/ts5-6/actual.d.ts", diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 265c69d95a99..e36eacfabae7 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -25,6 +25,7 @@ const imports = { actual: new Set(), full: new Set(), pure: new Set(), + index: new Set(), }; async function buildType(entry, options) { @@ -68,22 +69,24 @@ async function buildType(entry, options) { if (filter) modules = modules.filter(it => filter.has(it)); types.forEach(type => { + imports.index.add(type); imports[subset].add(type); imports.pure.add(path.join('pure', type)); }); if (customType) { + imports.index.add(customType); imports[subset].add(customType); imports.pure.add(customType); } - const filePath = buildFilePath(tsVersion, subset); - const filePathPure = buildFilePath(tsVersion, 'pure'); + const indexPath = buildFilePath(tsVersion, 'index'); + const purePath = buildFilePath(tsVersion, 'pure'); const tplPure = template({ ...options, modules, rawModules, level, entry, types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); const tpl = template({ ...options, modules, rawModules, level, entry, types, packageName: PACKAGE_NAME }); - await outputFile(filePathPure, `${ tplPure.dts }${ tplPure.dts ? '\n\n' : '' }`, { flag: 'a' }); - await outputFile(filePath, `${ tpl.dts }${ tpl.dts ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(indexPath, `${ tpl.dts }${ tpl.dts ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(purePath, `${ tplPure.dts }${ tplPure.dts ? '\n\n' : '' }`, { flag: 'a' }); if (!entry.endsWith('/')) { const entryWithExt = `${ entry }.js`; @@ -92,19 +95,19 @@ async function buildType(entry, options) { const tplWithExt = template({ ...options, modules, rawModules, level, types, entry: entryWithExt, packageName: PACKAGE_NAME }); - await outputFile(filePathPure, `${ tplPureWithExt.dts }${ tplPureWithExt.dts ? '\n\n' : '' }`, { flag: 'a' }); - await outputFile(filePath, `${ tplWithExt.dts }${ tplWithExt.dts ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(indexPath, `${ tplWithExt.dts }${ tplWithExt.dts ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(purePath, `${ tplPureWithExt.dts }${ tplPureWithExt.dts ? '\n\n' : '' }`, { flag: 'a' }); } if (entry.endsWith('/index')) { - const entryWithoutIndex = entry.replace(/index$/, ''); + const entryWithoutIndex = entry.replace(/\/index$/, ''); const tplPureWithoutIndex = template({ ...options, modules, rawModules, level, entry: entryWithoutIndex, types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); const tplWithoutIndex = template({ ...options, modules, rawModules, level, types, entry: entryWithoutIndex, packageName: PACKAGE_NAME }); - await outputFile(filePathPure, `${ tplPureWithoutIndex.dts }${ tplPureWithoutIndex.dts ? '\n\n' : '' }`, { flag: 'a' }); - await outputFile(filePath, `${ tplWithoutIndex.dts }${ tplWithoutIndex.dts ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(indexPath, `${ tplWithoutIndex.dts }${ tplWithoutIndex.dts ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(purePath, `${ tplPureWithoutIndex.dts }${ tplPureWithoutIndex.dts ? '\n\n' : '' }`, { flag: 'a' }); } if (proposal) { @@ -136,8 +139,11 @@ async function prependImports(version) { for (const subset of Object.keys(imports)) { const filePath = buildFilePath(version, subset); const importLines = buildImports(imports[subset]); - const originalContent = await fs.readFile(filePath, 'utf8'); - await outputFile(filePath, `${ importLines }\n\n${ originalContent }`); + let originalContent = ''; + if (await pathExists(filePath)) { + originalContent = await fs.readFile(filePath, 'utf8'); + } + await outputFile(filePath, `${ importLines }\n\n${ originalContent }`, { flag: 'w' }); } } @@ -200,7 +206,7 @@ async function buildPackageJson(breakpoints, namespaces) { }); packageJson.exports = {}; Object.entries(namespaces).forEach(([namespace, options]) => { - const namespaceKey = namespace ? `./${ namespace }${ options.isDir ? '/*' : '' }` : '.'; + const namespaceKey = namespace !== 'index' ? `./${ namespace }${ options.isDir ? '/*' : '' }` : '.'; packageJson.exports[namespaceKey] = {}; breakpoints.forEach((breakpoint, index) => { const isLast = index === breakpoints.length - 1; @@ -208,9 +214,6 @@ async function buildPackageJson(breakpoints, namespaces) { packageJson.exports[namespaceKey][`types${ isLast ? '' : `@>=${ breakpoint }` }`] = `./dist/${ breakpointString }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; }); packageJson.exports[namespaceKey].default = `./dist/ts${ defaultBreakpoint.toString().replace('.', '-') }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; - if (options.default) { - packageJson.exports['.'] = packageJson.exports[namespaceKey]; - } }); const exportsKeys = Object.keys(packageJson.exports).sort(); const exports = {}; @@ -228,12 +231,13 @@ if (VERSION) { await remove(BUILD_DIR); tsVersionBreakpoints.forEach(async version => await buildTypesForTSVersion(version)); const namespaces = { - es: { isDir: false, default: false }, - stable: { isDir: false, default: false }, - actual: { isDir: false, default: true }, - full: { isDir: false, default: false }, - pure: { isDir: false, default: false }, - proposals: { isDir: true, default: false }, + es: { isDir: false }, + stable: { isDir: false }, + actual: { isDir: false }, + full: { isDir: false }, + pure: { isDir: false }, + proposals: { isDir: true }, + index: { isDir: false }, }; await buildPackageJson(tsVersionBreakpoints, namespaces); } diff --git a/scripts/build-types/package.tpl.json b/scripts/build-types/package.tpl.json index efb86b0b587d..bb20757fcbbc 100644 --- a/scripts/build-types/package.tpl.json +++ b/scripts/build-types/package.tpl.json @@ -25,6 +25,6 @@ "email": "zloirock@zloirock.ru", "url": "http://zloirock.ru" }, - "types": "./actual.d.ts", + "types": "./index.d.ts", "sideEffects": false } diff --git a/tests/type-definitions/entries.pure.ts b/tests/type-definitions/entries.pure.ts index 4fd12a8f45b0..7739c910f404 100644 --- a/tests/type-definitions/entries.pure.ts +++ b/tests/type-definitions/entries.pure.ts @@ -4,5 +4,5 @@ new $date(); import $date2 from '@core-js/pure/full/date/index.js'; new $date2(); -import $date3 from '@core-js/pure/full/date/'; +import $date3 from '@core-js/pure/full/date'; new $date3(); diff --git a/tests/type-definitions/global/tsconfig.json b/tests/type-definitions/global/tsconfig.json index efcadcbb61dc..19ebf579cb23 100644 --- a/tests/type-definitions/global/tsconfig.json +++ b/tests/type-definitions/global/tsconfig.json @@ -3,7 +3,7 @@ "include": ["./**/*.ts"], "compilerOptions": { "types": [ - "@core-js/types/full" + "@core-js/types" ] } } diff --git a/tests/type-definitions/global/web/dom-exception.test.ts b/tests/type-definitions/global/web/dom-exception.test.ts index 6833f98459c3..5c01c8848e6e 100644 --- a/tests/type-definitions/global/web/dom-exception.test.ts +++ b/tests/type-definitions/global/web/dom-exception.test.ts @@ -1,6 +1,5 @@ // todo add after it becomes possible to create a type -// import '@core-js/full'; -// import '@core-js/types'; +// import 'core-js/full'; // // const ex1 = new DOMException(); // const ex2 = new DOMException('Some message'); diff --git a/tests/type-definitions/global/web/self.test.ts b/tests/type-definitions/global/web/self.test.ts index c643a10550ba..3f549dbacf6f 100644 --- a/tests/type-definitions/global/web/self.test.ts +++ b/tests/type-definitions/global/web/self.test.ts @@ -1,6 +1,5 @@ // todo add after it becomes possible to create a type -// import '@core-js/full'; -// import '@core-js/types'; +// import 'core-js/full'; // // const ref: typeof globalThis = self; // diff --git a/tests/type-definitions/global/web/url-search-params.test.ts b/tests/type-definitions/global/web/url-search-params.test.ts index 6e28466cd5d1..0cecd6b72e60 100644 --- a/tests/type-definitions/global/web/url-search-params.test.ts +++ b/tests/type-definitions/global/web/url-search-params.test.ts @@ -1,6 +1,5 @@ // todo add after it becomes possible to create a type -// import '@core-js/full'; -// import '@core-js/types'; +// import 'core-js/full'; // // const u0 = new URLSearchParams(); // const u1 = new URLSearchParams('a=1&b=2'); From 4c449f59ff61d2f1059551cb35e0b0daf18a3373 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 10 Dec 2025 20:41:43 +0700 Subject: [PATCH 081/315] Build types refactoring --- .../core-js-types/core-js-types.pure.d.ts | 12 ---- scripts/build-entries/index.mjs | 4 +- scripts/build-entries/templates.mjs | 60 +++++++++---------- scripts/build-types/index.mjs | 29 ++++----- scripts/build-types/pure.mjs | 4 +- 5 files changed, 47 insertions(+), 62 deletions(-) delete mode 100644 packages/core-js-types/src/base/core-js-types/core-js-types.pure.d.ts diff --git a/packages/core-js-types/src/base/core-js-types/core-js-types.pure.d.ts b/packages/core-js-types/src/base/core-js-types/core-js-types.pure.d.ts deleted file mode 100644 index bffa05d090d7..000000000000 --- a/packages/core-js-types/src/base/core-js-types/core-js-types.pure.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// -/// - -// For ensuring compatibility with TypeScript standard types, this code is based on: -// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2019.array.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - export type CoreJSDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } // from ts 5.2 - ? O - : Record & object; -} diff --git a/scripts/build-entries/index.mjs b/scripts/build-entries/index.mjs index 57a34ff89bc5..675f1185e642 100644 --- a/scripts/build-entries/index.mjs +++ b/scripts/build-entries/index.mjs @@ -1,6 +1,6 @@ import { getModulesMetadata } from './get-dependencies.mjs'; import { features, proposals } from './entries-definitions.mjs'; -import { $proposal, $path, wrapEntry } from './templates.mjs'; +import { $proposal, $path, wrapEntryInStrict } from './templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; import { expandModules, modulesToStage } from './helpers.mjs'; @@ -77,7 +77,7 @@ async function buildEntry(entry, options) { const filepath = `./packages/core-js/${ entry }.js`; await mkdir(dirname(filepath), { recursive: true }); - await writeFile(filepath, wrapEntry(tpl.entry)); + await writeFile(filepath, wrapEntryInStrict(tpl.entry)); built++; diff --git a/scripts/build-entries/templates.mjs b/scripts/build-entries/templates.mjs index f07d89bad9a3..ad89fb3ab7b5 100644 --- a/scripts/build-entries/templates.mjs +++ b/scripts/build-entries/templates.mjs @@ -7,7 +7,7 @@ const importModule = (module, level) => `require('${ level ? '../'.repeat(level) const importModules = ({ modules, level }) => modules.map(module => importModule(module, level)).join('\n'); -const buildTypeName = (namespace, name) => `CoreJS.${ namespace }${ String(name).charAt(0).toUpperCase() + String(name).slice(1) }`; +const buildCoreJSTypeName = (namespace, name) => `CoreJS.${ namespace }${ name.charAt(0).toUpperCase() + name.slice(1) }`; function isAllowedFunctionName(name) { try { @@ -36,13 +36,9 @@ const namespacesWithOneGeneric = [ 'AsyncIterator', ]; -function existsInES6(namespace) { - const missingNamespacesInES6 = [ - 'AsyncIterator', - ]; - - return !missingNamespacesInES6.includes(namespace); -} +const missingNamespacesInES6 = [ + 'AsyncIterator', +]; function getGenericsForNamespace(namespace) { if (namespace === 'WeakMap') { @@ -72,13 +68,13 @@ function getCustomGenerics(count) { return `<${ names.slice(0, count).join(', ') }>`; } -export const wrapEntry = template => `'use strict';\n${ template }\n`; +export const wrapEntryInStrict = template => `'use strict';\n${ template }\n`; export const $justImport = p => ({ entry: dedent` ${ importModules(p) } `, - dts: '', + types: '', }); export const $prototype = p => ({ @@ -89,7 +85,7 @@ export const $prototype = p => ({ module.exports = getBuiltInPrototypeMethod('${ p.namespace }', '${ p.name }'); `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { type method${ getGenericsForNamespace(p.namespace) } = ${ p.prefix ?? '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; export = method; @@ -105,7 +101,7 @@ export const $prototypeIterator = p => ({ module.exports = getIteratorMethod(${ p.source }); `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const method: typeof ${ p.prefix ?? '' }${ p.namespace }.prototype[typeof Symbol.iterator]; export = method; @@ -121,10 +117,10 @@ export const $uncurried = p => ({ module.exports = entryUnbind('${ p.namespace }', '${ p.name }'); `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { type method${ getGenericsForNamespace(p.namespace) } = ${ p.prefix ?? '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; - const resultMethod: ${ getGenericsForNamespace(p.namespace) }(self: ${ p.prefix && !existsInES6(p.namespace) ? p.prefix : '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters) => ReturnType; + const resultMethod: ${ getGenericsForNamespace(p.namespace) }(self: ${ p.prefix && missingNamespacesInES6.includes(p.namespace) ? p.prefix : '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters) => ReturnType; export = resultMethod; } `, @@ -138,9 +134,9 @@ export const $uncurriedWithCustomType = p => ({ module.exports = entryUnbind('${ p.namespace }', '${ p.name }'); `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { - const resultMethod: ${ getCustomGenerics(p.genericsCount) }(self: ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters<${ buildTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>) => ReturnType<${ buildTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>; + const resultMethod: ${ getCustomGenerics(p.genericsCount) }(self: ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters<${ buildCoreJSTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>) => ReturnType<${ buildCoreJSTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>; export = resultMethod; } `, @@ -155,7 +151,7 @@ export const $uncurriedIterator = p => ({ module.exports = uncurryThis(getIteratorMethod(${ p.source })); `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { type method${ getGenericsForNamespace(p.namespace) } = ${ p.namespace }${ getGenericsForNamespace(p.namespace) }[typeof Symbol.iterator]; const resultMethod: ${ getGenericsForNamespace(p.namespace) }(self: ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters) => ReturnType; @@ -172,7 +168,7 @@ export const $static = p => ({ module.exports = getBuiltInStaticMethod('${ p.namespace }', '${ p.name }'); `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const method: typeof ${ p.prefix ?? '' }${ p.namespace }.${ p.name }; export = method; @@ -195,7 +191,7 @@ export const $staticWithContext = p => ({ return apply(method, isCallable(this) ? this : getBuiltIn('${ p.namespace }'), arguments); }; `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const method: typeof ${ p.prefix ?? '' }${ p.namespace }.${ p.name }; export = method; @@ -214,7 +210,7 @@ export const $patchableStatic = p => ({ return apply(getBuiltInStaticMethod('${ p.namespace }', '${ p.name }'), this, arguments); }; `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const method: typeof ${ p.prefix ?? '' }${ p.namespace }.${ p.name }; export = method; @@ -230,7 +226,7 @@ export const $namespace = p => ({ module.exports = path.${ p.name }; `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const namespace: typeof ${ p.prefix ?? '' }${ p.name }; export = namespace; @@ -246,7 +242,7 @@ export const $helper = p => ({ module.exports = $export; `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const helper: (arg: NonNullable) => any; export = helper; @@ -262,7 +258,7 @@ export const $path = p => ({ module.exports = path; `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const path: typeof globalThis; export = path; @@ -283,7 +279,7 @@ export const $instanceArray = p => ({ return ownProperty; }; `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; @@ -305,7 +301,7 @@ export const $instanceNumber = p => ({ return ownProperty; }; `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; @@ -327,7 +323,7 @@ export const $instanceString = p => ({ return ownProperty; }; `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; @@ -349,7 +345,7 @@ export const $instanceFunction = p => ({ } return ownProperty; }; `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; @@ -377,7 +373,7 @@ export const $instanceDOMIterables = p => ({ return ownProperty; }; `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; @@ -402,7 +398,7 @@ export const $instanceArrayString = p => ({ return ownProperty; }; `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; @@ -433,7 +429,7 @@ export const $instanceArrayDOMIterables = p => ({ return ownProperty; }; `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; @@ -454,7 +450,7 @@ export const $instanceRegExpFlags = p => ({ return (it === RegExpPrototype || isPrototypeOf(RegExpPrototype, it)) ? flags(it) : it.flags; }; `, - dts: dedent` + types: dedent` declare module '${ p.packageName }${ p.entry }' { const method: (arg: NonNullable) => any; export = method; @@ -468,5 +464,5 @@ export const $proposal = p => ({ // ${ p.link } ${ importModules(p) } `, - dts: '', + types: '', }); diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index e36eacfabae7..74cf7a46eae2 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -82,32 +82,33 @@ async function buildType(entry, options) { const indexPath = buildFilePath(tsVersion, 'index'); const purePath = buildFilePath(tsVersion, 'pure'); - const tplPure = template({ ...options, modules, rawModules, level, entry, types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); - const tpl = template({ ...options, modules, rawModules, level, entry, types, packageName: PACKAGE_NAME }); + const entryWithTypes = template({ ...options, modules, rawModules, level, entry, types, packageName: PACKAGE_NAME }); + const entryWithTypesPure = template({ ...options, modules, rawModules, level, entry, types, packageName: PACKAGE_NAME_PURE, + prefix: TYPE_PREFIX }); - await outputFile(indexPath, `${ tpl.dts }${ tpl.dts ? '\n\n' : '' }`, { flag: 'a' }); - await outputFile(purePath, `${ tplPure.dts }${ tplPure.dts ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(indexPath, `${ entryWithTypes.types }${ entryWithTypes.types ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(purePath, `${ entryWithTypesPure.types }${ entryWithTypesPure.types ? '\n\n' : '' }`, { flag: 'a' }); if (!entry.endsWith('/')) { const entryWithExt = `${ entry }.js`; - const tplPureWithExt = template({ ...options, modules, rawModules, level, entry: entryWithExt, - types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); - const tplWithExt = template({ ...options, modules, rawModules, level, types, entry: entryWithExt, + const entryWithTypesWithExt = template({ ...options, modules, rawModules, level, types, entry: entryWithExt, packageName: PACKAGE_NAME }); + const entryWithTypesPureWithExt = template({ ...options, modules, rawModules, level, entry: entryWithExt, + types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); - await outputFile(indexPath, `${ tplWithExt.dts }${ tplWithExt.dts ? '\n\n' : '' }`, { flag: 'a' }); - await outputFile(purePath, `${ tplPureWithExt.dts }${ tplPureWithExt.dts ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(indexPath, `${ entryWithTypesWithExt.types }${ entryWithTypesWithExt.types ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(purePath, `${ entryWithTypesPureWithExt.types }${ entryWithTypesPureWithExt.types ? '\n\n' : '' }`, { flag: 'a' }); } if (entry.endsWith('/index')) { const entryWithoutIndex = entry.replace(/\/index$/, ''); - const tplPureWithoutIndex = template({ ...options, modules, rawModules, level, entry: entryWithoutIndex, types, - packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); - const tplWithoutIndex = template({ ...options, modules, rawModules, level, types, entry: entryWithoutIndex, + const entryWithTypesWithoutIndex = template({ ...options, modules, rawModules, level, types, entry: entryWithoutIndex, packageName: PACKAGE_NAME }); + const entryWithTypesPureWithoutIndex = template({ ...options, modules, rawModules, level, entry: entryWithoutIndex, types, + packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); - await outputFile(indexPath, `${ tplWithoutIndex.dts }${ tplWithoutIndex.dts ? '\n\n' : '' }`, { flag: 'a' }); - await outputFile(purePath, `${ tplPureWithoutIndex.dts }${ tplPureWithoutIndex.dts ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(indexPath, `${ entryWithTypesWithoutIndex.types }${ entryWithTypesWithoutIndex.types ? '\n\n' : '' }`, { flag: 'a' }); + await outputFile(purePath, `${ entryWithTypesPureWithoutIndex.types }${ entryWithTypesPureWithoutIndex.types ? '\n\n' : '' }`, { flag: 'a' }); } if (proposal) { diff --git a/scripts/build-types/pure.mjs b/scripts/build-types/pure.mjs index ec4a99df9df2..d3948733c199 100644 --- a/scripts/build-types/pure.mjs +++ b/scripts/build-types/pure.mjs @@ -97,7 +97,7 @@ function processLines(lines, prefix) { .filter(line => line !== null); } -function wrapDTSInNamespace(content, namespace = 'CoreJS') { +function wrapInNamespace(content, namespace = 'CoreJS') { const lines = content.split('\n'); const preamble = []; let i = 0; @@ -138,7 +138,7 @@ export async function preparePureTypes(typesPath, initialPath) { if (await pathExists(resultFilePath)) continue; const content = await fs.readFile(typePath, 'utf8'); if (content.includes('declare namespace')) continue; - const result = wrapDTSInNamespace(content); + const result = wrapInNamespace(content); await outputFile(resultFilePath, result); } } From 7b56f76d35bb968f4c5626e6864e77e6dbcbd92e Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 10 Dec 2025 23:44:54 +0700 Subject: [PATCH 082/315] Types package refactoring --- .gitignore | 2 +- packages/core-js-types/.npmignore | 5 + packages/core-js-types/package.json | 46 ++++---- .../core-js-types}/package.tpl.json | 0 .../src/base/core-js-types/core-js-types.d.ts | 2 +- .../src/base/core-js-types/flat-array.d.ts | 2 +- .../accessible-object-hasownproperty.d.ts | 2 +- .../base/proposals/array-buffer-base64.d.ts | 2 +- .../base/proposals/array-buffer-transfer.d.ts | 2 +- .../base/proposals/array-find-from-last.d.ts | 2 +- .../base/proposals/array-flat-map-custom.d.ts | 2 +- .../src/base/proposals/array-flat-map.d.ts | 2 +- .../src/base/proposals/array-from-async.d.ts | 2 +- .../src/base/proposals/array-grouping.d.ts | 2 +- .../src/base/proposals/array-includes.d.ts | 2 +- .../src/base/proposals/async-iteration.d.ts | 2 +- .../change-array-by-copy-custom.d.ts | 2 +- .../base/proposals/change-array-by-copy.d.ts | 2 +- .../src/base/proposals/error-cause.d.ts | 2 +- .../explicit-resource-management.d.ts | 2 +- .../src/base/proposals/float16.d.ts | 2 +- .../src/base/proposals/is-error.d.ts | 2 +- .../proposals/iterator-helpers-custom.d.ts | 2 +- .../src/base/proposals/iterator-helpers.d.ts | 2 +- .../base/proposals/object-from-entries.d.ts | 2 +- .../object-get-own-property-descriptors.d.ts | 2 +- .../base/proposals/object-values-entries.d.ts | 2 +- .../base/proposals/promise-all-settled.d.ts | 2 +- .../src/base/proposals/promise-any.d.ts | 2 +- .../src/base/proposals/promise-finally.d.ts | 2 +- .../src/base/proposals/promise-try.d.ts | 2 +- .../proposals/promise-with-resolvers.d.ts | 2 +- .../base/proposals/regexp-dotall-flag.d.ts | 2 +- .../base/proposals/regexp-named-groups.d.ts | 2 +- .../proposals/relative-indexing-method.d.ts | 2 +- .../base/proposals/set-methods-custom.d.ts | 2 +- .../src/base/proposals/set-methods.d.ts | 2 +- .../proposals/string-left-right-trim.d.ts | 2 +- .../src/base/proposals/string-match-all.d.ts | 2 +- .../src/base/proposals/string-padding.d.ts | 2 +- .../proposals/string-replace-all-custom.d.ts | 2 +- .../base/proposals/string-replace-all.d.ts | 2 +- .../base/proposals/symbol-description.d.ts | 2 +- .../well-formed-unicode-strings.d.ts | 2 +- .../src/base/pure/common/reflect.d.ts | 2 +- .../pure/proposals/array-buffer-transfer.d.ts | 2 +- .../pure/proposals/array-constructor.d.ts | 2 +- .../explicit-resource-management.d.ts | 2 +- .../src/base/pure/proposals/iterator.d.ts | 2 +- .../proposals/relative-indexing-method.d.ts | 2 +- .../proposals/string-left-right-trim.d.ts | 2 +- .../base/pure/proposals/string-match-all.d.ts | 2 +- .../base/pure/proposals/string-padding.d.ts | 2 +- .../pure/proposals/string-replace-all.d.ts | 2 +- .../src/base/pure/proposals/symbol.d.ts | 6 +- .../well-formed-unicode-strings.d.ts | 2 +- .../ts5-2/core-js-types/core-js-types.d.ts | 2 +- .../accessible-object-hasownproperty.d.ts | 2 +- .../ts5-2/proposals/array-buffer-base64.d.ts | 2 +- .../ts5-2/proposals/array-find-from-last.d.ts | 2 +- .../proposals/array-flat-map-custom.d.ts | 2 +- .../src/ts5-2/proposals/array-flat-map.d.ts | 2 +- .../src/ts5-2/proposals/array-from-async.d.ts | 2 +- .../src/ts5-2/proposals/array-grouping.d.ts | 2 +- .../src/ts5-2/proposals/array-includes.d.ts | 2 +- .../src/ts5-2/proposals/async-iteration.d.ts | 2 +- .../change-array-by-copy-custom.d.ts | 2 +- .../ts5-2/proposals/change-array-by-copy.d.ts | 2 +- .../src/ts5-2/proposals/error-cause.d.ts | 2 +- .../explicit-resource-management.d.ts | 2 +- .../src/ts5-2/proposals/float16.d.ts | 2 +- .../proposals/iterator-helpers-custom.d.ts | 2 +- .../src/ts5-2/proposals/iterator-helpers.d.ts | 2 +- .../ts5-2/proposals/object-from-entries.d.ts | 2 +- .../object-get-own-property-descriptors.d.ts | 2 +- .../proposals/object-values-entries.d.ts | 2 +- .../ts5-2/proposals/promise-all-settled.d.ts | 2 +- .../src/ts5-2/proposals/promise-any.d.ts | 2 +- .../src/ts5-2/proposals/promise-finally.d.ts | 2 +- .../src/ts5-2/proposals/promise-try.d.ts | 2 +- .../proposals/promise-with-resolvers.d.ts | 2 +- .../ts5-2/proposals/regexp-dotall-flag.d.ts | 2 +- .../ts5-2/proposals/regexp-named-groups.d.ts | 2 +- .../proposals/relative-indexing-method.d.ts | 2 +- .../ts5-2/proposals/set-methods-custom.d.ts | 2 +- .../src/ts5-2/proposals/set-methods.d.ts | 2 +- .../proposals/string-left-right-trim.d.ts | 2 +- .../src/ts5-2/proposals/string-match-all.d.ts | 2 +- .../src/ts5-2/proposals/string-padding.d.ts | 2 +- .../proposals/string-replace-all-custom.d.ts | 2 +- .../ts5-2/proposals/string-replace-all.d.ts | 2 +- .../ts5-2/proposals/symbol-description.d.ts | 2 +- .../well-formed-unicode-strings.d.ts | 2 +- scripts/build-entries/templates.mjs | 40 ++++--- scripts/build-types/index.mjs | 109 +++++++++++------- scripts/build-types/pure.mjs | 43 +++---- scripts/update-version.mjs | 3 + 97 files changed, 232 insertions(+), 198 deletions(-) create mode 100644 packages/core-js-types/.npmignore rename {scripts/build-types => packages/core-js-types}/package.tpl.json (100%) diff --git a/.gitignore b/.gitignore index 3299a2f4d86f..8de4641592cb 100644 --- a/.gitignore +++ b/.gitignore @@ -49,7 +49,7 @@ node_modules/ /packages/core-js-pure/index.js /packages/core-js-pure/package.json /packages/core-js-pure/LICENSE -/packages/core-js-types/dist/ +/packages/core-js-types/ts* /packages/core-js-types/LICENSE /tests/**/bundles/ /tests/compat/*.jar diff --git a/packages/core-js-types/.npmignore b/packages/core-js-types/.npmignore new file mode 100644 index 000000000000..cfa39b037d33 --- /dev/null +++ b/packages/core-js-types/.npmignore @@ -0,0 +1,5 @@ +node_modules/ +package.tpl.json +/src/ +*.log +.* diff --git a/packages/core-js-types/package.json b/packages/core-js-types/package.json index 66a24001f6b8..45c50bbc059d 100644 --- a/packages/core-js-types/package.json +++ b/packages/core-js-types/package.json @@ -30,50 +30,50 @@ "typesVersions": { ">=5.6": { "*": [ - "./dist/ts5-6/*" + "./ts5-6/*" ] }, ">=5.2": { "*": [ - "./dist/ts5-2/*" + "./ts5-2/*" ] } }, "exports": { ".": { - "types@>=5.6": "./dist/ts5-6/index.d.ts", - "types": "./dist/ts5-2/index.d.ts", - "default": "./dist/ts5-6/index.d.ts" + "types@>=5.6": "./ts5-6/index.d.ts", + "types": "./ts5-2/index.d.ts", + "default": "./ts5-6/index.d.ts" }, "./actual": { - "types@>=5.6": "./dist/ts5-6/actual.d.ts", - "types": "./dist/ts5-2/actual.d.ts", - "default": "./dist/ts5-6/actual.d.ts" + "types@>=5.6": "./ts5-6/actual.d.ts", + "types": "./ts5-2/actual.d.ts", + "default": "./ts5-6/actual.d.ts" }, "./es": { - "types@>=5.6": "./dist/ts5-6/es.d.ts", - "types": "./dist/ts5-2/es.d.ts", - "default": "./dist/ts5-6/es.d.ts" + "types@>=5.6": "./ts5-6/es.d.ts", + "types": "./ts5-2/es.d.ts", + "default": "./ts5-6/es.d.ts" }, "./full": { - "types@>=5.6": "./dist/ts5-6/full.d.ts", - "types": "./dist/ts5-2/full.d.ts", - "default": "./dist/ts5-6/full.d.ts" + "types@>=5.6": "./ts5-6/full.d.ts", + "types": "./ts5-2/full.d.ts", + "default": "./ts5-6/full.d.ts" }, "./proposals/*": { - "types@>=5.6": "./dist/ts5-6/proposals/*.d.ts", - "types": "./dist/ts5-2/proposals/*.d.ts", - "default": "./dist/ts5-6/proposals/*.d.ts" + "types@>=5.6": "./ts5-6/proposals/*.d.ts", + "types": "./ts5-2/proposals/*.d.ts", + "default": "./ts5-6/proposals/*.d.ts" }, "./pure": { - "types@>=5.6": "./dist/ts5-6/pure.d.ts", - "types": "./dist/ts5-2/pure.d.ts", - "default": "./dist/ts5-6/pure.d.ts" + "types@>=5.6": "./ts5-6/pure.d.ts", + "types": "./ts5-2/pure.d.ts", + "default": "./ts5-6/pure.d.ts" }, "./stable": { - "types@>=5.6": "./dist/ts5-6/stable.d.ts", - "types": "./dist/ts5-2/stable.d.ts", - "default": "./dist/ts5-6/stable.d.ts" + "types@>=5.6": "./ts5-6/stable.d.ts", + "types": "./ts5-2/stable.d.ts", + "default": "./ts5-6/stable.d.ts" } } } diff --git a/scripts/build-types/package.tpl.json b/packages/core-js-types/package.tpl.json similarity index 100% rename from scripts/build-types/package.tpl.json rename to packages/core-js-types/package.tpl.json diff --git a/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts index 1cc8655176fe..550bdebaef19 100644 --- a/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts +++ b/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts @@ -1,4 +1,4 @@ -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2019.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/core-js-types/flat-array.d.ts b/packages/core-js-types/src/base/core-js-types/flat-array.d.ts index 072ded56f28e..26b52316f412 100644 --- a/packages/core-js-types/src/base/core-js-types/flat-array.d.ts +++ b/packages/core-js-types/src/base/core-js-types/flat-array.d.ts @@ -1,4 +1,4 @@ -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2019.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts b/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts index b4a26afff155..cb8989c282aa 100644 --- a/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts +++ b/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-accessible-object-hasownproperty -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2022.object.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts index dbc36f0df75f..b85e129a2a1b 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts @@ -1,7 +1,7 @@ // proposal stage: 3 // https://github.com/tc39/proposal-arraybuffer-base64 -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.typedarrays.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts index b11b4866241c..457dcbca335e 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-arraybuffer-transfer -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/es2024.arraybuffer.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts index 8bc13e148613..33f8330e21e7 100644 --- a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-array-find-from-last -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/array-flat-map-custom.d.ts b/packages/core-js-types/src/base/proposals/array-flat-map-custom.d.ts index 93687e7aa9a8..56e9aa2ea260 100644 --- a/packages/core-js-types/src/base/proposals/array-flat-map-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/array-flat-map-custom.d.ts @@ -3,7 +3,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-flatMap -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/array-flat-map.d.ts b/packages/core-js-types/src/base/proposals/array-flat-map.d.ts index dead291ff4da..9b0ceb3c1e71 100644 --- a/packages/core-js-types/src/base/proposals/array-flat-map.d.ts +++ b/packages/core-js-types/src/base/proposals/array-flat-map.d.ts @@ -3,7 +3,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-flatMap -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/array-from-async.d.ts b/packages/core-js-types/src/base/proposals/array-from-async.d.ts index acd4ffe22961..fc92789b750a 100644 --- a/packages/core-js-types/src/base/proposals/array-from-async.d.ts +++ b/packages/core-js-types/src/base/proposals/array-from-async.d.ts @@ -1,7 +1,7 @@ // proposal stage: 3 // https://github.com/tc39/proposal-array-from-async -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/esnext.array.d.ts#L6 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/array-grouping.d.ts b/packages/core-js-types/src/base/proposals/array-grouping.d.ts index bedadd456513..5e3a7f6b1e5a 100644 --- a/packages/core-js-types/src/base/proposals/array-grouping.d.ts +++ b/packages/core-js-types/src/base/proposals/array-grouping.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-array-grouping -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.object.d.ts#L7 // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.collection.d.ts#L7 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/array-includes.d.ts b/packages/core-js-types/src/base/proposals/array-includes.d.ts index 9618c4cf1762..6b3a43766b83 100644 --- a/packages/core-js-types/src/base/proposals/array-includes.d.ts +++ b/packages/core-js-types/src/base/proposals/array-includes.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-Array.prototype.includes -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2016.array.include.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/async-iteration.d.ts b/packages/core-js-types/src/base/proposals/async-iteration.d.ts index 98856336caf0..be679d567ebe 100644 --- a/packages/core-js-types/src/base/proposals/async-iteration.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iteration.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-async-iteration -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2018.asynciterable.d.ts#L4 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts b/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts index fa55974c73c8..bab7c2913ebe 100644 --- a/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts @@ -3,7 +3,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-change-array-by-copy -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts index 265350ff2e09..fbd5aef7a301 100644 --- a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts +++ b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-change-array-by-copy -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/error-cause.d.ts b/packages/core-js-types/src/base/proposals/error-cause.d.ts index bcb796408ecb..e08ef8d852b6 100644 --- a/packages/core-js-types/src/base/proposals/error-cause.d.ts +++ b/packages/core-js-types/src/base/proposals/error-cause.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-error-cause -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/es2022.error.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts index e40893c0b489..6721c46ed410 100644 --- a/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts @@ -1,7 +1,7 @@ // proposal stage: 3 // https://github.com/tc39/proposal-explicit-resource-management -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/0a1aa6d6ebdfa16b82f4a6aaf282089b1d484e05/src/lib/esnext.disposable.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/float16.d.ts b/packages/core-js-types/src/base/proposals/float16.d.ts index 5a2aad50513b..76a56efa828e 100644 --- a/packages/core-js-types/src/base/proposals/float16.d.ts +++ b/packages/core-js-types/src/base/proposals/float16.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-float16array -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.float16.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/is-error.d.ts b/packages/core-js-types/src/base/proposals/is-error.d.ts index 6532a3c237eb..f92dfcf40522 100644 --- a/packages/core-js-types/src/base/proposals/is-error.d.ts +++ b/packages/core-js-types/src/base/proposals/is-error.d.ts @@ -1,7 +1,7 @@ // proposal stage: 3 // https://github.com/tc39/proposal-is-error -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/esnext.error.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts index d7f7c64b5d3a..3ddeebe1e6e7 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts @@ -3,7 +3,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-iterator-helpers -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts index 30e4d60d1975..d6ff6c0cf4a5 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-iterator-helpers -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/object-from-entries.d.ts b/packages/core-js-types/src/base/proposals/object-from-entries.d.ts index 30ce944a2a8a..7fea3279463c 100644 --- a/packages/core-js-types/src/base/proposals/object-from-entries.d.ts +++ b/packages/core-js-types/src/base/proposals/object-from-entries.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-object-from-entries -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d8aafb3197ebecd7faf919eaa39e77c5805cbff8/src/lib/es2019.object.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts b/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts index 891d0ac337f4..67ceaa76f561 100644 --- a/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts +++ b/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-object-getownpropertydescriptors -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2017.object.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/object-values-entries.d.ts b/packages/core-js-types/src/base/proposals/object-values-entries.d.ts index 7f9b6b14490d..aa0de63518f7 100644 --- a/packages/core-js-types/src/base/proposals/object-values-entries.d.ts +++ b/packages/core-js-types/src/base/proposals/object-values-entries.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-object-values-entries -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2017.object.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts index bd6c4e8f1e92..2d691fd65ca8 100644 --- a/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts @@ -3,7 +3,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-promise-allSettled -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2020.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/promise-any.d.ts b/packages/core-js-types/src/base/proposals/promise-any.d.ts index 33e106534b71..a15bc92ccc00 100644 --- a/packages/core-js-types/src/base/proposals/promise-any.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-any.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-promise-any -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2021.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/promise-finally.d.ts b/packages/core-js-types/src/base/proposals/promise-finally.d.ts index f84a3c70209d..850658dbc9b8 100644 --- a/packages/core-js-types/src/base/proposals/promise-finally.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-finally.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-promise-finally -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2018.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/promise-try.d.ts b/packages/core-js-types/src/base/proposals/promise-try.d.ts index 4ccdc516313a..9ac786ebdfb6 100644 --- a/packages/core-js-types/src/base/proposals/promise-try.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-try.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-promise-try -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/esnext.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts index 3478f3d1a778..d16cf05b6946 100644 --- a/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-promise-with-resolvers -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2024.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/regexp-dotall-flag.d.ts b/packages/core-js-types/src/base/proposals/regexp-dotall-flag.d.ts index 08bf52331aa3..b88f68d04b4a 100644 --- a/packages/core-js-types/src/base/proposals/regexp-dotall-flag.d.ts +++ b/packages/core-js-types/src/base/proposals/regexp-dotall-flag.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-regexp-dotall-flag -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2018.regexp.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/regexp-named-groups.d.ts b/packages/core-js-types/src/base/proposals/regexp-named-groups.d.ts index 141f940abfb7..2164fe5db0af 100644 --- a/packages/core-js-types/src/base/proposals/regexp-named-groups.d.ts +++ b/packages/core-js-types/src/base/proposals/regexp-named-groups.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-regexp-named-groups -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2018.regexp.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts index a1cb809ec54c..57392904b4f5 100644 --- a/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-relative-indexing-method -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.array.d.ts // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/set-methods-custom.d.ts b/packages/core-js-types/src/base/proposals/set-methods-custom.d.ts index a99087996264..a5c7c4a2cfed 100644 --- a/packages/core-js-types/src/base/proposals/set-methods-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/set-methods-custom.d.ts @@ -3,7 +3,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-set-methods -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/set-methods.d.ts b/packages/core-js-types/src/base/proposals/set-methods.d.ts index c56a736a6182..39826b824be4 100644 --- a/packages/core-js-types/src/base/proposals/set-methods.d.ts +++ b/packages/core-js-types/src/base/proposals/set-methods.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-set-methods -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts index a815f0047cc7..29883ddfd595 100644 --- a/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts +++ b/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-left-right-trim -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/string-match-all.d.ts b/packages/core-js-types/src/base/proposals/string-match-all.d.ts index 1c872989e57a..b49f3c69a82c 100644 --- a/packages/core-js-types/src/base/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/base/proposals/string-match-all.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-matchall -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/string-padding.d.ts b/packages/core-js-types/src/base/proposals/string-padding.d.ts index b98201bba3ad..55a5f67fbdc9 100644 --- a/packages/core-js-types/src/base/proposals/string-padding.d.ts +++ b/packages/core-js-types/src/base/proposals/string-padding.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-pad-start-end -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts b/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts index d456ad35fb2f..027cfd601e53 100644 --- a/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts @@ -3,7 +3,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-replaceall -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/proposals/string-replace-all.d.ts index 0c9b44e3064d..ad90b37057ad 100644 --- a/packages/core-js-types/src/base/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/base/proposals/string-replace-all.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-replaceall -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/es2021.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/symbol-description.d.ts b/packages/core-js-types/src/base/proposals/symbol-description.d.ts index 5aa1e41485c5..d982ebe7bfc5 100644 --- a/packages/core-js-types/src/base/proposals/symbol-description.d.ts +++ b/packages/core-js-types/src/base/proposals/symbol-description.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-Symbol-description -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.symbol.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts index d4c697742d7b..01b91d123fb1 100644 --- a/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts +++ b/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-is-usv-string -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2024.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/pure/common/reflect.d.ts b/packages/core-js-types/src/base/pure/common/reflect.d.ts index 00f78e5bcff4..7a5c15638da1 100644 --- a/packages/core-js-types/src/base/pure/common/reflect.d.ts +++ b/packages/core-js-types/src/base/pure/common/reflect.d.ts @@ -1,4 +1,4 @@ -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/38d95c8001300f525fd601dd0ce6d0ff5f12baee/src/lib/es2015.reflect.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts index d4ae08e3315e..f44beae65df9 100644 --- a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts @@ -4,7 +4,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-arraybuffer-transfer -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/es2024.arraybuffer.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts b/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts index 92a9617c8ad5..3e2671776675 100644 --- a/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts @@ -8,7 +8,7 @@ // proposal stage: 3 // https://github.com/tc39/proposal-array-from-async -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/esnext.array.d.ts#L6 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts index d3dfc48cebae..a6443b0e9b5e 100644 --- a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts @@ -5,7 +5,7 @@ // proposal stage: 3 // https://github.com/tc39/proposal-explicit-resource-management -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/0a1aa6d6ebdfa16b82f4a6aaf282089b1d484e05/src/lib/esnext.disposable.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 83a7ce12f56d..ad7ab84100ab 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -20,7 +20,7 @@ // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-sequencing -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts index 87acb99280b7..f70291a97038 100644 --- a/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts @@ -5,7 +5,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-relative-indexing-method -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.array.d.ts // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts index 65ab4d4bf97f..3cb8577d3012 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts @@ -5,7 +5,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-left-right-trim -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts index 193d192071d5..30d4c2fbf555 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts @@ -6,7 +6,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-matchall -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts b/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts index 7ea6e2d94fba..e290a8e2f641 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts @@ -5,7 +5,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-pad-start-end -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts index 3c216b0f4ce4..2e34179c0147 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts @@ -5,7 +5,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-replaceall -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/es2021.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts index bc1c3124efda..d4847d0d77ba 100644 --- a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts @@ -13,7 +13,7 @@ // proposal stage: 1 // https://github.com/tc39/proposal-pattern-matching -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2018.asynciterable.d.ts#L4 // proposal stage: 3 @@ -22,13 +22,13 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-matchall -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts // proposal stage: 4 // https://github.com/tc39/proposal-Symbol-description -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.symbol.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts index 4b186440f9d0..fd642df57393 100644 --- a/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts @@ -5,7 +5,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-is-usv-string -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2024.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts index 19ddcb1b9934..6a1621e111ed 100644 --- a/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts +++ b/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts @@ -1,4 +1,4 @@ -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2019.array.d.ts // https://github.com/microsoft/TypeScript/blob/6f4fb0145845db22791188c4d38e3a1a0edfd449/src/lib/es2018.asyncgenerator.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/accessible-object-hasownproperty.d.ts b/packages/core-js-types/src/ts5-2/proposals/accessible-object-hasownproperty.d.ts index a4e51205a188..f5cf3cc18aad 100644 --- a/packages/core-js-types/src/ts5-2/proposals/accessible-object-hasownproperty.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/accessible-object-hasownproperty.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-accessible-object-hasownproperty -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2022.object.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface ObjectConstructor { diff --git a/packages/core-js-types/src/ts5-2/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-buffer-base64.d.ts index faec22bae19f..85fa68b41eab 100644 --- a/packages/core-js-types/src/ts5-2/proposals/array-buffer-base64.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/array-buffer-base64.d.ts @@ -1,7 +1,7 @@ // proposal stage: 3 // https://github.com/tc39/proposal-arraybuffer-base64 -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.typedarrays.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-find-from-last.d.ts index 0ac8e21d189e..725dd286ec64 100644 --- a/packages/core-js-types/src/ts5-2/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/array-find-from-last.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-array-find-from-last -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/array-flat-map-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-flat-map-custom.d.ts index f54e8b3b212e..94c3b8c6a5b0 100644 --- a/packages/core-js-types/src/ts5-2/proposals/array-flat-map-custom.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/array-flat-map-custom.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-flatMap -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/array-flat-map.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-flat-map.d.ts index 5120e58dc54e..cb69a30384b7 100644 --- a/packages/core-js-types/src/ts5-2/proposals/array-flat-map.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/array-flat-map.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-flatMap -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/array-from-async.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-from-async.d.ts index ffe9843e2baa..aa234b066a35 100644 --- a/packages/core-js-types/src/ts5-2/proposals/array-from-async.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/array-from-async.d.ts @@ -1,7 +1,7 @@ // proposal stage: 3 // https://github.com/tc39/proposal-array-from-async -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/esnext.array.d.ts#L6 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/array-grouping.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-grouping.d.ts index 66c410a8c237..ed8bb784eaae 100644 --- a/packages/core-js-types/src/ts5-2/proposals/array-grouping.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/array-grouping.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-array-grouping -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.object.d.ts#L7 // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.collection.d.ts#L7 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/array-includes.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-includes.d.ts index 0f5cc4b6b628..508c900fa579 100644 --- a/packages/core-js-types/src/ts5-2/proposals/array-includes.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/array-includes.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-Array.prototype.includes -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2016.array.include.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/async-iteration.d.ts b/packages/core-js-types/src/ts5-2/proposals/async-iteration.d.ts index abc7c772078d..17bc57317010 100644 --- a/packages/core-js-types/src/ts5-2/proposals/async-iteration.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/async-iteration.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-async-iteration -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2018.asynciterable.d.ts#L4 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy-custom.d.ts index a40c18137eaf..f9c868a23824 100644 --- a/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy-custom.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy-custom.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-change-array-by-copy -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy.d.ts index cc8a2d3f4e2f..f1069ab1c155 100644 --- a/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-change-array-by-copy -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/error-cause.d.ts b/packages/core-js-types/src/ts5-2/proposals/error-cause.d.ts index 01bdbe8ef1d8..05e41bbb915c 100644 --- a/packages/core-js-types/src/ts5-2/proposals/error-cause.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/error-cause.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-error-cause -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/es2022.error.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts index 3bce356a9710..5f48e89dcc60 100644 --- a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts @@ -1,7 +1,7 @@ // proposal stage: 3 // https://github.com/tc39/proposal-explicit-resource-management -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/0a1aa6d6ebdfa16b82f4a6aaf282089b1d484e05/src/lib/esnext.disposable.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/float16.d.ts b/packages/core-js-types/src/ts5-2/proposals/float16.d.ts index 2d4c49dcc3bc..cd193a26528b 100644 --- a/packages/core-js-types/src/ts5-2/proposals/float16.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/float16.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-float16array -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.float16.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers-custom.d.ts index 29c5f9fa425a..b028b9a788b1 100644 --- a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers-custom.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-iterator-helpers -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts index 9e261bb2188a..0e913c1faacb 100644 --- a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-iterator-helpers -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/object-from-entries.d.ts b/packages/core-js-types/src/ts5-2/proposals/object-from-entries.d.ts index a4b46b1d81a3..47b8806c97b8 100644 --- a/packages/core-js-types/src/ts5-2/proposals/object-from-entries.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/object-from-entries.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-object-from-entries -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d8aafb3197ebecd7faf919eaa39e77c5805cbff8/src/lib/es2019.object.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/object-get-own-property-descriptors.d.ts b/packages/core-js-types/src/ts5-2/proposals/object-get-own-property-descriptors.d.ts index 03381a3b031f..7a281655e09b 100644 --- a/packages/core-js-types/src/ts5-2/proposals/object-get-own-property-descriptors.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/object-get-own-property-descriptors.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-object-getownpropertydescriptors -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2017.object.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/object-values-entries.d.ts b/packages/core-js-types/src/ts5-2/proposals/object-values-entries.d.ts index d2f4e35d18c2..09a84cb7655b 100644 --- a/packages/core-js-types/src/ts5-2/proposals/object-values-entries.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/object-values-entries.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-object-values-entries -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2017.object.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-all-settled.d.ts index db0d67f5c719..fe24d586c33a 100644 --- a/packages/core-js-types/src/ts5-2/proposals/promise-all-settled.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/promise-all-settled.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-promise-allSettled -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2020.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/promise-any.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-any.d.ts index 0470b9436996..281fcc39c63b 100644 --- a/packages/core-js-types/src/ts5-2/proposals/promise-any.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/promise-any.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-promise-any -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2021.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/promise-finally.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-finally.d.ts index 1936b256f060..3bfb0471a1a9 100644 --- a/packages/core-js-types/src/ts5-2/proposals/promise-finally.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/promise-finally.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-promise-finally -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2018.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/promise-try.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-try.d.ts index 75ff6358f34f..42a941065d0d 100644 --- a/packages/core-js-types/src/ts5-2/proposals/promise-try.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/promise-try.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-promise-try -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/esnext.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-with-resolvers.d.ts index 7a0a7efd7030..44659a8e494f 100644 --- a/packages/core-js-types/src/ts5-2/proposals/promise-with-resolvers.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/promise-with-resolvers.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-promise-with-resolvers -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2024.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/regexp-dotall-flag.d.ts b/packages/core-js-types/src/ts5-2/proposals/regexp-dotall-flag.d.ts index 931f2cedf514..63ce9946f1e4 100644 --- a/packages/core-js-types/src/ts5-2/proposals/regexp-dotall-flag.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/regexp-dotall-flag.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-regexp-dotall-flag -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2018.regexp.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/regexp-named-groups.d.ts b/packages/core-js-types/src/ts5-2/proposals/regexp-named-groups.d.ts index 141f940abfb7..2164fe5db0af 100644 --- a/packages/core-js-types/src/ts5-2/proposals/regexp-named-groups.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/regexp-named-groups.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-regexp-named-groups -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2018.regexp.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/ts5-2/proposals/relative-indexing-method.d.ts index 15ebeac28dc1..5532d8b8d322 100644 --- a/packages/core-js-types/src/ts5-2/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/relative-indexing-method.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-relative-indexing-method -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.array.d.ts // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/set-methods-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/set-methods-custom.d.ts index 6e5e628e8ba2..36e248e143e9 100644 --- a/packages/core-js-types/src/ts5-2/proposals/set-methods-custom.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/set-methods-custom.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-set-methods -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/set-methods.d.ts b/packages/core-js-types/src/ts5-2/proposals/set-methods.d.ts index 299278b564a6..70e5753afc10 100644 --- a/packages/core-js-types/src/ts5-2/proposals/set-methods.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/set-methods.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-set-methods -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-left-right-trim.d.ts index cbd4ce89a795..056e4d6aff96 100644 --- a/packages/core-js-types/src/ts5-2/proposals/string-left-right-trim.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/string-left-right-trim.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-left-right-trim -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts index afceb8f5fc28..2959ffed049e 100644 --- a/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-matchall -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/string-padding.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-padding.d.ts index c4e9a68da923..2aae76a0c586 100644 --- a/packages/core-js-types/src/ts5-2/proposals/string-padding.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/string-padding.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-pad-start-end -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/string-replace-all-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-replace-all-custom.d.ts index 928f0d7dc10e..6755fb61507e 100644 --- a/packages/core-js-types/src/ts5-2/proposals/string-replace-all-custom.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/string-replace-all-custom.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-replaceall -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/string-replace-all.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-replace-all.d.ts index 9fa6276b406b..ee1abf693888 100644 --- a/packages/core-js-types/src/ts5-2/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/string-replace-all.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-string-replaceall -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/symbol-description.d.ts b/packages/core-js-types/src/ts5-2/proposals/symbol-description.d.ts index 6d0927220518..7f133067eb18 100644 --- a/packages/core-js-types/src/ts5-2/proposals/symbol-description.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/symbol-description.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-Symbol-description -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.symbol.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/packages/core-js-types/src/ts5-2/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/ts5-2/proposals/well-formed-unicode-strings.d.ts index 3f4c2caf5e4d..3871f6fb9d2d 100644 --- a/packages/core-js-types/src/ts5-2/proposals/well-formed-unicode-strings.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/well-formed-unicode-strings.d.ts @@ -1,7 +1,7 @@ // proposal stage: 4 // https://github.com/tc39/proposal-is-usv-string -// For ensuring compatibility with TypeScript standard types, this code is based on: +// For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2024.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt diff --git a/scripts/build-entries/templates.mjs b/scripts/build-entries/templates.mjs index ad89fb3ab7b5..33bde366d247 100644 --- a/scripts/build-entries/templates.mjs +++ b/scripts/build-entries/templates.mjs @@ -9,6 +9,8 @@ const importModules = ({ modules, level }) => modules.map(module => importModule const buildCoreJSTypeName = (namespace, name) => `CoreJS.${ namespace }${ name.charAt(0).toUpperCase() + name.slice(1) }`; +const buildModulePath = ({ entry, packageName }) => `${ packageName }${ entry }`; + function isAllowedFunctionName(name) { try { // eslint-disable-next-line no-new-func -- safe @@ -86,7 +88,7 @@ export const $prototype = p => ({ module.exports = getBuiltInPrototypeMethod('${ p.namespace }', '${ p.name }'); `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { type method${ getGenericsForNamespace(p.namespace) } = ${ p.prefix ?? '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; export = method; } @@ -102,7 +104,7 @@ export const $prototypeIterator = p => ({ module.exports = getIteratorMethod(${ p.source }); `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const method: typeof ${ p.prefix ?? '' }${ p.namespace }.prototype[typeof Symbol.iterator]; export = method; } @@ -118,7 +120,7 @@ export const $uncurried = p => ({ module.exports = entryUnbind('${ p.namespace }', '${ p.name }'); `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { type method${ getGenericsForNamespace(p.namespace) } = ${ p.prefix ?? '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; const resultMethod: ${ getGenericsForNamespace(p.namespace) }(self: ${ p.prefix && missingNamespacesInES6.includes(p.namespace) ? p.prefix : '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters) => ReturnType; export = resultMethod; @@ -135,7 +137,7 @@ export const $uncurriedWithCustomType = p => ({ module.exports = entryUnbind('${ p.namespace }', '${ p.name }'); `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const resultMethod: ${ getCustomGenerics(p.genericsCount) }(self: ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters<${ buildCoreJSTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>) => ReturnType<${ buildCoreJSTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>; export = resultMethod; } @@ -152,7 +154,7 @@ export const $uncurriedIterator = p => ({ module.exports = uncurryThis(getIteratorMethod(${ p.source })); `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { type method${ getGenericsForNamespace(p.namespace) } = ${ p.namespace }${ getGenericsForNamespace(p.namespace) }[typeof Symbol.iterator]; const resultMethod: ${ getGenericsForNamespace(p.namespace) }(self: ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters) => ReturnType; export = resultMethod; @@ -169,7 +171,7 @@ export const $static = p => ({ module.exports = getBuiltInStaticMethod('${ p.namespace }', '${ p.name }'); `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const method: typeof ${ p.prefix ?? '' }${ p.namespace }.${ p.name }; export = method; } @@ -192,7 +194,7 @@ export const $staticWithContext = p => ({ }; `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const method: typeof ${ p.prefix ?? '' }${ p.namespace }.${ p.name }; export = method; } @@ -211,7 +213,7 @@ export const $patchableStatic = p => ({ }; `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const method: typeof ${ p.prefix ?? '' }${ p.namespace }.${ p.name }; export = method; } @@ -227,7 +229,7 @@ export const $namespace = p => ({ module.exports = path.${ p.name }; `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const namespace: typeof ${ p.prefix ?? '' }${ p.name }; export = namespace; } @@ -243,7 +245,7 @@ export const $helper = p => ({ module.exports = $export; `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const helper: (arg: NonNullable) => any; export = helper; } @@ -259,7 +261,7 @@ export const $path = p => ({ module.exports = path; `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const path: typeof globalThis; export = path; } @@ -280,7 +282,7 @@ export const $instanceArray = p => ({ }; `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const method: (arg: NonNullable) => any; export = method; } @@ -302,7 +304,7 @@ export const $instanceNumber = p => ({ }; `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const method: (arg: NonNullable) => any; export = method; } @@ -324,7 +326,7 @@ export const $instanceString = p => ({ }; `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const method: (arg: NonNullable) => any; export = method; } @@ -346,7 +348,7 @@ export const $instanceFunction = p => ({ }; `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const method: (arg: NonNullable) => any; export = method; } @@ -374,7 +376,7 @@ export const $instanceDOMIterables = p => ({ }; `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const method: (arg: NonNullable) => any; export = method; } @@ -399,7 +401,7 @@ export const $instanceArrayString = p => ({ }; `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const method: (arg: NonNullable) => any; export = method; } @@ -430,7 +432,7 @@ export const $instanceArrayDOMIterables = p => ({ }; `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const method: (arg: NonNullable) => any; export = method; } @@ -451,7 +453,7 @@ export const $instanceRegExpFlags = p => ({ }; `, types: dedent` - declare module '${ p.packageName }${ p.entry }' { + declare module '${ buildModulePath(p) }' { const method: (arg: NonNullable) => any; export = method; } diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 74cf7a46eae2..1778937b26f9 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -2,23 +2,22 @@ import { features, proposals } from '../build-entries/entries-definitions.mjs'; import { $path, $proposal } from '../build-entries/templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; import { getModulesMetadata } from '../build-entries/get-dependencies.mjs'; -import { argv, path, fs } from 'zx'; import { expandModules, modulesToStage } from '../build-entries/helpers.mjs'; import { preparePureTypes } from './pure.mjs'; const { copy, outputFile, pathExists, readdir, readFile, readJson, remove, writeJson } = fs; +const { green } = chalk; -const BUILD_DIR = 'packages/core-js-types/dist/'; +const BUILD_DIR = 'packages/core-js-types/'; const PACKAGE_JSON_DIR = 'packages/core-js-types/'; const PACKAGE_NAME = 'core-js/'; const PACKAGE_NAME_PURE = '@core-js/pure/'; -const PACKAGE_TEMPLATE = 'scripts/build-types/package.tpl.json'; +const PACKAGE_TEMPLATE = 'packages/core-js-types/package.tpl.json'; const SRC_DIR = 'packages/core-js-types/src/'; const SRC_BASE = 'base'; +const TS_VERSION_BREAKPOINTS = [5.2, 5.6]; const TYPE_PREFIX = 'CoreJS.CoreJS'; -const versionArg = argv._.find(item => item.startsWith('version=')); -const VERSION = versionArg ? versionArg.slice('version='.length) : undefined; const imports = { es: new Set(), stable: new Set(), @@ -27,6 +26,7 @@ const imports = { pure: new Set(), index: new Set(), }; +let outputFiles = {}; async function buildType(entry, options) { let { @@ -51,8 +51,6 @@ async function buildType(entry, options) { case 'full': template = templateFull ?? templateActual ?? templateStable ?? template; break; - case 'es-stage': - filter ??= ESWithProposalsSet; } if (!enforceEntryCreation && !expandModules(modules[0], filter, AllModules).length) return; @@ -73,6 +71,7 @@ async function buildType(entry, options) { imports[subset].add(type); imports.pure.add(path.join('pure', type)); }); + if (customType) { imports.index.add(customType); imports[subset].add(customType); @@ -81,50 +80,51 @@ async function buildType(entry, options) { const indexPath = buildFilePath(tsVersion, 'index'); const purePath = buildFilePath(tsVersion, 'pure'); + if (!outputFiles[indexPath]) outputFiles[indexPath] = ''; + if (!outputFiles[purePath]) outputFiles[purePath] = ''; const entryWithTypes = template({ ...options, modules, rawModules, level, entry, types, packageName: PACKAGE_NAME }); const entryWithTypesPure = template({ ...options, modules, rawModules, level, entry, types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); - await outputFile(indexPath, `${ entryWithTypes.types }${ entryWithTypes.types ? '\n\n' : '' }`, { flag: 'a' }); - await outputFile(purePath, `${ entryWithTypesPure.types }${ entryWithTypesPure.types ? '\n\n' : '' }`, { flag: 'a' }); + outputFiles[indexPath] += `${ entryWithTypes.types }${ entryWithTypes.types ? '\n' : '' }`; + outputFiles[purePath] += `${ entryWithTypesPure.types }${ entryWithTypesPure.types ? '\n' : '' }`; - if (!entry.endsWith('/')) { + if (!entry.endsWith('/')) { // add alias with .js ending const entryWithExt = `${ entry }.js`; const entryWithTypesWithExt = template({ ...options, modules, rawModules, level, types, entry: entryWithExt, packageName: PACKAGE_NAME }); const entryWithTypesPureWithExt = template({ ...options, modules, rawModules, level, entry: entryWithExt, types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); - await outputFile(indexPath, `${ entryWithTypesWithExt.types }${ entryWithTypesWithExt.types ? '\n\n' : '' }`, { flag: 'a' }); - await outputFile(purePath, `${ entryWithTypesPureWithExt.types }${ entryWithTypesPureWithExt.types ? '\n\n' : '' }`, { flag: 'a' }); + outputFiles[indexPath] += `${ entryWithTypesWithExt.types }${ entryWithTypesWithExt.types ? '\n' : '' }`; + outputFiles[purePath] += `${ entryWithTypesPureWithExt.types }${ entryWithTypesPureWithExt.types ? '\n' : '' }`; } - if (entry.endsWith('/index')) { + if (entry.endsWith('/index')) { // add alias to namespace without index const entryWithoutIndex = entry.replace(/\/index$/, ''); const entryWithTypesWithoutIndex = template({ ...options, modules, rawModules, level, types, entry: entryWithoutIndex, packageName: PACKAGE_NAME }); const entryWithTypesPureWithoutIndex = template({ ...options, modules, rawModules, level, entry: entryWithoutIndex, types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); - await outputFile(indexPath, `${ entryWithTypesWithoutIndex.types }${ entryWithTypesWithoutIndex.types ? '\n\n' : '' }`, { flag: 'a' }); - await outputFile(purePath, `${ entryWithTypesPureWithoutIndex.types }${ entryWithTypesPureWithoutIndex.types ? '\n\n' : '' }`, { flag: 'a' }); + outputFiles[indexPath] += `${ entryWithTypesWithoutIndex.types }${ entryWithTypesWithoutIndex.types ? '\n' : '' }`; + outputFiles[purePath] += `${ entryWithTypesPureWithoutIndex.types }${ entryWithTypesPureWithoutIndex.types ? '\n' : '' }`; } if (proposal) { const filePathProposal = buildFilePath(tsVersion, entry); + if (!outputFiles[filePathProposal]) outputFiles[filePathProposal] = ''; const proposalImports = buildImports(types, 1); - await outputFile(filePathProposal, `${ proposalImports }\n`, { flag: 'a' }); + outputFiles[filePathProposal] = `${ proposalImports }\n`; } } const ESModules = AllModules.filter(it => it.startsWith('es.')); -const ESWithProposalsModules = AllModules.filter(it => it.startsWith('es')); const StableModules = AllModules.filter(it => it.match(/^(?:es|web)\./)); const ActualModules = modulesToStage(StableModules, 3); const ESSet = new Set(ESModules); -const ESWithProposalsSet = new Set(ESWithProposalsModules); const StableSet = new Set(StableModules); const ActualSet = new Set(ActualModules); @@ -140,11 +140,7 @@ async function prependImports(version) { for (const subset of Object.keys(imports)) { const filePath = buildFilePath(version, subset); const importLines = buildImports(imports[subset]); - let originalContent = ''; - if (await pathExists(filePath)) { - originalContent = await fs.readFile(filePath, 'utf8'); - } - await outputFile(filePath, `${ importLines }\n\n${ originalContent }`, { flag: 'w' }); + outputFiles[filePath] = `${ importLines }\n${ outputFiles[filePath] ?? '' }`; } } @@ -163,15 +159,19 @@ async function fillCustomImportsForPure(typesPath, initialPath) { } async function buildTypesForTSVersion(tsVersion) { + outputFiles = {}; tsVersion = `ts${ tsVersion.toString().replace('.', '-') }`; + const bundlePath = path.join(BUILD_DIR, tsVersion); - const distTypesPath = path.join(bundlePath, 'types'); if (await pathExists(bundlePath)) await remove(bundlePath); await copy(path.join(SRC_DIR, SRC_BASE), path.join(BUILD_DIR, tsVersion, 'types')); + const srcPath = path.join(SRC_DIR, tsVersion); + const distTypesPath = path.join(bundlePath, 'types'); if (await pathExists(srcPath)) { await copy(srcPath, distTypesPath); } + await fillCustomImportsForPure(path.join(bundlePath, 'types', 'pure'), distTypesPath); await preparePureTypes(bundlePath, distTypesPath); @@ -193,18 +193,21 @@ async function buildTypesForTSVersion(tsVersion) { await buildType('index', { template: $path, modules: ActualModules, tsVersion }); await prependImports(tsVersion); + await saveOutputFiles(); } async function buildPackageJson(breakpoints, namespaces) { breakpoints = breakpoints.sort().reverse(); - const packageJson = await readJson(PACKAGE_TEMPLATE); const defaultBreakpoint = Math.max(...breakpoints); + + const packageJson = await readJson(PACKAGE_TEMPLATE); packageJson.typesVersions = {}; breakpoints.forEach(breakpoint => { packageJson.typesVersions[`>=${ breakpoint }`] = { - '*': [`./dist/ts${ breakpoint.toString().replace('.', '-') }/*`], + '*': [`./ts${ breakpoint.toString().replace('.', '-') }/*`], }; }); + packageJson.exports = {}; Object.entries(namespaces).forEach(([namespace, options]) => { const namespaceKey = namespace !== 'index' ? `./${ namespace }${ options.isDir ? '/*' : '' }` : '.'; @@ -212,9 +215,9 @@ async function buildPackageJson(breakpoints, namespaces) { breakpoints.forEach((breakpoint, index) => { const isLast = index === breakpoints.length - 1; const breakpointString = `ts${ breakpoint.toString().replace('.', '-') }`; - packageJson.exports[namespaceKey][`types${ isLast ? '' : `@>=${ breakpoint }` }`] = `./dist/${ breakpointString }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; + packageJson.exports[namespaceKey][`types${ isLast ? '' : `@>=${ breakpoint }` }`] = `./${ breakpointString }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; }); - packageJson.exports[namespaceKey].default = `./dist/ts${ defaultBreakpoint.toString().replace('.', '-') }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; + packageJson.exports[namespaceKey].default = `./ts${ defaultBreakpoint.toString().replace('.', '-') }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; }); const exportsKeys = Object.keys(packageJson.exports).sort(); const exports = {}; @@ -222,23 +225,41 @@ async function buildPackageJson(breakpoints, namespaces) { exports[key] = packageJson.exports[key]; }); packageJson.exports = exports; + writeJson(path.join(PACKAGE_JSON_DIR, 'package.json'), packageJson, { spaces: 2 }); } -if (VERSION) { - await buildTypesForTSVersion(VERSION); -} else { - const tsVersionBreakpoints = [5.2, 5.6]; - await remove(BUILD_DIR); - tsVersionBreakpoints.forEach(async version => await buildTypesForTSVersion(version)); - const namespaces = { - es: { isDir: false }, - stable: { isDir: false }, - actual: { isDir: false }, - full: { isDir: false }, - pure: { isDir: false }, - proposals: { isDir: true }, - index: { isDir: false }, - }; - await buildPackageJson(tsVersionBreakpoints, namespaces); +async function clearPackage() { + const entries = await readdir(BUILD_DIR, { withFileTypes: true }); + for (const entry of entries) { + if (/^ts\d{1,3}-\d{1,3}$/.test(entry.name)) { + await remove(path.join(BUILD_DIR, entry.name)); + } + } +} + +async function saveOutputFiles() { + const filePaths = Object.keys(outputFiles); + for (const filePath of filePaths) { + await outputFile(filePath, outputFiles[filePath], { flag: 'w' }); + } } + +await clearPackage(); + +for (const version of TS_VERSION_BREAKPOINTS) { + await buildTypesForTSVersion(version); +} + +const namespaces = { + es: { isDir: false }, + stable: { isDir: false }, + actual: { isDir: false }, + full: { isDir: false }, + pure: { isDir: false }, + proposals: { isDir: true }, + index: { isDir: false }, +}; +await buildPackageJson(TS_VERSION_BREAKPOINTS, namespaces); + +echo(green('Types successfully built')); diff --git a/scripts/build-types/pure.mjs b/scripts/build-types/pure.mjs index d3948733c199..19f52411f10e 100644 --- a/scripts/build-types/pure.mjs +++ b/scripts/build-types/pure.mjs @@ -1,24 +1,21 @@ -import { path, fs } from 'zx'; - const { outputFile, pathExists, readdir } = fs; function extractDeclareGlobalSections(lines) { const sections = []; const outside = []; - for (let i = 0; i < lines.length;) { + for (let i = 0; i < lines.length; i++) { if (/^\s*declare\s+global\s*\{/.test(lines[i])) { let depth = 1; const section = []; for (++i; i < lines.length && depth > 0; ++i) { - depth += (lines[i].match(/\{/g) || []).length; - depth -= (lines[i].match(/\}/g) || []).length; + depth += lines[i].match(/\{/g)?.length ?? 0; + depth -= lines[i].match(/\}/g)?.length ?? 0; if (depth === 0 && /^\s*\}\s*$/.test(lines[i])) break; if (depth > 0) section.push(lines[i]); } - ++i; sections.push(section); } else { - outside.push(lines[i++]); + outside.push(lines[i]); } } return { sections, outside }; @@ -30,14 +27,14 @@ function processLines(lines, prefix) { return lines .map(line => { const hasOptions = line.includes('@type-options'); - const optionsStr = hasOptions ? line.match(/@type-options\s+(?[\s\w,-]+)/)?.groups?.options : ''; + const optionsStr = hasOptions ? line.match(/@type-options\s+(?[A-Za-z][\s\w,-]+)$/)?.groups?.options : ''; const options = { - noExtends: !hasOptions ? false : optionsStr.includes('no-extends'), - noPrefix: !hasOptions ? false : optionsStr.includes('no-prefix'), - noConstructor: !hasOptions ? false : optionsStr.includes('no-constructor'), - exportBaseConstructor: !hasOptions ? false : optionsStr.includes('export-base-constructor'), - noExport: !hasOptions ? false : optionsStr.includes('no-export'), - noRedefine: !hasOptions ? false : optionsStr.includes('no-redefine'), + noExtends: hasOptions && optionsStr.includes('no-extends'), + noPrefix: hasOptions && optionsStr.includes('no-prefix'), + noConstructor: hasOptions && optionsStr.includes('no-constructor'), + exportBaseConstructor: hasOptions && optionsStr.includes('export-base-constructor'), + noExport: hasOptions && optionsStr.includes('no-export'), + noRedefine: hasOptions && optionsStr.includes('no-redefine'), }; if (noExport && /^[^{]*\}/.test(line)) { noExport = false; @@ -50,14 +47,16 @@ function processLines(lines, prefix) { return null; } if (line.includes('export {')) return null; - if (/^\s*(?:declare\s+)?interface\s+\w+\s*extends/.test(line) || options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+(?:<[^>]+>)?\s*\{/.test(line)) { + if (/^\s*(?:declare\s+)?interface\s+\w+\s*extends/.test(line) + || options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+(?:<[^>]+>)?\s*\{/.test(line)) { if (!options.noPrefix) { const m = line.match(/interface\s+(?\w+)/); if (m && m.groups) { prefixed.push(m.groups.name); } } - return line.replace(/^(?\s*)(?:declare\s+)?interface\s+(?[\s\w,<=>]+)/, `$export interface ${ !options.noPrefix ? prefix : '' }$`); + return line.replace(/^(?\s*)(?:declare\s+)?interface\s+(?[\s\w,<=>]+)/, + `$export interface ${ !options.noPrefix ? prefix : '' }$`); } if (!options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+/.test(line)) { const m = line.match(/^(?\s*)(?:declare\s+)?interface\s+(?\w+)(?<[^>]+>)?/); @@ -72,14 +71,18 @@ function processLines(lines, prefix) { const isConstructor = iName.includes('Constructor'); let constructorDeclaration; if (isConstructor) { - constructorDeclaration = !options.noRedefine ? `${ iIndent }var ${ entityName.replace('Constructor', '') }: ${ entityName };\n` : ''; + constructorDeclaration = !options.noRedefine ? + `${ iIndent }var ${ entityName.replace('Constructor', '') }: ${ entityName };\n` : ''; } else { - constructorDeclaration = !options.noRedefine ? `${ iIndent }var ${ entityName }: ${ options.exportBaseConstructor ? iName : entityName }${ options.noConstructor ? '' : 'Constructor' };\n` : ''; + constructorDeclaration = !options.noRedefine ? `${ iIndent }var ${ entityName }: ${ + options.exportBaseConstructor ? iName : entityName }${ options.noConstructor ? '' : 'Constructor' };\n` : ''; } - return `${ constructorDeclaration }${ iIndent }export interface ${ entityName }${ iExtend } extends ${ iName }${ genericsForExtends } {\n`; + return `${ constructorDeclaration }${ iIndent }export interface ${ + entityName }${ iExtend } extends ${ iName }${ genericsForExtends } {\n`; } if (/^\s*(?:declare\s+)?function/.test(line)) { - return line.replace(/^(?\s*)(?:declare\s+)?function\s+(?\w+)/, `$export function ${ !options.noPrefix ? prefix : '' }$`); + return line.replace(/^(?\s*)(?:declare\s+)?function\s+(?\w+)/, + `$export function ${ !options.noPrefix ? prefix : '' }$`); } if (/(?::|\|)\s*\w/.test(line)) { const sortedPrefixed = prefixed.sort((a, b) => b.length - a.length); diff --git a/scripts/update-version.mjs b/scripts/update-version.mjs index 376e59622c0b..8ebae952df9f 100644 --- a/scripts/update-version.mjs +++ b/scripts/update-version.mjs @@ -21,6 +21,7 @@ const README_COMPAT = 'packages/core-js-compat/README.md'; const SHARED = 'packages/core-js/internals/shared-store.js'; const BUILDER_CONFIG = 'packages/core-js-builder/config.js'; const USAGE = 'docs/web/docs/usage.md'; +const TYPES_PACKAGE_TEMPLATE = 'packages/core-js-types/package.tpl.json'; const NOW = new Date(); const CURRENT_YEAR = NOW.getFullYear(); @@ -87,6 +88,8 @@ else if (CURRENT_YEAR === OLD_YEAR) echo(red('bump is not required')); await $`npm run build-compat`; +await $`npm run build-types`; + const UNRELEASED_TAG = `${ coerce(PREV_VERSION) }-unreleased`; const modulesByVersions = await readJson('packages/core-js-compat/modules-by-versions.json'); From 155a508c3cc551ba2eae96feda2cf3af47cc1e27 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sat, 13 Dec 2025 01:16:47 +0200 Subject: [PATCH 083/315] update lockfiles --- tests/eslint/package-lock.json | 9 +-------- tests/type-definitions/package-lock.json | 10 ---------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/tests/eslint/package-lock.json b/tests/eslint/package-lock.json index e1a94fcb1653..f17ad719c99f 100644 --- a/tests/eslint/package-lock.json +++ b/tests/eslint/package-lock.json @@ -439,8 +439,7 @@ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@types/json-schema": { "version": "7.0.15", @@ -762,7 +761,6 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -879,7 +877,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -1254,7 +1251,6 @@ "integrity": "sha512-20MV9SUdeN6Jd84xESsKhRly+/vxI+hwvpBMA93s+9dAcjdCuCojn4IqUGS3lvVaqjVYGYHSRMCpeFtF2rQYxQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", @@ -2486,7 +2482,6 @@ "integrity": "sha512-75EA7EWZExL/j+MDKQrRbdzcRI2HOkRlmUw8fZJc1ioqFEOvBsq7Rt+A6yCxOt9w/TYNpkt52gC6nm/g5tFIng==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "acorn": "^8.5.0", "eslint-visitor-keys": "^5.0.0", @@ -4249,7 +4244,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -4334,7 +4328,6 @@ "dev": true, "hasInstallScript": true, "license": "MIT", - "peer": true, "dependencies": { "napi-postinstall": "^0.3.0" }, diff --git a/tests/type-definitions/package-lock.json b/tests/type-definitions/package-lock.json index ddede5c1dd20..d36672ed25f6 100644 --- a/tests/type-definitions/package-lock.json +++ b/tests/type-definitions/package-lock.json @@ -5,16 +5,6 @@ "packages": { "": { "name": "tests/type-definitions" - }, - "../../packages/core-js-types": { - "name": "@core-js/types", - "version": "4.0.0-alpha.0", - "extraneous": true, - "license": "SEE LICENSE IN LICENSE.md", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } } } } From a53e0d738651342f43d11607429cdc255b96301b Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sun, 14 Dec 2025 03:57:59 +0200 Subject: [PATCH 084/315] don't store generated package.json --- .github/workflows/ci.yml | 2 +- .gitignore | 1 + packages/core-js-types/package.json | 79 ----------------------------- scripts/update-version.mjs | 1 - 4 files changed, 2 insertions(+), 81 deletions(-) delete mode 100644 packages/core-js-types/package.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e6722016c36b..aa8be4ee5d2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: with: node-version: 25 cache: npm - - run: npm ci + - run: npm run prepare-monorepo - run: npx run-s build-types test-type-definitions-all karma: diff --git a/.gitignore b/.gitignore index 8de4641592cb..76340f29e8d9 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,7 @@ node_modules/ /packages/core-js-pure/index.js /packages/core-js-pure/package.json /packages/core-js-pure/LICENSE +/packages/core-js-types/package.json /packages/core-js-types/ts* /packages/core-js-types/LICENSE /tests/**/bundles/ diff --git a/packages/core-js-types/package.json b/packages/core-js-types/package.json deleted file mode 100644 index 45c50bbc059d..000000000000 --- a/packages/core-js-types/package.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "name": "@core-js/types", - "version": "4.0.0-alpha.0", - "publishConfig": { - "access": "public" - }, - "type": "commonjs", - "description": "TypeScript types for core-js", - "repository": { - "type": "git", - "url": "git+https://github.com/zloirock/core-js.git", - "directory": "packages/core-js-types" - }, - "homepage": "https://core-js.io", - "bugs": { - "url": "https://github.com/zloirock/core-js/issues" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - }, - "license": "SEE LICENSE IN LICENSE.md", - "author": { - "name": "Denis Pushkarev", - "email": "zloirock@zloirock.ru", - "url": "http://zloirock.ru" - }, - "types": "./index.d.ts", - "sideEffects": false, - "typesVersions": { - ">=5.6": { - "*": [ - "./ts5-6/*" - ] - }, - ">=5.2": { - "*": [ - "./ts5-2/*" - ] - } - }, - "exports": { - ".": { - "types@>=5.6": "./ts5-6/index.d.ts", - "types": "./ts5-2/index.d.ts", - "default": "./ts5-6/index.d.ts" - }, - "./actual": { - "types@>=5.6": "./ts5-6/actual.d.ts", - "types": "./ts5-2/actual.d.ts", - "default": "./ts5-6/actual.d.ts" - }, - "./es": { - "types@>=5.6": "./ts5-6/es.d.ts", - "types": "./ts5-2/es.d.ts", - "default": "./ts5-6/es.d.ts" - }, - "./full": { - "types@>=5.6": "./ts5-6/full.d.ts", - "types": "./ts5-2/full.d.ts", - "default": "./ts5-6/full.d.ts" - }, - "./proposals/*": { - "types@>=5.6": "./ts5-6/proposals/*.d.ts", - "types": "./ts5-2/proposals/*.d.ts", - "default": "./ts5-6/proposals/*.d.ts" - }, - "./pure": { - "types@>=5.6": "./ts5-6/pure.d.ts", - "types": "./ts5-2/pure.d.ts", - "default": "./ts5-6/pure.d.ts" - }, - "./stable": { - "types@>=5.6": "./ts5-6/stable.d.ts", - "types": "./ts5-2/stable.d.ts", - "default": "./ts5-6/stable.d.ts" - } - } -} diff --git a/scripts/update-version.mjs b/scripts/update-version.mjs index 8ebae952df9f..547acfb06cad 100644 --- a/scripts/update-version.mjs +++ b/scripts/update-version.mjs @@ -21,7 +21,6 @@ const README_COMPAT = 'packages/core-js-compat/README.md'; const SHARED = 'packages/core-js/internals/shared-store.js'; const BUILDER_CONFIG = 'packages/core-js-builder/config.js'; const USAGE = 'docs/web/docs/usage.md'; -const TYPES_PACKAGE_TEMPLATE = 'packages/core-js-types/package.tpl.json'; const NOW = new Date(); const CURRENT_YEAR = NOW.getFullYear(); From 8319e1f76a65066fa99cce511b09e0520714c1f7 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 15 Dec 2025 19:34:46 +0700 Subject: [PATCH 085/315] common types renamed & added type entries for annex-b and web --- .../object-prototype-accessor-methods.d.ts | 0 .../modules/es.object.define-getter.js | 2 +- .../modules/es.object.define-setter.js | 2 +- .../modules/es.object.lookup-getter.js | 2 +- .../modules/es.object.lookup-setter.js | 2 +- scripts/build-types/index.mjs | 73 +++++++++++++------ 6 files changed, 55 insertions(+), 26 deletions(-) rename packages/core-js-types/src/base/{common => annex-b}/object-prototype-accessor-methods.d.ts (100%) diff --git a/packages/core-js-types/src/base/common/object-prototype-accessor-methods.d.ts b/packages/core-js-types/src/base/annex-b/object-prototype-accessor-methods.d.ts similarity index 100% rename from packages/core-js-types/src/base/common/object-prototype-accessor-methods.d.ts rename to packages/core-js-types/src/base/annex-b/object-prototype-accessor-methods.d.ts diff --git a/packages/core-js/modules/es.object.define-getter.js b/packages/core-js/modules/es.object.define-getter.js index 51d8ae01f205..71e38ed70c0c 100644 --- a/packages/core-js/modules/es.object.define-getter.js +++ b/packages/core-js/modules/es.object.define-getter.js @@ -1,4 +1,4 @@ -// types: common/object-prototype-accessor-methods +// types: annex-b/object-prototype-accessor-methods 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/es.object.define-setter.js b/packages/core-js/modules/es.object.define-setter.js index 68cde586caed..b3c5a1057840 100644 --- a/packages/core-js/modules/es.object.define-setter.js +++ b/packages/core-js/modules/es.object.define-setter.js @@ -1,4 +1,4 @@ -// types: common/object-prototype-accessor-methods +// types: annex-b/object-prototype-accessor-methods 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/es.object.lookup-getter.js b/packages/core-js/modules/es.object.lookup-getter.js index 32956a2f7cf3..a24b5b7a508e 100644 --- a/packages/core-js/modules/es.object.lookup-getter.js +++ b/packages/core-js/modules/es.object.lookup-getter.js @@ -1,4 +1,4 @@ -// types: common/object-prototype-accessor-methods +// types: annex-b/object-prototype-accessor-methods 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/es.object.lookup-setter.js b/packages/core-js/modules/es.object.lookup-setter.js index 1112d310d93d..0abf45d84f02 100644 --- a/packages/core-js/modules/es.object.lookup-setter.js +++ b/packages/core-js/modules/es.object.lookup-setter.js @@ -1,4 +1,4 @@ -// types: common/object-prototype-accessor-methods +// types: annex-b/object-prototype-accessor-methods 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 1778937b26f9..c122fa75e7fe 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -33,7 +33,7 @@ async function buildType(entry, options) { entryFromNamespace, subset = entryFromNamespace ?? 'full', template, templateStable, templateActual, templateFull, filter, modules, enforceEntryCreation, - customType, tsVersion, proposal, + customType, tsVersion, proposal, types, ownEntryPoint, } = options; switch (subset) { @@ -53,18 +53,16 @@ async function buildType(entry, options) { break; } - if (!enforceEntryCreation && !expandModules(modules[0], filter, AllModules).length) return; - - const rawModules = modules; - - modules = expandModules(modules, filter, AllModules); - const level = entry.split('/').length - 1; - const { dependencies, types } = await getModulesMetadata(modules); - modules = dependencies; - - if (filter) modules = modules.filter(it => filter.has(it)); + if (!types) { + if (!enforceEntryCreation && !expandModules(modules[0], filter, AllModules).length) return; + modules = expandModules(modules, filter, AllModules); + const { dependencies, types: typePaths } = await getModulesMetadata(modules); + modules = dependencies; + if (filter) modules = modules.filter(it => filter.has(it)); + types = typePaths; + } types.forEach(type => { imports.index.add(type); @@ -83,8 +81,8 @@ async function buildType(entry, options) { if (!outputFiles[indexPath]) outputFiles[indexPath] = ''; if (!outputFiles[purePath]) outputFiles[purePath] = ''; - const entryWithTypes = template({ ...options, modules, rawModules, level, entry, types, packageName: PACKAGE_NAME }); - const entryWithTypesPure = template({ ...options, modules, rawModules, level, entry, types, packageName: PACKAGE_NAME_PURE, + const entryWithTypes = template({ ...options, modules, level, entry, types, packageName: PACKAGE_NAME }); + const entryWithTypesPure = template({ ...options, modules, level, entry, types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); outputFiles[indexPath] += `${ entryWithTypes.types }${ entryWithTypes.types ? '\n' : '' }`; @@ -92,9 +90,9 @@ async function buildType(entry, options) { if (!entry.endsWith('/')) { // add alias with .js ending const entryWithExt = `${ entry }.js`; - const entryWithTypesWithExt = template({ ...options, modules, rawModules, level, types, entry: entryWithExt, + const entryWithTypesWithExt = template({ ...options, modules, level, types, entry: entryWithExt, packageName: PACKAGE_NAME }); - const entryWithTypesPureWithExt = template({ ...options, modules, rawModules, level, entry: entryWithExt, + const entryWithTypesPureWithExt = template({ ...options, modules, level, entry: entryWithExt, types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); outputFiles[indexPath] += `${ entryWithTypesWithExt.types }${ entryWithTypesWithExt.types ? '\n' : '' }`; @@ -103,20 +101,20 @@ async function buildType(entry, options) { if (entry.endsWith('/index')) { // add alias to namespace without index const entryWithoutIndex = entry.replace(/\/index$/, ''); - const entryWithTypesWithoutIndex = template({ ...options, modules, rawModules, level, types, entry: entryWithoutIndex, + const entryWithTypesWithoutIndex = template({ ...options, modules, level, types, entry: entryWithoutIndex, packageName: PACKAGE_NAME }); - const entryWithTypesPureWithoutIndex = template({ ...options, modules, rawModules, level, entry: entryWithoutIndex, types, + const entryWithTypesPureWithoutIndex = template({ ...options, modules, level, entry: entryWithoutIndex, types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); outputFiles[indexPath] += `${ entryWithTypesWithoutIndex.types }${ entryWithTypesWithoutIndex.types ? '\n' : '' }`; outputFiles[purePath] += `${ entryWithTypesPureWithoutIndex.types }${ entryWithTypesPureWithoutIndex.types ? '\n' : '' }`; } - if (proposal) { - const filePathProposal = buildFilePath(tsVersion, entry); - if (!outputFiles[filePathProposal]) outputFiles[filePathProposal] = ''; - const proposalImports = buildImports(types, 1); - outputFiles[filePathProposal] = `${ proposalImports }\n`; + if (proposal || ownEntryPoint) { + const ownFilePath = buildFilePath(tsVersion, entry); + if (!outputFiles[ownFilePath]) outputFiles[ownFilePath] = ''; + const ownImports = buildImports(types, 1); + outputFiles[ownFilePath] = `${ ownImports }\n`; } } @@ -158,6 +156,28 @@ async function fillCustomImportsForPure(typesPath, initialPath) { } } +async function buildAdditionalEntries(dir, tsVersion) { + const dirPath = path.join(BUILD_DIR, tsVersion, 'types', dir); + const entries = await readdir(dirPath, { withFileTypes: true }); + const result = {}; + for (const entry of entries) { + if (entry.isDirectory()) { + continue; + } + const entryName = entry.name.replace('.d.ts', ''); + const entryPath = path.join(dir, entryName); + result[entryName] = { + template: () => ({ types: '' }), + ownEntryPoint: true, + modules: [], + tsVersion, + types: [entryPath], + }; + } + + return result; +} + async function buildTypesForTSVersion(tsVersion) { outputFiles = {}; tsVersion = `ts${ tsVersion.toString().replace('.', '-') }`; @@ -172,6 +192,9 @@ async function buildTypesForTSVersion(tsVersion) { await copy(srcPath, distTypesPath); } + const web = await buildAdditionalEntries('web', tsVersion); + const annexB = await buildAdditionalEntries('annex-b', tsVersion); + await fillCustomImportsForPure(path.join(bundlePath, 'types', 'pure'), distTypesPath); await preparePureTypes(bundlePath, distTypesPath); @@ -185,6 +208,12 @@ async function buildTypesForTSVersion(tsVersion) { for (const [name, definition] of Object.entries(proposals)) { await buildType(`proposals/${ name }`, { ...definition, template: $proposal, tsVersion, proposal: true }); } + for (const [name, definition] of Object.entries(web)) { + await buildType(`web/${ name }`, definition); + } + for (const [name, definition] of Object.entries(annexB)) { + await buildType(`annex-b/${ name }`, definition); + } await buildType('es/index', { template: $path, modules: ESModules, subset: 'es', tsVersion }); await buildType('stable/index', { template: $path, modules: StableModules, subset: 'stable', tsVersion }); From 7b3dcbd007d40485462fae4cb506b39cea02da9c Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 15 Dec 2025 20:30:53 +0700 Subject: [PATCH 086/315] Added Object.__proto__ accessor type --- packages/core-js-types/src/base/annex-b/object-proto.d.ts | 3 +++ packages/core-js/modules/es.object.proto.js | 1 + tests/type-definitions/global/annex-b/object-proto.test.ts | 3 +++ 3 files changed, 7 insertions(+) create mode 100644 packages/core-js-types/src/base/annex-b/object-proto.d.ts create mode 100644 tests/type-definitions/global/annex-b/object-proto.test.ts diff --git a/packages/core-js-types/src/base/annex-b/object-proto.d.ts b/packages/core-js-types/src/base/annex-b/object-proto.d.ts new file mode 100644 index 000000000000..8e994dbd4ffb --- /dev/null +++ b/packages/core-js-types/src/base/annex-b/object-proto.d.ts @@ -0,0 +1,3 @@ +interface Object { + __proto__: object | null; +} diff --git a/packages/core-js/modules/es.object.proto.js b/packages/core-js/modules/es.object.proto.js index dbd88f7fb688..1300596cacbe 100644 --- a/packages/core-js/modules/es.object.proto.js +++ b/packages/core-js/modules/es.object.proto.js @@ -1,3 +1,4 @@ +// types: annex-b/object-proto 'use strict'; var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); var isObject = require('../internals/is-object'); diff --git a/tests/type-definitions/global/annex-b/object-proto.test.ts b/tests/type-definitions/global/annex-b/object-proto.test.ts new file mode 100644 index 000000000000..28c9d7acee13 --- /dev/null +++ b/tests/type-definitions/global/annex-b/object-proto.test.ts @@ -0,0 +1,3 @@ +import 'core-js/full'; + +const objectProto: object | null = {}.__proto__; From e6c8ad7ac0ede29442bf90d853712ceb8c7815a1 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 15 Dec 2025 21:49:52 +0700 Subject: [PATCH 087/315] Types README.md --- packages/core-js-types/README.md | 74 ++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 packages/core-js-types/README.md diff --git a/packages/core-js-types/README.md b/packages/core-js-types/README.md new file mode 100644 index 000000000000..a350b1d546bf --- /dev/null +++ b/packages/core-js-types/README.md @@ -0,0 +1,74 @@ +![logo](https://user-images.githubusercontent.com/2213682/146607186-8e13ddef-26a4-4ebf-befd-5aac9d77c090.png) + +# Installation +`npm install --save @core-js/types` + +# Usage +Add to your `tsconfig.json`: +```json +{ + "compilerOptions": { + "types": [ + "@core-js/types" + ] + } +} +``` +or import it directly in your files: +```ts +import '@core-js/types'; +``` + +# Usage of pure version +Add this to your `tsconfig.json`: +```json +{ + "compilerOptions": { + "types": [ + "@core-js/types/pure" + ] + } +} +``` +then, when you import from the pure entry points, the corresponding types are picked up automatically: +```ts +import $findLast from '@core-js/pure/full/array/find-last'; + +$findLast([1, 3, 4, 2], v => v > 2); // => 4 +``` + +# DOM types +To work with DOM, you need to add DOM types to the `lib` section of your `tsconfig.json`, for example: +```json +{ + "compilerOptions": { + "lib": ["esnext", "dom"] + } +} +``` +In `pure` version you can use it without adding additional DOM types: +```ts +import $parse from '@core-js/pure/full/url/parse'; + +$parse('https://example.com/path?name=value#hash'); +``` + +# Namespace usage in pure version +If you need to use multiple methods from the same namespace, you can import the entire namespace instead: +```ts +import $array from '@core-js/pure/full/array'; + +$array.findLast([1, 3, 4, 2], v => v > 2); +$array.flatMap([1, 2, 3], x => [x, x * 2]); +``` + +# Package variants +You can import different variants of the package types: +```ts +import '@core-js/types/actual'; // types for all actual features - stable ES, web standards and stage 3 ES proposals +import '@core-js/types/full'; // types for all features - stable ES, web standards and all proposals +import '@core-js/types/stable'; // types for stable features - ES and web standards +import '@core-js/types/es'; // types for only stable ES features +``` + +# Reference import From 7f5e4e4405f753bfc2139609c38f497fd3b29cf5 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 17 Dec 2025 00:27:27 +0700 Subject: [PATCH 088/315] Build types refactoring --- scripts/build-types/index.mjs | 50 ++++++++---------- scripts/build-types/pure.mjs | 99 +++++++++++++++++++++++++---------- 2 files changed, 92 insertions(+), 57 deletions(-) diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index c122fa75e7fe..a55d9dee6955 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -28,6 +28,23 @@ const imports = { }; let outputFiles = {}; +function addType(filePath, template, options) { + const entryWithTypes = template(options); + outputFiles[filePath] += `${ entryWithTypes.types }${ entryWithTypes.types ? '\n' : '' }`; +} + +function addEntryTypes(tsVersion, template, options) { + const indexPath = buildFilePath(tsVersion, 'index'); + if (!outputFiles[indexPath]) outputFiles[indexPath] = ''; + const optionsGlobal = { ...options, packageName: PACKAGE_NAME }; + addType(indexPath, template, optionsGlobal); + + const purePath = buildFilePath(tsVersion, 'pure'); + if (!outputFiles[purePath]) outputFiles[purePath] = ''; + const optionsPure = { ...options, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }; + addType(purePath, template, optionsPure); +} + async function buildType(entry, options) { let { entryFromNamespace, @@ -75,39 +92,14 @@ async function buildType(entry, options) { imports[subset].add(customType); imports.pure.add(customType); } + options = { ...options, modules, level, entry, types }; - const indexPath = buildFilePath(tsVersion, 'index'); - const purePath = buildFilePath(tsVersion, 'pure'); - if (!outputFiles[indexPath]) outputFiles[indexPath] = ''; - if (!outputFiles[purePath]) outputFiles[purePath] = ''; - - const entryWithTypes = template({ ...options, modules, level, entry, types, packageName: PACKAGE_NAME }); - const entryWithTypesPure = template({ ...options, modules, level, entry, types, packageName: PACKAGE_NAME_PURE, - prefix: TYPE_PREFIX }); - - outputFiles[indexPath] += `${ entryWithTypes.types }${ entryWithTypes.types ? '\n' : '' }`; - outputFiles[purePath] += `${ entryWithTypesPure.types }${ entryWithTypesPure.types ? '\n' : '' }`; - + addEntryTypes(tsVersion, template, options); if (!entry.endsWith('/')) { // add alias with .js ending - const entryWithExt = `${ entry }.js`; - const entryWithTypesWithExt = template({ ...options, modules, level, types, entry: entryWithExt, - packageName: PACKAGE_NAME }); - const entryWithTypesPureWithExt = template({ ...options, modules, level, entry: entryWithExt, - types, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); - - outputFiles[indexPath] += `${ entryWithTypesWithExt.types }${ entryWithTypesWithExt.types ? '\n' : '' }`; - outputFiles[purePath] += `${ entryWithTypesPureWithExt.types }${ entryWithTypesPureWithExt.types ? '\n' : '' }`; + addEntryTypes(tsVersion, template, { ...options, entry: `${ entry }.js` }); } - if (entry.endsWith('/index')) { // add alias to namespace without index - const entryWithoutIndex = entry.replace(/\/index$/, ''); - const entryWithTypesWithoutIndex = template({ ...options, modules, level, types, entry: entryWithoutIndex, - packageName: PACKAGE_NAME }); - const entryWithTypesPureWithoutIndex = template({ ...options, modules, level, entry: entryWithoutIndex, types, - packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); - - outputFiles[indexPath] += `${ entryWithTypesWithoutIndex.types }${ entryWithTypesWithoutIndex.types ? '\n' : '' }`; - outputFiles[purePath] += `${ entryWithTypesPureWithoutIndex.types }${ entryWithTypesPureWithoutIndex.types ? '\n' : '' }`; + addEntryTypes(tsVersion, template, { ...options, entry: entry.replace(/\/index$/, '') }); } if (proposal || ownEntryPoint) { diff --git a/scripts/build-types/pure.mjs b/scripts/build-types/pure.mjs index 19f52411f10e..36d1888d035a 100644 --- a/scripts/build-types/pure.mjs +++ b/scripts/build-types/pure.mjs @@ -3,13 +3,16 @@ const { outputFile, pathExists, readdir } = fs; function extractDeclareGlobalSections(lines) { const sections = []; const outside = []; + for (let i = 0; i < lines.length; i++) { if (/^\s*declare\s+global\s*\{/.test(lines[i])) { let depth = 1; const section = []; + for (++i; i < lines.length && depth > 0; ++i) { depth += lines[i].match(/\{/g)?.length ?? 0; depth -= lines[i].match(/\}/g)?.length ?? 0; + if (depth === 0 && /^\s*\}\s*$/.test(lines[i])) break; if (depth > 0) section.push(lines[i]); } @@ -21,21 +24,26 @@ function extractDeclareGlobalSections(lines) { return { sections, outside }; } +function parseOptions(line) { + const hasOptions = line.includes('@type-options'); + const optionsStr = hasOptions ? line.match(/@type-options\s+(?[A-Za-z][\s\w,-]+)$/)?.groups?.options : ''; + return { + noExtends: hasOptions && optionsStr.includes('no-extends'), + noPrefix: hasOptions && optionsStr.includes('no-prefix'), + noConstructor: hasOptions && optionsStr.includes('no-constructor'), + exportBaseConstructor: hasOptions && optionsStr.includes('export-base-constructor'), + noExport: hasOptions && optionsStr.includes('no-export'), + noRedefine: hasOptions && optionsStr.includes('no-redefine'), + }; +} + function processLines(lines, prefix) { const prefixed = []; let noExport = false; return lines .map(line => { - const hasOptions = line.includes('@type-options'); - const optionsStr = hasOptions ? line.match(/@type-options\s+(?[A-Za-z][\s\w,-]+)$/)?.groups?.options : ''; - const options = { - noExtends: hasOptions && optionsStr.includes('no-extends'), - noPrefix: hasOptions && optionsStr.includes('no-prefix'), - noConstructor: hasOptions && optionsStr.includes('no-constructor'), - exportBaseConstructor: hasOptions && optionsStr.includes('export-base-constructor'), - noExport: hasOptions && optionsStr.includes('no-export'), - noRedefine: hasOptions && optionsStr.includes('no-redefine'), - }; + const options = parseOptions(line); + if (noExport && /^[^{]*\}/.test(line)) { noExport = false; return null; @@ -46,7 +54,10 @@ function processLines(lines, prefix) { noExport = true; return null; } + if (line.includes('export {')) return null; + + // Process interfaces that either don’t need to extend other interfaces or have already been extended if (/^\s*(?:declare\s+)?interface\s+\w+\s*extends/.test(line) || options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+(?:<[^>]+>)?\s*\{/.test(line)) { if (!options.noPrefix) { @@ -58,11 +69,13 @@ function processLines(lines, prefix) { return line.replace(/^(?\s*)(?:declare\s+)?interface\s+(?[\s\w,<=>]+)/, `$export interface ${ !options.noPrefix ? prefix : '' }$`); } + + // Process interfaces: prefix name, emit backing var (constructor) and make it extend original if (!options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+/.test(line)) { - const m = line.match(/^(?\s*)(?:declare\s+)?interface\s+(?\w+)(?<[^>]+>)?/); - const iIndent = m?.groups?.indent ?? ''; - const iName = m?.groups?.name ?? ''; - const iExtend = m?.groups?.extend ?? ''; + const match = line.match(/^(?\s*)(?:declare\s+)?interface\s+(?\w+)(?<[^>]+>)?/); + const iIndent = match?.groups?.indent ?? ''; + const iName = match?.groups?.name ?? ''; + const iExtend = match?.groups?.extend ?? ''; if (!options.noPrefix && iName !== '') { prefixed.push(iName); } @@ -80,10 +93,14 @@ function processLines(lines, prefix) { return `${ constructorDeclaration }${ iIndent }export interface ${ entityName }${ iExtend } extends ${ iName }${ genericsForExtends } {\n`; } + + // Process function if (/^\s*(?:declare\s+)?function/.test(line)) { return line.replace(/^(?\s*)(?:declare\s+)?function\s+(?\w+)/, `$export function ${ !options.noPrefix ? prefix : '' }$`); } + + // Replace prefixed types in the entire file if (/(?::|\|)\s*\w/.test(line)) { const sortedPrefixed = prefixed.sort((a, b) => b.length - a.length); sortedPrefixed.forEach(item => { @@ -91,6 +108,8 @@ function processLines(lines, prefix) { line = line.replace(reg, `$ ${ prefix }${ item }$`); }); } + + // Handle vars: prefix variable name, keep original type if (/^\s*(?:declare)?\svar/.test(line)) { const m = line.match(/^(?\s*)(?:declare\s+)?var\s+(?\w+):\s+(?\w+)/); return `${ m?.groups?.indent ?? '' }var ${ !options.noPrefix ? prefix : '' }${ m?.groups?.name ?? '' }: ${ m?.groups?.type };\n`; @@ -102,45 +121,69 @@ function processLines(lines, prefix) { function wrapInNamespace(content, namespace = 'CoreJS') { const lines = content.split('\n'); - const preamble = []; + const headerLines = []; + let i = 0; + // Process the header section up to the start of the main content for (; i < lines.length; i++) { const line = lines[i]; + + // Update reference paths and add to header if (/\/\/\/\s* `${ a }../${ b }${ c }`)); - } else if (/^\s*\/\//.test(line) || /^\s*$/.test(line)) { - preamble.push(line); - } else break; + headerLines.push(line.replace(/^\s*import\s.*from\s+["'].+["']/, + (_, start, importPath, end) => `${ start }../${ importPath }${ end }`)); + continue; + } + + // Comments & new lines add to header as is + if (/^\s*\/\//.test(line) || /^\s*$/.test(line)) { + headerLines.push(line); + continue; + } + break; } - const mainLines = lines.slice(i); - const { sections, outside } = extractDeclareGlobalSections(mainLines); - const nsBody = [...processLines(outside, namespace), ...sections.flatMap(s => processLines(s, namespace))] + + const bodyLines = lines.slice(i); + const { sections, outside } = extractDeclareGlobalSections(bodyLines); + + const namespaceBody = [...processLines(outside, namespace), ...sections.flatMap(s => processLines(s, namespace))] .reduce((res, line) => { - if ((line && line.trim() !== '') || (res.at(-1) && res.at(-1).trim() !== '')) res.push(line); + if (line?.trim() !== '' || (res.at(-1) && res.at(-1).trim() !== '')) res.push(line); return res; - }, []).map(line => line ? ` ${ line }` : '').join('\n'); - return `${ preamble.length ? `${ preamble.join('\n') }\n` : '' }declare namespace ${ namespace } {\n${ nsBody }\n}\n`; + }, []) + .map(line => line ? ` ${ line }` : '') + .join('\n'); + + return `${ headerLines.length ? `${ headerLines.join('\n') }\n` : '' }declare namespace ${ namespace } {\n${ namespaceBody }\n}\n`; } export async function preparePureTypes(typesPath, initialPath) { const entries = await readdir(typesPath, { withFileTypes: true }); for (const entry of entries) { if (entry.name === 'pure') continue; + if (entry.isDirectory()) { await preparePureTypes(path.join(typesPath, entry.name), initialPath); } else { if (entry.name.includes('core-js-types.d.ts')) continue; + const typePath = path.join(typesPath, entry.name); const resultFilePath = typePath.replace(initialPath, `${ initialPath }/pure/`); + if (await pathExists(resultFilePath)) continue; + const content = await fs.readFile(typePath, 'utf8'); + if (content.includes('declare namespace')) continue; + const result = wrapInNamespace(content); await outputFile(resultFilePath, result); } From 39efd882375bb7a71e74e5615ef6a2c53592cfa8 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 17 Dec 2025 01:55:06 +0700 Subject: [PATCH 089/315] Iterable DOM collections types --- .../base/web/iterable-dom-collections.d.ts | 271 ++++++++++++++++++ .../modules/web.dom-collections.entries.js | 1 + .../modules/web.dom-collections.for-each.js | 1 + .../modules/web.dom-collections.iterator.js | 1 + .../modules/web.dom-collections.keys.js | 1 + .../modules/web.dom-collections.values.js | 1 + .../web/iterable-dom-collections.test.ts | 38 +++ 7 files changed, 314 insertions(+) create mode 100644 packages/core-js-types/src/base/web/iterable-dom-collections.d.ts create mode 100644 tests/type-definitions/global/web/iterable-dom-collections.test.ts diff --git a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts new file mode 100644 index 000000000000..d6b950923a61 --- /dev/null +++ b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts @@ -0,0 +1,271 @@ +// use only with DOM lib +interface ArrayIterator extends IteratorObject { // @type-options no-export + [Symbol.iterator](): ArrayIterator; +} + +interface DOMTokenList { // @type-options no-export + /** + * Calls a defined callback function on each element of the DOMTokenList, + * passing the element, its index, and the entire DOMTokenList as arguments. + * @param callbackfn + * @param thisArg + */ + forEach( + callbackfn: (value: Element, index: number, collection: DOMTokenList) => void, + thisArg?: any + ): void; + + /** + * Returns an iterable of keys in the DOMTokenList. + */ + keys(): Iterable; + + /** + * Returns an iterable of values in the DOMTokenList. + */ + values(): Iterable; + + /** + * Returns an iterable of key, value pairs in the DOMTokenList. + */ + entries(): Iterable<[number, Element]>; + + [Symbol.iterator](): Iterable; +} + +interface NodeList { // @type-options no-export + /** + * Calls a defined callback function on each element of the NodeList, + * passing the element, its index, and the entire NodeList as arguments. + * @param callbackfn + * @param thisArg + */ + forEach( + callbackfn: (value: Node, index: number, collection: NodeList) => void, + thisArg?: any + ): void; + + /** + * Returns an iterable of keys in the NodeList. + */ + keys(): Iterable; + + /** + * Returns an iterable of values in the NodeList. + */ + values(): Iterable; + + /** + * Returns an iterable of key, value pairs in the NodeList. + */ + entries(): Iterable<[number, Node]>; + + /** + * Returns an iterable of values in the NodeList. + */ + [Symbol.iterator](): Iterable; +} + +interface CSSRuleList { // @type-options no-export + /** + * Returns an iterable of values in the CSSRuleList. + */ + [Symbol.iterator](): Iterable; +} + +interface CSSStyleDeclaration { // @type-options no-export + /** + * Returns an iterable of values in the CSSStyleDeclaration. + */ + [Symbol.iterator](): Iterable; +} + +interface CSSValueList { // @type-options no-export + /** + * Returns an iterable of values in the CSSValueList. + */ + [Symbol.iterator](): Iterable; +} + +interface ClientRectList { // @type-options no-export + /** + * Returns an iterable of values in the ClientRectList. + */ + [Symbol.iterator](): Iterable; +} + +interface DOMRectList { // @type-options no-export + /** + * Returns an iterable of values in the DOMRectList. + */ + [Symbol.iterator](): Iterable; +} + +interface DOMStringList { // @type-options no-export + /** + * Returns an iterable of values in the DOMStringList. + */ + [Symbol.iterator](): Iterable; +} + +interface DataTransferItemList { // @type-options no-export + /** + * Returns an iterable of values in the DataTransferItemList. + */ + [Symbol.iterator](): Iterable; +} + +interface FileList { // @type-options no-export + /** + * Returns an iterable of values in the FileList. + */ + [Symbol.iterator](): Iterable; +} + +interface HTMLAllCollection { // @type-options no-export + /** + * Returns an iterable of values in the HTMLAllCollection. + */ + [Symbol.iterator](): Iterable; +} + +interface HTMLCollection { // @type-options no-export + /** + * Returns an iterable of values in the HTMLCollection. + */ + [Symbol.iterator](): ArrayIterator; +} + +interface HTMLFormElement { // @type-options no-export + /** + * Returns an iterable of values in the HTMLFormElement. + */ + [Symbol.iterator](): Iterable; +} + +interface HTMLSelectElement { // @type-options no-export + /** + * Returns an iterable of values in the HTMLSelectElement. + */ + [Symbol.iterator](): Iterable; +} + +interface MediaList { // @type-options no-export + /** + * Returns an iterable of values in the MediaList. + */ + [Symbol.iterator](): Iterable; +} + +interface MimeTypeArray { // @type-options no-export + /** + * Returns an iterable of values in the MimeTypeArray. + */ + [Symbol.iterator](): Iterable; +} + +interface NamedNodeMap { // @type-options no-export + /** + * Returns an iterable of values in the NamedNodeMap. + */ + [Symbol.iterator](): Iterable; +} + +interface PaintRequestList { // @type-options no-export + /** + * Returns an iterable of values in the PaintRequestList. + */ + [Symbol.iterator](): Iterable; +} + +interface Plugin { // @type-options no-export + /** + * Returns an iterable of values in the Plugin. + */ + [Symbol.iterator](): Iterable; +} + +interface PluginArray { // @type-options no-export + /** + * Returns an iterable of values in the PluginArray. + */ + [Symbol.iterator](): Iterable; +} + +interface SVGLengthList { // @type-options no-export + /** + * Returns an iterable of values in the SVGLengthList. + */ + [Symbol.iterator](): Iterable; +} + +interface SVGNumberList { // @type-options no-export + /** + * Returns an iterable of values in the SVGNumberList. + */ + [Symbol.iterator](): Iterable; +} + +interface SVGPathSegList { // @type-options no-export + /** + * Returns an iterable of values in the SVGPathSegList. + */ + [Symbol.iterator](): Iterable; +} + +interface SVGPointList { // @type-options no-export + /** + * Returns an iterable of values in the SVGPointList. + */ + [Symbol.iterator](): Iterable; +} + +interface SVGStringList { // @type-options no-export + /** + * Returns an iterable of values in the SVGStringList. + */ + [Symbol.iterator](): Iterable; +} + +interface SVGTransformList { // @type-options no-export + /** + * Returns an iterable of values in the SVGTransformList. + */ + [Symbol.iterator](): Iterable; +} + +interface SourceBufferList { // @type-options no-export + /** + * Returns an iterable of values in the SourceBufferList. + */ + [Symbol.iterator](): Iterable; +} + +interface StyleSheetList { // @type-options no-export + /** + * Returns an iterable of values in the StyleSheetList. + * + */ + [Symbol.iterator](): Iterable; +} + +interface TextTrackCueList { // @type-options no-export + /** + * Returns an iterable of values in the TextTrackCueList. + */ + [Symbol.iterator](): Iterable; +} + +interface TextTrackList { // @type-options no-export + /** + * Returns an iterable of values in the TextTrackList. + */ + [Symbol.iterator](): Iterable; +} + +interface TouchList { // @type-options no-export + /** + * Returns an iterable of values in the TouchList. + */ + [Symbol.iterator](): Iterable; +} diff --git a/packages/core-js/modules/web.dom-collections.entries.js b/packages/core-js/modules/web.dom-collections.entries.js index 565ff5aacf3e..8e63b117c90a 100644 --- a/packages/core-js/modules/web.dom-collections.entries.js +++ b/packages/core-js/modules/web.dom-collections.entries.js @@ -1,3 +1,4 @@ +// types: web/iterable-dom-collections 'use strict'; var domIterablesDefineMethod = require('../internals/dom-iterables-define-method'); diff --git a/packages/core-js/modules/web.dom-collections.for-each.js b/packages/core-js/modules/web.dom-collections.for-each.js index cc1adfc3b0ad..cd51d8a6d3d0 100644 --- a/packages/core-js/modules/web.dom-collections.for-each.js +++ b/packages/core-js/modules/web.dom-collections.for-each.js @@ -1,3 +1,4 @@ +// types: web/iterable-dom-collections 'use strict'; var domIterablesDefineMethod = require('../internals/dom-iterables-define-method'); diff --git a/packages/core-js/modules/web.dom-collections.iterator.js b/packages/core-js/modules/web.dom-collections.iterator.js index 33b66156981a..1d5998c1f8ce 100644 --- a/packages/core-js/modules/web.dom-collections.iterator.js +++ b/packages/core-js/modules/web.dom-collections.iterator.js @@ -1,3 +1,4 @@ +// types: web/iterable-dom-collections 'use strict'; var domIterablesDefineMethod = require('../internals/dom-iterables-define-method'); var wellKnownSymbol = require('../internals/well-known-symbol'); diff --git a/packages/core-js/modules/web.dom-collections.keys.js b/packages/core-js/modules/web.dom-collections.keys.js index 15c1172b0f70..06e64d5ab0f2 100644 --- a/packages/core-js/modules/web.dom-collections.keys.js +++ b/packages/core-js/modules/web.dom-collections.keys.js @@ -1,3 +1,4 @@ +// types: web/iterable-dom-collections 'use strict'; var domIterablesDefineMethod = require('../internals/dom-iterables-define-method'); diff --git a/packages/core-js/modules/web.dom-collections.values.js b/packages/core-js/modules/web.dom-collections.values.js index e7e2a84c6354..c1353f4f1001 100644 --- a/packages/core-js/modules/web.dom-collections.values.js +++ b/packages/core-js/modules/web.dom-collections.values.js @@ -1,3 +1,4 @@ +// types: web/iterable-dom-collections 'use strict'; var domIterablesDefineMethod = require('../internals/dom-iterables-define-method'); var wellKnownSymbol = require('../internals/well-known-symbol'); diff --git a/tests/type-definitions/global/web/iterable-dom-collections.test.ts b/tests/type-definitions/global/web/iterable-dom-collections.test.ts new file mode 100644 index 000000000000..6e783af5358e --- /dev/null +++ b/tests/type-definitions/global/web/iterable-dom-collections.test.ts @@ -0,0 +1,38 @@ +import 'core-js/full'; + +declare const nodeList: NodeList +nodeList.forEach((value: Node, key: number, list: NodeList): void => {}); +nodeList.forEach((value: Node, key: number, list: NodeList): void => {}, []); +// @ts-expect-error +nodeList.forEach(); + +const k1: Iterable = nodeList.keys(); +// @ts-expect-error +nodeList.keys('string'); + +const v: Iterable = nodeList.values(); +// @ts-expect-error +nodeList.values('string'); + +const e: Iterable<[number, Node]> = nodeList.entries(); +// @ts-expect-error +nodeList.entries('string'); + +declare const domTokenList: DOMTokenList + +domTokenList.forEach((value: Node, key: number, list: DOMTokenList): void => {}); +domTokenList.forEach((value: Node, key: number, list: DOMTokenList): void => {}, []); +// @ts-expect-error +domTokenList.forEach(); + +const fomKeys: Iterable = domTokenList.keys(); +// @ts-expect-error +domTokenList.keys('string'); + +const domValues: Iterable = domTokenList.values(); +// @ts-expect-error +domTokenList.values('string'); + +const domEntries: Iterable<[number, Element]> = domTokenList.entries(); +// @ts-expect-error +domTokenList.entries('string'); From 3d5c7d02adeabd0f767f1f79c7a6a592d5ab9d03 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 17 Dec 2025 23:04:31 +0700 Subject: [PATCH 090/315] Build types refactoring --- scripts/build-types/index.mjs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index a55d9dee6955..05fbaf38ffea 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -28,21 +28,16 @@ const imports = { }; let outputFiles = {}; -function addType(filePath, template, options) { +function addType(tsVersion, subset, template, options) { + const filePath = buildFilePath(tsVersion, subset); + if (!outputFiles[filePath]) outputFiles[filePath] = ''; const entryWithTypes = template(options); outputFiles[filePath] += `${ entryWithTypes.types }${ entryWithTypes.types ? '\n' : '' }`; } function addEntryTypes(tsVersion, template, options) { - const indexPath = buildFilePath(tsVersion, 'index'); - if (!outputFiles[indexPath]) outputFiles[indexPath] = ''; - const optionsGlobal = { ...options, packageName: PACKAGE_NAME }; - addType(indexPath, template, optionsGlobal); - - const purePath = buildFilePath(tsVersion, 'pure'); - if (!outputFiles[purePath]) outputFiles[purePath] = ''; - const optionsPure = { ...options, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }; - addType(purePath, template, optionsPure); + addType(tsVersion, 'index', template, { ...options, packageName: PACKAGE_NAME }); + addType(tsVersion, 'pure', template, { ...options, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); } async function buildType(entry, options) { From 1ae39a1fbb6355ec12be37500bac9d781c0f4aee Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 18 Dec 2025 19:28:29 +0700 Subject: [PATCH 091/315] Update README.md --- packages/core-js-types/README.md | 58 +++++++++++++++++++------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/packages/core-js-types/README.md b/packages/core-js-types/README.md index a350b1d546bf..83c0b77cfdf2 100644 --- a/packages/core-js-types/README.md +++ b/packages/core-js-types/README.md @@ -1,7 +1,8 @@ ![logo](https://user-images.githubusercontent.com/2213682/146607186-8e13ddef-26a4-4ebf-befd-5aac9d77c090.png) +This package contains types for global & pure versions of `core-js`. # Installation -`npm install --save @core-js/types` +`npm install --save @core-js/types@4.0.0-alpha.0` # Usage Add to your `tsconfig.json`: @@ -19,41 +20,47 @@ or import it directly in your files: import '@core-js/types'; ``` -# Usage of pure version -Add this to your `tsconfig.json`: +## Usage of subsets +There are 4 types of subset: +- `@core-js/types/actual` - types for all actual features, including stable ECMAScript, web standards and stage 3 ECMAScript proposals +- `@core-js/types/es` - types for stable ECMAScript features only +- `@core-js/types/stable` - types for stable ECMAScript and web standards features +- `@core-js/types/full` - types for all features, including proposals +You can import them the same way as the main package, for example, to use stable version, add this to your `tsconfig.json`: ```json { "compilerOptions": { "types": [ - "@core-js/types/pure" + "@core-js/types/stable" ] } } ``` -then, when you import from the pure entry points, the corresponding types are picked up automatically: +or import it directly in your files: ```ts -import $findLast from '@core-js/pure/full/array/find-last'; - -$findLast([1, 3, 4, 2], v => v > 2); // => 4 +import '@core-js/types/stable'; ``` -# DOM types -To work with DOM, you need to add DOM types to the `lib` section of your `tsconfig.json`, for example: +# Types for the pure version +## Base usage +Add this to your `tsconfig.json`: ```json { "compilerOptions": { - "lib": ["esnext", "dom"] + "types": [ + "@core-js/types/pure" + ] } } ``` -In `pure` version you can use it without adding additional DOM types: +then, when you import from the pure entry points, the corresponding types are picked up automatically: ```ts -import $parse from '@core-js/pure/full/url/parse'; +import $findLast from '@core-js/pure/full/array/find-last'; -$parse('https://example.com/path?name=value#hash'); +$findLast([1, 3, 4, 2], v => v > 2); // => 4 ``` -# Namespace usage in pure version +## Namespace usage If you need to use multiple methods from the same namespace, you can import the entire namespace instead: ```ts import $array from '@core-js/pure/full/array'; @@ -62,13 +69,18 @@ $array.findLast([1, 3, 4, 2], v => v > 2); $array.flatMap([1, 2, 3], x => [x, x * 2]); ``` -# Package variants -You can import different variants of the package types: -```ts -import '@core-js/types/actual'; // types for all actual features - stable ES, web standards and stage 3 ES proposals -import '@core-js/types/full'; // types for all features - stable ES, web standards and all proposals -import '@core-js/types/stable'; // types for stable features - ES and web standards -import '@core-js/types/es'; // types for only stable ES features +# DOM types +Global types works correctly only with DOM lib. You need to add DOM types to the `lib` section of your `tsconfig.json`, for example: +```json +{ + "compilerOptions": { + "lib": ["esnext", "dom"] + } +} ``` +In `pure` version you can use it without adding additional DOM types: +```ts +import $parse from '@core-js/pure/full/url/parse'; -# Reference import +$parse('https://example.com/path?name=value#hash'); +``` From b2a5435e1532e795034455ab59e41584e2c03694 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 18 Dec 2025 20:05:37 +0700 Subject: [PATCH 092/315] Remove proposal stages from types & add some TSDocs --- .../src/base/annex-b/object-proto.d.ts | 3 ++ .../object-prototype-accessor-methods.d.ts | 26 ++++++++++++++++ .../accessible-object-hasownproperty.d.ts | 1 - .../base/proposals/array-buffer-base64.d.ts | 1 - .../base/proposals/array-buffer-transfer.d.ts | 1 - .../src/base/proposals/array-filtering.d.ts | 8 ++++- .../base/proposals/array-find-from-last.d.ts | 1 - .../base/proposals/array-flat-map-custom.d.ts | 1 - .../src/base/proposals/array-flat-map.d.ts | 3 -- .../src/base/proposals/array-from-async.d.ts | 1 - .../src/base/proposals/array-grouping.d.ts | 1 - .../src/base/proposals/array-includes.d.ts | 1 - .../proposals/array-is-template-object.d.ts | 1 - .../src/base/proposals/array-unique.d.ts | 1 - .../src/base/proposals/async-iteration.d.ts | 1 - .../proposals/async-iterator-helpers.d.ts | 1 - .../src/base/proposals/await-dictionary.d.ts | 1 - .../change-array-by-copy-custom.d.ts | 1 - .../base/proposals/change-array-by-copy.d.ts | 1 - .../base/proposals/collection-of-from.d.ts | 1 - .../data-view-get-set-uint8-clamped.d.ts | 1 - .../base/proposals/decorator-metadata.d.ts | 1 - .../src/base/proposals/error-cause.d.ts | 1 - .../explicit-resource-management.d.ts | 1 - .../src/base/proposals/float16.d.ts | 1 - .../base/proposals/function-demethodize.d.ts | 2 +- .../src/base/proposals/is-error.d.ts | 1 - .../src/base/proposals/iterator-chunking.d.ts | 1 - .../proposals/iterator-helpers-custom.d.ts | 1 - .../src/base/proposals/iterator-helpers.d.ts | 1 - .../src/base/proposals/iterator-join.d.ts | 5 ++- .../src/base/proposals/iterator-joint.d.ts | 1 - .../src/base/proposals/iterator-range.d.ts | 1 - .../base/proposals/iterator-sequencing.d.ts | 1 - .../proposals/json-parse-with-source.d.ts | 1 - .../src/base/proposals/map-upsert.d.ts | 1 - .../src/base/proposals/math-sum.d.ts | 1 - .../src/base/proposals/number-clamp.d.ts | 1 - .../base/proposals/object-from-entries.d.ts | 1 - .../object-get-own-property-descriptors.d.ts | 1 - .../base/proposals/object-values-entries.d.ts | 1 - .../src/base/proposals/pattern-matching.d.ts | 1 - .../base/proposals/promise-all-settled.d.ts | 1 - .../src/base/proposals/promise-any.d.ts | 1 - .../src/base/proposals/promise-finally.d.ts | 1 - .../src/base/proposals/promise-try.d.ts | 1 - .../proposals/promise-with-resolvers.d.ts | 1 - .../base/proposals/regexp-dotall-flag.d.ts | 1 - .../src/base/proposals/regexp-escaping.d.ts | 1 - .../base/proposals/regexp-named-groups.d.ts | 1 - .../proposals/relative-indexing-method.d.ts | 1 - .../base/proposals/set-methods-custom.d.ts | 1 - .../src/base/proposals/set-methods.d.ts | 1 - .../src/base/proposals/string-cooked.d.ts | 1 - .../src/base/proposals/string-dedent.d.ts | 1 - .../proposals/string-left-right-trim.d.ts | 1 - .../src/base/proposals/string-match-all.d.ts | 31 ++++++++----------- .../src/base/proposals/string-padding.d.ts | 1 - .../proposals/string-replace-all-custom.d.ts | 1 - .../base/proposals/string-replace-all.d.ts | 1 - .../base/proposals/symbol-description.d.ts | 1 - .../src/base/proposals/symbol-predicates.d.ts | 1 - .../well-formed-unicode-strings.d.ts | 1 - .../src/base/web/url-to-json.d.ts | 3 ++ 64 files changed, 57 insertions(+), 80 deletions(-) diff --git a/packages/core-js-types/src/base/annex-b/object-proto.d.ts b/packages/core-js-types/src/base/annex-b/object-proto.d.ts index 8e994dbd4ffb..79004b1b90b4 100644 --- a/packages/core-js-types/src/base/annex-b/object-proto.d.ts +++ b/packages/core-js-types/src/base/annex-b/object-proto.d.ts @@ -1,3 +1,6 @@ interface Object { + /** + * Deprecated accessor to `Object.prototype`. + */ __proto__: object | null; } diff --git a/packages/core-js-types/src/base/annex-b/object-prototype-accessor-methods.d.ts b/packages/core-js-types/src/base/annex-b/object-prototype-accessor-methods.d.ts index cf148f00e65a..11a99fd62ff9 100644 --- a/packages/core-js-types/src/base/annex-b/object-prototype-accessor-methods.d.ts +++ b/packages/core-js-types/src/base/annex-b/object-prototype-accessor-methods.d.ts @@ -1,9 +1,35 @@ interface Object { + /** + * Defines a getter function for the specified property on this object. + * This method is non-standard and deprecated; prefer `Object.defineProperty`. + * @param prop - The name or symbol of the property. + * @param getter - A function that will be called whenever the property is read. + */ __defineGetter__(prop: PropertyKey, getter: () => any): void; + /** + * Defines a setter function for the specified property on this object. + * This method is non-standard and deprecated; prefer `Object.defineProperty`. + * @param prop - The name or symbol of the property. + * @param setter - A function that will be called whenever the property is assigned a value. + */ __defineSetter__(prop: PropertyKey, setter: (val: any) => void): void; + /** + * Returns the getter function associated with the specified property, + * or `undefined` if the property has no getter. + * This method is non-standard and deprecated. + * @param prop - The name or symbol of the property. + * @returns The getter function for the property, or `undefined`. + */ __lookupGetter__(prop: PropertyKey): (() => any) | undefined; + /** + * Returns the setter function associated with the specified property, + * or `undefined` if the property has no setter. + * This method is non-standard and deprecated. + * @param prop - The name or symbol of the property. + * @returns The setter function for the property, or `undefined`. + */ __lookupSetter__(prop: PropertyKey): ((val: any) => void) | undefined; } diff --git a/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts b/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts index cb8989c282aa..364c1f717e59 100644 --- a/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts +++ b/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-accessible-object-hasownproperty // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts index b85e129a2a1b..445014236c63 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 3 // https://github.com/tc39/proposal-arraybuffer-base64 // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts index 457dcbca335e..8ed3ba32abaf 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-arraybuffer-transfer // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/array-filtering.d.ts b/packages/core-js-types/src/base/proposals/array-filtering.d.ts index 6df245b62c9c..72ffc75f7045 100644 --- a/packages/core-js-types/src/base/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/base/proposals/array-filtering.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 1 // https://github.com/tc39/proposal-array-filtering interface Array { // @type-options no-redefine @@ -101,6 +100,13 @@ interface Float32Array { // @type-options no-export } interface Float64Array { // @type-options no-export + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ filterReject(callbackFn: (value: number, index: number, target: Float64Array) => boolean, thisArg?: any): Float64Array; } diff --git a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts index 33f8330e21e7..ede80b55905b 100644 --- a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-array-find-from-last // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/array-flat-map-custom.d.ts b/packages/core-js-types/src/base/proposals/array-flat-map-custom.d.ts index 56e9aa2ea260..194a95d8d73f 100644 --- a/packages/core-js-types/src/base/proposals/array-flat-map-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/array-flat-map-custom.d.ts @@ -1,6 +1,5 @@ // Motivation: Custom type needed to keep generics strict -// proposal stage: 4 // https://github.com/tc39/proposal-flatMap // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/array-flat-map.d.ts b/packages/core-js-types/src/base/proposals/array-flat-map.d.ts index 9b0ceb3c1e71..52f4cbc1ddfa 100644 --- a/packages/core-js-types/src/base/proposals/array-flat-map.d.ts +++ b/packages/core-js-types/src/base/proposals/array-flat-map.d.ts @@ -1,6 +1,5 @@ /// -// proposal stage: 4 // https://github.com/tc39/proposal-flatMap // For ensuring compatibility with TypeScript standard types, this code is aligned with: @@ -12,7 +11,6 @@ interface Array { // @type-options no-redefine * 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 callback 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 this keyword can refer in the callback function. If @@ -23,7 +21,6 @@ interface Array { // @type-options no-redefine /** * 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(this: A, depth?: D): CoreJS.CoreJSFlatArray[]; diff --git a/packages/core-js-types/src/base/proposals/array-from-async.d.ts b/packages/core-js-types/src/base/proposals/array-from-async.d.ts index fc92789b750a..d145b047d850 100644 --- a/packages/core-js-types/src/base/proposals/array-from-async.d.ts +++ b/packages/core-js-types/src/base/proposals/array-from-async.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 3 // https://github.com/tc39/proposal-array-from-async // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/array-grouping.d.ts b/packages/core-js-types/src/base/proposals/array-grouping.d.ts index 5e3a7f6b1e5a..8d1d9c51511e 100644 --- a/packages/core-js-types/src/base/proposals/array-grouping.d.ts +++ b/packages/core-js-types/src/base/proposals/array-grouping.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-array-grouping // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/array-includes.d.ts b/packages/core-js-types/src/base/proposals/array-includes.d.ts index 6b3a43766b83..1fe1656df03a 100644 --- a/packages/core-js-types/src/base/proposals/array-includes.d.ts +++ b/packages/core-js-types/src/base/proposals/array-includes.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-Array.prototype.includes // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts b/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts index aa469688d346..c886aa131f4a 100644 --- a/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts +++ b/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 2 // https://github.com/tc39/proposal-array-is-template-object interface ArrayConstructor { // @type-options no-export diff --git a/packages/core-js-types/src/base/proposals/array-unique.d.ts b/packages/core-js-types/src/base/proposals/array-unique.d.ts index 3d22faa36462..f1c1f4f64ea1 100644 --- a/packages/core-js-types/src/base/proposals/array-unique.d.ts +++ b/packages/core-js-types/src/base/proposals/array-unique.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 1 // https://github.com/tc39/proposal-array-unique interface Array { // @type-options no-redefine diff --git a/packages/core-js-types/src/base/proposals/async-iteration.d.ts b/packages/core-js-types/src/base/proposals/async-iteration.d.ts index be679d567ebe..b2774ddeff80 100644 --- a/packages/core-js-types/src/base/proposals/async-iteration.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iteration.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-async-iteration // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index 0567377a00e7..c13250b5a9d2 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 2 // https://github.com/tc39/proposal-async-iterator-helpers interface AsyncIteratorConstructor { diff --git a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts index 354548a45777..d6dbc18027d6 100644 --- a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts @@ -1,6 +1,5 @@ /// -// proposal stage: 1 // https://github.com/tc39/proposal-await-dictionary interface PromiseConstructor { // @type-options no-redefine diff --git a/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts b/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts index bab7c2913ebe..e320dd02a36d 100644 --- a/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts @@ -1,6 +1,5 @@ // Motivation: Custom type needed to keep generics strict -// proposal stage: 4 // https://github.com/tc39/proposal-change-array-by-copy // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts index fbd5aef7a301..a3ea5c2a7767 100644 --- a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts +++ b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-change-array-by-copy // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts index b3b13d49e118..f488fd7211b4 100644 --- a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 1 // https://github.com/tc39/proposal-setmap-offrom interface MapConstructor { diff --git a/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts index 05fb7154b5e8..039340d59ffb 100644 --- a/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts +++ b/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 1 // https://github.com/tc39/proposal-dataview-get-set-uint8clamped interface DataView { // @type-options no-constructor diff --git a/packages/core-js-types/src/base/proposals/decorator-metadata.d.ts b/packages/core-js-types/src/base/proposals/decorator-metadata.d.ts index 82908a331f64..e548fa96e40b 100644 --- a/packages/core-js-types/src/base/proposals/decorator-metadata.d.ts +++ b/packages/core-js-types/src/base/proposals/decorator-metadata.d.ts @@ -1,6 +1,5 @@ /// -// proposal stage: 3 // https://github.com/tc39/proposal-decorator-metadata interface SymbolConstructor { diff --git a/packages/core-js-types/src/base/proposals/error-cause.d.ts b/packages/core-js-types/src/base/proposals/error-cause.d.ts index e08ef8d852b6..7593a5d6735e 100644 --- a/packages/core-js-types/src/base/proposals/error-cause.d.ts +++ b/packages/core-js-types/src/base/proposals/error-cause.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-error-cause // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts index 6721c46ed410..22a8d2281557 100644 --- a/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 3 // https://github.com/tc39/proposal-explicit-resource-management // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/float16.d.ts b/packages/core-js-types/src/base/proposals/float16.d.ts index 76a56efa828e..8f791c2cf5f8 100644 --- a/packages/core-js-types/src/base/proposals/float16.d.ts +++ b/packages/core-js-types/src/base/proposals/float16.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-float16array // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/function-demethodize.d.ts b/packages/core-js-types/src/base/proposals/function-demethodize.d.ts index a5b013681862..37568d4d18a8 100644 --- a/packages/core-js-types/src/base/proposals/function-demethodize.d.ts +++ b/packages/core-js-types/src/base/proposals/function-demethodize.d.ts @@ -1,5 +1,5 @@ -// proposal stage: 0 // https://github.com/js-choi/proposal-function-demethodize + interface Function { // @type-options no-constructor /** * Creates a function that calls the original with its first argument as `this` and the rest as regular arguments. diff --git a/packages/core-js-types/src/base/proposals/is-error.d.ts b/packages/core-js-types/src/base/proposals/is-error.d.ts index f92dfcf40522..60cba842ebe1 100644 --- a/packages/core-js-types/src/base/proposals/is-error.d.ts +++ b/packages/core-js-types/src/base/proposals/is-error.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 3 // https://github.com/tc39/proposal-is-error // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts b/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts index 6e44eb0c468b..6d83a8005baa 100644 --- a/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts @@ -1,6 +1,5 @@ /// -// proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-chunking interface Iterator { diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts index 3ddeebe1e6e7..c543b1dd0a35 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts @@ -1,6 +1,5 @@ // Motivation: Custom type needed to keep generics strict -// proposal stage: 4 // https://github.com/tc39/proposal-iterator-helpers // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts index d6ff6c0cf4a5..bd9433a175e3 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-iterator-helpers // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/iterator-join.d.ts b/packages/core-js-types/src/base/proposals/iterator-join.d.ts index 7f0151419bf2..1564e6a8495e 100644 --- a/packages/core-js-types/src/base/proposals/iterator-join.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-join.d.ts @@ -1,6 +1,9 @@ -// proposal stage: 0 // https://github.com/bakkot/proposal-iterator-join interface Iterator { + /** + * Creates a string by concatenating all elements provided by the iterator, separated by the specified separator. + * @param separator + */ join(separator?: unknown): string; } diff --git a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts index c49a5953a859..54411c0d5bac 100644 --- a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts @@ -1,6 +1,5 @@ /// -// proposal stage: 2.7 // https://github.com/tc39/proposal-joint-iteration type ZipOptions = { diff --git a/packages/core-js-types/src/base/proposals/iterator-range.d.ts b/packages/core-js-types/src/base/proposals/iterator-range.d.ts index 90df48a404c7..2db194f8eea3 100644 --- a/packages/core-js-types/src/base/proposals/iterator-range.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-range.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 2 // https://github.com/tc39/proposal-iterator.range declare global { diff --git a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts index 8a3ad0958ace..2d454f842b98 100644 --- a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts @@ -1,6 +1,5 @@ /// -// proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-sequencing interface IteratorConstructor { // @type-options no-extends diff --git a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts index 58c02930cf1e..270afe8a1083 100644 --- a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts +++ b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 3 // https://github.com/tc39/proposal-json-parse-with-source interface CoreJSReviverContext { // @type-options no-extends,no-prefix diff --git a/packages/core-js-types/src/base/proposals/map-upsert.d.ts b/packages/core-js-types/src/base/proposals/map-upsert.d.ts index 053128f0d551..ec5915e4fd2c 100644 --- a/packages/core-js-types/src/base/proposals/map-upsert.d.ts +++ b/packages/core-js-types/src/base/proposals/map-upsert.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 2 // https://github.com/tc39/proposal-upsert interface Map { // @type-options no-redefine diff --git a/packages/core-js-types/src/base/proposals/math-sum.d.ts b/packages/core-js-types/src/base/proposals/math-sum.d.ts index 3bbc0472db34..996559f09973 100644 --- a/packages/core-js-types/src/base/proposals/math-sum.d.ts +++ b/packages/core-js-types/src/base/proposals/math-sum.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 3 // https://github.com/tc39/proposal-math-sum interface Math { // @type-options no-constructor /** diff --git a/packages/core-js-types/src/base/proposals/number-clamp.d.ts b/packages/core-js-types/src/base/proposals/number-clamp.d.ts index 2fb0e2388b03..021463de0a47 100644 --- a/packages/core-js-types/src/base/proposals/number-clamp.d.ts +++ b/packages/core-js-types/src/base/proposals/number-clamp.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 2 // https://github.com/tc39/proposal-math-clamp interface Number { // @type-options export-base-constructor diff --git a/packages/core-js-types/src/base/proposals/object-from-entries.d.ts b/packages/core-js-types/src/base/proposals/object-from-entries.d.ts index 7fea3279463c..1b764764712e 100644 --- a/packages/core-js-types/src/base/proposals/object-from-entries.d.ts +++ b/packages/core-js-types/src/base/proposals/object-from-entries.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-object-from-entries // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts b/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts index 67ceaa76f561..53171639804e 100644 --- a/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts +++ b/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-object-getownpropertydescriptors // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/object-values-entries.d.ts b/packages/core-js-types/src/base/proposals/object-values-entries.d.ts index aa0de63518f7..6030b53d54ad 100644 --- a/packages/core-js-types/src/base/proposals/object-values-entries.d.ts +++ b/packages/core-js-types/src/base/proposals/object-values-entries.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-object-values-entries // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/pattern-matching.d.ts b/packages/core-js-types/src/base/proposals/pattern-matching.d.ts index 874f263f2930..c33c71983bf3 100644 --- a/packages/core-js-types/src/base/proposals/pattern-matching.d.ts +++ b/packages/core-js-types/src/base/proposals/pattern-matching.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 1 // https://github.com/tc39/proposal-pattern-matching interface SymbolConstructor { diff --git a/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts index 2d691fd65ca8..92381bf202c0 100644 --- a/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts @@ -1,6 +1,5 @@ /// -// proposal stage: 4 // https://github.com/tc39/proposal-promise-allSettled // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/promise-any.d.ts b/packages/core-js-types/src/base/proposals/promise-any.d.ts index a15bc92ccc00..96fcd7154e8a 100644 --- a/packages/core-js-types/src/base/proposals/promise-any.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-any.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-promise-any // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/promise-finally.d.ts b/packages/core-js-types/src/base/proposals/promise-finally.d.ts index 850658dbc9b8..035b3ac06a4c 100644 --- a/packages/core-js-types/src/base/proposals/promise-finally.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-finally.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-promise-finally // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/promise-try.d.ts b/packages/core-js-types/src/base/proposals/promise-try.d.ts index 9ac786ebdfb6..1cdf7e32d228 100644 --- a/packages/core-js-types/src/base/proposals/promise-try.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-try.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-promise-try // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts index d16cf05b6946..b7198e7879d0 100644 --- a/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-promise-with-resolvers // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/regexp-dotall-flag.d.ts b/packages/core-js-types/src/base/proposals/regexp-dotall-flag.d.ts index b88f68d04b4a..ca7bc3950d59 100644 --- a/packages/core-js-types/src/base/proposals/regexp-dotall-flag.d.ts +++ b/packages/core-js-types/src/base/proposals/regexp-dotall-flag.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-regexp-dotall-flag // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/regexp-escaping.d.ts b/packages/core-js-types/src/base/proposals/regexp-escaping.d.ts index 2d22fea70fa8..2e396fb86b51 100644 --- a/packages/core-js-types/src/base/proposals/regexp-escaping.d.ts +++ b/packages/core-js-types/src/base/proposals/regexp-escaping.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-regex-escaping interface RegExpConstructor { diff --git a/packages/core-js-types/src/base/proposals/regexp-named-groups.d.ts b/packages/core-js-types/src/base/proposals/regexp-named-groups.d.ts index 2164fe5db0af..b6e6f8fc2a8e 100644 --- a/packages/core-js-types/src/base/proposals/regexp-named-groups.d.ts +++ b/packages/core-js-types/src/base/proposals/regexp-named-groups.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-regexp-named-groups // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts index 57392904b4f5..4cb92a07f4b6 100644 --- a/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-relative-indexing-method // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/set-methods-custom.d.ts b/packages/core-js-types/src/base/proposals/set-methods-custom.d.ts index a5c7c4a2cfed..1f67c0aec7d5 100644 --- a/packages/core-js-types/src/base/proposals/set-methods-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/set-methods-custom.d.ts @@ -1,6 +1,5 @@ // Motivation: Custom type needed to keep generics strict -// proposal stage: 4 // https://github.com/tc39/proposal-set-methods // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/set-methods.d.ts b/packages/core-js-types/src/base/proposals/set-methods.d.ts index 39826b824be4..d01c64a3d2a1 100644 --- a/packages/core-js-types/src/base/proposals/set-methods.d.ts +++ b/packages/core-js-types/src/base/proposals/set-methods.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-set-methods // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/string-cooked.d.ts b/packages/core-js-types/src/base/proposals/string-cooked.d.ts index a04ec91d14f6..2bbedf148bcc 100644 --- a/packages/core-js-types/src/base/proposals/string-cooked.d.ts +++ b/packages/core-js-types/src/base/proposals/string-cooked.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 1 // https://github.com/tc39/proposal-string-cooked interface StringConstructor { diff --git a/packages/core-js-types/src/base/proposals/string-dedent.d.ts b/packages/core-js-types/src/base/proposals/string-dedent.d.ts index a0c4d9877b7d..e5ad7c925ed2 100644 --- a/packages/core-js-types/src/base/proposals/string-dedent.d.ts +++ b/packages/core-js-types/src/base/proposals/string-dedent.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 2 // https://github.com/tc39/proposal-string-dedent interface StringConstructor { diff --git a/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts index 29883ddfd595..0054bd2ae39e 100644 --- a/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts +++ b/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-string-left-right-trim // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/string-match-all.d.ts b/packages/core-js-types/src/base/proposals/string-match-all.d.ts index b49f3c69a82c..8fc417ec2270 100644 --- a/packages/core-js-types/src/base/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/base/proposals/string-match-all.d.ts @@ -1,27 +1,22 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-string-matchall // For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -declare global { - interface RegExpStringIterator extends IteratorObject { - [Symbol.iterator](): RegExpStringIterator; - } - - interface String { - /** - * Matches a string with a regular expression, and returns an iterable of matches - * containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. - */ - matchAll(regexp: RegExp): RegExpStringIterator; - } +interface RegExpStringIterator extends IteratorObject { + [Symbol.iterator](): RegExpStringIterator; +} - interface SymbolConstructor { - readonly matchAll: unique symbol; - } +interface String { + /** + * Matches a string with a regular expression, and returns an iterable of matches + * containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + matchAll(regexp: RegExp): RegExpStringIterator; } -export {}; +interface SymbolConstructor { + readonly matchAll: unique symbol; +} diff --git a/packages/core-js-types/src/base/proposals/string-padding.d.ts b/packages/core-js-types/src/base/proposals/string-padding.d.ts index 55a5f67fbdc9..44f082fdeaa7 100644 --- a/packages/core-js-types/src/base/proposals/string-padding.d.ts +++ b/packages/core-js-types/src/base/proposals/string-padding.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-string-pad-start-end // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts b/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts index 027cfd601e53..28b8d73b8d62 100644 --- a/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts @@ -1,6 +1,5 @@ // Motivation: Custom type needed to keep generics strict -// proposal stage: 4 // https://github.com/tc39/proposal-string-replaceall // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/proposals/string-replace-all.d.ts index ad90b37057ad..4a8ff7d6b96d 100644 --- a/packages/core-js-types/src/base/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/base/proposals/string-replace-all.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-string-replaceall // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/symbol-description.d.ts b/packages/core-js-types/src/base/proposals/symbol-description.d.ts index d982ebe7bfc5..0b5c7bc1dd43 100644 --- a/packages/core-js-types/src/base/proposals/symbol-description.d.ts +++ b/packages/core-js-types/src/base/proposals/symbol-description.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-Symbol-description // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts b/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts index cb97a1c2d394..d842ff0bd6cf 100644 --- a/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts +++ b/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 2 // https://github.com/tc39/proposal-symbol-predicates interface SymbolConstructor { diff --git a/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts index 01b91d123fb1..86a94fc3944f 100644 --- a/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts +++ b/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 4 // https://github.com/tc39/proposal-is-usv-string // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/web/url-to-json.d.ts b/packages/core-js-types/src/base/web/url-to-json.d.ts index c1675d18bb5e..316729dc8419 100644 --- a/packages/core-js-types/src/base/web/url-to-json.d.ts +++ b/packages/core-js-types/src/base/web/url-to-json.d.ts @@ -1,3 +1,6 @@ interface URL { // @type-options no-extends + /** + * Returns a JSON representation of the URL. + */ toJSON(): string; } From ff30dae5ae8a08d717955c09f2093103284833f3 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 18 Dec 2025 21:38:35 +0700 Subject: [PATCH 093/315] Update README.md --- packages/core-js-types/README.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/core-js-types/README.md b/packages/core-js-types/README.md index 83c0b77cfdf2..a4bb3b2ef53d 100644 --- a/packages/core-js-types/README.md +++ b/packages/core-js-types/README.md @@ -1,5 +1,13 @@ ![logo](https://user-images.githubusercontent.com/2213682/146607186-8e13ddef-26a4-4ebf-befd-5aac9d77c090.png) This package contains types for global & pure versions of `core-js`. +Although `core-js` is a polyfill library for the JavaScript, the built-in TypeScript types are not sufficient. +Additional types are needed for: +- features that are already in JavaScript, but not yet in TypeScript’s standard types; +- proposals, including those already implemented in JavaScript engines; +- explicit imports of features from the pure version. + +We decided to ship it as a separate package, because we cannot guarantee stable behavior, +primarily with upcoming minor TypeScript releases # Installation `npm install --save @core-js/types@4.0.0-alpha.0` @@ -19,6 +27,7 @@ or import it directly in your files: ```ts import '@core-js/types'; ``` +`@core-js/types` includes all types and entry points for the global version, but it is recommended to select only the subset you actually use instead. ## Usage of subsets There are 4 types of subset: @@ -61,7 +70,8 @@ $findLast([1, 3, 4, 2], v => v > 2); // => 4 ``` ## Namespace usage -If you need to use multiple methods from the same namespace, you can import the entire namespace instead: +If you need to use multiple methods from the same namespace, you can add `@core-js/types/pure` to `tsconfig.json` +and import the entire namespace instead: ```ts import $array from '@core-js/pure/full/array'; @@ -70,7 +80,8 @@ $array.flatMap([1, 2, 3], x => [x, x * 2]); ``` # DOM types -Global types works correctly only with DOM lib. You need to add DOM types to the `lib` section of your `tsconfig.json`, for example: +A part of the global types for web standards work correctly only with the DOM lib. +You need to add DOM types to the `lib` section of your `tsconfig.json`, for example: ```json { "compilerOptions": { @@ -78,9 +89,4 @@ Global types works correctly only with DOM lib. You need to add DOM types to the } } ``` -In `pure` version you can use it without adding additional DOM types: -```ts -import $parse from '@core-js/pure/full/url/parse'; - -$parse('https://example.com/path?name=value#hash'); -``` +In the `pure` version you can use it without adding DOM lib From f663cdebc4d1eb75439e785c69dd904e26b787b4 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 18 Dec 2025 21:38:59 +0700 Subject: [PATCH 094/315] Update TSDocs for __proto__ --- packages/core-js-types/src/base/annex-b/object-proto.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/annex-b/object-proto.d.ts b/packages/core-js-types/src/base/annex-b/object-proto.d.ts index 79004b1b90b4..94faf99d5d4f 100644 --- a/packages/core-js-types/src/base/annex-b/object-proto.d.ts +++ b/packages/core-js-types/src/base/annex-b/object-proto.d.ts @@ -1,6 +1,7 @@ interface Object { /** - * Deprecated accessor to `Object.prototype`. + * Accessor to [[Prototype]]. + * This is non-standard and deprecated; prefer get/set */ __proto__: object | null; } From 68c5200daa859a92f814b0e484dce7284f625854 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 18 Dec 2025 21:45:02 +0700 Subject: [PATCH 095/315] Update README.md --- packages/core-js-types/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/README.md b/packages/core-js-types/README.md index a4bb3b2ef53d..d34d222a52ec 100644 --- a/packages/core-js-types/README.md +++ b/packages/core-js-types/README.md @@ -6,8 +6,8 @@ Additional types are needed for: - proposals, including those already implemented in JavaScript engines; - explicit imports of features from the pure version. -We decided to ship it as a separate package, because we cannot guarantee stable behavior, -primarily with upcoming minor TypeScript releases +It is shipped as a separate package, because we cannot guarantee stable behavior, +primarily with upcoming minor TypeScript releases. # Installation `npm install --save @core-js/types@4.0.0-alpha.0` From 0e9dde23d4738b2f9f91725f43e3f6e271145120 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 19 Dec 2025 00:03:41 +0700 Subject: [PATCH 096/315] Update README.md --- packages/core-js-types/README.md | 63 ++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/packages/core-js-types/README.md b/packages/core-js-types/README.md index d34d222a52ec..822c576f4cb1 100644 --- a/packages/core-js-types/README.md +++ b/packages/core-js-types/README.md @@ -1,16 +1,18 @@ ![logo](https://user-images.githubusercontent.com/2213682/146607186-8e13ddef-26a4-4ebf-befd-5aac9d77c090.png) -This package contains types for global & pure versions of `core-js`. -Although `core-js` is a polyfill library for the JavaScript, the built-in TypeScript types are not sufficient. + +This package contains types for the global and pure versions of `core-js`. +Although `core-js` is a JavaScript standard library polyfill, the built-in TypeScript types are often not sufficient. Additional types are needed for: -- features that are already in JavaScript, but not yet in TypeScript’s standard types; +- features that are already in JavaScript but not yet in TypeScript’s standard types; - proposals, including those already implemented in JavaScript engines; - explicit imports of features from the pure version. -It is shipped as a separate package, because we cannot guarantee stable behavior, -primarily with upcoming minor TypeScript releases. +It is shipped as a separate package because we cannot guarantee stable behavior with future TypeScript releases, including minor ones. # Installation -`npm install --save @core-js/types@4.0.0-alpha.0` +```bash +npm install --save @core-js/types@4.0.0-alpha.0 +``` # Usage Add to your `tsconfig.json`: @@ -27,15 +29,16 @@ or import it directly in your files: ```ts import '@core-js/types'; ``` -`@core-js/types` includes all types and entry points for the global version, but it is recommended to select only the subset you actually use instead. +`@core-js/types` includes all types and entry points for the global version, but it is recommended to select only the subset you actually use. ## Usage of subsets -There are 4 types of subset: -- `@core-js/types/actual` - types for all actual features, including stable ECMAScript, web standards and stage 3 ECMAScript proposals -- `@core-js/types/es` - types for stable ECMAScript features only -- `@core-js/types/stable` - types for stable ECMAScript and web standards features -- `@core-js/types/full` - types for all features, including proposals -You can import them the same way as the main package, for example, to use stable version, add this to your `tsconfig.json`: +There are four main subsets: +- `@core-js/types/actual` - types for all actual features, including stable ECMAScript, web standards and Stage 3 ECMAScript proposals; +- `@core-js/types/es` - types for stable ECMAScript features only; +- `@core-js/types/stable` - types for stable ECMAScript and web standards features; +- `@core-js/types/full` - types for all features, including proposals. + +You can import them the same way as the main package. For example, to use only the stable subset, add this to your `tsconfig.json`: ```json { "compilerOptions": { @@ -50,6 +53,25 @@ or import it directly in your files: import '@core-js/types/stable'; ``` +## Usage of specific features +If you need types only for specific features, you can import them like this: +```json +{ + "compilerOptions": { + "types": [ + "@core-js/types/proposals/joint-iteration", + "@core-js/types/web/structured-clone" + ] + } +} +``` +or import them directly in your files: +```ts +import '@core-js/types/proposals/joint-iteration'; +import '@core-js/types/web/structured-clone'; +``` +You can find types for specific features on the corresponding pages in the [documentation](https://core-js.io/v4/docs/). + # Types for the pure version ## Base usage Add this to your `tsconfig.json`: @@ -62,31 +84,32 @@ Add this to your `tsconfig.json`: } } ``` -then, when you import from the pure entry points, the corresponding types are picked up automatically: +Then, when you import from the pure entry points, the corresponding types are picked up automatically: ```ts import $findLast from '@core-js/pure/full/array/find-last'; $findLast([1, 3, 4, 2], v => v > 2); // => 4 ``` -## Namespace usage -If you need to use multiple methods from the same namespace, you can add `@core-js/types/pure` to `tsconfig.json` -and import the entire namespace instead: +## Namespace usage in the pure version +If you need to use multiple methods from the same namespace, you can add `@core-js/types/pure` to `tsconfig.json` and import the entire namespace: ```ts import $array from '@core-js/pure/full/array'; $array.findLast([1, 3, 4, 2], v => v > 2); $array.flatMap([1, 2, 3], x => [x, x * 2]); ``` +(note that this is not recommended since tree shaking does not properly work in this case) # DOM types -A part of the global types for web standards work correctly only with the DOM lib. -You need to add DOM types to the `lib` section of your `tsconfig.json`, for example: +Some of the global types for web standards work correctly only with the DOM lib. +You need to add DOM types to the `lib` section of your `tsconfig.json` in addition to `@core-js/types`. For example: ```json { "compilerOptions": { + "types": ["@core-js/types"], "lib": ["esnext", "dom"] } } ``` -In the `pure` version you can use it without adding DOM lib +In the pure version, you can use these types without adding the DOM lib. From 5b04cc5580a19c01057606dc7d42aabbe2391206 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 19 Dec 2025 01:55:53 +0700 Subject: [PATCH 097/315] TypeScript type defintions docs for website --- ...essible-object-prototype-hasownproperty.md | 3 + .../features/proposals/array-deduplication.md | 3 + .../features/proposals/array-filtering.md | 3 + .../proposals/array-find-from-last.md | 3 + .../features/proposals/array-fromasync.md | 3 + .../docs/features/proposals/array-grouping.md | 3 + .../proposals/array-istemplateobject.md | 3 + .../proposals/array-prototype-flat-flatmap.md | 3 + .../proposals/array-prototype-includes.md | 3 + .../arraybuffer-prototype-transfer.md | 3 + .../proposals/asynciterator-helpers.md | 3 + .../features/proposals/await-dictionary.md | 5 +- .../proposals/change-array-by-copy.md | 3 + .../dataview-get-set-uint8clamped.md | 3 + .../docs/features/proposals/error-iserror.md | 3 + .../proposals/explicit-resource-management.md | 3 + .../features/proposals/float16-methods.md | 3 + .../function-prototype-demethodize.md | 3 + .../features/proposals/iterator-chunking.md | 3 + .../features/proposals/iterator-helpers.md | 3 + .../docs/features/proposals/iterator-join.md | 5 +- .../docs/features/proposals/iterator-range.md | 3 + .../features/proposals/iterator-sequencing.md | 3 + .../features/proposals/joint-iteration.md | 3 + .../json-parse-source-text-access.md | 3 + .../web/docs/features/proposals/map-upsert.md | 3 + .../features/proposals/math-sumprecise.md | 3 + .../proposals/number-prototype-clamp.md | 3 + .../features/proposals/object-fromentries.md | 3 + .../object-getownpropertydescriptors.md | 4 + .../proposals/object-values-entries.md | 3 + .../of-and-from-methods-on-collections.md | 4 + .../features/proposals/promise-allsettled.md | 3 + .../docs/features/proposals/promise-any.md | 3 + .../proposals/promise-prototype-finally.md | 3 + .../docs/features/proposals/promise-try.md | 3 + .../proposals/promise-withresolvers.md | 3 + .../features/proposals/regexp-dotall-flag.md | 3 + .../features/proposals/regexp-escaping.md | 3 + .../proposals/regexp-named-capture-groups.md | 3 + .../proposals/relative-indexing-method.md | 3 + .../docs/features/proposals/set-methods.md | 3 + .../docs/features/proposals/string-cooked.md | 3 + .../docs/features/proposals/string-dedent.md | 3 + .../features/proposals/string-matchall.md | 3 + .../docs/features/proposals/string-padding.md | 3 + .../features/proposals/string-replaceall.md | 3 + .../proposals/string-trimstart-trimend.md | 3 + .../proposals/symbol-asynciterator.md | 3 + .../symbol-custommatcher-for-extractors.md | 3 + .../symbol-custommatcher-pattern-matching.md | 3 + .../features/proposals/symbol-metadata.md | 3 + .../features/proposals/symbol-predicates.md | 3 + .../proposals/symbol-prototype-description.md | 3 + .../proposals/uint8array-base64-hex.md | 3 + .../proposals/well-formed-unicode-strings.md | 3 + .../web-standards/base64-utility-methods.md | 3 + .../web-standards/iterable-dom-collections.md | 3 + .../features/web-standards/queuemicrotask.md | 3 + .../features/web-standards/setimmediate.md | 3 + .../web-standards/structured-clone.md | 3 + .../web-standards/url-and-urlsearchparams.md | 3 + docs/web/docs/menu.json | 4 + docs/web/docs/typescript-type-definitions.md | 115 ++++++++++++++++++ 64 files changed, 309 insertions(+), 2 deletions(-) create mode 100644 docs/web/docs/typescript-type-definitions.md diff --git a/docs/web/docs/features/proposals/accessible-object-prototype-hasownproperty.md b/docs/web/docs/features/proposals/accessible-object-prototype-hasownproperty.md index c0c0469f3070..7349aa74b7ec 100644 --- a/docs/web/docs/features/proposals/accessible-object-prototype-hasownproperty.md +++ b/docs/web/docs/features/proposals/accessible-object-prototype-hasownproperty.md @@ -13,3 +13,6 @@ class Object { ```plaintext core-js/proposals/accessible-object-hasownproperty ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/accessible-object-hasownproperty`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts) diff --git a/docs/web/docs/features/proposals/array-deduplication.md b/docs/web/docs/features/proposals/array-deduplication.md index 39d0df81bbc2..81bf9ce6a032 100644 --- a/docs/web/docs/features/proposals/array-deduplication.md +++ b/docs/web/docs/features/proposals/array-deduplication.md @@ -22,6 +22,9 @@ core-js(-pure)/full/array(/prototype)/unique-by core-js/full/typed-array/unique-by ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/array-unique`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/array-unique.d.ts) + ## Examples ```js [1, 2, 3, 2, 1].uniqueBy(); // [1, 2, 3] diff --git a/docs/web/docs/features/proposals/array-filtering.md b/docs/web/docs/features/proposals/array-filtering.md index 8aac455befbf..b030ed3b65c7 100644 --- a/docs/web/docs/features/proposals/array-filtering.md +++ b/docs/web/docs/features/proposals/array-filtering.md @@ -23,6 +23,9 @@ core-js(-pure)/full/array(/prototype)/filter-reject core-js/full/typed-array/filter-reject ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/array-filtering`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/array-filtering.d.ts) + ## Examples ```js [1, 2, 3, 4, 5].filterReject(it => it % 2); // => [2, 4] diff --git a/docs/web/docs/features/proposals/array-find-from-last.md b/docs/web/docs/features/proposals/array-find-from-last.md index 83c11f7fc082..3fb749f92944 100644 --- a/docs/web/docs/features/proposals/array-find-from-last.md +++ b/docs/web/docs/features/proposals/array-find-from-last.md @@ -19,3 +19,6 @@ class %TypedArray% { ```plaintext core-js/proposals/array-find-from-last ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/array-find-from-last`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts) diff --git a/docs/web/docs/features/proposals/array-fromasync.md b/docs/web/docs/features/proposals/array-fromasync.md index d6137c2518ad..5b8c44f99462 100644 --- a/docs/web/docs/features/proposals/array-fromasync.md +++ b/docs/web/docs/features/proposals/array-fromasync.md @@ -13,3 +13,6 @@ class Array { ```plaintext core-js/proposals/array-from-async ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/array-from-async`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/array-from-async.d.ts) diff --git a/docs/web/docs/features/proposals/array-grouping.md b/docs/web/docs/features/proposals/array-grouping.md index e441fedca303..ea21f3c15c6c 100644 --- a/docs/web/docs/features/proposals/array-grouping.md +++ b/docs/web/docs/features/proposals/array-grouping.md @@ -17,3 +17,6 @@ class Map { ```plaintext core-js/proposals/array-grouping-v2 ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/array-grouping`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/array-grouping.d.ts) diff --git a/docs/web/docs/features/proposals/array-istemplateobject.md b/docs/web/docs/features/proposals/array-istemplateobject.md index c3e116d69bce..8fd6cee682fc 100644 --- a/docs/web/docs/features/proposals/array-istemplateobject.md +++ b/docs/web/docs/features/proposals/array-istemplateobject.md @@ -18,6 +18,9 @@ core-js/proposals/array-is-template-object core-js(-pure)/full/array/is-template-object ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/array-is-template-object`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts) + ## Example ```js console.log(Array.isTemplateObject((it => it)`qwe${ 123 }asd`)); // => true diff --git a/docs/web/docs/features/proposals/array-prototype-flat-flatmap.md b/docs/web/docs/features/proposals/array-prototype-flat-flatmap.md index 2bdbeb21076e..8354c8d102c9 100644 --- a/docs/web/docs/features/proposals/array-prototype-flat-flatmap.md +++ b/docs/web/docs/features/proposals/array-prototype-flat-flatmap.md @@ -14,3 +14,6 @@ class Array { ```plaintext core-js/proposals/array-flat-map ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/array-flat-map`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/array-flat-map.d.ts) diff --git a/docs/web/docs/features/proposals/array-prototype-includes.md b/docs/web/docs/features/proposals/array-prototype-includes.md index d725e01f820a..f90d37934fe7 100644 --- a/docs/web/docs/features/proposals/array-prototype-includes.md +++ b/docs/web/docs/features/proposals/array-prototype-includes.md @@ -16,3 +16,6 @@ class %TypedArray% { ```plaintext core-js/proposals/array-includes ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/array-includes`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/array-includes.d.ts) diff --git a/docs/web/docs/features/proposals/arraybuffer-prototype-transfer.md b/docs/web/docs/features/proposals/arraybuffer-prototype-transfer.md index fa0016c7e33e..c4f7ee9938d8 100644 --- a/docs/web/docs/features/proposals/arraybuffer-prototype-transfer.md +++ b/docs/web/docs/features/proposals/arraybuffer-prototype-transfer.md @@ -15,3 +15,6 @@ class ArrayBuffer { ```plaintext core-js/proposals/array-buffer-transfer ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/array-buffer-transfer`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts) diff --git a/docs/web/docs/features/proposals/asynciterator-helpers.md b/docs/web/docs/features/proposals/asynciterator-helpers.md index 519eb7491da5..860303818c16 100644 --- a/docs/web/docs/features/proposals/asynciterator-helpers.md +++ b/docs/web/docs/features/proposals/asynciterator-helpers.md @@ -47,6 +47,9 @@ core-js(-pure)/actual|full/async-iterator/to-array core-js(-pure)/actual|full/iterator/to-async ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/async-iterator-helpers`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts) + ## Examples ```js await AsyncIterator.from([1, 2, 3, 4, 5, 6, 7]) diff --git a/docs/web/docs/features/proposals/await-dictionary.md b/docs/web/docs/features/proposals/await-dictionary.md index 15b86e9e7d84..3f25366b1f76 100644 --- a/docs/web/docs/features/proposals/await-dictionary.md +++ b/docs/web/docs/features/proposals/await-dictionary.md @@ -19,12 +19,15 @@ class Promise { ``` ## [Entry points]({docs-version}/docs/usage#h-entry-points) -```ts +```plaintext core-js/proposals/promise-all-keyed core-js(-pure)/full/promise/all-keyed core-js(-pure)/full/promise/all-settled-keyed ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/await-dictionary`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/await-dictionary.d.ts) + ## Examples ```js await Promise.allKeyed({ diff --git a/docs/web/docs/features/proposals/change-array-by-copy.md b/docs/web/docs/features/proposals/change-array-by-copy.md index ec65731f418a..e485bda27447 100644 --- a/docs/web/docs/features/proposals/change-array-by-copy.md +++ b/docs/web/docs/features/proposals/change-array-by-copy.md @@ -29,3 +29,6 @@ core-js/es|stable|actual|full/typed-array/to-reversed core-js/es|stable|actual|full/typed-array/to-sorted core-js/es|stable|actual|full/typed-array/with ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/change-array-by-copy`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts) diff --git a/docs/web/docs/features/proposals/dataview-get-set-uint8clamped.md b/docs/web/docs/features/proposals/dataview-get-set-uint8clamped.md index d870e2f0bdb4..64a94fea8dda 100644 --- a/docs/web/docs/features/proposals/dataview-get-set-uint8clamped.md +++ b/docs/web/docs/features/proposals/dataview-get-set-uint8clamped.md @@ -20,6 +20,9 @@ core-js/full/dataview/get-uint8-clamped core-js/full/dataview/set-uint8-clamped ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/data-view-get-set-uint8-clamped`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts) + ## Examples ```js const view = new DataView(new ArrayBuffer(1)); diff --git a/docs/web/docs/features/proposals/error-iserror.md b/docs/web/docs/features/proposals/error-iserror.md index 2ede2ef817a8..531136875c40 100644 --- a/docs/web/docs/features/proposals/error-iserror.md +++ b/docs/web/docs/features/proposals/error-iserror.md @@ -14,5 +14,8 @@ class Error { core-js/proposals/is-error ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/is-error`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/is-error.d.ts) + > [!WARNING] > We have no bulletproof way to polyfill this `Error.isError` / check if the object is an error, so it's an enough naive implementation. diff --git a/docs/web/docs/features/proposals/explicit-resource-management.md b/docs/web/docs/features/proposals/explicit-resource-management.md index ee0079f2de16..4c1c394f4278 100644 --- a/docs/web/docs/features/proposals/explicit-resource-management.md +++ b/docs/web/docs/features/proposals/explicit-resource-management.md @@ -54,3 +54,6 @@ class AsyncIterator { ```plaintext core-js/proposals/explicit-resource-management ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/explicit-resource-management`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts) diff --git a/docs/web/docs/features/proposals/float16-methods.md b/docs/web/docs/features/proposals/float16-methods.md index 36a8c7d50173..be5132cf3204 100644 --- a/docs/web/docs/features/proposals/float16-methods.md +++ b/docs/web/docs/features/proposals/float16-methods.md @@ -18,3 +18,6 @@ namespace Math { ```plaintext core-js/proposals/float16 ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/float16`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/float16.d.ts) diff --git a/docs/web/docs/features/proposals/function-prototype-demethodize.md b/docs/web/docs/features/proposals/function-prototype-demethodize.md index f2588984a23b..bc0cb24e40b2 100644 --- a/docs/web/docs/features/proposals/function-prototype-demethodize.md +++ b/docs/web/docs/features/proposals/function-prototype-demethodize.md @@ -18,6 +18,9 @@ core-js(-pure)/full/function/demethodize core-js(-pure)/full/function/prototype/demethodize ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/function-demethodize`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/function-demethodize.d.ts) + ## Examples ```js const slice = Array.prototype.slice.demethodize(); diff --git a/docs/web/docs/features/proposals/iterator-chunking.md b/docs/web/docs/features/proposals/iterator-chunking.md index 02074a072f4d..0bf7f8cbc110 100644 --- a/docs/web/docs/features/proposals/iterator-chunking.md +++ b/docs/web/docs/features/proposals/iterator-chunking.md @@ -20,6 +20,9 @@ core-js(-pure)/full/iterator/chunks core-js(-pure)/full/iterator/windows ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/iterator-chunking`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts) + ## Examples ```js const digits = () => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].values(); diff --git a/docs/web/docs/features/proposals/iterator-helpers.md b/docs/web/docs/features/proposals/iterator-helpers.md index 98c2a55c9ed6..b5065a0e4446 100644 --- a/docs/web/docs/features/proposals/iterator-helpers.md +++ b/docs/web/docs/features/proposals/iterator-helpers.md @@ -25,3 +25,6 @@ class Iterator { ```plaintext core-js/proposals/iterator-helpers ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/iterator-helpers`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts) diff --git a/docs/web/docs/features/proposals/iterator-join.md b/docs/web/docs/features/proposals/iterator-join.md index 88cc8df32d94..8b248ba1ce21 100644 --- a/docs/web/docs/features/proposals/iterator-join.md +++ b/docs/web/docs/features/proposals/iterator-join.md @@ -13,11 +13,14 @@ class Iterator { ``` ## [Entry points]({docs-version}/docs/usage#h-entry-points) -```ts +```plaintext core-js/proposals/iterator-join core-js(-pure)/full/iterator/join ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/iterator-join`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/iterator-join.d.ts) + ## Examples ```js const digits = () => [1, 2, 3].values(); diff --git a/docs/web/docs/features/proposals/iterator-range.md b/docs/web/docs/features/proposals/iterator-range.md index bba294de8efb..b455f35a03cc 100644 --- a/docs/web/docs/features/proposals/iterator-range.md +++ b/docs/web/docs/features/proposals/iterator-range.md @@ -19,6 +19,9 @@ core-js/proposals/number-range core-js(-pure)/full/iterator/range ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/iterator-range`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/iterator-range.d.ts) + ## Example ```js for (const i of Iterator.range(1, 10)) { diff --git a/docs/web/docs/features/proposals/iterator-sequencing.md b/docs/web/docs/features/proposals/iterator-sequencing.md index 5f7e8a72d180..2c49e7bc807b 100644 --- a/docs/web/docs/features/proposals/iterator-sequencing.md +++ b/docs/web/docs/features/proposals/iterator-sequencing.md @@ -18,6 +18,9 @@ core-js/proposals/iterator-sequencing core-js(-pure)/es|stable|actual|full/iterator/concat ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/iterator-sequencing`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts) + ## Example ```js Iterator.concat([0, 1].values(), [2, 3], function * () { diff --git a/docs/web/docs/features/proposals/joint-iteration.md b/docs/web/docs/features/proposals/joint-iteration.md index 124189a6d913..a4e82799d685 100644 --- a/docs/web/docs/features/proposals/joint-iteration.md +++ b/docs/web/docs/features/proposals/joint-iteration.md @@ -32,6 +32,9 @@ core-js(-pure)/actual|full/iterator/zip core-js(-pure)/actual|full/iterator/zip-keyed ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/iterator-joint`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/iterator-joint.d.ts) + ## Example ```js Iterator.zip([ diff --git a/docs/web/docs/features/proposals/json-parse-source-text-access.md b/docs/web/docs/features/proposals/json-parse-source-text-access.md index d5ca28ad48fd..9bac10544a1f 100644 --- a/docs/web/docs/features/proposals/json-parse-source-text-access.md +++ b/docs/web/docs/features/proposals/json-parse-source-text-access.md @@ -26,6 +26,9 @@ core-js(-pure)/es|stable|actual|full/json/raw-json core-js(-pure)/es|stable|actual|full/json/stringify ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/json-parse-with-source`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts) + ## Examples ```js function digitsToBigInt(key, val, { source }) { diff --git a/docs/web/docs/features/proposals/map-upsert.md b/docs/web/docs/features/proposals/map-upsert.md index 1846ab8f1219..2c954b7396ad 100644 --- a/docs/web/docs/features/proposals/map-upsert.md +++ b/docs/web/docs/features/proposals/map-upsert.md @@ -27,6 +27,9 @@ core-js(-pure)/es|stable|actual|full/weak-map/get-or-insert core-js(-pure)/es|stable|actual|full/weak-map/get-or-insert-computed ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/map-upsert`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/map-upsert.d.ts) + ## Examples ```js const map = new Map([['a', 1]]); diff --git a/docs/web/docs/features/proposals/math-sumprecise.md b/docs/web/docs/features/proposals/math-sumprecise.md index 76229801edbd..6417592a389a 100644 --- a/docs/web/docs/features/proposals/math-sumprecise.md +++ b/docs/web/docs/features/proposals/math-sumprecise.md @@ -13,3 +13,6 @@ namespace Math { ```plaintext core-js/proposals/math-sum ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/math-sum`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/math-sum.d.ts) diff --git a/docs/web/docs/features/proposals/number-prototype-clamp.md b/docs/web/docs/features/proposals/number-prototype-clamp.md index 347106ad29d5..c07a26be77fa 100644 --- a/docs/web/docs/features/proposals/number-prototype-clamp.md +++ b/docs/web/docs/features/proposals/number-prototype-clamp.md @@ -18,6 +18,9 @@ core-js/proposals/math-clamp-v2 core-js(-pure)/full/number/clamp ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/number-clamp`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/number-clamp.d.ts) + ## Example ```js 5.0.clamp(0, 10); // => 5 diff --git a/docs/web/docs/features/proposals/object-fromentries.md b/docs/web/docs/features/proposals/object-fromentries.md index 4d31ca16a316..ed1979bd53de 100644 --- a/docs/web/docs/features/proposals/object-fromentries.md +++ b/docs/web/docs/features/proposals/object-fromentries.md @@ -13,3 +13,6 @@ class Object { ```plaintext core-js/proposals/object-from-entries ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/object-from-entries`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/object-from-entries.d.ts) diff --git a/docs/web/docs/features/proposals/object-getownpropertydescriptors.md b/docs/web/docs/features/proposals/object-getownpropertydescriptors.md index a524b2930af5..567d306163d3 100644 --- a/docs/web/docs/features/proposals/object-getownpropertydescriptors.md +++ b/docs/web/docs/features/proposals/object-getownpropertydescriptors.md @@ -13,3 +13,7 @@ class Object { ```plaintext core-js/proposals/object-getownpropertydescriptors ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/object-get-own-property-descriptors`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts) + diff --git a/docs/web/docs/features/proposals/object-values-entries.md b/docs/web/docs/features/proposals/object-values-entries.md index b04ee9ed38f1..4202662c3042 100644 --- a/docs/web/docs/features/proposals/object-values-entries.md +++ b/docs/web/docs/features/proposals/object-values-entries.md @@ -14,3 +14,6 @@ class Object { ```plaintext core-js/proposals/object-values-entries ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/object-values-entries`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/object-values-entries.d.ts) diff --git a/docs/web/docs/features/proposals/of-and-from-methods-on-collections.md b/docs/web/docs/features/proposals/of-and-from-methods-on-collections.md index 43b0ab86dc59..becf164161a0 100644 --- a/docs/web/docs/features/proposals/of-and-from-methods-on-collections.md +++ b/docs/web/docs/features/proposals/of-and-from-methods-on-collections.md @@ -41,6 +41,10 @@ core-js(-pure)/full/weak-map/from core-js(-pure)/full/weak-map/of ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/collection-of-from`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/collection-of-from.d.ts) + + ## Examples ```js Set.of(1, 2, 3, 2, 1); // => Set {1, 2, 3} diff --git a/docs/web/docs/features/proposals/promise-allsettled.md b/docs/web/docs/features/proposals/promise-allsettled.md index 9df12f71a6a6..ece3a0a8d6c0 100644 --- a/docs/web/docs/features/proposals/promise-allsettled.md +++ b/docs/web/docs/features/proposals/promise-allsettled.md @@ -13,3 +13,6 @@ class Promise { ```plaintext core-js/proposals/promise-all-settled ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/promise-all-settled`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts) diff --git a/docs/web/docs/features/proposals/promise-any.md b/docs/web/docs/features/proposals/promise-any.md index 57cbd43fdd96..dd6f813e6c19 100644 --- a/docs/web/docs/features/proposals/promise-any.md +++ b/docs/web/docs/features/proposals/promise-any.md @@ -19,3 +19,6 @@ class Promise { ```plaintext core-js/proposals/promise-any ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/promise-any`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/promise-any.d.ts) diff --git a/docs/web/docs/features/proposals/promise-prototype-finally.md b/docs/web/docs/features/proposals/promise-prototype-finally.md index 907e8b2ce9cb..4b1c0e1a63d7 100644 --- a/docs/web/docs/features/proposals/promise-prototype-finally.md +++ b/docs/web/docs/features/proposals/promise-prototype-finally.md @@ -13,3 +13,6 @@ class Promise { ```plaintext core-js/proposals/promise-finally ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/promise-finally`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/promise-finally.d.ts) diff --git a/docs/web/docs/features/proposals/promise-try.md b/docs/web/docs/features/proposals/promise-try.md index 4847a9db12ba..30c21129f538 100644 --- a/docs/web/docs/features/proposals/promise-try.md +++ b/docs/web/docs/features/proposals/promise-try.md @@ -13,3 +13,6 @@ class Promise { ```plaintext core-js/proposals/promise-try ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/promise-try`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/promise-try.d.ts) diff --git a/docs/web/docs/features/proposals/promise-withresolvers.md b/docs/web/docs/features/proposals/promise-withresolvers.md index 309fad0b38a8..9b0b00364149 100644 --- a/docs/web/docs/features/proposals/promise-withresolvers.md +++ b/docs/web/docs/features/proposals/promise-withresolvers.md @@ -13,3 +13,6 @@ class Promise { ```plaintext core-js/proposals/promise-with-resolvers ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/promise-with-resolvers`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts) diff --git a/docs/web/docs/features/proposals/regexp-dotall-flag.md b/docs/web/docs/features/proposals/regexp-dotall-flag.md index 1e7ef92d9e83..d575f5e4784b 100644 --- a/docs/web/docs/features/proposals/regexp-dotall-flag.md +++ b/docs/web/docs/features/proposals/regexp-dotall-flag.md @@ -17,3 +17,6 @@ class RegExp { ```plaintext core-js/proposals/regexp-dotall-flag ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/regexp-dotall-flag`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/regexp-dotall-flag.d.ts) diff --git a/docs/web/docs/features/proposals/regexp-escaping.md b/docs/web/docs/features/proposals/regexp-escaping.md index 3a1b3f8f7e46..57f622e7595c 100644 --- a/docs/web/docs/features/proposals/regexp-escaping.md +++ b/docs/web/docs/features/proposals/regexp-escaping.md @@ -13,3 +13,6 @@ class RegExp { ```plaintext core-js/proposals/regexp-escaping ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/regexp-escaping`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/regexp-escaping.d.ts) diff --git a/docs/web/docs/features/proposals/regexp-named-capture-groups.md b/docs/web/docs/features/proposals/regexp-named-capture-groups.md index 857f127c29ca..58bc1b1694a4 100644 --- a/docs/web/docs/features/proposals/regexp-named-capture-groups.md +++ b/docs/web/docs/features/proposals/regexp-named-capture-groups.md @@ -16,3 +16,6 @@ class RegExp { ```plaintext core-js/proposals/regexp-named-groups ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/regexp-named-groups`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/regexp-named-groups.d.ts) diff --git a/docs/web/docs/features/proposals/relative-indexing-method.md b/docs/web/docs/features/proposals/relative-indexing-method.md index 36d0adf62600..ec1e345c3d79 100644 --- a/docs/web/docs/features/proposals/relative-indexing-method.md +++ b/docs/web/docs/features/proposals/relative-indexing-method.md @@ -21,3 +21,6 @@ class %TypedArray% { ```plaintext core-js/proposals/relative-indexing-method ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/relative-indexing-method`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts) diff --git a/docs/web/docs/features/proposals/set-methods.md b/docs/web/docs/features/proposals/set-methods.md index 90c28855a0b3..1b7d967b7166 100644 --- a/docs/web/docs/features/proposals/set-methods.md +++ b/docs/web/docs/features/proposals/set-methods.md @@ -19,3 +19,6 @@ class Set { ```plaintext core-js/proposals/set-methods ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/set-methods`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/set-methods.d.ts) diff --git a/docs/web/docs/features/proposals/string-cooked.md b/docs/web/docs/features/proposals/string-cooked.md index b95a484e5a7b..3de4439d95ad 100644 --- a/docs/web/docs/features/proposals/string-cooked.md +++ b/docs/web/docs/features/proposals/string-cooked.md @@ -18,6 +18,9 @@ core-js/proposals/string-cooked core-js(-pure)/full/string/cooked ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/string-cooked`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/string-cooked.d.ts) + ## Example ```js function safePath(strings, ...subs) { diff --git a/docs/web/docs/features/proposals/string-dedent.md b/docs/web/docs/features/proposals/string-dedent.md index 463ddb7a4546..d670db747a2e 100644 --- a/docs/web/docs/features/proposals/string-dedent.md +++ b/docs/web/docs/features/proposals/string-dedent.md @@ -18,6 +18,9 @@ core-js/proposals/string-dedent core-js(-pure)/full/string/dedent ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/string-dedent`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/string-dedent.d.ts) + ## Example ```js const message = 42; diff --git a/docs/web/docs/features/proposals/string-matchall.md b/docs/web/docs/features/proposals/string-matchall.md index d1dd99b0f308..3cb12e9b6927 100644 --- a/docs/web/docs/features/proposals/string-matchall.md +++ b/docs/web/docs/features/proposals/string-matchall.md @@ -12,3 +12,6 @@ class String { ```plaintext core-js/proposals/string-match-all ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/string-match-all`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/string-match-all.d.ts) diff --git a/docs/web/docs/features/proposals/string-padding.md b/docs/web/docs/features/proposals/string-padding.md index b53c46ac1665..b09316b8337a 100644 --- a/docs/web/docs/features/proposals/string-padding.md +++ b/docs/web/docs/features/proposals/string-padding.md @@ -15,3 +15,6 @@ class String { ```plaintext core-js/proposals/string-padding ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/string-padding`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/string-padding.d.ts) diff --git a/docs/web/docs/features/proposals/string-replaceall.md b/docs/web/docs/features/proposals/string-replaceall.md index 3e7b462cf443..c0cf935effd8 100644 --- a/docs/web/docs/features/proposals/string-replaceall.md +++ b/docs/web/docs/features/proposals/string-replaceall.md @@ -13,3 +13,6 @@ class String { ```plaintext core-js/proposals/string-replace-all ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/string-replace-all`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/string-replace-all.d.ts) diff --git a/docs/web/docs/features/proposals/string-trimstart-trimend.md b/docs/web/docs/features/proposals/string-trimstart-trimend.md index 397981e49f72..a0368f834164 100644 --- a/docs/web/docs/features/proposals/string-trimstart-trimend.md +++ b/docs/web/docs/features/proposals/string-trimstart-trimend.md @@ -16,3 +16,6 @@ class String { ```plaintext core-js/proposals/string-left-right-trim ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/string-left-right-trim`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts) diff --git a/docs/web/docs/features/proposals/symbol-asynciterator.md b/docs/web/docs/features/proposals/symbol-asynciterator.md index e90b3753652b..2b748e3c3257 100644 --- a/docs/web/docs/features/proposals/symbol-asynciterator.md +++ b/docs/web/docs/features/proposals/symbol-asynciterator.md @@ -13,3 +13,6 @@ class Symbol { ```plaintext core-js/proposals/async-iteration ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/async-iteration`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/async-iteration.d.ts) diff --git a/docs/web/docs/features/proposals/symbol-custommatcher-for-extractors.md b/docs/web/docs/features/proposals/symbol-custommatcher-for-extractors.md index 31973e3a2800..11d75a41ad74 100644 --- a/docs/web/docs/features/proposals/symbol-custommatcher-for-extractors.md +++ b/docs/web/docs/features/proposals/symbol-custommatcher-for-extractors.md @@ -17,3 +17,6 @@ class Symbol { core-js/proposals/pattern-extractors core-js(-pure)/full/symbol/custom-matcher ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/pattern-matching`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/pattern-matching.d.ts) diff --git a/docs/web/docs/features/proposals/symbol-custommatcher-pattern-matching.md b/docs/web/docs/features/proposals/symbol-custommatcher-pattern-matching.md index e8e8b2485aa4..01763136fa76 100644 --- a/docs/web/docs/features/proposals/symbol-custommatcher-pattern-matching.md +++ b/docs/web/docs/features/proposals/symbol-custommatcher-pattern-matching.md @@ -17,3 +17,6 @@ class Symbol { core-js/proposals/pattern-matching-v2 core-js(-pure)/full/symbol/custom-matcher ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/pattern-matching`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/pattern-matching.d.ts) diff --git a/docs/web/docs/features/proposals/symbol-metadata.md b/docs/web/docs/features/proposals/symbol-metadata.md index 793364d44679..d789e092259b 100644 --- a/docs/web/docs/features/proposals/symbol-metadata.md +++ b/docs/web/docs/features/proposals/symbol-metadata.md @@ -20,3 +20,6 @@ class Function { core-js/proposals/decorator-metadata core-js(-pure)/actual|full/symbol/metadata ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/decorator-metadata`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/decorator-metadata.d.ts) diff --git a/docs/web/docs/features/proposals/symbol-predicates.md b/docs/web/docs/features/proposals/symbol-predicates.md index 2696a9685250..1cdcdc4ab70e 100644 --- a/docs/web/docs/features/proposals/symbol-predicates.md +++ b/docs/web/docs/features/proposals/symbol-predicates.md @@ -20,6 +20,9 @@ core-js(-pure)/full/symbol/is-registered-symbol core-js(-pure)/full/symbol/is-well-known-symbol ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/symbol-predicates`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts) + ## Example ```js Symbol.isRegisteredSymbol(Symbol.for('key')); // => true diff --git a/docs/web/docs/features/proposals/symbol-prototype-description.md b/docs/web/docs/features/proposals/symbol-prototype-description.md index 5ac8d0abbc31..995118042806 100644 --- a/docs/web/docs/features/proposals/symbol-prototype-description.md +++ b/docs/web/docs/features/proposals/symbol-prototype-description.md @@ -13,3 +13,6 @@ class Symbol { ```plaintext core-js/proposals/symbol-description ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/symbol-description`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/symbol-description.d.ts) diff --git a/docs/web/docs/features/proposals/uint8array-base64-hex.md b/docs/web/docs/features/proposals/uint8array-base64-hex.md index e4ca8b7515b2..dc1cea85b6f5 100644 --- a/docs/web/docs/features/proposals/uint8array-base64-hex.md +++ b/docs/web/docs/features/proposals/uint8array-base64-hex.md @@ -18,3 +18,6 @@ class Uint8Array { ```plaintext core-js/proposals/array-buffer-base64 ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/array-buffer-base64`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts) diff --git a/docs/web/docs/features/proposals/well-formed-unicode-strings.md b/docs/web/docs/features/proposals/well-formed-unicode-strings.md index a9a11d6838dd..5215cfb07cc6 100644 --- a/docs/web/docs/features/proposals/well-formed-unicode-strings.md +++ b/docs/web/docs/features/proposals/well-formed-unicode-strings.md @@ -14,3 +14,6 @@ class String { ```plaintext core-js/proposals/well-formed-unicode-strings ``` + +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/proposals/well-formed-unicode-strings`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts) diff --git a/docs/web/docs/features/web-standards/base64-utility-methods.md b/docs/web/docs/features/web-standards/base64-utility-methods.md index fe007e38c5ed..acbc97e2541f 100644 --- a/docs/web/docs/features/web-standards/base64-utility-methods.md +++ b/docs/web/docs/features/web-standards/base64-utility-methods.md @@ -17,6 +17,9 @@ core-js(-pure)/stable|actual|full/atob core-js(-pure)/stable|actual|full/btoa ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/web/atob-btoa`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/web/atob-btoa.d.ts) + ## Examples ```js btoa('hi, core-js'); // => 'aGksIGNvcmUtanM=' diff --git a/docs/web/docs/features/web-standards/iterable-dom-collections.md b/docs/web/docs/features/web-standards/iterable-dom-collections.md index 2fb3d000e10e..96773688a47a 100644 --- a/docs/web/docs/features/web-standards/iterable-dom-collections.md +++ b/docs/web/docs/features/web-standards/iterable-dom-collections.md @@ -58,6 +58,9 @@ core-js/stable|actual|full/dom-collections/values core-js/stable|actual|full/dom-collections/for-each ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/web/iterable-dom-collections`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts) + ## Examples ```js for (let { id } of document.querySelectorAll('*')) { diff --git a/docs/web/docs/features/web-standards/queuemicrotask.md b/docs/web/docs/features/web-standards/queuemicrotask.md index 55030826d989..4a0d4a7e8910 100644 --- a/docs/web/docs/features/web-standards/queuemicrotask.md +++ b/docs/web/docs/features/web-standards/queuemicrotask.md @@ -14,6 +14,9 @@ function queueMicrotask(fn: Function): void; core-js(-pure)/stable|actual|full/queue-microtask ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/web/queue-microtask`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/web/queue-microtask.d.ts) + ## Example ```js queueMicrotask(() => console.log('called as microtask')); diff --git a/docs/web/docs/features/web-standards/setimmediate.md b/docs/web/docs/features/web-standards/setimmediate.md index 705c6635ddad..24e9e6fba7b1 100644 --- a/docs/web/docs/features/web-standards/setimmediate.md +++ b/docs/web/docs/features/web-standards/setimmediate.md @@ -15,6 +15,9 @@ core-js(-pure)/stable|actual|full/set-immediate core-js(-pure)/stable|actual|full/clear-immediate ``` +## [TypeScript type definitions]({docs-version}/docs/typescript-type-definitions) +[`@core-js/types/web/efficient-script-yielding`](https://github.com/zloirock/core-js/blob/v4-types/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts) + ## Examples ```js setImmediate((arg1, arg2) => { diff --git a/docs/web/docs/features/web-standards/structured-clone.md b/docs/web/docs/features/web-standards/structured-clone.md index c57fd10ca378..2e70000f73a5 100644 --- a/docs/web/docs/features/web-standards/structured-clone.md +++ b/docs/web/docs/features/web-standards/structured-clone.md @@ -14,6 +14,9 @@ function structuredClone(value: Serializable, { transfer?: Sequence true diff --git a/docs/web/docs/menu.json b/docs/web/docs/menu.json index 0e308cfdbc45..898b36d6f869 100644 --- a/docs/web/docs/menu.json +++ b/docs/web/docs/menu.json @@ -7,6 +7,10 @@ "title": "Supported engines and compatibility data", "url": "{docs-version}/docs/engines" }, + { + "title": "TypeScript type definitions", + "url": "{docs-version}/docs/typescript-type-definitions" + }, { "title": "Features", "children": [ diff --git a/docs/web/docs/typescript-type-definitions.md b/docs/web/docs/typescript-type-definitions.md new file mode 100644 index 000000000000..aa69220843e5 --- /dev/null +++ b/docs/web/docs/typescript-type-definitions.md @@ -0,0 +1,115 @@ +# TypeScript Type Definitions + +This package contains types for the global and pure versions of `core-js`. +Although `core-js` is a JavaScript standard library polyfill, the built-in TypeScript types are often not sufficient. +Additional types are needed for: +- features that are already in JavaScript but not yet in TypeScript’s standard types; +- proposals, including those already implemented in JavaScript engines; +- explicit imports of features from the pure version. + +It is shipped as a separate package because we cannot guarantee stable behavior with future TypeScript releases, including minor ones. + +## Installation +```sh +npm install --save @core-js/types@4.0.0-alpha.0 +``` + +## Usage +Add to your `tsconfig.json`: +```json +{ + "compilerOptions": { + "types": [ + "@core-js/types" + ] + } +} +``` +or import it directly in your files: +```ts +import '@core-js/types'; +``` +`@core-js/types` includes all types and entry points for the global version, but it is recommended to select only the subset you actually use. + +### Usage of subsets +There are four main subsets: +- `@core-js/types/actual` - types for all actual features, including stable ECMAScript, web standards and Stage 3 ECMAScript proposals; +- `@core-js/types/es` - types for stable ECMAScript features only; +- `@core-js/types/stable` - types for stable ECMAScript and web standards features; +- `@core-js/types/full` - types for all features, including proposals. + +You can import them the same way as the main package. For example, to use only the stable subset, add this to your `tsconfig.json`: +```json +{ + "compilerOptions": { + "types": [ + "@core-js/types/stable" + ] + } +} +``` +or import it directly in your files: +```ts +import '@core-js/types/stable'; +``` + +### Usage of specific features +If you need types only for specific features, you can import them like this: +```json +{ + "compilerOptions": { + "types": [ + "@core-js/types/proposals/joint-iteration", + "@core-js/types/web/structured-clone" + ] + } +} +``` +or import them directly in your files: +```ts +import '@core-js/types/proposals/joint-iteration'; +import '@core-js/types/web/structured-clone'; +``` +You can find types for specific features on the corresponding pages in the [documentation](https://core-js.io/{docs-version}/docs/). + +## Types for the pure version +### Base usage +Add this to your `tsconfig.json`: +```json +{ + "compilerOptions": { + "types": [ + "@core-js/types/pure" + ] + } +} +``` +Then, when you import from the pure entry points, the corresponding types are picked up automatically: +```ts +import $findLast from '@core-js/pure/full/array/find-last'; + +$findLast([1, 3, 4, 2], v => v > 2); // => 4 +``` + +### Namespace usage in the pure version +If you need to use multiple methods from the same namespace, you can add `@core-js/types/pure` to `tsconfig.json` and import the entire namespace: +```ts +import $array from '@core-js/pure/full/array'; + +$array.findLast([1, 3, 4, 2], v => v > 2); +$array.flatMap([1, 2, 3], x => [x, x * 2]); +``` +(note that this is not recommended since tree shaking does not properly work in this case) + +## DOM types +Some of the global types for web standards work correctly only with the DOM lib. +You need to add DOM types to the `lib` section of your `tsconfig.json` in addition to `@core-js/types`. For example: +```json +{ + "compilerOptions": { + "types": ["@core-js/types"], + "lib": ["esnext", "dom"] + } +} +``` +In the pure version, you can use these types without adding the DOM lib. From 66dbf8a5c7c94190b384b4a6e22d42c989ffe287 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 19 Dec 2025 18:42:25 +0700 Subject: [PATCH 098/315] Fix TSDocs --- packages/core-js-types/src/base/annex-b/object-proto.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/annex-b/object-proto.d.ts b/packages/core-js-types/src/base/annex-b/object-proto.d.ts index 94faf99d5d4f..6bc651664631 100644 --- a/packages/core-js-types/src/base/annex-b/object-proto.d.ts +++ b/packages/core-js-types/src/base/annex-b/object-proto.d.ts @@ -1,7 +1,7 @@ interface Object { /** * Accessor to [[Prototype]]. - * This is non-standard and deprecated; prefer get/set + * This is non-standard and deprecated; prefer { Object, Reflect }.{ getPrototypeOf, setPrototypeOf } */ __proto__: object | null; } From 6c9753ab57fca0744975cebd27b182d962f7d246 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 19 Dec 2025 19:04:06 +0700 Subject: [PATCH 099/315] Fix structured clone docs From e4561d3fc9a229df0e1b13505f09b5ea25fd514f Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 19 Dec 2025 19:07:06 +0700 Subject: [PATCH 100/315] Add update types README.md in update-version script --- scripts/update-version.mjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/update-version.mjs b/scripts/update-version.mjs index 547acfb06cad..8817bcc6d6c3 100644 --- a/scripts/update-version.mjs +++ b/scripts/update-version.mjs @@ -18,6 +18,7 @@ const CHANGELOG = 'CHANGELOG.md'; const LICENSE = 'LICENSE'; const README = 'README.md'; const README_COMPAT = 'packages/core-js-compat/README.md'; +const README_TYPES = 'packages/core-js-types/README.md'; const SHARED = 'packages/core-js/internals/shared-store.js'; const BUILDER_CONFIG = 'packages/core-js-builder/config.js'; const USAGE = 'docs/web/docs/usage.md'; @@ -34,6 +35,9 @@ await writeFile(README, readme.replaceAll(PREV_VERSION, NEW_VERSION).replaceAll( const readmeCompat = await readFile(README_COMPAT, 'utf8'); await writeFile(README_COMPAT, readmeCompat.replaceAll(PREV_VERSION_MINOR, NEW_VERSION_MINOR)); +const readmeTypes = await readFile(README_TYPES, 'utf8'); +await writeFile(README_TYPES, readmeTypes.replaceAll(PREV_VERSION_MINOR, NEW_VERSION_MINOR)); + const shared = await readFile(SHARED, 'utf8'); await writeFile(SHARED, shared.replaceAll(PREV_VERSION, NEW_VERSION).replaceAll(OLD_YEAR, CURRENT_YEAR)); From b9f883cb956f0b6838848812f2840af9b746039d Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 20 Dec 2025 04:21:31 +0700 Subject: [PATCH 101/315] Add missing type declarations & remove unnecessary type declarations --- packages/core-js/modules/es.aggregate-error.constructor.js | 1 + packages/core-js/modules/es.iterator.constructor.js | 3 +++ packages/core-js/modules/es.json.raw-json.js | 1 + packages/core-js/modules/es.regexp.flags.js | 1 - packages/core-js/modules/es.set.constructor.js | 1 - packages/core-js/modules/es.symbol.constructor.js | 1 + packages/core-js/modules/es.symbol.match-all.js | 1 + packages/core-js/modules/es.typed-array.find-last-index.js | 1 + packages/core-js/modules/es.typed-array.find-last.js | 1 + packages/core-js/modules/es.typed-array.includes.js | 1 + 10 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/core-js/modules/es.aggregate-error.constructor.js b/packages/core-js/modules/es.aggregate-error.constructor.js index d8551e9d8922..d393e968976a 100644 --- a/packages/core-js/modules/es.aggregate-error.constructor.js +++ b/packages/core-js/modules/es.aggregate-error.constructor.js @@ -1,3 +1,4 @@ +// types: proposals/error-cause 'use strict'; var $ = require('../internals/export'); var isPrototypeOf = require('../internals/object-is-prototype-of'); diff --git a/packages/core-js/modules/es.iterator.constructor.js b/packages/core-js/modules/es.iterator.constructor.js index 063d33c748a8..b473170da470 100644 --- a/packages/core-js/modules/es.iterator.constructor.js +++ b/packages/core-js/modules/es.iterator.constructor.js @@ -1,3 +1,6 @@ +// types: proposals/iterator-helpers +// types: proposals/iterator-sequencing +// types: proposals/explicit-resource-management 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/es.json.raw-json.js b/packages/core-js/modules/es.json.raw-json.js index e5c30dc64081..f9c1d249292c 100644 --- a/packages/core-js/modules/es.json.raw-json.js +++ b/packages/core-js/modules/es.json.raw-json.js @@ -1,3 +1,4 @@ +// types: proposals/json-parse-with-source 'use strict'; var $ = require('../internals/export'); var NATIVE_RAW_JSON = require('../internals/native-raw-json'); diff --git a/packages/core-js/modules/es.regexp.flags.js b/packages/core-js/modules/es.regexp.flags.js index 075cd418e5b4..9ae8e303a5d8 100644 --- a/packages/core-js/modules/es.regexp.flags.js +++ b/packages/core-js/modules/es.regexp.flags.js @@ -1,5 +1,4 @@ // types: proposals/regexp-dotall-flag -// types: proposals/regexp-named-groups 'use strict'; var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); var regExpFlagsDetection = require('../internals/regexp-flags-detection'); diff --git a/packages/core-js/modules/es.set.constructor.js b/packages/core-js/modules/es.set.constructor.js index a63f265a995d..a35ebe1e90fb 100644 --- a/packages/core-js/modules/es.set.constructor.js +++ b/packages/core-js/modules/es.set.constructor.js @@ -1,4 +1,3 @@ -// types: proposals/set-methods 'use strict'; var collection = require('../internals/collection'); var collectionStrong = require('../internals/collection-strong'); diff --git a/packages/core-js/modules/es.symbol.constructor.js b/packages/core-js/modules/es.symbol.constructor.js index 23edb3576159..486b754377c9 100644 --- a/packages/core-js/modules/es.symbol.constructor.js +++ b/packages/core-js/modules/es.symbol.constructor.js @@ -1,3 +1,4 @@ +// types: proposals/symbol-description 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/es.symbol.match-all.js b/packages/core-js/modules/es.symbol.match-all.js index 19a3bd07bb9d..46d21606f78a 100644 --- a/packages/core-js/modules/es.symbol.match-all.js +++ b/packages/core-js/modules/es.symbol.match-all.js @@ -1,3 +1,4 @@ +// types: proposals/string-match-all 'use strict'; var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/es.typed-array.find-last-index.js b/packages/core-js/modules/es.typed-array.find-last-index.js index 4691821bb1eb..f56787e179cb 100644 --- a/packages/core-js/modules/es.typed-array.find-last-index.js +++ b/packages/core-js/modules/es.typed-array.find-last-index.js @@ -1,3 +1,4 @@ +// types: proposals/array-find-from-last 'use strict'; var exportTypedArrayMethod = require('../internals/export-typed-array-method'); var aTypedArray = require('../internals/a-typed-array'); diff --git a/packages/core-js/modules/es.typed-array.find-last.js b/packages/core-js/modules/es.typed-array.find-last.js index 186f6bea5e5f..eaf006561e9e 100644 --- a/packages/core-js/modules/es.typed-array.find-last.js +++ b/packages/core-js/modules/es.typed-array.find-last.js @@ -1,3 +1,4 @@ +// types: proposals/array-find-from-last 'use strict'; var exportTypedArrayMethod = require('../internals/export-typed-array-method'); var aTypedArray = require('../internals/a-typed-array'); diff --git a/packages/core-js/modules/es.typed-array.includes.js b/packages/core-js/modules/es.typed-array.includes.js index e2917486a18b..d9ade2d53eb0 100644 --- a/packages/core-js/modules/es.typed-array.includes.js +++ b/packages/core-js/modules/es.typed-array.includes.js @@ -1,3 +1,4 @@ +// types: proposals/array-includes 'use strict'; var exportTypedArrayMethod = require('../internals/export-typed-array-method'); var aTypedArray = require('../internals/a-typed-array'); From c0f976623248a1c42ccb75924bc4b215674f14e9 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 20 Dec 2025 05:06:28 +0700 Subject: [PATCH 102/315] Update README.md and TypeScript type definitions doc --- docs/web/docs/typescript-type-definitions.md | 27 +++++++++++++++----- packages/core-js-types/README.md | 25 ++++++++++++++---- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/docs/web/docs/typescript-type-definitions.md b/docs/web/docs/typescript-type-definitions.md index aa69220843e5..5433ca384282 100644 --- a/docs/web/docs/typescript-type-definitions.md +++ b/docs/web/docs/typescript-type-definitions.md @@ -15,20 +15,27 @@ npm install --save @core-js/types@4.0.0-alpha.0 ``` ## Usage -Add to your `tsconfig.json`: +You must include at least the ES6 types in your `tsconfig.json` because our types are built on top of the ES6 type definitions +and `DOM` lib for the global version if you use something related (see [DOM types](#dom-types) section): ```json { "compilerOptions": { + "lib": [ + "es6", + "dom" + ], "types": [ "@core-js/types" ] } } ``` -or import it directly in your files: + +You can also import the types directly into your files instead of specifying `core-js` types in your `tsconfig.json`: ```ts import '@core-js/types'; ``` + `@core-js/types` includes all types and entry points for the global version, but it is recommended to select only the subset you actually use. ### Usage of subsets @@ -70,14 +77,17 @@ or import them directly in your files: import '@core-js/types/proposals/joint-iteration'; import '@core-js/types/web/structured-clone'; ``` -You can find types for specific features on the corresponding pages in the [documentation](https://core-js.io/{docs-version}/docs/). +You can find types for specific features on the corresponding pages in the [documentation](https://core-js.io/v4/docs/). ## Types for the pure version ### Base usage -Add this to your `tsconfig.json`: +Add this to your `tsconfig.json`, keeping in mind that ES types (at least ES6) are required: ```json { "compilerOptions": { + "lib": [ + "es6" + ], "types": [ "@core-js/types/pure" ] @@ -107,8 +117,13 @@ You need to add DOM types to the `lib` section of your `tsconfig.json` in additi ```json { "compilerOptions": { - "types": ["@core-js/types"], - "lib": ["esnext", "dom"] + "types": [ + "@core-js/types" + ], + "lib": [ + "esnext", + "dom" + ] } } ``` diff --git a/packages/core-js-types/README.md b/packages/core-js-types/README.md index 822c576f4cb1..c4f5da108559 100644 --- a/packages/core-js-types/README.md +++ b/packages/core-js-types/README.md @@ -15,20 +15,27 @@ npm install --save @core-js/types@4.0.0-alpha.0 ``` # Usage -Add to your `tsconfig.json`: +You must include at least the ES6 types in your `tsconfig.json` because our types are built on top of the ES6 type definitions +and `DOM` lib for the global version if you use something related (see [DOM types](#dom-types) section): ```json { "compilerOptions": { + "lib": [ + "es6", + "dom" + ], "types": [ "@core-js/types" ] } } ``` -or import it directly in your files: + +You can also import the types directly into your files instead of specifying `core-js` types in your `tsconfig.json`: ```ts import '@core-js/types'; ``` + `@core-js/types` includes all types and entry points for the global version, but it is recommended to select only the subset you actually use. ## Usage of subsets @@ -74,10 +81,13 @@ You can find types for specific features on the corresponding pages in the [docu # Types for the pure version ## Base usage -Add this to your `tsconfig.json`: +Add this to your `tsconfig.json`, keeping in mind that ES types (at least ES6) are required: ```json { "compilerOptions": { + "lib": [ + "es6" + ], "types": [ "@core-js/types/pure" ] @@ -107,8 +117,13 @@ You need to add DOM types to the `lib` section of your `tsconfig.json` in additi ```json { "compilerOptions": { - "types": ["@core-js/types"], - "lib": ["esnext", "dom"] + "types": [ + "@core-js/types" + ], + "lib": [ + "esnext", + "dom" + ] } } ``` From 5d54a684fa95555df2854fa5f29414517b3f96bb Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 23 Dec 2025 02:39:51 +0700 Subject: [PATCH 103/315] Types stabilization --- .../src/base/core-js-types/core-js-types.d.ts | 4 ---- .../global/proposals/await-dictionary.test.ts | 11 ++++++--- .../proposals/promise-all-settled.test.ts | 24 +++++++++++-------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts index 550bdebaef19..fd3d36e253e2 100644 --- a/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts +++ b/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts @@ -13,10 +13,6 @@ declare global { [Symbol.asyncIterator](): AsyncIterableIterator; } - interface PromiseFulfilledResult { status: "fulfilled"; value: T; } - - interface PromiseRejectedResult { status: "rejected"; reason: any; } - interface AsyncIterator { // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. next(...[value]: [] | [TNext]): Promise>; diff --git a/tests/type-definitions/global/proposals/await-dictionary.test.ts b/tests/type-definitions/global/proposals/await-dictionary.test.ts index 563a3c46e9e6..a6aad67a8f71 100644 --- a/tests/type-definitions/global/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/global/proposals/await-dictionary.test.ts @@ -18,14 +18,19 @@ Promise.allKeyed({ a: 1, b: Promise.resolve(2) }); // @ts-expect-error Promise.allKeyed([ Promise.resolve(1), Promise.resolve(2) ]); -declare type AllSettledKeyedResult = PromiseFulfilledResult | PromiseRejectedResult; -const resASK: Promise<{ a: AllSettledKeyedResult, b: AllSettledKeyedResult, c: AllSettledKeyedResult }> = Promise.allSettledKeyed({ +interface CoreJSPromiseResult { + status: string; + value?: T; + reason?: any; +} + +const resASK: Promise<{ a: CoreJSPromiseResult, b: CoreJSPromiseResult, c: CoreJSPromiseResult }> = Promise.allSettledKeyed({ a: Promise.resolve(1), b: Promise.resolve('string'), c: Promise.resolve(true), }); -const resASK2: Promise<{ [sym]: AllSettledKeyedResult }> = Promise.allSettledKeyed({ +const resASK2: Promise<{ [sym]: CoreJSPromiseResult }> = Promise.allSettledKeyed({ [sym]: Promise.resolve(1) }); diff --git a/tests/type-definitions/global/proposals/promise-all-settled.test.ts b/tests/type-definitions/global/proposals/promise-all-settled.test.ts index 963013a8037a..52aa50cbaa82 100644 --- a/tests/type-definitions/global/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/global/proposals/promise-all-settled.test.ts @@ -5,26 +5,30 @@ const arr = [Promise.resolve(1), Promise.resolve(2)]; const strArr = ["a", "b", "c"]; const promiseLike = { then: (cb: (val: number) => void) => cb(42) }; -type PromiseResult = PromiseFulfilledResult | PromiseRejectedResult; +interface CoreJSPromiseResult { + status: string; + value?: T; + reason?: any; +} const settled1: Promise<[ - PromiseResult, - PromiseResult, - PromiseResult + CoreJSPromiseResult, + CoreJSPromiseResult, + CoreJSPromiseResult ]> = Promise.allSettled(promises); -const settled2: Promise[]> = Promise.allSettled([Promise.resolve(10), Promise.resolve(20), 30]); -const settled3: Promise[]> = Promise.allSettled(strArr); -const settled4: Promise[]> = Promise.allSettled(new Set([1, 2, 3])); -const settled5: Promise[]> = Promise.allSettled([promiseLike]); +const settled2: Promise[]> = Promise.allSettled([Promise.resolve(10), Promise.resolve(20), 30]); +const settled3: Promise[]> = Promise.allSettled(strArr); +const settled4: Promise[]> = Promise.allSettled(new Set([1, 2, 3])); +const settled5: Promise[]> = Promise.allSettled([promiseLike]); const emptyTuple: [] = []; const settled6: Promise<[]> = Promise.allSettled(emptyTuple); const mixedTuple = [42, Promise.resolve("bar")] as const; const settled7: Promise<[ - PromiseResult, - PromiseResult + CoreJSPromiseResult, + CoreJSPromiseResult ]> = Promise.allSettled(mixedTuple); // @ts-expect-error From 2ff6c9618fb8786d0426ea665d7e921b49078dd0 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 23 Dec 2025 02:40:10 +0700 Subject: [PATCH 104/315] Types for TS 5.5 stabilization --- .../ts5-2/core-js-types/core-js-types.d.ts | 37 +-- .../accessible-object-hasownproperty.d.ts | 9 - .../ts5-2/proposals/array-buffer-base64.d.ts | 41 --- .../proposals/array-buffer-transfer.d.ts | 11 - .../src/ts5-2/proposals/array-filtering.d.ts | 50 ---- .../ts5-2/proposals/array-find-from-last.d.ts | 102 ------- .../proposals/array-flat-map-custom.d.ts | 10 - .../src/ts5-2/proposals/array-flat-map.d.ts | 18 -- .../src/ts5-2/proposals/array-from-async.d.ts | 16 -- .../src/ts5-2/proposals/array-grouping.d.ts | 15 - .../src/ts5-2/proposals/array-includes.d.ts | 54 ---- .../proposals/array-is-template-object.d.ts | 5 - .../src/ts5-2/proposals/array-unique.d.ts | 50 ---- .../src/ts5-2/proposals/async-iteration.d.ts | 16 -- .../proposals/async-iterator-helpers.d.ts | 40 --- .../src/ts5-2/proposals/await-dictionary.d.ts | 14 - .../change-array-by-copy-custom.d.ts | 10 - .../ts5-2/proposals/change-array-by-copy.d.ts | 110 ------- .../ts5-2/proposals/collection-of-from.d.ts | 25 -- .../data-view-get-set-uint8-clamped.d.ts | 8 - .../ts5-2/proposals/decorator-metadata.d.ts | 16 -- .../src/ts5-2/proposals/error-cause.d.ts | 60 ---- .../explicit-resource-management.d.ts | 121 +++++++- .../src/ts5-2/proposals/float16.d.ts | 16 -- .../ts5-2/proposals/function-demethodize.d.ts | 5 - .../src/ts5-2/proposals/is-error.d.ts | 5 - .../ts5-2/proposals/iterator-chunking.d.ts | 14 - .../proposals/iterator-helpers-custom.d.ts | 18 -- .../src/ts5-2/proposals/iterator-join.d.ts | 6 - .../src/ts5-2/proposals/iterator-joint.d.ts | 24 -- .../src/ts5-2/proposals/iterator-range.d.ts | 18 -- .../ts5-2/proposals/iterator-sequencing.d.ts | 14 - .../proposals/json-parse-with-source.d.ts | 22 -- .../src/ts5-2/proposals/map-upsert.d.ts | 14 - .../src/ts5-2/proposals/math-sum.d.ts | 5 - .../src/ts5-2/proposals/number-clamp.d.ts | 6 - .../ts5-2/proposals/object-from-entries.d.ts | 12 - .../object-get-own-property-descriptors.d.ts | 12 - .../proposals/object-values-entries.d.ts | 14 - .../src/ts5-2/proposals/pattern-matching.d.ts | 6 - .../ts5-2/proposals/promise-all-settled.d.ts | 18 -- .../src/ts5-2/proposals/promise-any.d.ts | 24 -- .../src/ts5-2/proposals/promise-finally.d.ts | 10 - .../src/ts5-2/proposals/promise-try.d.ts | 11 - .../proposals/promise-with-resolvers.d.ts | 20 -- .../ts5-2/proposals/regexp-dotall-flag.d.ts | 10 - .../src/ts5-2/proposals/regexp-escaping.d.ts | 8 - .../ts5-2/proposals/regexp-named-groups.d.ts | 18 -- .../proposals/relative-indexing-method.d.ts | 63 ---- .../ts5-2/proposals/set-methods-custom.d.ts | 20 -- .../src/ts5-2/proposals/set-methods.d.ts | 50 ---- .../src/ts5-2/proposals/string-cooked.d.ts | 8 - .../src/ts5-2/proposals/string-dedent.d.ts | 6 - .../proposals/string-left-right-trim.d.ts | 16 -- .../src/ts5-2/proposals/string-match-all.d.ts | 4 +- .../src/ts5-2/proposals/string-padding.d.ts | 12 - .../proposals/string-replace-all-custom.d.ts | 10 - .../ts5-2/proposals/string-replace-all.d.ts | 16 -- .../ts5-2/proposals/symbol-description.d.ts | 10 - .../ts5-2/proposals/symbol-predicates.d.ts | 8 - .../well-formed-unicode-strings.d.ts | 12 - .../src/ts5-2/pure/proposals/iterator.d.ts | 234 +++++++++++++++ .../ts5-2/web/iterable-dom-collections.d.ts | 271 ++++++++++++++++++ 63 files changed, 636 insertions(+), 1272 deletions(-) delete mode 100644 packages/core-js-types/src/ts5-2/proposals/accessible-object-hasownproperty.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/array-buffer-base64.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/array-buffer-transfer.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/array-filtering.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/array-find-from-last.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/array-flat-map-custom.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/array-flat-map.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/array-from-async.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/array-grouping.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/array-includes.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/array-is-template-object.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/array-unique.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/async-iteration.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/await-dictionary.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/change-array-by-copy-custom.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/change-array-by-copy.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/collection-of-from.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/data-view-get-set-uint8-clamped.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/decorator-metadata.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/error-cause.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/float16.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/function-demethodize.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/is-error.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/iterator-chunking.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/iterator-helpers-custom.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/iterator-join.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/iterator-joint.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/iterator-range.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/iterator-sequencing.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/json-parse-with-source.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/map-upsert.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/math-sum.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/number-clamp.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/object-from-entries.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/object-get-own-property-descriptors.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/object-values-entries.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/pattern-matching.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/promise-all-settled.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/promise-any.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/promise-finally.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/promise-try.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/promise-with-resolvers.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/regexp-dotall-flag.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/regexp-escaping.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/regexp-named-groups.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/relative-indexing-method.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/set-methods-custom.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/set-methods.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/string-cooked.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/string-dedent.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/string-left-right-trim.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/string-padding.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/string-replace-all-custom.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/string-replace-all.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/symbol-description.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/symbol-predicates.d.ts delete mode 100644 packages/core-js-types/src/ts5-2/proposals/well-formed-unicode-strings.d.ts create mode 100644 packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts create mode 100644 packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts diff --git a/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts index 6a1621e111ed..1a7c6f64dcc9 100644 --- a/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts +++ b/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts @@ -10,6 +10,10 @@ declare global { [Symbol.asyncIterator](): AsyncIteratorObject; } + interface AsyncIterableIterator extends AsyncIterator { + [Symbol.asyncIterator](): AsyncIterableIterator; + } + interface AsyncGenerator extends AsyncIteratorObject { next(...[value]: [] | [undefined]): Promise>; return(value: TReturn | PromiseLike): Promise>; @@ -17,33 +21,20 @@ declare global { [Symbol.asyncIterator](): AsyncGenerator; } - interface PromiseFulfilledResult { status: "fulfilled"; value: T; } + interface AsyncIterator { + // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. + next(...[value]: [] | [TNext]): Promise>; + return?(value?: TReturn | PromiseLike): Promise>; + throw?(e?: any): Promise>; + } + + interface AsyncIteratorConstructor {} - interface PromiseRejectedResult { status: "rejected"; reason: any; } + var AsyncIterator: AsyncIteratorConstructor; - interface AsyncIterable { + interface AsyncIterable { [Symbol.asyncIterator](): AsyncIterator; } } -export type CoreJSDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } // from ts 5.2 - ? O - : Record & object; - export type CoreJSIteratorObject = IteratorObject; - -export type CoreJSFlatArray = typeof globalThis extends { FlatArray: infer O } // from ts 4.4 - ? O - : { - done: Arr; - recur: Arr extends ReadonlyArray ? CoreJSFlatArray - : Arr; - }[Depth extends -1 ? "done" : "recur"]; - -export type CoreJSPromiseSettledResult = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020 - ? O - : PromiseFulfilledResult | PromiseRejectedResult; - -export type CoreJSBuiltinIteratorReturn = ReturnType extends Iterator - ? TReturn - : any; diff --git a/packages/core-js-types/src/ts5-2/proposals/accessible-object-hasownproperty.d.ts b/packages/core-js-types/src/ts5-2/proposals/accessible-object-hasownproperty.d.ts deleted file mode 100644 index f5cf3cc18aad..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/accessible-object-hasownproperty.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-accessible-object-hasownproperty - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2022.object.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface ObjectConstructor { - hasOwn(o: object, v: PropertyKey): boolean; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-buffer-base64.d.ts deleted file mode 100644 index 85fa68b41eab..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/array-buffer-base64.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -// proposal stage: 3 -// https://github.com/tc39/proposal-arraybuffer-base64 - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.typedarrays.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -type alphabet = 'base64' | 'base64url'; - -type lastChunkHandling = 'loose' | 'strict' | 'stop-before-partial'; - -type fromBase64Options = { - alphabet?: alphabet; - lastChunkHandling?: lastChunkHandling; -} - -type toBase64Options = { - alphabet?: alphabet; - omitPadding?: boolean; -} - -type processMetadata = { - read: number; - written: number; -} - -interface Uint8ArrayConstructor { - fromBase64(str: string, opts?: fromBase64Options): Uint8Array; - - fromHex(str: string): Uint8Array; -} - -interface Uint8Array { - setFromBase64(str: string, opts?: fromBase64Options): processMetadata; - - setFromHex(str: string): processMetadata; - - toBase64(opts?: toBase64Options): string; - - toHex(): string; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-buffer-transfer.d.ts deleted file mode 100644 index 50046c7dc41e..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/array-buffer-transfer.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-arraybuffer-transfer - -interface ArrayBuffer { - // todo hack for modern ts - // get detached(): boolean; - - transfer(newByteLength?: number): ArrayBuffer; - - transferToFixedLength(newByteLength?: number): ArrayBuffer; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/array-filtering.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-filtering.d.ts deleted file mode 100644 index e4b456324fab..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/array-filtering.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -// proposal stage: 1 -// https://github.com/tc39/proposal-array-filtering - -interface Array { - filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; -} - -interface Int8Array { - filterReject(callbackFn: (value: number, index: number, target: Int8Array) => boolean, thisArg?: any): Int8Array; -} - -interface Uint8Array { - filterReject(callbackFn: (value: number, index: number, target: Uint8Array) => boolean, thisArg?: any): Uint8Array; -} - -interface Uint8ClampedArray { - filterReject(callbackFn: (value: number, index: number, target: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; -} - -interface Int16Array { - filterReject(callbackFn: (value: number, index: number, target: Int16Array) => boolean, thisArg?: any): Int16Array; -} - -interface Uint16Array { - filterReject(callbackFn: (value: number, index: number, target: Uint16Array) => boolean, thisArg?: any): Uint16Array; -} - -interface Int32Array { - filterReject(callbackFn: (value: number, index: number, target: Int32Array) => boolean, thisArg?: any): Int32Array; -} - -interface Uint32Array { - filterReject(callbackFn: (value: number, index: number, target: Uint32Array) => boolean, thisArg?: any): Uint32Array; -} - -interface Float32Array { - filterReject(callbackFn: (value: number, index: number, target: Float32Array) => boolean, thisArg?: any): Float32Array; -} - -interface Float64Array { - filterReject(callbackFn: (value: number, index: number, target: Float64Array) => boolean, thisArg?: any): Float64Array; -} - -interface BigInt64Array { - filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array; -} - -interface BigUint64Array { - filterReject(callbackFn: (value: bigint, index: number, target: BigUint64Array) => boolean, thisArg?: any): BigUint64Array; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-find-from-last.d.ts deleted file mode 100644 index 725dd286ec64..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/array-find-from-last.d.ts +++ /dev/null @@ -1,102 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-array-find-from-last - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface Array { - findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T | undefined; - - findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; -} - -interface Int8Array { - findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; - - findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; -} - -interface Uint8Array { - findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; - - findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; -} - -interface Uint8ClampedArray { - findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; - - findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; -} - -interface Int16Array { - findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; - - findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; -} - -interface Uint16Array { - findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; - - findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; -} - -interface Int32Array { - findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; - - findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; -} - -interface Uint32Array { - findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; - - findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; -} - -interface Float32Array { - findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; - - findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; -} - -interface Float64Array { - findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; - - findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; -} - -interface BigInt64Array { - findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): bigint | undefined; - - findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; -} - -interface BigUint64Array { - findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; - - findLast(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): bigint | undefined; - - findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/array-flat-map-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-flat-map-custom.d.ts deleted file mode 100644 index 94c3b8c6a5b0..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/array-flat-map-custom.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-flatMap - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - export type ArrayFlatMap = (callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This) => U[]; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/array-flat-map.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-flat-map.d.ts deleted file mode 100644 index cb69a30384b7..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/array-flat-map.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-flatMap - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -import { CoreJSFlatArray } from '../core-js-types/core-js-types'; - -declare global { - interface Array { - flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): U[]; - - flat(this: A, depth?: D): CoreJSFlatArray[]; - } -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/array-from-async.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-from-async.d.ts deleted file mode 100644 index aa234b066a35..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/array-from-async.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -// proposal stage: 3 -// https://github.com/tc39/proposal-array-from-async - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/esnext.array.d.ts#L6 -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare global { - interface ArrayConstructor { - fromAsync(iterableOrArrayLike: AsyncIterable | AsyncGenerator | Iterable> | ArrayLike>): Promise; - - fromAsync(iterableOrArrayLike: AsyncIterable | AsyncGenerator | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; - } -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/array-grouping.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-grouping.d.ts deleted file mode 100644 index ed8bb784eaae..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/array-grouping.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-array-grouping - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.object.d.ts#L7 -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2024.collection.d.ts#L7 -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface ObjectConstructor { - groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Partial>; -} - -interface MapConstructor { - groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Map; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/array-includes.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-includes.d.ts deleted file mode 100644 index 508c900fa579..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/array-includes.d.ts +++ /dev/null @@ -1,54 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-Array.prototype.includes - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2016.array.include.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface Array { - includes(searchElement: T, fromIndex?: number): boolean; -} - -interface Int8Array { - includes(searchElement: number, fromIndex?: number): boolean; -} - -interface Uint8Array { - includes(searchElement: number, fromIndex?: number): boolean; -} - -interface Uint8ClampedArray { - includes(searchElement: number, fromIndex?: number): boolean; -} - -interface Int16Array { - includes(searchElement: number, fromIndex?: number): boolean; -} - -interface Uint16Array { - includes(searchElement: number, fromIndex?: number): boolean; -} - -interface Int32Array { - includes(searchElement: number, fromIndex?: number): boolean; -} - -interface Uint32Array { - includes(searchElement: number, fromIndex?: number): boolean; -} - -interface Float32Array { - includes(searchElement: number, fromIndex?: number): boolean; -} - -interface Float64Array { - includes(searchElement: number, fromIndex?: number): boolean; -} - -interface BigInt64Array { - includes(searchElement: bigint, fromIndex?: number): boolean; -} - -interface BigUint64Array { - includes(searchElement: bigint, fromIndex?: number): boolean; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/array-is-template-object.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-is-template-object.d.ts deleted file mode 100644 index 6ab53db2e94a..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/array-is-template-object.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -// proposal stage: 2 -// https://github.com/tc39/proposal-array-is-template-object -interface ArrayConstructor { - isTemplateObject(value: any): value is TemplateStringsArray; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/array-unique.d.ts b/packages/core-js-types/src/ts5-2/proposals/array-unique.d.ts deleted file mode 100644 index e2f85333abcc..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/array-unique.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -// proposal stage: 1 -// https://github.com/tc39/proposal-array-unique - -interface Array { - uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; -} - -interface Int8Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int8Array; -} - -interface Uint8Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8Array; -} - -interface Uint8ClampedArray { - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8ClampedArray; -} - -interface Int16Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int16Array; -} - -interface Uint16Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint16Array; -} - -interface Int32Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int32Array; -} - -interface Uint32Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint32Array; -} - -interface Float32Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float32Array; -} - -interface Float64Array { - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float64Array; -} - -interface BigInt64Array { - uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigInt64Array; -} - -interface BigUint64Array { - uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigUint64Array; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/async-iteration.d.ts b/packages/core-js-types/src/ts5-2/proposals/async-iteration.d.ts deleted file mode 100644 index 17bc57317010..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/async-iteration.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-async-iteration - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2018.asynciterable.d.ts#L4 -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface SymbolConstructor { - readonly asyncIterator: unique symbol; -} - -interface AsyncIteratorConstructor { - -} - -declare var AsyncIterator: AsyncIteratorConstructor; diff --git a/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts deleted file mode 100644 index 6af36a9606f1..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -// proposal stage: 2 -// https://github.com/tc39/proposal-async-iterator-helpers - -declare global { - interface AsyncIteratorConstructor { - from(iterable: AsyncIterable | AsyncGenerator | Iterable | AsyncIteratorObject): AsyncIteratorObject; - } - - var AsyncIterator: AsyncIteratorConstructor; - - interface AsyncIterator { - drop(limit: number): AsyncIteratorObject; - - every(predicate: (value: T, index: number) => boolean): Promise; - - filter(predicate: (value: T, index: number) => boolean): AsyncIteratorObject; - - find(predicate: (value: T, index: number) => boolean): Promise; - - flatMap(mapper: (value: T, index: number) => any): AsyncIteratorObject; - - forEach(callbackFn: (value: T, index: number) => void): Promise; - - map(mapper: (value: T, index: number) => any): AsyncIteratorObject; - - reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; - - some(predicate: (value: T, index: number) => boolean): Promise; - - take(limit: number): AsyncIteratorObject; - - toArray(): Promise; - } - - interface Iterator { - toAsync(): AsyncIteratorObject; - } -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/await-dictionary.d.ts b/packages/core-js-types/src/ts5-2/proposals/await-dictionary.d.ts deleted file mode 100644 index 3a6e22e45634..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/await-dictionary.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -// proposal stage: 1 -// https://github.com/tc39/proposal-await-dictionary - -import { CoreJSPromiseSettledResult } from '../core-js-types/core-js-types'; - -declare global { - interface PromiseConstructor { - allKeyed>>(promises: D): Promise <{ [k in keyof D]: Awaited }>; - - allSettledKeyed>>(promises: D): Promise <{ [k in keyof D]: CoreJSPromiseSettledResult> }>; - } -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy-custom.d.ts deleted file mode 100644 index f9c868a23824..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy-custom.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-change-array-by-copy - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - export type ArrayToSpliced = ((start: number, deleteCount: number, ...items: T[]) => T[]) | ((start: number, deleteCount?: number)=> T[]); -} diff --git a/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy.d.ts deleted file mode 100644 index f1069ab1c155..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/change-array-by-copy.d.ts +++ /dev/null @@ -1,110 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-change-array-by-copy - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare global { - interface Array { - toReversed(): T[]; - - toSorted(compareFn?: (a: T, b: T) => number): T[]; - - toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; - - toSpliced(start: number, deleteCount?: number): T[]; - - with(index: number, value: T): T[]; - } - - interface Int8Array { - toReversed(): Int8Array; - - toSorted(compareFn?: (a: number, b: number) => number): Int8Array; - - with(index: number, value: number): Int8Array; - } - - interface Uint8Array { - toReversed(): Uint8Array; - - toSorted(compareFn?: (a: number, b: number) => number): Uint8Array; - - with(index: number, value: number): Uint8Array; - } - - interface Uint8ClampedArray { - toReversed(): Uint8ClampedArray; - - toSorted(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; - - with(index: number, value: number): Uint8ClampedArray; - } - - interface Int16Array { - toReversed(): Int16Array; - - toSorted(compareFn?: (a: number, b: number) => number): Int16Array; - - with(index: number, value: number): Int16Array; - } - - interface Uint16Array { - toReversed(): Uint16Array; - - toSorted(compareFn?: (a: number, b: number) => number): Uint16Array; - - with(index: number, value: number): Uint16Array; - } - - interface Int32Array { - toReversed(): Int32Array; - - toSorted(compareFn?: (a: number, b: number) => number): Int32Array; - - with(index: number, value: number): Int32Array; - } - - interface Uint32Array { - toReversed(): Uint32Array; - - toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; - - with(index: number, value: number): Uint32Array; - } - - interface Float32Array { - toReversed(): Float32Array; - - toSorted(compareFn?: (a: number, b: number) => number): Float32Array; - - with(index: number, value: number): Float32Array; - } - - interface Float64Array { - toReversed(): Float64Array; - - toSorted(compareFn?: (a: number, b: number) => number): Float64Array; - - with(index: number, value: number): Float64Array; - } - - interface BigInt64Array { - toReversed(): BigInt64Array; - - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; - - with(index: number, value: bigint): BigInt64Array; - } - - interface BigUint64Array { - toReversed(): BigUint64Array; - - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; - - with(index: number, value: bigint): BigUint64Array; - } -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/collection-of-from.d.ts b/packages/core-js-types/src/ts5-2/proposals/collection-of-from.d.ts deleted file mode 100644 index 6e6bdeb8e2bd..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/collection-of-from.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -// proposal stage: 1 -// https://github.com/tc39/proposal-setmap-offrom -interface MapConstructor { - from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): Map; - - of(...items: [K, V][]): Map; -} - -interface SetConstructor { - from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): Set; - - of(...items: T[]): Set; -} - -interface WeakMapConstructor { - from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): WeakMap; - - of(...items: [K, V][]): WeakMap; -} - -interface WeakSetConstructor { - from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): WeakSet; - - of(...items: T[]): WeakSet; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/ts5-2/proposals/data-view-get-set-uint8-clamped.d.ts deleted file mode 100644 index e0022c602323..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/data-view-get-set-uint8-clamped.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// proposal stage: 1 -// https://github.com/tc39/proposal-dataview-get-set-uint8clamped - -interface DataView { - getUint8Clamped(byteOffset: number): number; - - setUint8Clamped(byteOffset: number, value: number): void; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/decorator-metadata.d.ts b/packages/core-js-types/src/ts5-2/proposals/decorator-metadata.d.ts deleted file mode 100644 index 2c2e21069a55..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/decorator-metadata.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -// proposal stage: 3 -// https://github.com/tc39/proposal-decorator-metadata - -import { CoreJSDecoratorMetadataObject } from '../core-js-types/core-js-types.js'; - -declare global { - interface SymbolConstructor { - readonly metadata: unique symbol; - } - - interface Function { - [Symbol.metadata]: CoreJSDecoratorMetadataObject | null; - } -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/error-cause.d.ts b/packages/core-js-types/src/ts5-2/proposals/error-cause.d.ts deleted file mode 100644 index 05e41bbb915c..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/error-cause.d.ts +++ /dev/null @@ -1,60 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-error-cause - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/es2022.error.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare global { - interface ErrorOptions { - cause?: unknown; - } - - interface Error { - cause?: unknown; // ts <= 4.7 Error | undefined - } - - interface ErrorConstructor { - new(message?: string, options?: ErrorOptions): Error; - - (message?: string, options?: ErrorOptions): Error; - } - - interface EvalErrorConstructor { - new(message?: string, options?: ErrorOptions): EvalError; - - (message?: string, options?: ErrorOptions): EvalError; - } - - interface RangeErrorConstructor { - new(message?: string, options?: ErrorOptions): RangeError; - - (message?: string, options?: ErrorOptions): RangeError; - } - - interface ReferenceErrorConstructor { - new(message?: string, options?: ErrorOptions): ReferenceError; - - (message?: string, options?: ErrorOptions): ReferenceError; - } - - interface SyntaxErrorConstructor { - new(message?: string, options?: ErrorOptions): SyntaxError; - - (message?: string, options?: ErrorOptions): SyntaxError; - } - - interface TypeErrorConstructor { - new(message?: string, options?: ErrorOptions): TypeError; - - (message?: string, options?: ErrorOptions): TypeError; - } - - interface URIErrorConstructor { - new(message?: string, options?: ErrorOptions): URIError; - - (message?: string, options?: ErrorOptions): URIError; - } -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts index 5f48e89dcc60..906178579b7b 100644 --- a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts @@ -1,4 +1,3 @@ -// proposal stage: 3 // https://github.com/tc39/proposal-explicit-resource-management // For ensuring compatibility with TypeScript standard types, this code is aligned with: @@ -6,16 +5,22 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface SymbolConstructor { + /** + * A method that is used to release resources held by an object. Called by the semantics of the `using` statement. + */ readonly dispose: unique symbol; + /** + * A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement. + */ readonly asyncDispose: unique symbol; } -interface Disposable { +interface Disposable { // @type-options no-constructor [Symbol.dispose](): void; } -interface AsyncDisposable { +interface AsyncDisposable { // @type-options no-constructor [Symbol.asyncDispose](): PromiseLike; } @@ -35,16 +40,66 @@ interface SuppressedErrorConstructor { declare var SuppressedError: SuppressedErrorConstructor; interface DisposableStack { + /** + * Returns a value indicating whether this stack has been disposed. + */ readonly disposed: boolean; + /** + * Disposes each resource in the stack in the reverse order that they were added. + */ dispose(): void; + /** + * Adds a disposable resource to the stack, returning the resource. + * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @returns The provided {@link value}. + */ use(value: T): T; + /** + * Adds a value and associated disposal callback as a resource to the stack. + * @param value The value to add. + * @param onDispose The callback to use in place of a `[Symbol.dispose]()` method. Will be invoked with `value` + * as the first parameter. + * @returns The provided {@link value}. + */ adopt(value: T, onDispose: (value: T) => void): T; + /** + * Adds a callback to be invoked when the stack is disposed. + */ defer(onDispose: () => void): void; + /** + * Move all resources out of this stack and into a new `DisposableStack`, and marks this stack as disposed. + * @example + * ```ts + * class C { + * #res1: Disposable; + * #res2: Disposable; + * #disposables: DisposableStack; + * constructor() { + * // stack will be disposed when exiting constructor for any reason + * using stack = new DisposableStack(); + * + * // get first resource + * this.#res1 = stack.use(getResource1()); + * + * // get second resource. If this fails, both `stack` and `#res1` will be disposed. + * this.#res2 = stack.use(getResource2()); + * + * // all operations succeeded, move resources out of `stack` so that they aren't disposed + * // when constructor exits + * this.#disposables = stack.move(); + * } + * + * [Symbol.dispose]() { + * this.#disposables.dispose(); + * } + * } + * ``` + */ move(): DisposableStack; [Symbol.dispose](): void; @@ -61,16 +116,66 @@ interface DisposableStackConstructor { declare var DisposableStack: DisposableStackConstructor; interface AsyncDisposableStack { + /** + * Returns a value indicating whether this stack has been disposed. + */ readonly disposed: boolean; + /** + * Disposes each resource in the stack in the reverse order that they were added. + */ disposeAsync(): Promise; + /** + * Adds a disposable resource to the stack, returning the resource. + * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @returns The provided {@link value}. + */ use(value: T): T; + /** + * Adds a value and associated disposal callback as a resource to the stack. + * @param value The value to add. + * @param onDisposeAsync The callback to use in place of a `[Symbol.asyncDispose]()` method. Will be invoked with `value` + * as the first parameter. + * @returns The provided {@link value}. + */ adopt(value: T, onDisposeAsync: (value: T) => PromiseLike | void): T; + /** + * Adds a callback to be invoked when the stack is disposed. + */ defer(onDisposeAsync: () => PromiseLike | void): void; + /** + * Move all resources out of this stack and into a new `DisposableStack`, and marks this stack as disposed. + * @example + * ```ts + * class C { + * #res1: Disposable; + * #res2: Disposable; + * #disposables: DisposableStack; + * constructor() { + * // stack will be disposed when exiting constructor for any reason + * using stack = new DisposableStack(); + * + * // get first resource + * this.#res1 = stack.use(getResource1()); + * + * // get second resource. If this fails, both `stack` and `#res1` will be disposed. + * this.#res2 = stack.use(getResource2()); + * + * // all operations succeeded, move resources out of `stack` so that they aren't disposed + * // when constructor exits + * this.#disposables = stack.move(); + * } + * + * [Symbol.dispose]() { + * this.#disposables.dispose(); + * } + * } + * ``` + */ move(): AsyncDisposableStack; [Symbol.asyncDispose](): Promise; @@ -86,6 +191,12 @@ interface AsyncDisposableStackConstructor { declare var AsyncDisposableStack: AsyncDisposableStackConstructor; -interface IteratorObject extends Disposable {} +interface IteratorObject extends Disposable {} // @type-options no-extends -interface AsyncIteratorObject extends AsyncDisposable {} +interface AsyncIteratorObject extends AsyncDisposable {} // @type-options no-extends + +interface AsyncIteratorConstructor {} + +declare var AsyncIterator: AsyncIteratorConstructor; + +interface AsyncIterator {} diff --git a/packages/core-js-types/src/ts5-2/proposals/float16.d.ts b/packages/core-js-types/src/ts5-2/proposals/float16.d.ts deleted file mode 100644 index cd193a26528b..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/float16.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-float16array - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.float16.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface Math { - f16round(x: number): number; -} - -interface DataView { - getFloat16(byteOffset: number, littleEndian?: boolean): number; - - setFloat16(byteOffset: number, value: number, littleEndian?: boolean): void; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/function-demethodize.d.ts b/packages/core-js-types/src/ts5-2/proposals/function-demethodize.d.ts deleted file mode 100644 index 0c829273ed92..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/function-demethodize.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -// proposal stage: 0 -// https://github.com/js-choi/proposal-function-demethodize -interface Function { - demethodize(this: (this: T, ...args: Args) => R): (thisArg: T, ...args: Args) => R; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/is-error.d.ts b/packages/core-js-types/src/ts5-2/proposals/is-error.d.ts deleted file mode 100644 index fc6a8d1fac03..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/is-error.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -// proposal stage: 3 -// https://github.com/tc39/proposal-is-error -interface ErrorConstructor { - isError(value: any): value is Error; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/iterator-chunking.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-chunking.d.ts deleted file mode 100644 index e6e7b2ef25d3..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/iterator-chunking.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -// proposal stage: 2.7 -// https://github.com/tc39/proposal-iterator-chunking - -import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; - -declare global { - interface Iterator { - chunks(chunkSize: number): CoreJSIteratorObject; - - windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJSIteratorObject; - } -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers-custom.d.ts deleted file mode 100644 index b028b9a788b1..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers-custom.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-iterator-helpers - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - interface IteratorObject extends Iterator {} - - export type CoreJsIteratorObject = IteratorObject; - - export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => CoreJsIteratorObject; - - export type IteratorMap = (callback: (value: T, index: number) => U) => CoreJsIteratorObject; - - export type IteratorReduce = (callback: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/iterator-join.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-join.d.ts deleted file mode 100644 index 7f0151419bf2..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/iterator-join.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// proposal stage: 0 -// https://github.com/bakkot/proposal-iterator-join - -interface Iterator { - join(separator?: unknown): string; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/iterator-joint.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-joint.d.ts deleted file mode 100644 index 28e9688e09e7..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/iterator-joint.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -// proposal stage: 2.7 -// https://github.com/tc39/proposal-joint-iteration - -import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; - -declare global { - type ZipOptions = { - mode?: "shortest" | "longest" | "strict"; - - padding?: object; - }; - - interface IteratorConstructor { - zip(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[T, U]>; - - zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[number, T, U]>; - - zipKeyed(record: Record>, options?: ZipOptions): CoreJSIteratorObject<[PropertyKey, T, U]>; - } - - var Iterator: IteratorConstructor; -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/iterator-range.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-range.d.ts deleted file mode 100644 index 3d69aa141212..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/iterator-range.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// proposal stage: 2 -// https://github.com/tc39/proposal-Number.range - -declare global { - type IteratorRangeOptions = { - step?: T; - - inclusive?: boolean; - }; - - interface IteratorConstructor { - range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): IteratorObject - } - - var Iterator: IteratorConstructor; -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-sequencing.d.ts deleted file mode 100644 index b2c986fb1f20..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/iterator-sequencing.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -// proposal stage: 2.7 -// https://github.com/tc39/proposal-iterator-sequencing - -import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; - -declare global { - interface IteratorConstructor { - concat(...iterators: Iterable[]): CoreJSIteratorObject; - } - - var Iterator: IteratorConstructor; -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/ts5-2/proposals/json-parse-with-source.d.ts deleted file mode 100644 index 4ae35de411e0..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/json-parse-with-source.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -// proposal stage: 3 -// https://github.com/tc39/proposal-json-parse-with-source - -interface CoreJSReviverContext { - readonly __brand: unique symbol; - - source: string; -} - -interface CoreJSRawJSON { - readonly __brand: unique symbol; - - rawJSON: string; -} - -interface JSON { - isRawJSON(value: any): value is CoreJSRawJSON; - - parse(text: string, reviver?: (key: string, value: any, context: CoreJSReviverContext) => any): T; - - rawJSON(value: string): CoreJSRawJSON; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/map-upsert.d.ts b/packages/core-js-types/src/ts5-2/proposals/map-upsert.d.ts deleted file mode 100644 index 0884acf4d246..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/map-upsert.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -// proposal stage: 2 -// https://github.com/tc39/proposal-upsert - -interface Map { - getOrInsert(key: K, value: V): V; - - getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; -} - -interface WeakMap { - getOrInsert(key: K, value: V): V; - - getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/math-sum.d.ts b/packages/core-js-types/src/ts5-2/proposals/math-sum.d.ts deleted file mode 100644 index b6086c79854c..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/math-sum.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -// proposal stage: 3 -// https://github.com/tc39/proposal-math-sum -interface Math { - sumPrecise(...values: number[]): number; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/number-clamp.d.ts b/packages/core-js-types/src/ts5-2/proposals/number-clamp.d.ts deleted file mode 100644 index d2c703e838cf..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/number-clamp.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// proposal stage: 2 -// https://github.com/tc39/proposal-math-clamp - -interface Number { - clamp(lower: number, upper: number): number; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/object-from-entries.d.ts b/packages/core-js-types/src/ts5-2/proposals/object-from-entries.d.ts deleted file mode 100644 index 47b8806c97b8..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/object-from-entries.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-object-from-entries - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/d8aafb3197ebecd7faf919eaa39e77c5805cbff8/src/lib/es2019.object.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface ObjectConstructor { - fromEntries(entries: Iterable): { [k: string]: T; }; - - fromEntries(entries: Iterable): any; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/object-get-own-property-descriptors.d.ts b/packages/core-js-types/src/ts5-2/proposals/object-get-own-property-descriptors.d.ts deleted file mode 100644 index 7a281655e09b..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/object-get-own-property-descriptors.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-object-getownpropertydescriptors - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2017.object.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface ObjectConstructor { - getOwnPropertyDescriptors(o: T): { [P in keyof T]: TypedPropertyDescriptor; } & { - [x: string]: PropertyDescriptor; - }; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/object-values-entries.d.ts b/packages/core-js-types/src/ts5-2/proposals/object-values-entries.d.ts deleted file mode 100644 index 09a84cb7655b..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/object-values-entries.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-object-values-entries - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2017.object.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface ObjectConstructor { - values(o: { [s: string]: T; } | ArrayLike): T[]; - values(o: {}): any[]; - - entries(o: { [s: string]: T; } | ArrayLike): [string, T][]; - entries(o: {}): [string, any][]; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/pattern-matching.d.ts b/packages/core-js-types/src/ts5-2/proposals/pattern-matching.d.ts deleted file mode 100644 index 874f263f2930..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/pattern-matching.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// proposal stage: 1 -// https://github.com/tc39/proposal-pattern-matching - -interface SymbolConstructor { - readonly customMatcher: unique symbol; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-all-settled.d.ts deleted file mode 100644 index fe24d586c33a..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/promise-all-settled.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-promise-allSettled - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2020.promise.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -import { CoreJSPromiseSettledResult } from '../core-js-types/core-js-types'; - -declare global { - interface PromiseConstructor { - allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJSPromiseSettledResult>; }>; - - allSettled(values: Iterable>): Promise>[]>; - } -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/promise-any.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-any.d.ts deleted file mode 100644 index 281fcc39c63b..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/promise-any.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-promise-any - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2021.promise.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface PromiseConstructor { - any(values: T): Promise>; - - any(values: Iterable>): Promise>; -} - -interface AggregateError extends Error { - errors: any[]; -} - -interface AggregateErrorConstructor { - new (errors: Iterable, message?: string): AggregateError; - (errors: Iterable, message?: string): AggregateError; - readonly prototype: AggregateError; -} - -declare var AggregateError: AggregateErrorConstructor; diff --git a/packages/core-js-types/src/ts5-2/proposals/promise-finally.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-finally.d.ts deleted file mode 100644 index 3bfb0471a1a9..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/promise-finally.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-promise-finally - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2018.promise.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface Promise { - finally(onfinally?: (() => void) | undefined | null): Promise; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/promise-try.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-try.d.ts deleted file mode 100644 index 42a941065d0d..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/promise-try.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-promise-try - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/esnext.promise.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface PromiseConstructor { - try(callbackFn: (...args: U) => T | PromiseLike, ...args: U): Promise>; -} - diff --git a/packages/core-js-types/src/ts5-2/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/ts5-2/proposals/promise-with-resolvers.d.ts deleted file mode 100644 index 44659a8e494f..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/promise-with-resolvers.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-promise-with-resolvers - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2024.promise.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface PromiseWithResolvers { - promise: Promise; - - resolve: (value: T | PromiseLike) => void; - - reject: (reason?: any) => void; -} - -interface PromiseConstructor { - withResolvers(): PromiseWithResolvers; -} - - diff --git a/packages/core-js-types/src/ts5-2/proposals/regexp-dotall-flag.d.ts b/packages/core-js-types/src/ts5-2/proposals/regexp-dotall-flag.d.ts deleted file mode 100644 index 63ce9946f1e4..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/regexp-dotall-flag.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-regexp-dotall-flag - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2018.regexp.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface RegExp { - readonly dotAll: boolean; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/regexp-escaping.d.ts b/packages/core-js-types/src/ts5-2/proposals/regexp-escaping.d.ts deleted file mode 100644 index e3526cfa3e88..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/regexp-escaping.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-regex-escaping - -interface RegExpConstructor { - escape(string: string): string; -} - -declare var RegExp: RegExpConstructor; diff --git a/packages/core-js-types/src/ts5-2/proposals/regexp-named-groups.d.ts b/packages/core-js-types/src/ts5-2/proposals/regexp-named-groups.d.ts deleted file mode 100644 index 2164fe5db0af..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/regexp-named-groups.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-regexp-named-groups - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2018.regexp.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface RegExpExecArray extends Array { - groups?: { - [key: string]: string; - }; -} - -interface RegExpMatchArray extends Array { - groups?: { - [key: string]: string; - }; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/ts5-2/proposals/relative-indexing-method.d.ts deleted file mode 100644 index 5532d8b8d322..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/relative-indexing-method.d.ts +++ /dev/null @@ -1,63 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-relative-indexing-method - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.array.d.ts -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.string.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface String { - at(index: number): string | undefined; -} - -interface Array { - at(index: number): T | undefined; -} - -interface ReadonlyArray { - at(index: number): T | undefined; -} - -interface Int8Array { - at(index: number): number | undefined; -} - -interface Uint8Array { - at(index: number): number | undefined; -} - -interface Uint8ClampedArray { - at(index: number): number | undefined; -} - -interface Int16Array { - at(index: number): number | undefined; -} - -interface Uint16Array { - at(index: number): number | undefined; -} - -interface Int32Array { - at(index: number): number | undefined; -} - -interface Uint32Array { - at(index: number): number | undefined; -} - -interface Float32Array { - at(index: number): number | undefined; -} - -interface Float64Array { - at(index: number): number | undefined; -} - -interface BigInt64Array { - at(index: number): bigint | undefined; -} - -interface BigUint64Array { - at(index: number): bigint | undefined; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/set-methods-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/set-methods-custom.d.ts deleted file mode 100644 index 36e248e143e9..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/set-methods-custom.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-set-methods - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - interface ReadonlySetLike { - keys(): Iterator; - - has(value: T): boolean; - - readonly size: number; - } - - export type SetUnion = (other: ReadonlySetLike) => Set; - - export type SetSymmetricDifference = (other: ReadonlySetLike) => Set; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/set-methods.d.ts b/packages/core-js-types/src/ts5-2/proposals/set-methods.d.ts deleted file mode 100644 index 70e5753afc10..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/set-methods.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-set-methods - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare global { - interface ReadonlySetLike { - keys(): Iterator; - - has(value: T): boolean; - - readonly size: number; - } - - interface Set { - union(other: ReadonlySetLike): Set; - - intersection(other: ReadonlySetLike): Set; - - difference(other: ReadonlySetLike): Set; - - symmetricDifference(other: ReadonlySetLike): Set; - - isSubsetOf(other: ReadonlySetLike): boolean; - - isSupersetOf(other: ReadonlySetLike): boolean; - - isDisjointFrom(other: ReadonlySetLike): boolean; - } - - interface ReadonlySet { - union(other: ReadonlySetLike): Set; - - intersection(other: ReadonlySetLike): Set; - - difference(other: ReadonlySetLike): Set; - - symmetricDifference(other: ReadonlySetLike): Set; - - isSubsetOf(other: ReadonlySetLike): boolean; - - isSupersetOf(other: ReadonlySetLike): boolean; - - isDisjointFrom(other: ReadonlySetLike): boolean; - } -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/string-cooked.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-cooked.d.ts deleted file mode 100644 index 8968780a6054..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/string-cooked.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// proposal stage: 1 -// https://github.com/tc39/proposal-string-cooked - -interface StringConstructor { - cooked(template: readonly string[], ...substitutions: any[]): string; - - cooked(template: string, ...substitutions: any[]): string; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/string-dedent.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-dedent.d.ts deleted file mode 100644 index 6486f012be0f..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/string-dedent.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// proposal stage: 2 -// https://github.com/tc39/proposal-string-dedent - -interface StringConstructor { - dedent(strings: TemplateStringsArray, ...values: any[]): string; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-left-right-trim.d.ts deleted file mode 100644 index 056e4d6aff96..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/string-left-right-trim.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-string-left-right-trim - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.string.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface String { - trimEnd(): string; - - trimStart(): string; - - trimLeft(): string; - - trimRight(): string; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts index 2959ffed049e..505d7d7b6289 100644 --- a/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts @@ -5,10 +5,8 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -import { CoreJSBuiltinIteratorReturn } from '../core-js-types/core-js-types'; - declare global { - interface RegExpStringIterator extends IteratorObject { + interface RegExpStringIterator extends IteratorObject { [Symbol.iterator](): RegExpStringIterator; } diff --git a/packages/core-js-types/src/ts5-2/proposals/string-padding.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-padding.d.ts deleted file mode 100644 index 2aae76a0c586..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/string-padding.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-string-pad-start-end - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface String { - padStart(maxLength: number, fillString?: string): string; - - padEnd(maxLength: number, fillString?: string): string; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/string-replace-all-custom.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-replace-all-custom.d.ts deleted file mode 100644 index 6755fb61507e..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/string-replace-all-custom.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-string-replaceall - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - export type StringReplaceAll = ((searchValue: string | RegExp, replaceValue: string) => string) | ((searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string) => string); -} diff --git a/packages/core-js-types/src/ts5-2/proposals/string-replace-all.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-replace-all.d.ts deleted file mode 100644 index ee1abf693888..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/string-replace-all.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-string-replaceall - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare global { - interface String { - replaceAll(searchValue: string | RegExp, replaceValue: string): string; - - replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; - } -} - -export {}; diff --git a/packages/core-js-types/src/ts5-2/proposals/symbol-description.d.ts b/packages/core-js-types/src/ts5-2/proposals/symbol-description.d.ts deleted file mode 100644 index 7f133067eb18..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/symbol-description.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-Symbol-description - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.symbol.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface Symbol { - readonly description: string | undefined; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/symbol-predicates.d.ts b/packages/core-js-types/src/ts5-2/proposals/symbol-predicates.d.ts deleted file mode 100644 index 165818730057..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/symbol-predicates.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// proposal stage: 2 -// https://github.com/tc39/proposal-symbol-predicates - -interface SymbolConstructor { - isRegisteredSymbol(value: any): boolean; - - isWellKnownSymbol(value: any): boolean; -} diff --git a/packages/core-js-types/src/ts5-2/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/ts5-2/proposals/well-formed-unicode-strings.d.ts deleted file mode 100644 index 3871f6fb9d2d..000000000000 --- a/packages/core-js-types/src/ts5-2/proposals/well-formed-unicode-strings.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// proposal stage: 4 -// https://github.com/tc39/proposal-is-usv-string - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2024.string.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -interface String { - isWellFormed(): boolean; - - toWellFormed(): string; -} diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts new file mode 100644 index 000000000000..49fcb8278dbb --- /dev/null +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -0,0 +1,234 @@ +/// + +// Motivation: Has dependencies on internal types + +// proposal stage: 2.7 +// https://github.com/tc39/proposal-iterator-chunking + +// proposal stage: 4 +// https://github.com/tc39/proposal-iterator-helpers + +// proposal stage: 0 +// https://github.com/bakkot/proposal-iterator-join + +// proposal stage: 2.7 +// https://github.com/tc39/proposal-joint-iteration + +// proposal stage: 2 +// https://github.com/tc39/proposal-iterator.range + +// proposal stage: 2.7 +// https://github.com/tc39/proposal-iterator-sequencing + +// For ensuring compatibility with TypeScript standard types, this code is aligned with: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + type ZipOptions = { + mode?: 'shortest' | 'longest' | 'strict'; + + padding?: object; + }; + + type IteratorRangeOptions = { + step?: T; + + inclusive?: boolean; + }; + + interface CoreJSPromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: ((value: T) => TResult1 | CoreJSPromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | CoreJSPromiseLike) | undefined | null): CoreJSPromiseLike; + } + + interface CoreJSAsyncIterator { + next(...[value]: [] | [TNext]): Promise>; + return?(value?: TReturn | CoreJSPromiseLike): Promise>; + throw?(e?: any): Promise>; + } + + export interface CoreJSAsyncIteratorObject extends CoreJSAsyncIterator {} + export interface CoreJSAsyncIteratorObject extends CoreJSAsyncDisposable {} + export interface CoreJSAsyncIterable { + [CoreJSSymbol.asyncIterator](): CoreJSAsyncIterator; + } + + export interface CoreJSIteratorObject extends CoreJSDisposable {} + + export interface CoreJSIterator extends Iterator { + /** + * Yields arrays containing up to the specified number of elements + * chunked from the source iterator. + * @param chunkSize The maximum number of elements per chunk. Must be a positive integer. + * @returns An iterator yielding arrays of at most `chunkSize` elements from the source iterator. + */ + chunks(chunkSize: number): CoreJSIteratorObject; + + /** + * Yields overlapping arrays (windows) of the given size from the iterator. + * @param windowSize The size of each window. Must be a positive integer. + * @param undersized 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. + * @returns An iterator yielding arrays of the specified window size. + */ + windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJSIteratorObject; + + /** + * Creates an iterator whose values are the result of applying the callback to the values from this iterator. + * @param callbackfn A function that accepts up to two arguments to be used to transform values from the underlying iterator. + */ + map(callbackfn: (value: T, index: number) => U): CoreJSIteratorObject; + + /** + * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. + * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + */ + filter(predicate: (value: T, index: number) => value is S): CoreJSIteratorObject; + /** + * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. + * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + */ + filter(predicate: (value: T, index: number) => unknown): CoreJSIteratorObject; + + /** + * Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached. + * @param limit The maximum number of values to yield. + */ + take(limit: number): CoreJSIteratorObject; + + /** + * Creates an iterator whose values are the values from this iterator after skipping the provided count. + * @param count The number of values to drop. + */ + drop(count: number): CoreJSIteratorObject; + + /** + * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. + * @param callback A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. + */ + flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; + + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; + + /** + * Creates a new array from the values yielded by this iterator. + */ + toArray(): T[]; + + /** + * Performs the specified action for each element in the iterator. + * @param callbackfn A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. + */ + forEach(callbackfn: (value: T, index: number) => void): void; + + /** + * Determines whether the specified callback function returns true for any element of this iterator. + * @param predicate A function that accepts up to two arguments. The `some` method calls + * the predicate function for each element in this iterator until the predicate returns a value + * true, or until the end of the iterator. + */ + some(predicate: (value: T, index: number) => unknown): boolean; + + /** + * Determines whether all the members of this iterator satisfy the specified test. + * @param predicate A function that accepts up to two arguments. The every method calls + * the predicate function for each element in this iterator until the predicate returns + * false, or until the end of this iterator. + */ + every(predicate: (value: T, index: number) => unknown): boolean; + + /** + * Returns the value of the first element in this iterator where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of this iterator, in + * 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. + */ + find(predicate: (value: T, index: number) => value is S): S | undefined; + find(predicate: (value: T, index: number) => unknown): T | undefined; + + join(separator?: unknown): string; + } + + export interface CoreJSIteratorConstructor { + /** + * Creates a native iterator from an iterator or iterable object. + * Returns its input if the input already inherits from the built-in Iterator class. + * @param value An iterator or iterable object to convert a native iterator. + */ + from(value: Iterator | Iterable): CoreJSIteratorObject; + + /** + * Takes an iterable of iterables and produces an iterable of arrays where position corresponds + * to position in the passed iterable. + * @param iterables An Iterable of iterables. + * @param options Optional object: + * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; + * - padding: an object specifying padding values for each key when mode is 'longest'. + * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. + */ + zip(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[T, U]>; + + /** + * takes an object whose values are iterables and produces an iterable of objects where keys. + * correspond to keys in the passed object. + * @param iterables An Iterable of iterables. + * @param options Optional object: + * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; + * - padding: an object specifying padding values for each key when mode is 'longest'. + * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. + */ + zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[number, T, U]>; + /** + * takes an object whose values are iterables and produces an iterable of objects where keys. + * correspond to keys in the passed object. + * @param record An object of iterables. + * @param options Optional object: + * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; + * - padding: an object specifying padding values for each key when mode is 'longest'. + * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. + */ + zipKeyed(record: Record>, options?: ZipOptions): CoreJSIteratorObject<[PropertyKey, T, U]>; + + /** + * Returns an iterator that generates a sequence of numbers or bigints within a range. + * @param start The starting value of the sequence. + * @param end The end value of the sequence (exclusive by default). + * @param options Optional object: + * - step: The difference between consecutive values (default is 1). + * - inclusive: If true, the end value is included in the range (default is false). + * @returns An iterator of numbers or bigints. + */ + range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): CoreJSIteratorObject + + /** + * Creates an iterator that sequentially yields values from the provided iterables. + * @param iterators The iterables to concatenate. + * @returns An iterator yielding values from each input iterable in sequence. + */ + concat(...iterators: Iterable[]): CoreJSIteratorObject; + } + + var CoreJSIterator: CoreJSIteratorConstructor; +} diff --git a/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts new file mode 100644 index 000000000000..7af333d593a4 --- /dev/null +++ b/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts @@ -0,0 +1,271 @@ +// use only with DOM lib +interface ArrayIterator extends IteratorObject { // @type-options no-export + [Symbol.iterator](): ArrayIterator; +} + +interface DOMTokenList { // @type-options no-export + /** + * Calls a defined callback function on each element of the DOMTokenList, + * passing the element, its index, and the entire DOMTokenList as arguments. + * @param callbackfn + * @param thisArg + */ + forEach( + callbackfn: (value: Element, index: number, collection: DOMTokenList) => void, + thisArg?: any + ): void; + + /** + * Returns an iterable of keys in the DOMTokenList. + */ + keys(): Iterable; + + /** + * Returns an iterable of values in the DOMTokenList. + */ + values(): Iterable; + + /** + * Returns an iterable of key, value pairs in the DOMTokenList. + */ + entries(): Iterable<[number, Element]>; + + [Symbol.iterator](): Iterable; +} + +interface NodeList { // @type-options no-export + /** + * Calls a defined callback function on each element of the NodeList, + * passing the element, its index, and the entire NodeList as arguments. + * @param callbackfn + * @param thisArg + */ + forEach( + callbackfn: (value: Node, index: number, collection: NodeList) => void, + thisArg?: any + ): void; + + /** + * Returns an iterable of keys in the NodeList. + */ + keys(): Iterable; + + /** + * Returns an iterable of values in the NodeList. + */ + values(): Iterable; + + /** + * Returns an iterable of key, value pairs in the NodeList. + */ + entries(): Iterable<[number, Node]>; + + /** + * Returns an iterable of values in the NodeList. + */ + [Symbol.iterator](): Iterable; +} + +interface CSSRuleList { // @type-options no-export + /** + * Returns an iterable of values in the CSSRuleList. + */ + [Symbol.iterator](): Iterable; +} + +interface CSSStyleDeclaration { // @type-options no-export + /** + * Returns an iterable of values in the CSSStyleDeclaration. + */ + [Symbol.iterator](): Iterable; +} + +interface CSSValueList { // @type-options no-export + /** + * Returns an iterable of values in the CSSValueList. + */ + [Symbol.iterator](): Iterable; +} + +interface ClientRectList { // @type-options no-export + /** + * Returns an iterable of values in the ClientRectList. + */ + [Symbol.iterator](): Iterable; +} + +interface DOMRectList { // @type-options no-export + /** + * Returns an iterable of values in the DOMRectList. + */ + [Symbol.iterator](): Iterable; +} + +interface DOMStringList { // @type-options no-export + /** + * Returns an iterable of values in the DOMStringList. + */ + [Symbol.iterator](): Iterable; +} + +interface DataTransferItemList { // @type-options no-export + /** + * Returns an iterable of values in the DataTransferItemList. + */ + [Symbol.iterator](): Iterable; +} + +interface FileList { // @type-options no-export + /** + * Returns an iterable of values in the FileList. + */ + [Symbol.iterator](): Iterable; +} + +interface HTMLAllCollection { // @type-options no-export + /** + * Returns an iterable of values in the HTMLAllCollection. + */ + [Symbol.iterator](): Iterable; +} + +interface HTMLCollection { // @type-options no-export + /** + * Returns an iterable of values in the HTMLCollection. + */ + [Symbol.iterator](): ArrayIterator; +} + +interface HTMLFormElement { // @type-options no-export + /** + * Returns an iterable of values in the HTMLFormElement. + */ + [Symbol.iterator](): Iterable; +} + +interface HTMLSelectElement { // @type-options no-export + /** + * Returns an iterable of values in the HTMLSelectElement. + */ + [Symbol.iterator](): Iterable; +} + +interface MediaList { // @type-options no-export + /** + * Returns an iterable of values in the MediaList. + */ + [Symbol.iterator](): Iterable; +} + +interface MimeTypeArray { // @type-options no-export + /** + * Returns an iterable of values in the MimeTypeArray. + */ + [Symbol.iterator](): Iterable; +} + +interface NamedNodeMap { // @type-options no-export + /** + * Returns an iterable of values in the NamedNodeMap. + */ + [Symbol.iterator](): Iterable; +} + +interface PaintRequestList { // @type-options no-export + /** + * Returns an iterable of values in the PaintRequestList. + */ + [Symbol.iterator](): Iterable; +} + +interface Plugin { // @type-options no-export + /** + * Returns an iterable of values in the Plugin. + */ + [Symbol.iterator](): Iterable; +} + +interface PluginArray { // @type-options no-export + /** + * Returns an iterable of values in the PluginArray. + */ + [Symbol.iterator](): Iterable; +} + +interface SVGLengthList { // @type-options no-export + /** + * Returns an iterable of values in the SVGLengthList. + */ + [Symbol.iterator](): Iterable; +} + +interface SVGNumberList { // @type-options no-export + /** + * Returns an iterable of values in the SVGNumberList. + */ + [Symbol.iterator](): Iterable; +} + +interface SVGPathSegList { // @type-options no-export + /** + * Returns an iterable of values in the SVGPathSegList. + */ + [Symbol.iterator](): Iterable; +} + +interface SVGPointList { // @type-options no-export + /** + * Returns an iterable of values in the SVGPointList. + */ + [Symbol.iterator](): Iterable; +} + +interface SVGStringList { // @type-options no-export + /** + * Returns an iterable of values in the SVGStringList. + */ + [Symbol.iterator](): Iterable; +} + +interface SVGTransformList { // @type-options no-export + /** + * Returns an iterable of values in the SVGTransformList. + */ + [Symbol.iterator](): Iterable; +} + +interface SourceBufferList { // @type-options no-export + /** + * Returns an iterable of values in the SourceBufferList. + */ + [Symbol.iterator](): Iterable; +} + +interface StyleSheetList { // @type-options no-export + /** + * Returns an iterable of values in the StyleSheetList. + * + */ + [Symbol.iterator](): Iterable; +} + +interface TextTrackCueList { // @type-options no-export + /** + * Returns an iterable of values in the TextTrackCueList. + */ + [Symbol.iterator](): Iterable; +} + +interface TextTrackList { // @type-options no-export + /** + * Returns an iterable of values in the TextTrackList. + */ + [Symbol.iterator](): Iterable; +} + +interface TouchList { // @type-options no-export + /** + * Returns an iterable of values in the TouchList. + */ + [Symbol.iterator](): Iterable; +} From 69fe0e27d794603347af0388297e4431036dfbef Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 23 Dec 2025 22:01:20 +0700 Subject: [PATCH 105/315] Update ES in README.md to actual --- packages/core-js-types/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core-js-types/README.md b/packages/core-js-types/README.md index c4f5da108559..1bafb8a83e52 100644 --- a/packages/core-js-types/README.md +++ b/packages/core-js-types/README.md @@ -21,7 +21,7 @@ and `DOM` lib for the global version if you use something related (see [DOM type { "compilerOptions": { "lib": [ - "es6", + "es2025", "dom" ], "types": [ @@ -86,7 +86,7 @@ Add this to your `tsconfig.json`, keeping in mind that ES types (at least ES6) a { "compilerOptions": { "lib": [ - "es6" + "es2025" ], "types": [ "@core-js/types/pure" @@ -121,7 +121,7 @@ You need to add DOM types to the `lib` section of your `tsconfig.json` in additi "@core-js/types" ], "lib": [ - "esnext", + "es2025", "dom" ] } From e3915e5a0f8500c82a3b62674111770ab60af452 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 24 Dec 2025 02:52:05 +0700 Subject: [PATCH 106/315] Types stabilization for TS <= 5.5 --- .../core-js-types/src/base/web/url-parse.d.ts | 5 + .../ts5-2/core-js-types/core-js-types.d.ts | 4 +- .../proposals/async-iterator-helpers.d.ts | 99 +++++++++++++++++++ .../explicit-resource-management.d.ts | 4 +- scripts/build-entries/entries-definitions.mjs | 4 +- scripts/build-entries/templates.mjs | 16 +++ tests/type-definitions/runner.mjs | 13 ++- 7 files changed, 135 insertions(+), 10 deletions(-) create mode 100644 packages/core-js-types/src/base/web/url-parse.d.ts create mode 100644 packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts diff --git a/packages/core-js-types/src/base/web/url-parse.d.ts b/packages/core-js-types/src/base/web/url-parse.d.ts new file mode 100644 index 000000000000..a5a72eca2fe4 --- /dev/null +++ b/packages/core-js-types/src/base/web/url-parse.d.ts @@ -0,0 +1,5 @@ +/// + +declare namespace CoreJS { + export type URLParse = (url: string | CoreJSURL, base?: string | CoreJSURL) => CoreJSURL | null; +} diff --git a/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts index 1a7c6f64dcc9..8dbb224d9084 100644 --- a/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts +++ b/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts @@ -6,7 +6,7 @@ declare global { interface IteratorObject extends Iterator {} - interface AsyncIteratorObject extends AsyncIterator { + interface AsyncIteratorObject extends AsyncIterator { [Symbol.asyncIterator](): AsyncIteratorObject; } @@ -21,7 +21,7 @@ declare global { [Symbol.asyncIterator](): AsyncGenerator; } - interface AsyncIterator { + interface AsyncIterator { // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. next(...[value]: [] | [TNext]): Promise>; return?(value?: TReturn | PromiseLike): Promise>; diff --git a/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts new file mode 100644 index 000000000000..ae3f8e563cc8 --- /dev/null +++ b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts @@ -0,0 +1,99 @@ +// https://github.com/tc39/proposal-async-iterator-helpers + +interface AsyncIteratorConstructor { + /** + * Creates an `AsyncIterator` from an iterable object + * @param iterable An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` + * @returns A new `AsyncIterator` instance + */ + from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; +} + +declare var AsyncIterator: AsyncIteratorConstructor; + +interface AsyncIterator { + /** + * Drops elements from the iterator until the limit is reached + * @param limit The number of elements to drop + * @returns A new `AsyncIterator` + */ + drop(limit: number): AsyncIteratorObject; + + /** + * Check if every value generated by the iterator passes the `predicate` function. + * @param predicate A function that tests each element of the iterator + * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` + */ + every(predicate: (value: T, index: number) => boolean): Promise; + + /** + * Creates a new `AsyncIterator` that contains only the elements that pass the `predicate` function. + * @param predicate A function that tests each element of the iterator + * @returns A new `AsyncIterator` + */ + filter(predicate: (value: T, index: number) => boolean): AsyncIteratorObject; + + /** + * Finds the first element in the iterator that satisfies the `predicate` function. + * @param predicate A function that tests each element of the iterator + * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` + */ + find(predicate: (value: T, index: number) => boolean): Promise; + + /** + * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. + * @param mapper A function that transforms each element of the iterator + * @returns A new `AsyncIterator` + */ + flatMap(mapper: (value: T, index: number) => any): AsyncIteratorObject; + + /** + * Executes a provided function once for each element in the iterator. + * @param callbackFn A function that is called for each element of the iterator + * @returns A `Promise` that resolves when all elements have been processed + */ + forEach(callbackFn: (value: T, index: number) => void): Promise; + + /** + * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. + * @param mapper A function that transforms each element of the iterator + * @returns A new `AsyncIterator` + */ + map(mapper: (value: T, index: number) => any): AsyncIteratorObject; + + /** + * Reduces the elements of the iterator to a single value using the `reducer` function. + * @param reducer A function that combines two elements of the iterator + * @param initialValue An optional initial value to start the reduction + * @returns A `Promise` that resolves to the reduced value + */ + reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; + + /** + * Checks if any value in the iterator matches a given `predicate` + * @param predicate A function that tests each element of the iterator + * @returns A `Promise` that resolves to `true` if any element passes the `predicate`, otherwise `false` + */ + some(predicate: (value: T, index: number) => boolean): Promise; + + /** + * Creates a new `AsyncIterator` that yields only the first `limit` elements from the original iterator. + * @param limit The maximum number of elements to take + * @returns A new `AsyncIterator` + */ + take(limit: number): AsyncIteratorObject; + + /** + * Collects all elements from the iterator into an array. + * @returns A `Promise` that resolves to an array containing all elements from the iterator + */ + toArray(): Promise; +} + +interface Iterator { + /** + * Creates an `AsyncIterator` from the current `Iterator` + * @returns A new `AsyncIterator` instance + */ + toAsync(): AsyncIteratorObject; +} diff --git a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts index 906178579b7b..6aa09f24df78 100644 --- a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts @@ -193,10 +193,10 @@ declare var AsyncDisposableStack: AsyncDisposableStackConstructor; interface IteratorObject extends Disposable {} // @type-options no-extends -interface AsyncIteratorObject extends AsyncDisposable {} // @type-options no-extends +interface AsyncIteratorObject extends AsyncDisposable {} // @type-options no-extends interface AsyncIteratorConstructor {} declare var AsyncIterator: AsyncIteratorConstructor; -interface AsyncIterator {} +interface AsyncIterator {} diff --git a/scripts/build-entries/entries-definitions.mjs b/scripts/build-entries/entries-definitions.mjs index 70649bea5e85..36c0d97516c0 100644 --- a/scripts/build-entries/entries-definitions.mjs +++ b/scripts/build-entries/entries-definitions.mjs @@ -6,6 +6,7 @@ import { $prototypeIterator, $static, $staticWithContext, + $staticWithCustomType, $patchableStatic, $namespace, $helper, @@ -3093,9 +3094,10 @@ export const features = { }, 'url/parse': { modules: ['web.url.parse'], - template: $static, + template: $staticWithCustomType, namespace: 'URL', name: 'parse', + customType: 'web/url-parse', }, 'url/to-json': { modules: ['web.url.to-json'], diff --git a/scripts/build-entries/templates.mjs b/scripts/build-entries/templates.mjs index 33bde366d247..d6e062d4ed7d 100644 --- a/scripts/build-entries/templates.mjs +++ b/scripts/build-entries/templates.mjs @@ -201,6 +201,22 @@ export const $staticWithContext = p => ({ `, }); +export const $staticWithCustomType = p => ({ + entry: dedent` + ${ importModules(p) } + + var getBuiltInStaticMethod = ${ importInternal('get-built-in-static-method', p.level) } + + module.exports = getBuiltInStaticMethod('${ p.namespace }', '${ p.name }'); + `, + types: dedent` + declare module '${ buildModulePath(p) }' { + const method: ${ buildCoreJSTypeName(p.namespace, p.name) }; + export = method; + } + `, +}); + export const $patchableStatic = p => ({ entry: dedent` ${ importModules(p) } diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index e60b0ef323b8..8770cb3473dc 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -7,7 +7,7 @@ const ALL_TESTS = process.env.ALL_TYPE_DEFINITIONS_TESTS === '1'; const targets = [ 'esnext', - 'es2023', + 'es2022', 'es6', ]; const typeScriptVersions = [ @@ -15,7 +15,10 @@ const typeScriptVersions = [ '5.8', '5.7', '5.6', - // '5.5' + // '5.5', fails with node types: Named property 'next' of types 'AsyncIterator' and 'AsyncIteratorObject' are not identical. + // '5.4', + // '5.3', + // '5.2', ]; const envs = [ null, @@ -47,13 +50,13 @@ async function runTestsOnEnv({ typeScriptVersion, target, type, env, lib }) { $.verbose = false; const envLibName = env ? env.substring(0, env.lastIndexOf('@')) : ''; const command = `npx -p typescript@${ typeScriptVersion }${ env ? ` -p ${ env }` : '' } ` - + `tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target }${ lib ? `,${ lib }` : '' }${ env ? ` --types @core-js/types${ type === 'pure' ? '/pure' : '/full' },${ envLibName }` : '' }`; + + `tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target }${ lib ? `,${ lib }` : '' }${ env ? ` --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }` : '' }`; echo(`$ ${ command }`); try { if (env && lib) { - await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target },${ lib } --types @core-js/types${ type === 'pure' ? '/pure' : '/full' },${ envLibName }`.quiet(); + await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target },${ lib } --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }`.quiet(); } else if (env) { - await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target } --types @core-js/types${ type === 'pure' ? '/pure' : '/full' },${ envLibName }`.quiet(); + await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target } --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }`.quiet(); } else if (lib) { await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target },${ lib }`.quiet(); } else { From 04ac416482789c084b3892c842ba3da1f9e1877a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 24 Dec 2025 22:31:28 +0700 Subject: [PATCH 107/315] Fix prototype template --- scripts/build-entries/templates.mjs | 13 ++++++++++++- tests/type-definitions/templates.import.ts | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/scripts/build-entries/templates.mjs b/scripts/build-entries/templates.mjs index d6e062d4ed7d..1dbf3408612c 100644 --- a/scripts/build-entries/templates.mjs +++ b/scripts/build-entries/templates.mjs @@ -55,6 +55,16 @@ function getGenericsForNamespace(namespace) { return ''; } +function getAnyGenericsForNamespace(namespace) { + if (namespacesWithTwoGeneric.includes(namespace)) { + return ''; + } + if (namespacesWithOneGeneric.includes(namespace)) { + return ''; + } + return ''; +} + function getCommonGenericsForNamespace(namespace) { if (namespacesWithTwoGeneric.includes(namespace)) { return ''; @@ -89,7 +99,8 @@ export const $prototype = p => ({ `, types: dedent` declare module '${ buildModulePath(p) }' { - type method${ getGenericsForNamespace(p.namespace) } = ${ p.prefix ?? '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; + type methodType${ getGenericsForNamespace(p.namespace) } = ${ p.prefix ?? '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; + const method: methodType${ getAnyGenericsForNamespace(p.namespace) }; export = method; } `, diff --git a/tests/type-definitions/templates.import.ts b/tests/type-definitions/templates.import.ts index e9e523076ad0..a64bd2287dbf 100644 --- a/tests/type-definitions/templates.import.ts +++ b/tests/type-definitions/templates.import.ts @@ -4,17 +4,17 @@ import '@core-js/pure/full/array-buffer/detached'; import detached from '@core-js/pure/full/array-buffer/detached'; // $prototype -// import at from '@core-js/pure/full/array/prototype/at'; -// const atResult1: number = at.call([1, 2, 3], -2); -// at.apply([1, 2, 3], [-2]); -// // @ts-expect-error -// at.call([1, 2, 3], null); -// // @ts-expect-error -// at.call(123); -// // @ts-expect-error -// at('string'); -// // @ts-expect-error -// at(null); +import at from '@core-js/pure/full/array/prototype/at'; +const atResult1: number = at.call([1, 2, 3], -2); +at.apply([1, 2, 3], [-2]); +// @ts-expect-error +at.call([1, 2, 3], null); +// @ts-expect-error +at.call(123); +// @ts-expect-error +at('string'); +// @ts-expect-error +at(null); // $prototypeIterator import arrayVirtualIterator from '@core-js/pure/full/array/prototype/iterator'; From e56fe0a2675e5eaf8bf29a671767a81262ed03dd Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 27 Dec 2025 01:04:47 +0700 Subject: [PATCH 108/315] Add test for prototype methods without generics --- tests/type-definitions/templates.import.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/type-definitions/templates.import.ts b/tests/type-definitions/templates.import.ts index a64bd2287dbf..2543ebc8d7b0 100644 --- a/tests/type-definitions/templates.import.ts +++ b/tests/type-definitions/templates.import.ts @@ -3,9 +3,9 @@ import '@core-js/pure/full/array-buffer/detached'; // @ts-expect-error it has no exports import detached from '@core-js/pure/full/array-buffer/detached'; -// $prototype +// $prototype with generics import at from '@core-js/pure/full/array/prototype/at'; -const atResult1: number = at.call([1, 2, 3], -2); +at.call([1, 2, 3], -2); // we can't save strict result type for prototype methods with generics. It is any here at.apply([1, 2, 3], [-2]); // @ts-expect-error at.call([1, 2, 3], null); @@ -16,6 +16,19 @@ at('string'); // @ts-expect-error at(null); +// $prototype without generics +import stringAt from '@core-js/pure/full/string/prototype/at'; +const stringAtResult: string | undefined = stringAt.call('asd', -2); +stringAt.apply('asd', [-2]); +// @ts-expect-error +stringAt.call('asd', null); +// @ts-expect-error +stringAt.call('asd'); +// @ts-expect-error +stringAt([1]); +// @ts-expect-error +stringAt(null); + // $prototypeIterator import arrayVirtualIterator from '@core-js/pure/full/array/prototype/iterator'; const aviValue1: number = arrayVirtualIterator.call([1]).next().value; From 55b03a88fc1a7864763276f5ad5ac1f11e2f4265 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 27 Dec 2025 01:44:19 +0700 Subject: [PATCH 109/315] Update clearImmediate type & tests for Bun|Node compatibility --- .../core-js-types/src/base/web/efficient-script-yielding.d.ts | 2 +- .../global/web/efficient-script-yielding.test.ts | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts b/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts index 2a46793da57e..07d29c3f53be 100644 --- a/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts +++ b/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts @@ -1,4 +1,4 @@ -type Immediate = number | object; +type Immediate = number | object | undefined; // For compatibility with Node, `undefined` has been added /** * Schedules the execution of a function as soon as possible after the current script yields. diff --git a/tests/type-definitions/global/web/efficient-script-yielding.test.ts b/tests/type-definitions/global/web/efficient-script-yielding.test.ts index 4478f70abacd..ba0e97df8056 100644 --- a/tests/type-definitions/global/web/efficient-script-yielding.test.ts +++ b/tests/type-definitions/global/web/efficient-script-yielding.test.ts @@ -8,6 +8,4 @@ setImmediate(); // @ts-expect-error setImmediate(42); // @ts-expect-error -clearImmediate(); -// @ts-expect-error clearImmediate('str'); From f5e03cc2d4b022c03408bf3596dc54a4a9eb65d4 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 27 Dec 2025 01:46:51 +0700 Subject: [PATCH 110/315] Add comment explaining why Bun tests are disabled --- tests/type-definitions/runner.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 8770cb3473dc..d93d55db177d 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -27,7 +27,7 @@ const envs = [ '@types/node@18', '@types/node@16', // '@types/node@15', // fails - // '@types/bun@latest', // fails + // '@types/bun@latest', // conflicts with DOM types (TextDecorator, SharedArrayBuffer...) ]; const types = [ 'global', From 0e6b53f712dfa955e58ed7ce667b6ccf7933da61 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 27 Dec 2025 01:56:39 +0700 Subject: [PATCH 111/315] Code improvements --- tests/type-definitions/runner.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index d93d55db177d..0322f4794160 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -49,10 +49,12 @@ function getEnvPath(env) { async function runTestsOnEnv({ typeScriptVersion, target, type, env, lib }) { $.verbose = false; const envLibName = env ? env.substring(0, env.lastIndexOf('@')) : ''; - const command = `npx -p typescript@${ typeScriptVersion }${ env ? ` -p ${ env }` : '' } ` - + `tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target }${ lib ? `,${ lib }` : '' }${ env ? ` --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }` : '' }`; + const command = `npx -p typescript@${ typeScriptVersion }${ + env ? ` -p ${ env }` : '' } tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target }${ lib ? `,${ lib }` : '' }${ + env ? ` --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }` : '' }`; echo(`$ ${ command }`); try { + tested++; if (env && lib) { await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target },${ lib } --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }`.quiet(); } else if (env) { @@ -63,9 +65,7 @@ async function runTestsOnEnv({ typeScriptVersion, target, type, env, lib }) { await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target }`.quiet(); } echo(chalk.green(`$ ${ command }`)); - tested++; } catch (error) { - tested++; failed++; echo(`$ ${ chalk.red(command) }\n ${ error }`); } From 92fd2fdc000df5ba07a3d34d9e6585cd77aea97a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 29 Dec 2025 12:54:11 +0700 Subject: [PATCH 112/315] Types coverage --- package.json | 3 ++- .../modules/web.dom-exception.constructor.js | 1 + .../core-js/modules/web.dom-exception.stack.js | 1 + .../modules/web.dom-exception.to-string-tag.js | 1 + packages/core-js/modules/web.self.js | 1 + .../modules/web.url-search-params.constructor.js | 1 + .../modules/web.url-search-params.delete.js | 1 + .../core-js/modules/web.url-search-params.has.js | 1 + .../core-js/modules/web.url-search-params.size.js | 1 + packages/core-js/modules/web.url.can-parse.js | 1 + packages/core-js/modules/web.url.constructor.js | 1 + packages/core-js/modules/web.url.parse.js | 1 + tests/eslint/package-lock.json | 9 ++++++++- tests/type-definitions/coverage.mjs | 14 ++++++++++++++ 14 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/type-definitions/coverage.mjs diff --git a/package.json b/package.json index d0f9df981a64..7572d0c2ef8e 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "lint": "run-s prepare lint-raw", "lint-raw": "run-s build-types test-eslint bundle-package test-publint", "test": "run-s prepare test-raw", - "test-raw": "run-s lint-raw test-type-definitions bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check", + "test-raw": "run-s lint-raw test-type-definitions types-coverage bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check", "test-eslint": "npm run zxi time tests/eslint/runner.mjs", "test-publint": "npm run zxi time tests/publint/runner.mjs", "test-unit": "run-s test-unit-karma test-unit-node test-unit-bun", @@ -59,6 +59,7 @@ "test-type-definitions": "npm run zxi time cd tests/type-definitions/runner.mjs", "test-type-definitions-all": "ALL_TYPE_DEFINITIONS_TESTS=1 npm run zxi time cd tests/type-definitions/runner.mjs", "test262": "npm run zxi time cd tests/test262/runner.mjs", + "types-coverage": "npm run zxi tests/type-definitions/coverage.mjs", "refresh": "UPDATE_DEPENDENCIES=1 npm run prepare-monorepo && npm run test-raw", "refresh-safe": "npm run prepare-monorepo && npm run test-raw", "downloads": "npm run zxi scripts/downloads-by-versions.mjs", diff --git a/packages/core-js/modules/web.dom-exception.constructor.js b/packages/core-js/modules/web.dom-exception.constructor.js index efc29424ae65..073c9dd49c95 100644 --- a/packages/core-js/modules/web.dom-exception.constructor.js +++ b/packages/core-js/modules/web.dom-exception.constructor.js @@ -1,3 +1,4 @@ +// no types: has types only for the pure version 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/web.dom-exception.stack.js b/packages/core-js/modules/web.dom-exception.stack.js index d166b6651504..3cda15508db7 100644 --- a/packages/core-js/modules/web.dom-exception.stack.js +++ b/packages/core-js/modules/web.dom-exception.stack.js @@ -1,3 +1,4 @@ +// no types: has types only for the pure version 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.dom-exception.to-string-tag.js b/packages/core-js/modules/web.dom-exception.to-string-tag.js index f53c6d50db8f..707d3ce7760d 100644 --- a/packages/core-js/modules/web.dom-exception.to-string-tag.js +++ b/packages/core-js/modules/web.dom-exception.to-string-tag.js @@ -1,3 +1,4 @@ +// no types: has types only for the pure version 'use strict'; var getBuiltIn = require('../internals/get-built-in'); var setToStringTag = require('../internals/set-to-string-tag'); diff --git a/packages/core-js/modules/web.self.js b/packages/core-js/modules/web.self.js index 596d2d46c5fc..fd6d6cae4f36 100644 --- a/packages/core-js/modules/web.self.js +++ b/packages/core-js/modules/web.self.js @@ -1,3 +1,4 @@ +// no types: because of a conflict with lib.dom.d.ts 'use strict'; var globalThis = require('../internals/global-this'); var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); diff --git a/packages/core-js/modules/web.url-search-params.constructor.js b/packages/core-js/modules/web.url-search-params.constructor.js index 0a2fe6fd68b5..ac904e93d430 100644 --- a/packages/core-js/modules/web.url-search-params.constructor.js +++ b/packages/core-js/modules/web.url-search-params.constructor.js @@ -1,3 +1,4 @@ +// no types: because of a conflict with lib.dom.d.ts 'use strict'; var $ = require('../internals/export'); var safeGetBuiltIn = require('../internals/safe-get-built-in'); diff --git a/packages/core-js/modules/web.url-search-params.delete.js b/packages/core-js/modules/web.url-search-params.delete.js index 3c3ce235d8de..26d2b0ba2fc0 100644 --- a/packages/core-js/modules/web.url-search-params.delete.js +++ b/packages/core-js/modules/web.url-search-params.delete.js @@ -1,3 +1,4 @@ +// no types: because of a conflict with lib.dom.d.ts 'use strict'; var defineBuiltIn = require('../internals/define-built-in'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/web.url-search-params.has.js b/packages/core-js/modules/web.url-search-params.has.js index 6e6e3f1e9f50..3fcadb2d9a6e 100644 --- a/packages/core-js/modules/web.url-search-params.has.js +++ b/packages/core-js/modules/web.url-search-params.has.js @@ -1,3 +1,4 @@ +// no types: because of a conflict with lib.dom.d.ts 'use strict'; var defineBuiltIn = require('../internals/define-built-in'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/web.url-search-params.size.js b/packages/core-js/modules/web.url-search-params.size.js index aabd6d5bb567..5ce3f7ae8993 100644 --- a/packages/core-js/modules/web.url-search-params.size.js +++ b/packages/core-js/modules/web.url-search-params.size.js @@ -1,3 +1,4 @@ +// no types: because of a conflict with lib.dom.d.ts 'use strict'; var uncurryThis = require('../internals/function-uncurry-this'); var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); diff --git a/packages/core-js/modules/web.url.can-parse.js b/packages/core-js/modules/web.url.can-parse.js index d969ff8d68d1..0ea7235f71ea 100644 --- a/packages/core-js/modules/web.url.can-parse.js +++ b/packages/core-js/modules/web.url.can-parse.js @@ -1,3 +1,4 @@ +// no types: because of a conflict with lib.dom.d.ts 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/web.url.constructor.js b/packages/core-js/modules/web.url.constructor.js index 49df2c1a9901..140963961e8d 100644 --- a/packages/core-js/modules/web.url.constructor.js +++ b/packages/core-js/modules/web.url.constructor.js @@ -1,3 +1,4 @@ +// no types: because of a conflict with lib.dom.d.ts 'use strict'; var $ = require('../internals/export'); var USE_NATIVE_URL = require('../internals/url-constructor-detection'); diff --git a/packages/core-js/modules/web.url.parse.js b/packages/core-js/modules/web.url.parse.js index f1757df55a9c..cfe56bbee6d6 100644 --- a/packages/core-js/modules/web.url.parse.js +++ b/packages/core-js/modules/web.url.parse.js @@ -1,3 +1,4 @@ +// no types: because of a conflict with lib.dom.d.ts 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/tests/eslint/package-lock.json b/tests/eslint/package-lock.json index f17ad719c99f..e1a94fcb1653 100644 --- a/tests/eslint/package-lock.json +++ b/tests/eslint/package-lock.json @@ -439,7 +439,8 @@ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", "dev": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/@types/json-schema": { "version": "7.0.15", @@ -761,6 +762,7 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -877,6 +879,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -1251,6 +1254,7 @@ "integrity": "sha512-20MV9SUdeN6Jd84xESsKhRly+/vxI+hwvpBMA93s+9dAcjdCuCojn4IqUGS3lvVaqjVYGYHSRMCpeFtF2rQYxQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", @@ -2482,6 +2486,7 @@ "integrity": "sha512-75EA7EWZExL/j+MDKQrRbdzcRI2HOkRlmUw8fZJc1ioqFEOvBsq7Rt+A6yCxOt9w/TYNpkt52gC6nm/g5tFIng==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "acorn": "^8.5.0", "eslint-visitor-keys": "^5.0.0", @@ -4244,6 +4249,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -4328,6 +4334,7 @@ "dev": true, "hasInstallScript": true, "license": "MIT", + "peer": true, "dependencies": { "napi-postinstall": "^0.3.0" }, diff --git a/tests/type-definitions/coverage.mjs b/tests/type-definitions/coverage.mjs new file mode 100644 index 000000000000..f14794133bce --- /dev/null +++ b/tests/type-definitions/coverage.mjs @@ -0,0 +1,14 @@ +import { modules as AllModules } from '@core-js/compat/src/data.mjs'; + +const { readFile } = fs; +const { red } = chalk; + +const MODULES_PATH = 'packages/core-js/modules/'; +const Modules = AllModules.filter(it => it.match(/^(?:esnext|web)\./)); +for (const moduleName of Modules) { + const modulePath = path.join(MODULES_PATH, `${ moduleName }.js`); + const content = await readFile(modulePath, 'utf8'); + if (!/\/\/ (?:types:|no\stypes)/.test(content)) { + echo(red('No types for module:'), path.resolve(modulePath)); + } +} From 68ed547aec1165dd3f04e06d9eee14a199e0beac Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 30 Dec 2025 23:31:45 +0700 Subject: [PATCH 113/315] Imports in tests refactoring --- .../base/web/efficient-script-yielding.d.ts | 4 +-- tests/type-definitions/entries.pure.ts | 12 ++++----- .../type-definitions/pure/common/date.test.ts | 6 ++--- .../array-is-template-object.test.ts | 4 +-- .../pure/proposals/async-iteration.test.ts | 8 +++--- .../proposals/async-iterator-helper.test.ts | 5 ++-- .../pure/proposals/await-dictionary.test.ts | 20 +++++++------- .../explicit-resource-management.test.ts | 25 +++++++----------- .../pure/proposals/extractors.test.ts | 12 ++++----- .../pure/proposals/float16.test.ts | 6 ++--- .../proposals/function-demethodize.test.ts | 4 +-- .../pure/proposals/is-error.test.ts | 12 ++++----- .../pure/proposals/iterator-chunking.test.ts | 20 +++++++------- .../pure/proposals/iterator-joint.test.ts | 22 ++++++++-------- .../pure/proposals/iterator-range.test.ts | 18 ++++++------- .../proposals/iterator-sequencing.test.ts | 18 ++++++------- .../proposals/json-parse-with-source.test.ts | 26 +++++++++---------- .../pure/proposals/pattern-matching.test.ts | 8 +++--- .../pure/proposals/string-cooked.test.ts | 12 ++++----- .../pure/proposals/string-dedent.test.ts | 14 +++++----- .../pure/web/url-search-params.test.ts | 14 +++++----- tests/type-definitions/pure/web/url.test.ts | 8 +++--- 22 files changed, 136 insertions(+), 142 deletions(-) diff --git a/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts b/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts index 07d29c3f53be..4415724fa281 100644 --- a/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts +++ b/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts @@ -1,4 +1,4 @@ -type Immediate = number | object | undefined; // For compatibility with Node, `undefined` has been added +type Immediate = number | object; /** * Schedules the execution of a function as soon as possible after the current script yields. @@ -12,4 +12,4 @@ declare function setImmediate(handler: (...args: any[]) => void, ...args: any[]) * Cancels a function scheduled with setImmediate. * @param immediate The identifier of the scheduled function to cancel. */ -declare function clearImmediate(immediate: Immediate): void; +declare function clearImmediate(immediate: Immediate | undefined): void; // For compatibility with Node, `undefined` has been added diff --git a/tests/type-definitions/entries.pure.ts b/tests/type-definitions/entries.pure.ts index 7739c910f404..8d6e1f2ec450 100644 --- a/tests/type-definitions/entries.pure.ts +++ b/tests/type-definitions/entries.pure.ts @@ -1,8 +1,8 @@ -import $date from '@core-js/pure/full/date/index'; -new $date(); +import $Date from '@core-js/pure/full/date/index'; +new $Date(); -import $date2 from '@core-js/pure/full/date/index.js'; -new $date2(); +import $Date2 from '@core-js/pure/full/date/index.js'; +new $Date2(); -import $date3 from '@core-js/pure/full/date'; -new $date3(); +import $Date3 from '@core-js/pure/full/date'; +new $Date3(); diff --git a/tests/type-definitions/pure/common/date.test.ts b/tests/type-definitions/pure/common/date.test.ts index c797e6a0b5f0..bed02b60a976 100644 --- a/tests/type-definitions/pure/common/date.test.ts +++ b/tests/type-definitions/pure/common/date.test.ts @@ -1,4 +1,4 @@ -import $date from '@core-js/pure/full/date/index'; +import $Date from '@core-js/pure/full/date/index'; -new $date(); -new $date('2020-01-01'); +new $Date(); +new $Date('2020-01-01'); diff --git a/tests/type-definitions/pure/proposals/array-is-template-object.test.ts b/tests/type-definitions/pure/proposals/array-is-template-object.test.ts index e31c139c373b..8dcf17c0fed5 100644 --- a/tests/type-definitions/pure/proposals/array-is-template-object.test.ts +++ b/tests/type-definitions/pure/proposals/array-is-template-object.test.ts @@ -1,6 +1,6 @@ import arrayIsTemplateObject from '@core-js/pure/full/array/is-template-object'; import objectFreeze from '@core-js/pure/full/object/freeze'; -import sym from '@core-js/pure/full/symbol/index'; +import $Symbol from '@core-js/pure/full/symbol/index'; const t: boolean = arrayIsTemplateObject([]); arrayIsTemplateObject({}); @@ -8,7 +8,7 @@ arrayIsTemplateObject(['a', 'b']); arrayIsTemplateObject(objectFreeze(['foo', 'bar'])); arrayIsTemplateObject(123); arrayIsTemplateObject('str'); -arrayIsTemplateObject(sym()); +arrayIsTemplateObject($Symbol()); declare const x: unknown; if (arrayIsTemplateObject(x)) { diff --git a/tests/type-definitions/pure/proposals/async-iteration.test.ts b/tests/type-definitions/pure/proposals/async-iteration.test.ts index 80f00e3fd7b9..888b6f1f98a5 100644 --- a/tests/type-definitions/pure/proposals/async-iteration.test.ts +++ b/tests/type-definitions/pure/proposals/async-iteration.test.ts @@ -1,8 +1,8 @@ -import $symbol from '@core-js/pure/full/symbol/index'; +import $Symbol from '@core-js/pure/full/symbol/index'; -const sym: symbol = $symbol.asyncIterator; +const sym: symbol = $Symbol.asyncIterator; // @ts-expect-error -const bad1: string = $symbol.asyncIterator; +const bad1: string = $Symbol.asyncIterator; // @ts-expect-error -$symbol['asyncIterator'] = $symbol("other"); +$Symbol['asyncIterator'] = $Symbol('other'); diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 58e06312a01a..3048dd201b5a 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -11,12 +11,13 @@ import some from '@core-js/pure/full/async-iterator/some'; import take from '@core-js/pure/full/async-iterator/take'; import toArray from '@core-js/pure/full/async-iterator/to-array'; import toAsync from '@core-js/pure/full/iterator/to-async'; -import asyncIterator from '@core-js/pure/full/async-iterator/index'; +import $AsyncIterator from '@core-js/pure/full/async-iterator'; const aiton = from([1, 2, 3]); +aiton.next(); aiton.toArray(); from(new Set([1, 2, 3])); -from((function* () { yield 3; })()); +from((function * () { yield 3; })()); const aitos = from('abc'); declare const ilb: Iterable; diff --git a/tests/type-definitions/pure/proposals/await-dictionary.test.ts b/tests/type-definitions/pure/proposals/await-dictionary.test.ts index ba7752748b2b..55df2a3d5627 100644 --- a/tests/type-definitions/pure/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/pure/proposals/await-dictionary.test.ts @@ -1,27 +1,27 @@ -import allKeyed from '@core-js/pure/full/promise/all-keyed'; -import allSettledKeyed from '@core-js/pure/full/promise/all-settled-keyed'; +import promiseAllKeyed from '@core-js/pure/full/promise/all-keyed'; +import promiseAllSettledKeyed from '@core-js/pure/full/promise/all-settled-keyed'; -const res: Promise<{ a: number, b: string, c: boolean }> = allKeyed({ +const res: Promise<{ a: number, b: string, c: boolean }> = promiseAllKeyed({ a: Promise.resolve(1), b: Promise.resolve('string'), c: Promise.resolve(true), }); const sym = Symbol('sym'); -const res2: Promise<{ [sym]: number }> = allKeyed({ +const res2: Promise<{ [sym]: number }> = promiseAllKeyed({ [sym]: Promise.resolve(1) }); // @ts-expect-error -allKeyed(); +promiseAllKeyed(); // @ts-expect-error -allKeyed({ a: 1, b: Promise.resolve(2) }); +promiseAllKeyed({ a: 1, b: Promise.resolve(2) }); // @ts-expect-error -allKeyed([ Promise.resolve(1), Promise.resolve(2) ]); +promiseAllKeyed([ Promise.resolve(1), Promise.resolve(2) ]); // @ts-expect-error -allSettledKeyed(); +promiseAllSettledKeyed(); // @ts-expect-error -allSettledKeyed({ a: 1, b: Promise.resolve(2) }); +promiseAllSettledKeyed({ a: 1, b: Promise.resolve(2) }); // @ts-expect-error -allSettledKeyed([ Promise.resolve(1), Promise.resolve(2) ]); +promiseAllSettledKeyed([ Promise.resolve(1), Promise.resolve(2) ]); diff --git a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts index f8ae808607d3..c7586c328b75 100644 --- a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts @@ -1,11 +1,11 @@ import symbolDispose from '@core-js/pure/full/symbol/dispose'; import symbolAsyncDispose from '@core-js/pure/full/symbol/async-dispose'; import symbolToStringTag from '@core-js/pure/full/symbol/to-string-tag'; -import suppressedError from '@core-js/pure/full/suppressed-error/constructor'; -import disposableStack from '@core-js/pure/full/disposable-stack/constructor'; -import asyncDisposableStack from '@core-js/pure/full/async-disposable-stack/constructor'; import iteratorRange from '@core-js/pure/full/iterator/range'; import asyncIteratorFrom from '@core-js/pure/full/async-iterator/from'; +import $SuppressedError from '@core-js/pure/full/suppressed-error/constructor'; +import $DisposableStack from '@core-js/pure/full/disposable-stack/constructor'; +import $AsyncDisposableStack from '@core-js/pure/full/async-disposable-stack/constructor'; const d: symbol = symbolDispose; const ad: symbol = symbolAsyncDispose; @@ -13,13 +13,6 @@ const ad: symbol = symbolAsyncDispose; // @ts-expect-error const wrong: number = symbolDispose; -declare type HasSymbolDispose = { - [symbolDispose]: () => void; -}; -declare type HasSymbolAsyncDispose = { - [symbolAsyncDispose]: () => void; -}; - const objD = { [symbolDispose]() { /* empty */ } }; @@ -30,21 +23,21 @@ const objAD = { } objAD[symbolAsyncDispose](); -const err1 = new suppressedError('err', 'suppressed', 'msg'); +const err1 = new $SuppressedError('err', 'suppressed', 'msg'); err1.error; err1.suppressed; const m1: string = err1.message; const _: Error = err1; -const err2 = suppressedError(123, 456); +const err2 = $SuppressedError(123, 456); err2.error; err2.suppressed; err2.message; // @ts-expect-error -new suppressedError(1, 2, 3, 4); +new $SuppressedError(1, 2, 3, 4); -const objDS = new disposableStack(); +const objDS = new $DisposableStack(); const disposed: boolean = objDS.disposed; objDS.dispose(); objDS.use(objD); @@ -67,8 +60,8 @@ objDS.move(1); // @ts-expect-error objDS[symbolToStringTag] = 'foo'; -asyncDisposableStack.prototype; -const objADS = new asyncDisposableStack(); +$AsyncDisposableStack.prototype; +const objADS = new $AsyncDisposableStack(); const disposedASD: boolean = objDS.disposed; const rda: Promise = objADS.disposeAsync(); objADS.use(objAD); diff --git a/tests/type-definitions/pure/proposals/extractors.test.ts b/tests/type-definitions/pure/proposals/extractors.test.ts index 23b64362e952..68ad75916647 100644 --- a/tests/type-definitions/pure/proposals/extractors.test.ts +++ b/tests/type-definitions/pure/proposals/extractors.test.ts @@ -1,10 +1,10 @@ -import symbolCustomMatcher from '@core-js/pure/full/symbol/custom-matcher'; -import $symbol from '@core-js/pure/full/symbol/index'; +import $customMatcher from '@core-js/pure/full/symbol/custom-matcher'; +import $Symbol from '@core-js/pure/full/symbol/index'; -const rscs1: symbol = symbolCustomMatcher; -const rscs2: typeof symbolCustomMatcher = symbolCustomMatcher; +const rscs1: symbol = $customMatcher; +const rscs2: typeof $customMatcher = $customMatcher; // @ts-expect-error -$symbol['customMatcher'] = $symbol("other"); +$Symbol['customMatcher'] = $Symbol("other"); // @ts-expect-error -const n: number = symbolCustomMatcher; +const n: number = $customMatcher; diff --git a/tests/type-definitions/pure/proposals/float16.test.ts b/tests/type-definitions/pure/proposals/float16.test.ts index 4d5c1fe0ecfa..25baff63f4d9 100644 --- a/tests/type-definitions/pure/proposals/float16.test.ts +++ b/tests/type-definitions/pure/proposals/float16.test.ts @@ -1,6 +1,6 @@ -import f16round from '@core-js/pure/full/math/f16round'; +import mathF16round from '@core-js/pure/full/math/f16round'; -const res: number = f16round(1); +const res: number = mathF16round(1); // @ts-expect-error -f16round('123'); +mathF16round('123'); diff --git a/tests/type-definitions/pure/proposals/function-demethodize.test.ts b/tests/type-definitions/pure/proposals/function-demethodize.test.ts index 82ceadb9350b..5f2ec6d8ca54 100644 --- a/tests/type-definitions/pure/proposals/function-demethodize.test.ts +++ b/tests/type-definitions/pure/proposals/function-demethodize.test.ts @@ -1,7 +1,7 @@ -import demethodize from '@core-js/pure/full/function/demethodize'; +import $demethodize from '@core-js/pure/full/function/demethodize'; function sumTo(this: { base: number }, a: number, b: number): number { return this.base + a + b; } -demethodize(sumTo); +$demethodize(sumTo); diff --git a/tests/type-definitions/pure/proposals/is-error.test.ts b/tests/type-definitions/pure/proposals/is-error.test.ts index 866e7fa85531..8eb56a0f0376 100644 --- a/tests/type-definitions/pure/proposals/is-error.test.ts +++ b/tests/type-definitions/pure/proposals/is-error.test.ts @@ -1,12 +1,12 @@ -import isError from '@core-js/pure/full/error/is-error'; +import $isError from '@core-js/pure/full/error/is-error'; const e = new Error(); const ne = { foo: 1 }; -const re1: boolean = isError(e); -isError(ne); -isError(undefined); -isError('str'); +const re1: boolean = $isError(e); +$isError(ne); +$isError(undefined); +$isError('str'); // @ts-expect-error -isError(); +$isError(); diff --git a/tests/type-definitions/pure/proposals/iterator-chunking.test.ts b/tests/type-definitions/pure/proposals/iterator-chunking.test.ts index 0cc1017e3761..f0f3d38a5025 100644 --- a/tests/type-definitions/pure/proposals/iterator-chunking.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-chunking.test.ts @@ -1,26 +1,26 @@ -import chunks from '@core-js/pure/full/iterator/chunks'; -import windows from '@core-js/pure/full/iterator/windows'; +import iteratorChunks from '@core-js/pure/full/iterator/chunks'; +import iteratorWindows from '@core-js/pure/full/iterator/windows'; declare function getNumberIterator(): Iterator; const numbersIter = getNumberIterator(); -const chunksObj: Iterator = chunks(numbersIter, 2); -const windowsObj: Iterator = windows(numbersIter, 4); +const chunksObj: Iterator = iteratorChunks(numbersIter, 2); +const windowsObj: Iterator = iteratorWindows(numbersIter, 4); const chunkNext = chunksObj.next(); const windowsNext = windowsObj.next(); // @ts-expect-error -chunks(numbersIter); +iteratorChunks(numbersIter); // @ts-expect-error -chunks(numbersIter, '2'); +iteratorChunks(numbersIter, '2'); // @ts-expect-error -chunks(numbersIter, 2, 3); +iteratorChunks(numbersIter, 2, 3); // @ts-expect-error -windows(numbersIter); +iteratorWindows(numbersIter); // @ts-expect-error -windows(numbersIter, {}); +iteratorWindows(numbersIter, {}); // @ts-expect-error -windows(numbersIter, 4, 1); +iteratorWindows(numbersIter, 4, 1); diff --git a/tests/type-definitions/pure/proposals/iterator-joint.test.ts b/tests/type-definitions/pure/proposals/iterator-joint.test.ts index 25a0cdf65d70..f132ceb083b4 100644 --- a/tests/type-definitions/pure/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-joint.test.ts @@ -1,17 +1,17 @@ -import zip from '@core-js/pure/full/iterator/zip'; -import zipKeyed from '@core-js/pure/full/iterator/zip-keyed'; +import iteratorZip from '@core-js/pure/full/iterator/zip'; +import iteratorZipKeyed from '@core-js/pure/full/iterator/zip-keyed'; -zip([[1, 2, 3], [4, 5, 6]]); -zip([['a', 'b', 'c'], ['d', 'e', 'f']]); -zip([[1, 2, 3], [4, 5, 6]], { mode: "shortest" }); -zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); -zipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: "shortest" }); +iteratorZip([[1, 2, 3], [4, 5, 6]]); +iteratorZip([['a', 'b', 'c'], ['d', 'e', 'f']]); +iteratorZip([[1, 2, 3], [4, 5, 6]], { mode: "shortest" }); +iteratorZipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); +iteratorZipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: "shortest" }); // @ts-expect-error -zip(true); +iteratorZip(true); // @ts-expect-error -zip([[1, 2, 3], [4, 5, 6]], { mode: "incorrect" }); +iteratorZip([[1, 2, 3], [4, 5, 6]], { mode: "incorrect" }); // @ts-expect-error -zipKeyed(42); +iteratorZipKeyed(42); // @ts-expect-error -zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }, { foo: "bar" }); +iteratorZipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }, { foo: "bar" }); diff --git a/tests/type-definitions/pure/proposals/iterator-range.test.ts b/tests/type-definitions/pure/proposals/iterator-range.test.ts index 247713a43dfc..a2742b07802b 100644 --- a/tests/type-definitions/pure/proposals/iterator-range.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-range.test.ts @@ -1,15 +1,15 @@ -import range from '@core-js/pure/full/iterator/range'; +import iteratorRange from '@core-js/pure/full/iterator/range'; -const rir1: Iterator = range(1, 10); -range(1, 10, 1); -range(1, 10, { step: 1 }); -range(1, 10, { inclusive: true }); +const rir1: Iterator = iteratorRange(1, 10); +iteratorRange(1, 10, 1); +iteratorRange(1, 10, { step: 1 }); +iteratorRange(1, 10, { inclusive: true }); // @ts-expect-error -range(0, 10, 'not-a-number'); +iteratorRange(0, 10, 'not-a-number'); // @ts-expect-error -range(0, 10, { inclusive: 3 }); +iteratorRange(0, 10, { inclusive: 3 }); // @ts-expect-error -range(0, 10, { step: 'smth' }); +iteratorRange(0, 10, { step: 'smth' }); // @ts-expect-error -range(0, 10, { foo: 'bar' }); +iteratorRange(0, 10, { foo: 'bar' }); diff --git a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts index 45adf848eccc..34b708962cb3 100644 --- a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts @@ -1,4 +1,4 @@ -import concat from '@core-js/pure/full/iterator/concat'; +import iteratorConcat from '@core-js/pure/full/iterator/concat'; declare const its1: Iterable; declare const arrs: string[]; @@ -6,15 +6,15 @@ declare const arrn: number[]; declare const arrb: boolean[]; declare const itb1: Iterable; -const ri1: Iterator = concat(its1); -const ri2: Iterator = concat(arrs); -const ri3: Iterator = concat(arrn); -const ri4: Iterator = concat(arrb, itb1); -const ri5: Iterator = concat(); +const ri1: Iterator = iteratorConcat(its1); +const ri2: Iterator = iteratorConcat(arrs); +const ri3: Iterator = iteratorConcat(arrn); +const ri4: Iterator = iteratorConcat(arrb, itb1); +const ri5: Iterator = iteratorConcat(); // @ts-expect-error -concat(1); +iteratorConcat(1); // @ts-expect-error -concat(true); +iteratorConcat(true); // @ts-expect-error -concat({}); +iteratorConcat({}); diff --git a/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts b/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts index fc96ad78026c..c70d5b13e15c 100644 --- a/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts +++ b/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts @@ -1,6 +1,6 @@ -import rawJSON from '@core-js/pure/full/json/raw-json'; -import isRawJSON from '@core-js/pure/full/json/is-raw-json'; -import parse from '@core-js/pure/full/json/parse'; +import $rawJSON from '@core-js/pure/full/json/raw-json'; +import $isRawJSON from '@core-js/pure/full/json/is-raw-json'; +import $parse from '@core-js/pure/full/json/parse'; declare type CoreJSRawJSON = { rawJSON: string; @@ -10,16 +10,16 @@ declare type CoreJSReviverContext = { source: string; } -const r: CoreJSRawJSON = rawJSON('{"a":123}'); +const r: CoreJSRawJSON = $rawJSON('{"a":123}'); -const isr1: boolean = isRawJSON(r); -const isr2: boolean = isRawJSON({}); -const isr3: boolean = isRawJSON('abc'); -const isr4: boolean = isRawJSON(undefined); +const isr1: boolean = $isRawJSON(r); +const isr2: boolean = $isRawJSON({}); +const isr3: boolean = $isRawJSON('abc'); +const isr4: boolean = $isRawJSON(undefined); declare const smth: unknown; -if (isRawJSON(smth)) { +if ($isRawJSON(smth)) { smth.rawJSON; const s: string = smth.rawJSON; // @ts-expect-error @@ -27,10 +27,10 @@ if (isRawJSON(smth)) { } // @ts-expect-error -rawJSON(123); +$rawJSON(123); // @ts-expect-error -rawJSON(); +$rawJSON(); -parse('{"tooBigForNumber":9007199254740993}', (key: string, value: any, context: CoreJSReviverContext) => {}); +$parse('{"tooBigForNumber":9007199254740993}', (key: string, value: any, context: CoreJSReviverContext) => {}); // @ts-expect-error -parse('{"tooBigForNumber":9007199254740993}', (key: string, value: any, context: []) => {}); +$parse('{"tooBigForNumber":9007199254740993}', (key: string, value: any, context: []) => {}); diff --git a/tests/type-definitions/pure/proposals/pattern-matching.test.ts b/tests/type-definitions/pure/proposals/pattern-matching.test.ts index 2521f4fb8732..aa13232b3450 100644 --- a/tests/type-definitions/pure/proposals/pattern-matching.test.ts +++ b/tests/type-definitions/pure/proposals/pattern-matching.test.ts @@ -1,8 +1,8 @@ -import $symbol from '@core-js/pure/full/symbol/index'; +import $Symbol from '@core-js/pure/full/symbol/index'; -const sym: symbol = $symbol.customMatcher; +const sym: symbol = $Symbol.customMatcher; // @ts-expect-error -const bad1: string = $symbol.customMatcher; +const bad1: string = $Symbol.customMatcher; // @ts-expect-error -$symbol['customMatcher'] = $symbol("other"); +$Symbol['customMatcher'] = $Symbol("other"); diff --git a/tests/type-definitions/pure/proposals/string-cooked.test.ts b/tests/type-definitions/pure/proposals/string-cooked.test.ts index 64ad5f105f4e..4178bd702f8a 100644 --- a/tests/type-definitions/pure/proposals/string-cooked.test.ts +++ b/tests/type-definitions/pure/proposals/string-cooked.test.ts @@ -1,10 +1,10 @@ -import cooked from '@core-js/pure/full/string/cooked'; +import stringCooked from '@core-js/pure/full/string/cooked'; -const rcooked1: string = cooked('foo', 1, 2, 3); -cooked(['foo', 'bar'], 1, 2); -cooked([]); +const rcooked1: string = stringCooked('foo', 1, 2, 3); +stringCooked(['foo', 'bar'], 1, 2); +stringCooked([]); // @ts-expect-error -cooked(1); +stringCooked(1); // @ts-expect-error -cooked(false); +stringCooked(false); diff --git a/tests/type-definitions/pure/proposals/string-dedent.test.ts b/tests/type-definitions/pure/proposals/string-dedent.test.ts index 6cafb975506c..5c416a9bda69 100644 --- a/tests/type-definitions/pure/proposals/string-dedent.test.ts +++ b/tests/type-definitions/pure/proposals/string-dedent.test.ts @@ -1,16 +1,16 @@ -import dedent from '@core-js/pure/full/string/dedent'; +import stringDedent from '@core-js/pure/full/string/dedent'; -const rdedent1: string = dedent`foo\nbar`; -const rdedent2: string = dedent`line1 +const rdedent1: string = stringDedent`foo\nbar`; +const rdedent2: string = stringDedent`line1 line2 line3`; const tpl = Object.assign(['foo', 'bar'], { raw: ['foo', 'bar'] }) as TemplateStringsArray; -dedent(tpl, 1, 2); +stringDedent(tpl, 1, 2); // @ts-expect-error -dedent(['foo', 'bar'], 1, 2); +stringDedent(['foo', 'bar'], 1, 2); // @ts-expect-error -dedent('foo', 1, 2); +stringDedent('foo', 1, 2); // @ts-expect-error -dedent(); +stringDedent(); diff --git a/tests/type-definitions/pure/web/url-search-params.test.ts b/tests/type-definitions/pure/web/url-search-params.test.ts index a51cdccea1e3..79702a604394 100644 --- a/tests/type-definitions/pure/web/url-search-params.test.ts +++ b/tests/type-definitions/pure/web/url-search-params.test.ts @@ -1,13 +1,13 @@ -import $urlSearchParams from '@core-js/pure/full/url-search-params/index'; +import $URLSearchParams from '@core-js/pure/full/url-search-params/index'; -const ps1 = new $urlSearchParams(); -new $urlSearchParams('a=1&b=2'); -new $urlSearchParams([['a', '1'], ['b', '2']]); -new $urlSearchParams(ps1); -new $urlSearchParams({ foo: "bar" }); +const ps1 = new $URLSearchParams(); +new $URLSearchParams('a=1&b=2'); +new $URLSearchParams([['a', '1'], ['b', '2']]); +new $URLSearchParams(ps1); +new $URLSearchParams({ foo: "bar" }); // @ts-expect-error -new $urlSearchParams(42); +new $URLSearchParams(42); ps1.append('k', 'v'); // @ts-expect-error diff --git a/tests/type-definitions/pure/web/url.test.ts b/tests/type-definitions/pure/web/url.test.ts index 0e95cd550a5e..79bada1fe969 100644 --- a/tests/type-definitions/pure/web/url.test.ts +++ b/tests/type-definitions/pure/web/url.test.ts @@ -1,7 +1,7 @@ -import $url from '@core-js/pure/full/url/index'; +import $URL from '@core-js/pure/full/url/index'; -const u1 = new $url('https://example.com/path?name=value#hash'); -new $url('/path', 'https://example.com'); +const u1 = new $URL('https://example.com/path?name=value#hash'); +new $URL('/path', 'https://example.com'); let str: string; str = u1.pathname; @@ -12,4 +12,4 @@ str = u1.toJSON(); str = u1.toString(); // @ts-expect-error -new $url(null); +new $URL(null); From 7feee80aa5e4fa540115d66e05a36bc8c256b8ce Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 6 Jan 2026 03:36:59 +0700 Subject: [PATCH 114/315] Return our own Promise type in pure types --- .../src/base/core-js-types/promise.d.ts | 58 +++++++++++++++++++ .../src/base/proposals/array-from-async.d.ts | 4 +- .../explicit-resource-management.d.ts | 2 +- .../base/proposals/promise-all-settled.d.ts | 4 +- .../src/base/proposals/promise-any.d.ts | 4 +- .../src/base/proposals/promise-finally.d.ts | 2 +- .../src/base/proposals/promise-try.d.ts | 2 +- .../proposals/promise-with-resolvers.d.ts | 2 +- .../pure/proposals/array-constructor.d.ts | 5 +- .../proposals/async-iterator-helpers.d.ts | 13 +++-- .../explicit-resource-management.d.ts | 2 +- .../src/base/pure/proposals/iterator.d.ts | 7 ++- scripts/build-types/pure.mjs | 6 ++ .../global/proposals/array-from-async.test.ts | 18 +++--- tests/type-definitions/helpers.ts | 5 ++ .../pure/proposals/array-from-async.test.ts | 16 ++--- .../proposals/async-iterator-helper.test.ts | 19 +++--- .../explicit-resource-management.test.ts | 16 ++--- .../proposals/promise-all-settled.test.ts | 27 ++++++--- .../pure/proposals/promise-any.test.ts | 19 +++--- .../pure/proposals/promise-finally.test.ts | 26 +++++---- .../pure/proposals/promise-try.test.ts | 21 +++---- .../proposals/promise-with-resolvers.test.ts | 7 ++- 23 files changed, 189 insertions(+), 96 deletions(-) create mode 100644 packages/core-js-types/src/base/core-js-types/promise.d.ts create mode 100644 tests/type-definitions/helpers.ts diff --git a/packages/core-js-types/src/base/core-js-types/promise.d.ts b/packages/core-js-types/src/base/core-js-types/promise.d.ts new file mode 100644 index 000000000000..27d60be4f39c --- /dev/null +++ b/packages/core-js-types/src/base/core-js-types/promise.d.ts @@ -0,0 +1,58 @@ +declare namespace CoreJS { + export interface CoreJSPromise extends Promise {} + + export interface CoreJSPromiseConstructor { + readonly prototype: CoreJSPromise; + + /** + * Creates a new Promise. + * @param executor A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used to resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (executor: (resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void) => void): CoreJSPromise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: T): CoreJSPromise<{ -readonly [P in keyof T]: Awaited; }>; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: T): CoreJSPromise>; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason?: any): CoreJSPromise; + + /** + * Creates a new resolved promise. + * @returns A resolved promise. + */ + resolve(): CoreJSPromise; + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T): CoreJSPromise>; + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | PromiseLike): CoreJSPromise>; + } + + var CoreJSPromise: CoreJSPromiseConstructor; +} diff --git a/packages/core-js-types/src/base/proposals/array-from-async.d.ts b/packages/core-js-types/src/base/proposals/array-from-async.d.ts index d145b047d850..a0eac4c32b63 100644 --- a/packages/core-js-types/src/base/proposals/array-from-async.d.ts +++ b/packages/core-js-types/src/base/proposals/array-from-async.d.ts @@ -9,7 +9,7 @@ interface ArrayConstructor { * Creates an array from an async iterator or iterable object. * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. */ - fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; // @type-options prefix-return-type /** * Creates an array from an async iterator or iterable object. @@ -19,5 +19,5 @@ interface ArrayConstructor { * Each return value is awaited before being added to result array. * @param thisArg Value of 'this' used when executing mapFn. */ - fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; // @type-options prefix-return-type } diff --git a/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts index 22a8d2281557..af3220e4767d 100644 --- a/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts @@ -178,7 +178,7 @@ interface AsyncDisposableStack { */ move(): AsyncDisposableStack; - [Symbol.asyncDispose](): Promise; + [Symbol.asyncDispose](): Promise; // @type-options prefix-return-type readonly [Symbol.toStringTag]: string; } diff --git a/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts index 92381bf202c0..d919489e5b88 100644 --- a/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts @@ -13,7 +13,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJS.CoreJSPromiseSettledResult>; }>; + allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJS.CoreJSPromiseSettledResult>; }>; // @type-options prefix-return-type /** * Creates a Promise that is resolved with an array of results when all @@ -21,5 +21,5 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - allSettled(values: Iterable>): Promise>[]>; + allSettled(values: Iterable>): Promise>[]>; // @type-options prefix-return-type } diff --git a/packages/core-js-types/src/base/proposals/promise-any.d.ts b/packages/core-js-types/src/base/proposals/promise-any.d.ts index 96fcd7154e8a..62f71b9577a0 100644 --- a/packages/core-js-types/src/base/proposals/promise-any.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-any.d.ts @@ -10,14 +10,14 @@ interface PromiseConstructor { * @param values An array or iterable of Promises. * @returns A new Promise. */ - any(values: T): Promise>; + any(values: T): Promise>; // @type-options prefix-return-type /** * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. * @param values An array or iterable of Promises. * @returns A new Promise. */ - any(values: Iterable>): Promise>; + any(values: Iterable>): Promise>; // @type-options prefix-return-type } interface AggregateError extends Error { // @type-options no-redefine diff --git a/packages/core-js-types/src/base/proposals/promise-finally.d.ts b/packages/core-js-types/src/base/proposals/promise-finally.d.ts index 035b3ac06a4c..6c73d23c10b4 100644 --- a/packages/core-js-types/src/base/proposals/promise-finally.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-finally.d.ts @@ -11,5 +11,5 @@ interface Promise { * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). * @returns A Promise for the completion of the callback. */ - finally(onfinally?: (() => void) | undefined | null): Promise; + finally(onfinally?: (() => void) | undefined | null): Promise; // @type-options prefix-return-type } diff --git a/packages/core-js-types/src/base/proposals/promise-try.d.ts b/packages/core-js-types/src/base/proposals/promise-try.d.ts index 1cdf7e32d228..178a3d3de67d 100644 --- a/packages/core-js-types/src/base/proposals/promise-try.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-try.d.ts @@ -18,6 +18,6 @@ interface PromiseConstructor { * - Already rejected, if the callback synchronously throws an error. * - Asynchronously fulfilled or rejected, if the callback returns a promise. */ - try(callbackFn: (...args: U) => T | PromiseLike, ...args: U): Promise>; + try(callbackFn: (...args: U) => T | PromiseLike, ...args: U): Promise>; // @type-options prefix-return-type } diff --git a/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts index b7198e7879d0..fbb80469e1f5 100644 --- a/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts @@ -5,7 +5,7 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface PromiseWithResolvers { // @type-options no-extends, no-prefix - promise: Promise; + promise: Promise; // @type-options prefix-return-type resolve: (value: T | PromiseLike) => void; diff --git a/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts b/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts index 3e2671776675..6bb842db288f 100644 --- a/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts @@ -1,4 +1,5 @@ /// +/// // Motivation: We must omit methods `fromAsync` and `isTemplateObject` because they cause a signature mismatch error. @@ -20,7 +21,7 @@ declare namespace CoreJS { * Creates an array from an async iterator or iterable object. * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. */ - fromAsync(iterableOrArrayLike: CoreJSAsyncIterable | Iterable> | ArrayLike>): Promise; + fromAsync(iterableOrArrayLike: CoreJSAsyncIterable | Iterable> | ArrayLike>): CoreJSPromise; /** * Creates an array from an async iterator or iterable object. @@ -30,7 +31,7 @@ declare namespace CoreJS { * Each return value is awaited before being added to result array. * @param thisArg Value of 'this' used when executing mapFn. */ - fromAsync(iterableOrArrayLike: CoreJSAsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; + fromAsync(iterableOrArrayLike: CoreJSAsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): CoreJSPromise[]>; /** * Determines whether an `value` is a `TemplateStringsArray` diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index fe09cca81e44..c8818d83e7a7 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -1,5 +1,6 @@ /// /// +/// // Motivation: Has dependencies on internal types, e.g. AsyncIterable, AsyncIteratorObject @@ -30,7 +31,7 @@ declare namespace CoreJS { * @param predicate A function that tests each element of the iterator * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` */ - every(predicate: (value: T, index: number) => boolean): Promise; + every(predicate: (value: T, index: number) => boolean): CoreJSPromise; /** * Creates a new `AsyncIterator` that contains only the elements that pass the `predicate` function. @@ -44,7 +45,7 @@ declare namespace CoreJS { * @param predicate A function that tests each element of the iterator * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` */ - find(predicate: (value: T, index: number) => boolean): Promise; + find(predicate: (value: T, index: number) => boolean): CoreJSPromise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. @@ -58,7 +59,7 @@ declare namespace CoreJS { * @param callbackFn A function that is called for each element of the iterator * @returns A `Promise` that resolves when all elements have been processed */ - forEach(callbackFn: (value: T, index: number) => void): Promise; + forEach(callbackFn: (value: T, index: number) => void): CoreJSPromise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. @@ -73,14 +74,14 @@ declare namespace CoreJS { * @param initialValue An optional initial value to start the reduction * @returns A `Promise` that resolves to the reduced value */ - reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; + reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): CoreJSPromise; /** * Checks if any value in the iterator matches a given `predicate` * @param predicate A function that tests each element of the iterator * @returns A `Promise` that resolves to `true` if any element passes the `predicate`, otherwise `false` */ - some(predicate: (value: T, index: number) => boolean): Promise; + some(predicate: (value: T, index: number) => boolean): CoreJSPromise; /** * Creates a new `AsyncIterator` that yields only the first `limit` elements from the original iterator. @@ -93,7 +94,7 @@ declare namespace CoreJS { * Collects all elements from the iterator into an array. * @returns A `Promise` that resolves to an array containing all elements from the iterator */ - toArray(): Promise; + toArray(): CoreJSPromise; } var CoreJSAsyncIterator: CoreJSAsyncIteratorConstructor; diff --git a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts index a6443b0e9b5e..6931268116fb 100644 --- a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts @@ -125,7 +125,7 @@ declare namespace CoreJS { /** * Disposes each resource in the stack in the reverse order that they were added. */ - disposeAsync(): Promise; + disposeAsync(): CoreJSPromise; /** * Adds a disposable resource to the stack, returning the resource. diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index ad7ab84100ab..78128a72fb02 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -1,4 +1,5 @@ /// +/// // Motivation: Has dependencies on internal types @@ -48,9 +49,9 @@ declare namespace CoreJS { } interface CoreJSAsyncIterator { - next(...[value]: [] | [TNext]): Promise>; - return?(value?: TReturn | CoreJSPromiseLike): Promise>; - throw?(e?: any): Promise>; + next(...[value]: [] | [TNext]): CoreJSPromise>; + return?(value?: TReturn | CoreJSPromiseLike): CoreJSPromise>; + throw?(e?: any): CoreJSPromise>; } export interface CoreJSAsyncIteratorObject extends CoreJSAsyncIterator {} diff --git a/scripts/build-types/pure.mjs b/scripts/build-types/pure.mjs index 36d1888d035a..f593363b6024 100644 --- a/scripts/build-types/pure.mjs +++ b/scripts/build-types/pure.mjs @@ -34,6 +34,7 @@ function parseOptions(line) { exportBaseConstructor: hasOptions && optionsStr.includes('export-base-constructor'), noExport: hasOptions && optionsStr.includes('no-export'), noRedefine: hasOptions && optionsStr.includes('no-redefine'), + prefixReturnType: hasOptions && optionsStr.includes('prefix-return-type'), }; } @@ -100,6 +101,11 @@ function processLines(lines, prefix) { `$export function ${ !options.noPrefix ? prefix : '' }$`); } + if (options.prefixReturnType) { + return line.replace(/^(?.*):\s(?[a-z_]\w*)(?<[^;]+);/i, + `$: ${ prefix }$$;`); + } + // Replace prefixed types in the entire file if (/(?::|\|)\s*\w/.test(line)) { const sortedPrefixed = prefixed.sort((a, b) => b.length - a.length); diff --git a/tests/type-definitions/global/proposals/array-from-async.test.ts b/tests/type-definitions/global/proposals/array-from-async.test.ts index fa8209bf9c1d..e035512be193 100644 --- a/tests/type-definitions/global/proposals/array-from-async.test.ts +++ b/tests/type-definitions/global/proposals/array-from-async.test.ts @@ -1,12 +1,12 @@ import 'core-js/full'; -Array.fromAsync([1, 2, 3]); -Array.fromAsync([Promise.resolve(1), 2, 3]); -Array.fromAsync((async function* () { yield 1; })()); -Array.fromAsync([1, 2, 3], (value: number, index: number) => value.toString()); -Array.fromAsync([Promise.resolve(1), 2, 3], (value: number) => value + 1); -Array.fromAsync((async function* () { yield 1; })(), function (value: number) { return value * 2; }); -Array.fromAsync([1, 2, 3], function (this: {foo: string}, value: number) { return value.toString(); }, {foo: 'str'}); +const p1: Promise = Array.fromAsync([1, 2, 3]); +const p2: Promise = Array.fromAsync([Promise.resolve(1), 2, 3]); +const p3: Promise = Array.fromAsync((async function* () { yield 1; })()); +const p4: Promise = Array.fromAsync([1, 2, 3], (value: number, index: number) => value.toString()); +const p5: Promise = Array.fromAsync([Promise.resolve(1), 2, 3], (value: number) => value + 1); +const p6: Promise = Array.fromAsync((async function* () { yield 1; })(), function (value: number) { return value * 2; }); +const p7: Promise = Array.fromAsync([1, 2, 3], function (this: { foo: string }, value: number) { return value.toString(); }, { foo: 'str' }); async function t1() { const n: number[] = await Array.fromAsync([1, 2, 3]); @@ -20,8 +20,8 @@ async function t2() { } declare const arrLike: { [index: number]: PromiseLike; length: 2 }; -Array.fromAsync(arrLike); -Array.fromAsync(arrLike, (value: number) => value); +const p8: Promise = Array.fromAsync(arrLike); +const p9: Promise = Array.fromAsync(arrLike, (value: number) => value); // @ts-expect-error Array.fromAsync([1, 2, 3], (value: string) => value); diff --git a/tests/type-definitions/helpers.ts b/tests/type-definitions/helpers.ts new file mode 100644 index 000000000000..b4b03e286651 --- /dev/null +++ b/tests/type-definitions/helpers.ts @@ -0,0 +1,5 @@ +export default interface CoreJSPromiseLike { + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; + + finally(onfinally?: (() => void) | undefined | null): PromiseLike; +} diff --git a/tests/type-definitions/pure/proposals/array-from-async.test.ts b/tests/type-definitions/pure/proposals/array-from-async.test.ts index 2a3500bf22e5..261bfdb8ab51 100644 --- a/tests/type-definitions/pure/proposals/array-from-async.test.ts +++ b/tests/type-definitions/pure/proposals/array-from-async.test.ts @@ -1,10 +1,12 @@ import arrayFromAsync from '@core-js/pure/full/array/from-async'; +import promiseResolve from '@core-js/pure/full/promise/resolve'; +import CoreJSPromiseLike from '../../helpers'; -arrayFromAsync([1, 2, 3]); -arrayFromAsync([Promise.resolve(1), 2, 3]); -arrayFromAsync([1, 2, 3], (value: number, index: number) => value.toString()); -arrayFromAsync([Promise.resolve(1), 2, 3], (value: number) => value + 1); -arrayFromAsync([1, 2, 3], function (this: { foo: string }, value: number) { return value.toString(); }, {foo: 'str'}); +const p1: CoreJSPromiseLike = arrayFromAsync([1, 2, 3]); +const p2: CoreJSPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3]); +const p3: CoreJSPromiseLike = arrayFromAsync([1, 2, 3], (value: number, index: number) => value.toString()); +const p4: CoreJSPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3], (value: number) => value + 1); +const p5: CoreJSPromiseLike = arrayFromAsync([1, 2, 3], function (this: { foo: string }, value: number) { return value.toString(); }, { foo: 'str' }); async function t1() { const n: number[] = await arrayFromAsync([1, 2, 3]); @@ -18,8 +20,8 @@ async function t2() { } declare const arrLike: { [index: number]: PromiseLike; length: 2 }; -arrayFromAsync(arrLike); -arrayFromAsync(arrLike, (value: number) => value); +const p6: CoreJSPromiseLike = arrayFromAsync(arrLike); +const p7: CoreJSPromiseLike = arrayFromAsync(arrLike, (value: number) => value); // @ts-expect-error arrayFromAsync([1, 2, 3], (value: string) => value); diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 3048dd201b5a..3f644f99720b 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -11,7 +11,8 @@ import some from '@core-js/pure/full/async-iterator/some'; import take from '@core-js/pure/full/async-iterator/take'; import toArray from '@core-js/pure/full/async-iterator/to-array'; import toAsync from '@core-js/pure/full/iterator/to-async'; -import $AsyncIterator from '@core-js/pure/full/async-iterator'; +// import $AsyncIterator from '@core-js/pure/full/async-iterator'; // todo +import CoreJSPromiseLike from '../../helpers'; const aiton = from([1, 2, 3]); aiton.next(); @@ -40,16 +41,16 @@ toAsync(is); toAsync(itn); drop(aiton, 3); -const r2: Promise = every(aiton, (v: number, i: number) => v > 0); +const r2: CoreJSPromiseLike = every(aiton, (v: number, i: number) => v > 0); filter(aiton, (v: number, i: number) => v > 0); -const r4: Promise = find(aiton, (v: number, i: number) => v > 0); +const r4: CoreJSPromiseLike = find(aiton, (v: number, i: number) => v > 0); flatMap(aiton, (v: number, i: number) => `${v}`); -const r6: Promise = forEach(aiton, (v: number, i: number) => { }); +const r6: CoreJSPromiseLike = forEach(aiton, (v: number, i: number) => { }); map(aiton, (v: number, i: number) => v * 2); -const r8: Promise = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); -const r9: Promise = some(aiton, (v: number, i: number) => v > 0); +const r8: CoreJSPromiseLike = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); +const r9: CoreJSPromiseLike = some(aiton, (v: number, i: number) => v > 0); take(aiton, 10); -const r11: Promise = toArray(aiton); +const r11: CoreJSPromiseLike = toArray(aiton); // @ts-expect-error drop(ain); @@ -74,8 +75,8 @@ take(ain); // @ts-expect-error toArray(ain, 1); -const s0: Promise = toArray(aiton); -const f0: Promise = find(aitos, (v: string, i: number) => v.length === 1); +const s0: CoreJSPromiseLike = toArray(aiton); +const f0: CoreJSPromiseLike = find(aitos, (v: string, i: number) => v.length === 1); // @ts-expect-error map(ais, (v: string, i: number) => v.length === 1, 'extra'); diff --git a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts index c7586c328b75..b7dfb2614257 100644 --- a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts @@ -1,3 +1,4 @@ +import promiseResolve from '@core-js/pure/full/promise/resolve'; import symbolDispose from '@core-js/pure/full/symbol/dispose'; import symbolAsyncDispose from '@core-js/pure/full/symbol/async-dispose'; import symbolToStringTag from '@core-js/pure/full/symbol/to-string-tag'; @@ -6,6 +7,7 @@ import asyncIteratorFrom from '@core-js/pure/full/async-iterator/from'; import $SuppressedError from '@core-js/pure/full/suppressed-error/constructor'; import $DisposableStack from '@core-js/pure/full/disposable-stack/constructor'; import $AsyncDisposableStack from '@core-js/pure/full/async-disposable-stack/constructor'; +import CoreJSPromiseLike from '../../helpers'; const d: symbol = symbolDispose; const ad: symbol = symbolAsyncDispose; @@ -19,9 +21,9 @@ const objD = { objD[symbolDispose](); const objAD = { - [symbolAsyncDispose]() { return Promise.resolve(); } + [symbolAsyncDispose]() { return promiseResolve(); } } -objAD[symbolAsyncDispose](); +const p1: CoreJSPromiseLike = objAD[symbolAsyncDispose](); const err1 = new $SuppressedError('err', 'suppressed', 'msg'); err1.error; @@ -63,19 +65,19 @@ objDS[symbolToStringTag] = 'foo'; $AsyncDisposableStack.prototype; const objADS = new $AsyncDisposableStack(); const disposedASD: boolean = objDS.disposed; -const rda: Promise = objADS.disposeAsync(); +const rda: CoreJSPromiseLike = objADS.disposeAsync(); objADS.use(objAD); objADS.use(objD); const ruseASD3: null = objADS.use(null); const ruseASD4: undefined = objADS.use(undefined); const radoptASD1: string = objADS.adopt('foo', (value: string) => { /* empty */ }); const radoptASD2: string = objADS.adopt('foo', async (value: string) => { /* empty */ }); -const radoptASD3: string = objADS.adopt('foo', (value: string) => Promise.resolve()); -const radoptASD4: string = objADS.adopt('foo', async (value: string) => Promise.resolve()); +const radoptASD3: string = objADS.adopt('foo', (value: string) => promiseResolve()); +const radoptASD4: string = objADS.adopt('foo', async (value: string) => promiseResolve()); objADS.defer(() => { /* empty */ }); objADS.defer(async () => { /* empty */ }); -objADS.defer(() => Promise.resolve()); -objADS.defer(async () => Promise.resolve()); +objADS.defer(() => promiseResolve()); +objADS.defer(async () => promiseResolve()); objADS.move(); objADS[symbolAsyncDispose](); const rtsASD1: string = objADS[symbolToStringTag]; diff --git a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts index 0269297a97cf..a3cd0922b499 100644 --- a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts @@ -1,20 +1,29 @@ import promiseAllSettled from '@core-js/pure/full/promise/all-settled'; import promiseResolve from '@core-js/pure/full/promise/resolve'; +import CoreJSPromiseLike from '../../helpers'; + +interface CoreJSPromiseResult { + status: string; + value?: T; + reason?: any; +} -promiseResolve(1); -promiseResolve('foo'); const promiseLike = { then: (cb: (val: number) => void) => cb(42) }; -promiseAllSettled([promiseResolve(10), promiseResolve(20), 30]); -promiseAllSettled(['a', 'b', 'c']); -promiseAllSettled(new Set([1, 2, 3])); +const p1: CoreJSPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = + promiseAllSettled([promiseResolve(10), promiseResolve(20), 30]); +const p2: CoreJSPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = + promiseAllSettled(['a', 'b', 'c']); +const p3: CoreJSPromiseLike[]> = + promiseAllSettled(new Set([1, 2, 3])); promiseAllSettled([promiseLike]); const emptyTuple: [] = []; -const settled6: Promise<[]> = promiseAllSettled(emptyTuple); +const settled6: CoreJSPromiseLike<[]> = promiseAllSettled(emptyTuple); -const mixedTuple = [42, promiseResolve("bar")] as const; -promiseAllSettled(mixedTuple); +const mixedTuple = [42, promiseResolve('bar')] as const; +const p4: CoreJSPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult]> = + promiseAllSettled(mixedTuple); // @ts-expect-error promiseAllSettled(); @@ -29,4 +38,4 @@ promiseAllSettled({ foo: 123 }); promiseAllSettled([1, 2], 123); // @ts-expect-error -promiseAllSettled([promiseResolve(1)], "extra"); +promiseAllSettled([promiseResolve(1)], 'extra'); diff --git a/tests/type-definitions/pure/proposals/promise-any.test.ts b/tests/type-definitions/pure/proposals/promise-any.test.ts index cf089a60c736..61e12d8dd89c 100644 --- a/tests/type-definitions/pure/proposals/promise-any.test.ts +++ b/tests/type-definitions/pure/proposals/promise-any.test.ts @@ -1,5 +1,6 @@ import promiseAny from '@core-js/pure/full/promise/any'; import promiseResolve from '@core-js/pure/full/promise/resolve'; +import CoreJSPromiseLike from '../../helpers'; const arr = [promiseResolve(1), promiseResolve("foo"), 3] as const; const justNumbers = [1, 2, 3]; @@ -8,16 +9,16 @@ const promiseLike = { then: (cb: (val: number) => void) => cb(123) }; const emptyTuple: [] = []; const mixed = [true, promiseResolve("z")] as const; -const any1: Promise = promiseAny(arr); -const any2: Promise = promiseAny(["x", "y", promiseResolve(5)]); -const any3: Promise = promiseAny(emptyTuple); -const any4: Promise = promiseAny(mixed); +const any1: CoreJSPromiseLike = promiseAny(arr); +const any2: CoreJSPromiseLike = promiseAny(["x", "y", promiseResolve(5)]); +const any3: CoreJSPromiseLike = promiseAny(emptyTuple); +const any4: CoreJSPromiseLike = promiseAny(mixed); -const any5: Promise = promiseAny(justNumbers); -const any6: Promise = promiseAny(setOfStrings); -const any7: Promise = promiseAny([promiseLike]); -const any8: Promise = promiseAny(new Set([1])); -const any9: Promise = promiseAny([promiseResolve()]); +const any5: CoreJSPromiseLike = promiseAny(justNumbers); +const any6: CoreJSPromiseLike = promiseAny(setOfStrings); +const any7: CoreJSPromiseLike = promiseAny([promiseLike]); +const any8: CoreJSPromiseLike = promiseAny(new Set([1])); +const any9: CoreJSPromiseLike = promiseAny([promiseResolve()]); // @ts-expect-error promiseAny(); diff --git a/tests/type-definitions/pure/proposals/promise-finally.test.ts b/tests/type-definitions/pure/proposals/promise-finally.test.ts index 4a87a582bbb6..f585c6276cb8 100644 --- a/tests/type-definitions/pure/proposals/promise-finally.test.ts +++ b/tests/type-definitions/pure/proposals/promise-finally.test.ts @@ -1,16 +1,20 @@ import promiseFinally from '@core-js/pure/full/promise/finally'; import promiseResolve from '@core-js/pure/full/promise/resolve'; - -const p1 = promiseResolve(42); -const pf1: Promise = promiseFinally(p1); -const pf2: Promise = promiseFinally(p1, undefined); -const pf3: Promise = promiseFinally(p1, null); -const pf4: Promise = promiseFinally(p1, () => {}); -const pf5: Promise = promiseFinally(p1, function () {}); - -const p2 = Promise.reject("err"); -const pf6: Promise = promiseFinally(p2); -const pf7: Promise = promiseFinally(p2, () => {}); +import promiseReject from '@core-js/pure/full/promise/reject'; +import CoreJSPromiseLike from '../../helpers'; + +const pr1: CoreJSPromiseLike = promiseResolve(42); +declare const p1: Promise; +const pf1: CoreJSPromiseLike = promiseFinally(p1); +const pf2: CoreJSPromiseLike = promiseFinally(p1, undefined); +const pf3: CoreJSPromiseLike = promiseFinally(p1, null); +const pf4: CoreJSPromiseLike = promiseFinally(p1, () => {}); +const pf5: CoreJSPromiseLike = promiseFinally(p1, function () {}); + +const pr2: CoreJSPromiseLike = promiseReject("err"); +declare const p2: Promise; +const pf6: CoreJSPromiseLike = promiseFinally(p2); +const pf7: CoreJSPromiseLike = promiseFinally(p2, () => {}); // @ts-expect-error promiseFinally(p1, 123); diff --git a/tests/type-definitions/pure/proposals/promise-try.test.ts b/tests/type-definitions/pure/proposals/promise-try.test.ts index a2c17d6777b3..9832e9be3ae3 100644 --- a/tests/type-definitions/pure/proposals/promise-try.test.ts +++ b/tests/type-definitions/pure/proposals/promise-try.test.ts @@ -1,18 +1,19 @@ import promiseTry from '@core-js/pure/full/promise/try'; import promiseResolve from '@core-js/pure/full/promise/resolve'; +import CoreJSPromiseLike from '../../helpers'; -const pt1: Promise = promiseTry(() => 42); -const pt2: Promise = promiseTry(() => promiseResolve("hi")); -const pt3: Promise = promiseTry((a: number, b: number) => a + b, 1, 2); -const pt4: Promise = promiseTry((x: string) => x + "!!", "test"); -const pt5: Promise = promiseTry(() => {}); -const pt6: Promise = promiseTry((b: boolean) => b, false); +const pt1: CoreJSPromiseLike = promiseTry(() => 42); +const pt2: CoreJSPromiseLike = promiseTry(() => promiseResolve("hi")); +const pt3: CoreJSPromiseLike = promiseTry((a: number, b: number) => a + b, 1, 2); +const pt4: CoreJSPromiseLike = promiseTry((x: string) => x + "!!", "test"); +const pt5: CoreJSPromiseLike = promiseTry(() => {}); +const pt6: CoreJSPromiseLike = promiseTry((b: boolean) => b, false); -const pt7: Promise = promiseTry((a: number, b: string, c: boolean) => c ? a : Number(b), 10, "100", true); -const pt8: Promise = promiseTry((a: string) => promiseResolve(a), "bar"); +const pt7: CoreJSPromiseLike = promiseTry((a: number, b: string, c: boolean) => c ? a : Number(b), 10, "100", true); +const pt8: CoreJSPromiseLike = promiseTry((a: string) => promiseResolve(a), "bar"); -declare function returnsPromise(): Promise; -const pt9: Promise = promiseTry(() => returnsPromise()); +declare function returnsPromise(): CoreJSPromiseLike; +const pt9: CoreJSPromiseLike = promiseTry(() => returnsPromise()); // @ts-expect-error promiseTry(); diff --git a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts index 1099f757b7c7..20810fc8a7ca 100644 --- a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts +++ b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts @@ -1,13 +1,14 @@ import promiseWithResolvers from '@core-js/pure/full/promise/with-resolvers'; import promiseResolve from '@core-js/pure/full/promise/resolve'; +import CoreJSPromiseLike from '../../helpers'; const pr = promiseWithResolvers(); const pr2 = promiseWithResolvers(); const pr3 = promiseWithResolvers(); -const p1: Promise = pr.promise; -const p2: Promise = pr2.promise; -const p3: Promise = pr3.promise; +const p1: CoreJSPromiseLike = pr.promise; +const p2: CoreJSPromiseLike = pr2.promise; +const p3: CoreJSPromiseLike = pr3.promise; pr.resolve(42); pr.resolve(promiseResolve(43)); From 6263fcf60daf3468583ede649d573f732a2cffdc Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 7 Jan 2026 03:53:05 +0700 Subject: [PATCH 115/315] Return our own types in pure types --- .../src/base/core-js-types/map.d.ts | 13 +++ .../src/base/core-js-types/set.d.ts | 10 ++ .../src/base/core-js-types/weak-map.d.ts | 12 ++ .../src/base/core-js-types/weak-set.d.ts | 11 ++ .../src/base/proposals/array-grouping.d.ts | 2 +- .../src/base/proposals/set-methods.d.ts | 16 +-- .../pure/proposals/collection-of-from.d.ts | 105 ++++++++++++++++++ .../pure/proposals/set-methods-custom.d.ts | 23 ++++ .../src/base/pure/web/url-parse.d.ts | 4 +- scripts/build-types/index.mjs | 2 +- scripts/build-types/pure.mjs | 5 +- tests/type-definitions/helpers.ts | 26 ++++- .../pure/proposals/array-from-async.test.ts | 2 +- .../pure/proposals/array-grouping.test.ts | 5 +- .../proposals/async-iterator-helper.test.ts | 2 +- .../pure/proposals/collection-of-from.test.ts | 29 ++--- .../explicit-resource-management.test.ts | 2 +- .../proposals/promise-all-settled.test.ts | 2 +- .../pure/proposals/promise-any.test.ts | 2 +- .../pure/proposals/promise-finally.test.ts | 2 +- .../pure/proposals/promise-try.test.ts | 2 +- .../proposals/promise-with-resolvers.test.ts | 2 +- .../pure/proposals/set-methods.test.ts | 28 ++--- 23 files changed, 253 insertions(+), 54 deletions(-) create mode 100644 packages/core-js-types/src/base/core-js-types/map.d.ts create mode 100644 packages/core-js-types/src/base/core-js-types/set.d.ts create mode 100644 packages/core-js-types/src/base/core-js-types/weak-map.d.ts create mode 100644 packages/core-js-types/src/base/core-js-types/weak-set.d.ts create mode 100644 packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts create mode 100644 packages/core-js-types/src/base/pure/proposals/set-methods-custom.d.ts diff --git a/packages/core-js-types/src/base/core-js-types/map.d.ts b/packages/core-js-types/src/base/core-js-types/map.d.ts new file mode 100644 index 000000000000..a28355695788 --- /dev/null +++ b/packages/core-js-types/src/base/core-js-types/map.d.ts @@ -0,0 +1,13 @@ +declare namespace CoreJS { + export interface CoreJSMap extends Map {} + + export interface CoreJSMapConstructor { + readonly prototype: CoreJSMap; + + new (): CoreJSMap; + new (entries?: readonly (readonly [K, V])[] | null): CoreJSMap; + new (iterable?: Iterable | null): CoreJSMap; + } + + var CoreJSMap: CoreJSMapConstructor; +} diff --git a/packages/core-js-types/src/base/core-js-types/set.d.ts b/packages/core-js-types/src/base/core-js-types/set.d.ts new file mode 100644 index 000000000000..e501da3b4ce0 --- /dev/null +++ b/packages/core-js-types/src/base/core-js-types/set.d.ts @@ -0,0 +1,10 @@ +declare namespace CoreJS { + export interface CoreJSSet extends Set {} + + export interface CoreJSSetConstructor extends SetConstructor { + new (values?: readonly T[] | null): CoreJSSet; + readonly prototype: CoreJSSet; + } + + var CoreJSSet: CoreJSSetConstructor; +} diff --git a/packages/core-js-types/src/base/core-js-types/weak-map.d.ts b/packages/core-js-types/src/base/core-js-types/weak-map.d.ts new file mode 100644 index 000000000000..cb97584d169f --- /dev/null +++ b/packages/core-js-types/src/base/core-js-types/weak-map.d.ts @@ -0,0 +1,12 @@ +declare namespace CoreJS { + export interface CoreJSWeakMap extends WeakMap {} + + export interface CoreJSWeakMapConstructor { + readonly prototype: CoreJSWeakMap; + + new (entries?: readonly (readonly [K, V])[] | null): CoreJSWeakMap; + new (iterable: Iterable): CoreJSWeakMap; + } + + var CoreJSWeakMap: CoreJSWeakMapConstructor; +} diff --git a/packages/core-js-types/src/base/core-js-types/weak-set.d.ts b/packages/core-js-types/src/base/core-js-types/weak-set.d.ts new file mode 100644 index 000000000000..5f938a34fc49 --- /dev/null +++ b/packages/core-js-types/src/base/core-js-types/weak-set.d.ts @@ -0,0 +1,11 @@ +declare namespace CoreJS { + export interface CoreJSWeakSet extends WeakSet {} + + export interface CoreJSWeakSetConstructor extends WeakSetConstructor { + readonly prototype: CoreJSWeakSet; + + new (values?: readonly T[] | null): CoreJSWeakSet; + } + + var CoreJSWeakSet: CoreJSWeakSetConstructor; +} diff --git a/packages/core-js-types/src/base/proposals/array-grouping.d.ts b/packages/core-js-types/src/base/proposals/array-grouping.d.ts index 8d1d9c51511e..c37f9ca26dbf 100644 --- a/packages/core-js-types/src/base/proposals/array-grouping.d.ts +++ b/packages/core-js-types/src/base/proposals/array-grouping.d.ts @@ -20,5 +20,5 @@ interface MapConstructor { * @param items An iterable. * @param keySelector A callback which will be invoked for each item in items. */ - groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Map; + groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Map; // @type-options prefix-return-type } diff --git a/packages/core-js-types/src/base/proposals/set-methods.d.ts b/packages/core-js-types/src/base/proposals/set-methods.d.ts index d01c64a3d2a1..c0c8c90e62a6 100644 --- a/packages/core-js-types/src/base/proposals/set-methods.d.ts +++ b/packages/core-js-types/src/base/proposals/set-methods.d.ts @@ -25,22 +25,22 @@ interface Set { // @type-options no-redefine /** * @returns a new Set containing all the elements in this Set and also all the elements in the argument. */ - union(other: ReadonlySetLike): Set; + union(other: ReadonlySetLike): Set; // @type-options prefix-return-type /** * @returns a new Set containing all the elements which are both in this Set and in the argument. */ - intersection(other: ReadonlySetLike): Set; + intersection(other: ReadonlySetLike): Set; // @type-options prefix-return-type /** * @returns a new Set containing all the elements in this Set which are not also in the argument. */ - difference(other: ReadonlySetLike): Set; + difference(other: ReadonlySetLike): Set; // @type-options prefix-return-type /** * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. */ - symmetricDifference(other: ReadonlySetLike): Set; + symmetricDifference(other: ReadonlySetLike): Set; // @type-options prefix-return-type /** * @returns a boolean indicating whether all the elements in this Set are also in the argument. @@ -62,22 +62,22 @@ interface ReadonlySet { // @type-options no-redefine /** * @returns a new Set containing all the elements in this Set and also all the elements in the argument. */ - union(other: ReadonlySetLike): Set; + union(other: ReadonlySetLike): Set; // @type-options prefix-return-type /** * @returns a new Set containing all the elements which are both in this Set and in the argument. */ - intersection(other: ReadonlySetLike): Set; + intersection(other: ReadonlySetLike): Set; // @type-options prefix-return-type /** * @returns a new Set containing all the elements in this Set which are not also in the argument. */ - difference(other: ReadonlySetLike): Set; + difference(other: ReadonlySetLike): Set; // @type-options prefix-return-type /** * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. */ - symmetricDifference(other: ReadonlySetLike): Set; + symmetricDifference(other: ReadonlySetLike): Set; // @type-options prefix-return-type /** * @returns a boolean indicating whether all the elements in this Set are also in the argument. diff --git a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts new file mode 100644 index 000000000000..dbabf1c37057 --- /dev/null +++ b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts @@ -0,0 +1,105 @@ +/// +/// +/// +/// + +// Motivation: import our own Map/Set/WeakMap/WeakSet types & redefine return types + +// https://github.com/tc39/proposal-setmap-offrom + +declare namespace CoreJS { + export interface CoreJSMapConstructor extends MapConstructor { + + /** + * Creates a new `Map` instance from an iterable or array-like object of [key, value] pairs. + * Optionally, applies a mapping function to each pair. + * @param source Iterable or array-like object of [key, value] pairs. + * @param mapFn Function to call on every [key, value] pair before adding to the `Map`. + * @param thisArg Value to use as this when executing mapFn. + * @return A new `Map` instance. + */ + from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): CoreJS.CoreJSMap; + + /** + * Creates a new `Map` instance from a variable number of arguments, + * where each pair of arguments is interpreted as a key and a value. + * @param items An even number of arguments representing key-value pairs. + * @return A new `Map` instance. + */ + of(...items: [K, V][]): CoreJS.CoreJSMap; + } + + var CoreJSMap: CoreJSMapConstructor; + + + export interface CoreJSSetConstructor extends SetConstructor { + + /** + * Creates a new `Set` instance from an iterable or array-like object of [key, value] pairs. + * Optionally, applies a mapping function to each pair. + * @param source Iterable or array-like object of [key, value] pairs. + * @param mapFn Function to call on every [key, value] pair before adding to the `Set`. + * @param thisArg Value to use as this when executing mapFn. + * @return A new `Set` instance. + */ + from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): CoreJS.CoreJSSet; + + /** + * Creates a new `Set` instance from a variable number of arguments, + * where each pair of arguments is interpreted as a key and a value. + * @param items An even number of arguments representing key-value pairs. + * @return A new `Set` instance. + */ + of(...items: T[]): CoreJS.CoreJSSet; + } + + var CoreJSSet: CoreJSSetConstructor; + + + export interface CoreJSWeakMapConstructor extends WeakMapConstructor { + + /** + * Creates a new `WeakMap` instance from an iterable or array-like object of [key, value] pairs. + * Optionally, applies a mapping function to each pair. + * @param source Iterable or array-like object of [key, value] pairs. + * @param mapFn Function to call on every [key, value] pair before adding to the `WeakMap`. + * @param thisArg Value to use as this when executing mapFn. + * @return A new `WeakMap` instance. + */ + from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): CoreJS.CoreJSWeakMap; + + /** + * Creates a new `WeakMap` instance from a variable number of arguments, + * where each pair of arguments is interpreted as a key and a value. + * @param items An even number of arguments representing key-value pairs. + * @return A new `Weak` instance. + */ + of(...items: [K, V][]): CoreJS.CoreJSWeakMap; + } + + var CoreJSWeakMap: CoreJSWeakMapConstructor; + + + export interface CoreJSWeakSetConstructor extends WeakSetConstructor { + + /** + * Creates a new `WeakSet` instance from an iterable or array-like object of [key, value] pairs. + * Optionally, applies a mapping function to each pair. + * @param source Iterable or array-like object of [key, value] pairs. + * @param mapFn Function to call on every [key, value] pair before adding to the `WeakSet`. + * @param thisArg Value to use as this when executing mapFn. + * @return A new `WeakSet` instance. + */ + from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): CoreJS.CoreJSWeakSet; + + /** + * Creates a new `WeakSet` instance from a variable number of arguments, + * where each pair of arguments is interpreted as a key and a value. + * @param items An even number of arguments representing key-value pairs. + * @return A new `WeakSet` instance. + */ + of(...items: T[]): CoreJS.CoreJSWeakSet; + } + + var CoreJSWeakSet: CoreJSWeakSetConstructor; +} diff --git a/packages/core-js-types/src/base/pure/proposals/set-methods-custom.d.ts b/packages/core-js-types/src/base/pure/proposals/set-methods-custom.d.ts new file mode 100644 index 000000000000..a21a82be77e7 --- /dev/null +++ b/packages/core-js-types/src/base/pure/proposals/set-methods-custom.d.ts @@ -0,0 +1,23 @@ +/// + +// Motivation: Custom type needed to keep generics strict & return our CoreJSSet type + +// https://github.com/tc39/proposal-set-methods + +// For ensuring compatibility with TypeScript standard types, this code is aligned with: +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + interface ReadonlySetLike { + keys(): Iterator; + + has(value: T): boolean; + + readonly size: number; + } + + export type SetUnion = (other: ReadonlySetLike) => CoreJS.CoreJSSet; + + export type SetSymmetricDifference = (other: ReadonlySetLike) => CoreJS.CoreJSSet; +} diff --git a/packages/core-js-types/src/base/pure/web/url-parse.d.ts b/packages/core-js-types/src/base/pure/web/url-parse.d.ts index 53469fb170a6..92c42199fbe3 100644 --- a/packages/core-js-types/src/base/pure/web/url-parse.d.ts +++ b/packages/core-js-types/src/base/pure/web/url-parse.d.ts @@ -1,7 +1,5 @@ /// declare namespace CoreJS { - export interface CoreJSURLConstructor { - parse(url: string | CoreJSURL, base?: string | CoreJSURL): CoreJSURL | null; - } + export type URLParse = (url: string | CoreJSURL, base?: string | CoreJSURL) => CoreJSURL | null; } diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 05fbaf38ffea..e145d9a8d559 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -85,7 +85,7 @@ async function buildType(entry, options) { if (customType) { imports.index.add(customType); imports[subset].add(customType); - imports.pure.add(customType); + imports.pure.add(path.join('pure', customType)); } options = { ...options, modules, level, entry, types }; diff --git a/scripts/build-types/pure.mjs b/scripts/build-types/pure.mjs index f593363b6024..45c3dc56270a 100644 --- a/scripts/build-types/pure.mjs +++ b/scripts/build-types/pure.mjs @@ -103,7 +103,7 @@ function processLines(lines, prefix) { if (options.prefixReturnType) { return line.replace(/^(?.*):\s(?[a-z_]\w*)(?<[^;]+);/i, - `$: ${ prefix }$$;`); + `$: ${ prefix }.${ prefix }$$;`); } // Replace prefixed types in the entire file @@ -188,9 +188,8 @@ export async function preparePureTypes(typesPath, initialPath) { const content = await fs.readFile(typePath, 'utf8'); - if (content.includes('declare namespace')) continue; + const result = (content.includes('declare namespace')) ? content : wrapInNamespace(content); - const result = wrapInNamespace(content); await outputFile(resultFilePath, result); } } diff --git a/tests/type-definitions/helpers.ts b/tests/type-definitions/helpers.ts index b4b03e286651..0d2c6f7fa89f 100644 --- a/tests/type-definitions/helpers.ts +++ b/tests/type-definitions/helpers.ts @@ -1,5 +1,29 @@ -export default interface CoreJSPromiseLike { +export interface CoreJSPromiseLike { then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; finally(onfinally?: (() => void) | undefined | null): PromiseLike; } + +export interface CoreJSMapLike extends Map { + getOrInsert(key: K, value: V): V; + + getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; +} + +export interface CoreJSWeakMapLike extends WeakMap { + getOrInsert(key: K, value: V): V; + + getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; +} + +export interface CoreJSSetLike extends Set { + union(...args: any[]): CoreJSSetLike; + intersection(...args: any[]): CoreJSSetLike; + difference(...args: any[]): CoreJSSetLike; + symmetricDifference(...args: any[]): CoreJSSetLike; + isSubsetOf(...args: any[]): boolean; + isSupersetOf(...args: any[]): boolean; + isDisjointFrom(...args: any[]): boolean; +} + +export interface CoreJSWeakSetLike extends WeakSet {} diff --git a/tests/type-definitions/pure/proposals/array-from-async.test.ts b/tests/type-definitions/pure/proposals/array-from-async.test.ts index 261bfdb8ab51..12265e8762c1 100644 --- a/tests/type-definitions/pure/proposals/array-from-async.test.ts +++ b/tests/type-definitions/pure/proposals/array-from-async.test.ts @@ -1,6 +1,6 @@ import arrayFromAsync from '@core-js/pure/full/array/from-async'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import CoreJSPromiseLike from '../../helpers'; +import { CoreJSPromiseLike } from '../../helpers'; const p1: CoreJSPromiseLike = arrayFromAsync([1, 2, 3]); const p2: CoreJSPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3]); diff --git a/tests/type-definitions/pure/proposals/array-grouping.test.ts b/tests/type-definitions/pure/proposals/array-grouping.test.ts index 4ccb5b12e3d7..6da5d624772d 100644 --- a/tests/type-definitions/pure/proposals/array-grouping.test.ts +++ b/tests/type-definitions/pure/proposals/array-grouping.test.ts @@ -1,11 +1,12 @@ import objectGroupBy from '@core-js/pure/full/object/group-by'; import mapGroupBy from '@core-js/pure/full/map/group-by'; +import { CoreJSMapLike } from '../../helpers'; const arr = [1, 2, 3, 4, 5]; const objGroup: Partial> = objectGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); -const mapGroup: Map<'even' | 'odd', number[]> = mapGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); +const mapGroup: CoreJSMapLike<'even' | 'odd', number[]> = mapGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); const objGroup2: Partial> = objectGroupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); -const mapGroup2: Map = mapGroupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); +const mapGroup2: CoreJSMapLike = mapGroupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); objectGroupBy('test', c => c); objectGroupBy(new Set([1, 2, 3]), item => item > 2 ? 'big' : 'small'); diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 3f644f99720b..08655abcaf97 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -12,7 +12,7 @@ import take from '@core-js/pure/full/async-iterator/take'; import toArray from '@core-js/pure/full/async-iterator/to-array'; import toAsync from '@core-js/pure/full/iterator/to-async'; // import $AsyncIterator from '@core-js/pure/full/async-iterator'; // todo -import CoreJSPromiseLike from '../../helpers'; +import { CoreJSPromiseLike } from '../../helpers'; const aiton = from([1, 2, 3]); aiton.next(); diff --git a/tests/type-definitions/pure/proposals/collection-of-from.test.ts b/tests/type-definitions/pure/proposals/collection-of-from.test.ts index 61f9bc00a8c6..47ba7a8c5426 100644 --- a/tests/type-definitions/pure/proposals/collection-of-from.test.ts +++ b/tests/type-definitions/pure/proposals/collection-of-from.test.ts @@ -6,9 +6,10 @@ import weakMapFrom from '@core-js/pure/full/weak-map/from'; import weakMapOf from '@core-js/pure/full/weak-map/of'; import weakSetFrom from '@core-js/pure/full/weak-set/from'; import weakSetOf from '@core-js/pure/full/weak-set/of'; +import { CoreJSMapLike, CoreJSSetLike, CoreJSWeakMapLike, CoreJSWeakSetLike } from '../../helpers'; -const rm: Map = mapFrom([[1, 'a'], [2, 'b']] as [number, string][]); -const rm2: Map = mapFrom([[1, 10], [2, 20]] as [number, number][], (v: number, k: number) => v + k); +const rm: CoreJSMapLike = mapFrom([[1, 'a'], [2, 'b']] as [number, string][]); +const rm2: CoreJSMapLike = mapFrom([[1, 10], [2, 20]] as [number, number][], (v: number, k: number) => v + k); mapFrom([[1, 10], [2, 20]] as [number, number][], function (this: { n: number }, v: number) { return v + this.n; }, { n: 2 }); // @ts-expect-error mapFrom([['a', 1], ['b', 2]], (v: string, k: number) => v); @@ -18,28 +19,28 @@ mapFrom([1, 2]); mapFrom(); mapOf(['a', 1], ['b', 2]); -const rm4: Map = mapOf(['a', 1], ['b', 2]); +const rm4: CoreJSMapLike = mapOf(['a', 1], ['b', 2]); // @ts-expect-error mapOf([1, 2, 3]); // @ts-expect-error mapOf(1, 2); -const rs1: Set = setFrom([1, 2, 3]); -const rs2: Set = setFrom([1, 2, 3], x => x.toString()); -const rs3: Set<[string, number]> = setFrom([['a', 1], ['b', 2]]); +const rs1: CoreJSSetLike = setFrom([1, 2, 3]); +const rs2: CoreJSSetLike = setFrom([1, 2, 3], x => x.toString()); +const rs3: CoreJSSetLike<[string, number]> = setFrom([['a', 1], ['b', 2]]); setFrom(['a', 'b'], function (this: { s: string }, value: string) { return value + this.s; }, { s: '-' }); // @ts-expect-error setFrom([1, 2, 3], (v: string) => v); // @ts-expect-error setFrom(); -const rso1: Set = setOf(1, 2, 3); -const rso2: Set = setOf('a', 'b', 'c'); +const rso1: CoreJSSetLike = setOf(1, 2, 3); +const rso2: CoreJSSetLike = setOf('a', 'b', 'c'); // @ts-expect-error setOf({ 'foo': 'bar' }, 2); -const rwm1: WeakMap<{ a: number }, string> = weakMapFrom([[{ a: 1 }, 'x']] as [{ a: number }, string][]); -const rwm2: WeakMap = weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], (v, k) => v.toString()); +const rwm1: CoreJSWeakMapLike<{ a: number }, string> = weakMapFrom([[{ a: 1 }, 'x']] as [{ a: number }, string][]); +const rwm2: CoreJSWeakMapLike = weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], (v, k) => v.toString()); weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], function (this: { s: string }, v: number) { return this.s + v; }, { s: '-' }); // @ts-expect-error weakMapFrom([[1, 2], [2, 3]]); @@ -50,14 +51,14 @@ weakMapFrom([1, 2]); // @ts-expect-error weakMapFrom(); -const rwmo1: WeakMap = weakMapOf([{}, 2]); +const rwmo1: CoreJSWeakMapLike = weakMapOf([{}, 2]); // @ts-expect-error weakMapOf([1, 2]); // @ts-expect-error weakMapOf({}); -const rws1: WeakSet = weakSetFrom([{}]); -const rws2: WeakSet = weakSetFrom([{}, {}], x => x); +const rws1: CoreJSWeakSetLike = weakSetFrom([{}]); +const rws2: CoreJSWeakSetLike = weakSetFrom([{}, {}], x => x); weakSetFrom([{}], function (this: { s: string }, obj: object) { return obj; }, { s: '-' }); // @ts-expect-error weakSetFrom([1, 2]); @@ -68,6 +69,6 @@ weakSetFrom(); // @ts-expect-error weakSetFrom([{}], x => 'not-an-object'); -const rwso1: WeakSet = weakSetOf({}); +const rwso1: CoreJSWeakSetLike = weakSetOf({}); // @ts-expect-error weakSetOf(1); diff --git a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts index b7dfb2614257..071dbfa890bd 100644 --- a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts @@ -7,7 +7,7 @@ import asyncIteratorFrom from '@core-js/pure/full/async-iterator/from'; import $SuppressedError from '@core-js/pure/full/suppressed-error/constructor'; import $DisposableStack from '@core-js/pure/full/disposable-stack/constructor'; import $AsyncDisposableStack from '@core-js/pure/full/async-disposable-stack/constructor'; -import CoreJSPromiseLike from '../../helpers'; +import { CoreJSPromiseLike } from '../../helpers'; const d: symbol = symbolDispose; const ad: symbol = symbolAsyncDispose; diff --git a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts index a3cd0922b499..eb9e4daa16f8 100644 --- a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts @@ -1,6 +1,6 @@ import promiseAllSettled from '@core-js/pure/full/promise/all-settled'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import CoreJSPromiseLike from '../../helpers'; +import { CoreJSPromiseLike } from '../../helpers'; interface CoreJSPromiseResult { status: string; diff --git a/tests/type-definitions/pure/proposals/promise-any.test.ts b/tests/type-definitions/pure/proposals/promise-any.test.ts index 61e12d8dd89c..18b5b0296b28 100644 --- a/tests/type-definitions/pure/proposals/promise-any.test.ts +++ b/tests/type-definitions/pure/proposals/promise-any.test.ts @@ -1,6 +1,6 @@ import promiseAny from '@core-js/pure/full/promise/any'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import CoreJSPromiseLike from '../../helpers'; +import { CoreJSPromiseLike } from '../../helpers'; const arr = [promiseResolve(1), promiseResolve("foo"), 3] as const; const justNumbers = [1, 2, 3]; diff --git a/tests/type-definitions/pure/proposals/promise-finally.test.ts b/tests/type-definitions/pure/proposals/promise-finally.test.ts index f585c6276cb8..98daf59e0c47 100644 --- a/tests/type-definitions/pure/proposals/promise-finally.test.ts +++ b/tests/type-definitions/pure/proposals/promise-finally.test.ts @@ -1,7 +1,7 @@ import promiseFinally from '@core-js/pure/full/promise/finally'; import promiseResolve from '@core-js/pure/full/promise/resolve'; import promiseReject from '@core-js/pure/full/promise/reject'; -import CoreJSPromiseLike from '../../helpers'; +import { CoreJSPromiseLike } from '../../helpers'; const pr1: CoreJSPromiseLike = promiseResolve(42); declare const p1: Promise; diff --git a/tests/type-definitions/pure/proposals/promise-try.test.ts b/tests/type-definitions/pure/proposals/promise-try.test.ts index 9832e9be3ae3..d14b4924342e 100644 --- a/tests/type-definitions/pure/proposals/promise-try.test.ts +++ b/tests/type-definitions/pure/proposals/promise-try.test.ts @@ -1,6 +1,6 @@ import promiseTry from '@core-js/pure/full/promise/try'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import CoreJSPromiseLike from '../../helpers'; +import { CoreJSPromiseLike } from '../../helpers'; const pt1: CoreJSPromiseLike = promiseTry(() => 42); const pt2: CoreJSPromiseLike = promiseTry(() => promiseResolve("hi")); diff --git a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts index 20810fc8a7ca..b8693b8002a2 100644 --- a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts +++ b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts @@ -1,6 +1,6 @@ import promiseWithResolvers from '@core-js/pure/full/promise/with-resolvers'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import CoreJSPromiseLike from '../../helpers'; +import { CoreJSPromiseLike } from '../../helpers'; const pr = promiseWithResolvers(); const pr2 = promiseWithResolvers(); diff --git a/tests/type-definitions/pure/proposals/set-methods.test.ts b/tests/type-definitions/pure/proposals/set-methods.test.ts index 6755602f7324..a00e184bdd09 100644 --- a/tests/type-definitions/pure/proposals/set-methods.test.ts +++ b/tests/type-definitions/pure/proposals/set-methods.test.ts @@ -1,3 +1,4 @@ +import $Set from '@core-js/pure/full/set'; import setUnion from '@core-js/pure/full/set/union'; import setIntersection from '@core-js/pure/full/set/intersection'; import setDifference from '@core-js/pure/full/set/difference'; @@ -5,9 +6,10 @@ import setSymmetricDifference from '@core-js/pure/full/set/symmetric-difference' import setIsSubsetOf from '@core-js/pure/full/set/is-subset-of'; import setIsSupersetOf from '@core-js/pure/full/set/is-superset-of'; import setIsDisjointFrom from '@core-js/pure/full/set/is-disjoint-from'; +import { CoreJSSetLike } from '../../helpers'; -const setA = new Set([1, 2, 3]); -const setB = new Set(['a', 'b', 'c']); +const setA = new $Set([1, 2, 3]); +const setB = new $Set(['a', 'b', 'c']); const setLike = { keys() { return [1, 2, 3][Symbol.iterator](); }, @@ -21,20 +23,20 @@ const setLikeStr = { size: 2 }; -const unionAB: Set = setUnion(setA, setB); -const unionAL: Set = setUnion(setA, setLike); -const unionALS: Set = setUnion(setA, setLikeStr); +const unionAB: CoreJSSetLike = setUnion(setA, setB); +const unionAL: CoreJSSetLike = setUnion(setA, setLike); +const unionALS: CoreJSSetLike = setUnion(setA, setLikeStr); -const interAB: Set = setIntersection(setA, setB); -const interAN: Set = setIntersection(setA, setLike); -const intersectionALS: Set = setIntersection(setA, setLikeStr); +const interAB: CoreJSSetLike = setIntersection(setA, setB); +const interAN: CoreJSSetLike = setIntersection(setA, setLike); +const intersectionALS: CoreJSSetLike = setIntersection(setA, setLikeStr); -const diffAB: Set = setDifference(setA, setB); -const diffAN: Set = setDifference(setA, setLike); -const diffALS: Set = setDifference(setA, setLikeStr); +const diffAB: CoreJSSetLike = setDifference(setA, setB); +const diffAN: CoreJSSetLike = setDifference(setA, setLike); +const diffALS: CoreJSSetLike = setDifference(setA, setLikeStr); -const symdiffAB: Set = setSymmetricDifference(setA, setB); -const symdiffAL: Set = setSymmetricDifference(setA, setLike); +const symdiffAB: CoreJSSetLike = setSymmetricDifference(setA, setB); +const symdiffAL: CoreJSSetLike = setSymmetricDifference(setA, setLike); const sub: boolean = setIsSubsetOf(setA, setLikeStr); const superSet: boolean = setIsSupersetOf(setA, setLikeStr); From 9f81aed4ebc3f196c10dcdf1c2d9d6b307f6ef01 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 7 Jan 2026 03:59:43 +0700 Subject: [PATCH 116/315] Fix package-lock.json --- tests/eslint/package-lock.json | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tests/eslint/package-lock.json b/tests/eslint/package-lock.json index e1a94fcb1653..f17ad719c99f 100644 --- a/tests/eslint/package-lock.json +++ b/tests/eslint/package-lock.json @@ -439,8 +439,7 @@ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@types/json-schema": { "version": "7.0.15", @@ -762,7 +761,6 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -879,7 +877,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -1254,7 +1251,6 @@ "integrity": "sha512-20MV9SUdeN6Jd84xESsKhRly+/vxI+hwvpBMA93s+9dAcjdCuCojn4IqUGS3lvVaqjVYGYHSRMCpeFtF2rQYxQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", @@ -2486,7 +2482,6 @@ "integrity": "sha512-75EA7EWZExL/j+MDKQrRbdzcRI2HOkRlmUw8fZJc1ioqFEOvBsq7Rt+A6yCxOt9w/TYNpkt52gC6nm/g5tFIng==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "acorn": "^8.5.0", "eslint-visitor-keys": "^5.0.0", @@ -4249,7 +4244,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -4334,7 +4328,6 @@ "dev": true, "hasInstallScript": true, "license": "MIT", - "peer": true, "dependencies": { "napi-postinstall": "^0.3.0" }, From 0841bae408d0cd8022e6520e1989b0f679de2424 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 8 Jan 2026 02:16:17 +0700 Subject: [PATCH 117/315] Update ts type definitions site docs --- docs/web/docs/typescript-type-definitions.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/web/docs/typescript-type-definitions.md b/docs/web/docs/typescript-type-definitions.md index 5433ca384282..74ec6ca385c1 100644 --- a/docs/web/docs/typescript-type-definitions.md +++ b/docs/web/docs/typescript-type-definitions.md @@ -21,7 +21,7 @@ and `DOM` lib for the global version if you use something related (see [DOM type { "compilerOptions": { "lib": [ - "es6", + "es2025", "dom" ], "types": [ @@ -77,7 +77,7 @@ or import them directly in your files: import '@core-js/types/proposals/joint-iteration'; import '@core-js/types/web/structured-clone'; ``` -You can find types for specific features on the corresponding pages in the [documentation](https://core-js.io/v4/docs/). +You can find types for specific features on the corresponding pages in the [documentation]({docs-version}/docs/). ## Types for the pure version ### Base usage @@ -86,7 +86,7 @@ Add this to your `tsconfig.json`, keeping in mind that ES types (at least ES6) a { "compilerOptions": { "lib": [ - "es6" + "es2025" ], "types": [ "@core-js/types/pure" @@ -121,7 +121,7 @@ You need to add DOM types to the `lib` section of your `tsconfig.json` in additi "@core-js/types" ], "lib": [ - "esnext", + "es2025", "dom" ] } From 9a2d824a95d15e16cd9ba7494a52ddd69e824024 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 8 Jan 2026 03:08:38 +0700 Subject: [PATCH 118/315] Add motivation for old TS types --- .../proposals/async-iterator-helpers.d.ts | 2 + .../explicit-resource-management.d.ts | 4 +- .../src/ts5-2/proposals/iterator-helpers.d.ts | 76 ++++++++++++++++++- .../src/ts5-2/proposals/string-match-all.d.ts | 28 +++---- .../src/ts5-2/pure/proposals/iterator.d.ts | 8 +- 5 files changed, 98 insertions(+), 20 deletions(-) diff --git a/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts index ae3f8e563cc8..cc233d25ade1 100644 --- a/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts @@ -1,3 +1,5 @@ +// Motivation: AsyncIterator had different signatures until TS 5.7 + // https://github.com/tc39/proposal-async-iterator-helpers interface AsyncIteratorConstructor { diff --git a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts index 6aa09f24df78..ce173a996beb 100644 --- a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts @@ -1,3 +1,5 @@ +// Motivation: IteratorObject, AsyncIteratorObject, and AsyncIterator had different signatures until TS 5.7 + // https://github.com/tc39/proposal-explicit-resource-management // For ensuring compatibility with TypeScript standard types, this code is aligned with: @@ -124,7 +126,7 @@ interface AsyncDisposableStack { /** * Disposes each resource in the stack in the reverse order that they were added. */ - disposeAsync(): Promise; + disposeAsync(): Promise; // @type-options prefix-return-type /** * Adds a disposable resource to the stack, returning the resource. diff --git a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts index 0e913c1faacb..a72c23651942 100644 --- a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts @@ -1,4 +1,5 @@ -// proposal stage: 4 +// Motivation: Iterable until TS 5.6 used only one type parameter + // https://github.com/tc39/proposal-iterator-helpers // For ensuring compatibility with TypeScript standard types, this code is aligned with: @@ -9,34 +10,103 @@ import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; declare global { interface Iterator { + /** + * Creates an iterator whose values are the result of applying the callback to the values from this iterator. + * @param callbackfn A function that accepts up to two arguments to be used to transform values from the underlying iterator. + */ map(callbackfn: (value: T, index: number) => U): CoreJSIteratorObject; + /** + * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. + * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + */ filter(predicate: (value: T, index: number) => value is S): CoreJSIteratorObject; + /** + * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. + * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + */ filter(predicate: (value: T, index: number) => unknown): CoreJSIteratorObject; + /** + * Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached. + * @param limit The maximum number of values to yield. + */ take(limit: number): CoreJSIteratorObject; + /** + * Creates an iterator whose values are the values from this iterator after skipping the provided count. + * @param count The number of values to drop. + */ drop(count: number): CoreJSIteratorObject; - flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; // ts < 5.6 Iterable + /** + * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. + * @param callback A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. + */ + flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. + */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. + */ reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; + /** + * Creates a new array from the values yielded by this iterator. + */ toArray(): T[]; + /** + * Performs the specified action for each element in the iterator. + * @param callbackfn A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. + */ forEach(callbackfn: (value: T, index: number) => void): void; + /** + * Determines whether the specified callback function returns true for any element of this iterator. + * @param predicate A function that accepts up to two arguments. The `some` method calls + * the predicate function for each element in this iterator until the predicate returns a value + * true, or until the end of the iterator. + */ some(predicate: (value: T, index: number) => unknown): boolean; + /** + * Determines whether all the members of this iterator satisfy the specified test. + * @param predicate A function that accepts up to two arguments. The every method calls + * the predicate function for each element in this iterator until the predicate returns + * false, or until the end of this iterator. + */ every(predicate: (value: T, index: number) => unknown): boolean; + /** + * Returns the value of the first element in this iterator where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of this iterator, in + * 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. + */ find(predicate: (value: T, index: number) => value is S): S | undefined; find(predicate: (value: T, index: number) => unknown): T | undefined; } - interface IteratorConstructor { + interface IteratorConstructor { // @type-options no-extends + /** + * Creates a native iterator from an iterator or iterable object. + * Returns its input if the input already inherits from the built-in Iterator class. + * @param value An iterator or iterable object to convert a native iterator. + */ from(value: Iterator | Iterable): CoreJSIteratorObject; } diff --git a/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts index 505d7d7b6289..544c84df57ed 100644 --- a/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts @@ -1,22 +1,24 @@ -// proposal stage: 4 +// Motivation: BuiltinIteratorReturn available only from TS 5.6 + // https://github.com/tc39/proposal-string-matchall // For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -declare global { - interface RegExpStringIterator extends IteratorObject { - [Symbol.iterator](): RegExpStringIterator; - } - - interface String { - matchAll(regexp: RegExp): RegExpStringIterator; - } +interface RegExpStringIterator extends IteratorObject { + [Symbol.iterator](): RegExpStringIterator; +} - interface SymbolConstructor { - readonly matchAll: unique symbol; - } +interface String { + /** + * Matches a string with a regular expression, and returns an iterable of matches + * containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + matchAll(regexp: RegExp): RegExpStringIterator; } -export {}; +interface SymbolConstructor { + readonly matchAll: unique symbol; +} diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index 49fcb8278dbb..231bcfdc2afa 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -1,6 +1,8 @@ /// +/// // Motivation: Has dependencies on internal types +// Motivation: Iterable until TS 5.6 used only one type parameter // proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-chunking @@ -48,9 +50,9 @@ declare namespace CoreJS { } interface CoreJSAsyncIterator { - next(...[value]: [] | [TNext]): Promise>; - return?(value?: TReturn | CoreJSPromiseLike): Promise>; - throw?(e?: any): Promise>; + next(...[value]: [] | [TNext]): CoreJS.CoreJSPromise>; + return?(value?: TReturn | CoreJSPromiseLike): CoreJS.CoreJSPromise>; + throw?(e?: any): CoreJS.CoreJSPromise>; } export interface CoreJSAsyncIteratorObject extends CoreJSAsyncIterator {} From ff2417258e1b2da7580447b4ee44701f9239947a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 8 Jan 2026 22:10:09 +0700 Subject: [PATCH 119/315] Check promise like types --- tests/type-definitions/helpers.ts | 19 ++++++++++++++ .../pure/proposals/array-from-async.test.ts | 16 ++++++------ .../proposals/async-iterator-helper.test.ts | 18 ++++++------- .../pure/proposals/await-dictionary.test.ts | 25 +++++++++++-------- .../explicit-resource-management.test.ts | 6 ++--- .../proposals/promise-all-settled.test.ts | 12 ++++----- .../pure/proposals/promise-any.test.ts | 20 +++++++-------- .../pure/proposals/promise-finally.test.ts | 20 +++++++-------- .../pure/proposals/promise-try.test.ts | 22 ++++++++-------- .../proposals/promise-with-resolvers.test.ts | 8 +++--- 10 files changed, 94 insertions(+), 72 deletions(-) diff --git a/tests/type-definitions/helpers.ts b/tests/type-definitions/helpers.ts index 0d2c6f7fa89f..040dc8ae37c7 100644 --- a/tests/type-definitions/helpers.ts +++ b/tests/type-definitions/helpers.ts @@ -4,6 +4,8 @@ export interface CoreJSPromiseLike { finally(onfinally?: (() => void) | undefined | null): PromiseLike; } +export type AnyPromiseLike = CoreJSPromiseLike | Promise; + export interface CoreJSMapLike extends Map { getOrInsert(key: K, value: V): V; @@ -27,3 +29,20 @@ export interface CoreJSSetLike extends Set { } export interface CoreJSWeakSetLike extends WeakSet {} + +export interface CoreJSIteratorLike extends Iterator { + chunks(...args: any[]): CoreJSIteratorLike; + windows(...args: any[]): CoreJSIteratorLike; + map(...args: any[]): CoreJSIteratorLike; + filter(...args: any[]): CoreJSIteratorLike; + take(...args: any[]): CoreJSIteratorLike; + drop(...args: any[]): CoreJSIteratorLike; + flatMap(...args: any[]): CoreJSIteratorLike; + reduce(...args: any[]): CoreJSIteratorLike; + toArray(): T[]; + forEach(...args: any[]): void; + some(...args: any[]): boolean; + every(...args: any[]): boolean; + find(...args: any[]): T | undefined; + join(...args: any[]): string; +} diff --git a/tests/type-definitions/pure/proposals/array-from-async.test.ts b/tests/type-definitions/pure/proposals/array-from-async.test.ts index 12265e8762c1..30af1e2c0784 100644 --- a/tests/type-definitions/pure/proposals/array-from-async.test.ts +++ b/tests/type-definitions/pure/proposals/array-from-async.test.ts @@ -1,12 +1,12 @@ import arrayFromAsync from '@core-js/pure/full/array/from-async'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseLike } from '../../helpers'; +import { AnyPromiseLike } from '../../helpers'; -const p1: CoreJSPromiseLike = arrayFromAsync([1, 2, 3]); -const p2: CoreJSPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3]); -const p3: CoreJSPromiseLike = arrayFromAsync([1, 2, 3], (value: number, index: number) => value.toString()); -const p4: CoreJSPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3], (value: number) => value + 1); -const p5: CoreJSPromiseLike = arrayFromAsync([1, 2, 3], function (this: { foo: string }, value: number) { return value.toString(); }, { foo: 'str' }); +const p1: AnyPromiseLike = arrayFromAsync([1, 2, 3]); +const p2: AnyPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3]); +const p3: AnyPromiseLike = arrayFromAsync([1, 2, 3], (value: number, index: number) => value.toString()); +const p4: AnyPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3], (value: number) => value + 1); +const p5: AnyPromiseLike = arrayFromAsync([1, 2, 3], function (this: { foo: string }, value: number) { return value.toString(); }, { foo: 'str' }); async function t1() { const n: number[] = await arrayFromAsync([1, 2, 3]); @@ -20,8 +20,8 @@ async function t2() { } declare const arrLike: { [index: number]: PromiseLike; length: 2 }; -const p6: CoreJSPromiseLike = arrayFromAsync(arrLike); -const p7: CoreJSPromiseLike = arrayFromAsync(arrLike, (value: number) => value); +const p6: AnyPromiseLike = arrayFromAsync(arrLike); +const p7: AnyPromiseLike = arrayFromAsync(arrLike, (value: number) => value); // @ts-expect-error arrayFromAsync([1, 2, 3], (value: string) => value); diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 08655abcaf97..b7f3eb88a1b7 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -12,7 +12,7 @@ import take from '@core-js/pure/full/async-iterator/take'; import toArray from '@core-js/pure/full/async-iterator/to-array'; import toAsync from '@core-js/pure/full/iterator/to-async'; // import $AsyncIterator from '@core-js/pure/full/async-iterator'; // todo -import { CoreJSPromiseLike } from '../../helpers'; +import { AnyPromiseLike } from '../../helpers'; const aiton = from([1, 2, 3]); aiton.next(); @@ -41,16 +41,16 @@ toAsync(is); toAsync(itn); drop(aiton, 3); -const r2: CoreJSPromiseLike = every(aiton, (v: number, i: number) => v > 0); +const r2: AnyPromiseLike = every(aiton, (v: number, i: number) => v > 0); filter(aiton, (v: number, i: number) => v > 0); -const r4: CoreJSPromiseLike = find(aiton, (v: number, i: number) => v > 0); +const r4: AnyPromiseLike = find(aiton, (v: number, i: number) => v > 0); flatMap(aiton, (v: number, i: number) => `${v}`); -const r6: CoreJSPromiseLike = forEach(aiton, (v: number, i: number) => { }); +const r6: AnyPromiseLike = forEach(aiton, (v: number, i: number) => { }); map(aiton, (v: number, i: number) => v * 2); -const r8: CoreJSPromiseLike = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); -const r9: CoreJSPromiseLike = some(aiton, (v: number, i: number) => v > 0); +const r8: AnyPromiseLike = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); +const r9: AnyPromiseLike = some(aiton, (v: number, i: number) => v > 0); take(aiton, 10); -const r11: CoreJSPromiseLike = toArray(aiton); +const r11: AnyPromiseLike = toArray(aiton); // @ts-expect-error drop(ain); @@ -75,8 +75,8 @@ take(ain); // @ts-expect-error toArray(ain, 1); -const s0: CoreJSPromiseLike = toArray(aiton); -const f0: CoreJSPromiseLike = find(aitos, (v: string, i: number) => v.length === 1); +const s0: AnyPromiseLike = toArray(aiton); +const f0: AnyPromiseLike = find(aitos, (v: string, i: number) => v.length === 1); // @ts-expect-error map(ais, (v: string, i: number) => v.length === 1, 'extra'); diff --git a/tests/type-definitions/pure/proposals/await-dictionary.test.ts b/tests/type-definitions/pure/proposals/await-dictionary.test.ts index 55df2a3d5627..b5f4f272d135 100644 --- a/tests/type-definitions/pure/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/pure/proposals/await-dictionary.test.ts @@ -1,27 +1,30 @@ import promiseAllKeyed from '@core-js/pure/full/promise/all-keyed'; import promiseAllSettledKeyed from '@core-js/pure/full/promise/all-settled-keyed'; +import promiseResolve from '@core-js/pure/full/promise/resolve'; +import $Symbol from '@core-js/pure/full/symbol'; +import { AnyPromiseLike } from '../../helpers'; -const res: Promise<{ a: number, b: string, c: boolean }> = promiseAllKeyed({ - a: Promise.resolve(1), - b: Promise.resolve('string'), - c: Promise.resolve(true), +const res: AnyPromiseLike<{ a: number, b: string, c: boolean }> = promiseAllKeyed({ + a: promiseResolve(1), + b: promiseResolve('string'), + c: promiseResolve(true), }); -const sym = Symbol('sym'); -const res2: Promise<{ [sym]: number }> = promiseAllKeyed({ - [sym]: Promise.resolve(1) +const sym = $Symbol('sym'); +const res2: AnyPromiseLike<{ [sym]: number }> = promiseAllKeyed({ + [sym]: promiseResolve(1) }); // @ts-expect-error promiseAllKeyed(); // @ts-expect-error -promiseAllKeyed({ a: 1, b: Promise.resolve(2) }); +promiseAllKeyed({ a: 1, b: promiseResolve(2) }); // @ts-expect-error -promiseAllKeyed([ Promise.resolve(1), Promise.resolve(2) ]); +promiseAllKeyed([ promiseResolve(1), promiseResolve(2) ]); // @ts-expect-error promiseAllSettledKeyed(); // @ts-expect-error -promiseAllSettledKeyed({ a: 1, b: Promise.resolve(2) }); +promiseAllSettledKeyed({ a: 1, b: promiseResolve(2) }); // @ts-expect-error -promiseAllSettledKeyed([ Promise.resolve(1), Promise.resolve(2) ]); +promiseAllSettledKeyed([ promiseResolve(1), promiseResolve(2) ]); diff --git a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts index 071dbfa890bd..20974b658bee 100644 --- a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts @@ -7,7 +7,7 @@ import asyncIteratorFrom from '@core-js/pure/full/async-iterator/from'; import $SuppressedError from '@core-js/pure/full/suppressed-error/constructor'; import $DisposableStack from '@core-js/pure/full/disposable-stack/constructor'; import $AsyncDisposableStack from '@core-js/pure/full/async-disposable-stack/constructor'; -import { CoreJSPromiseLike } from '../../helpers'; +import { AnyPromiseLike } from '../../helpers'; const d: symbol = symbolDispose; const ad: symbol = symbolAsyncDispose; @@ -23,7 +23,7 @@ objD[symbolDispose](); const objAD = { [symbolAsyncDispose]() { return promiseResolve(); } } -const p1: CoreJSPromiseLike = objAD[symbolAsyncDispose](); +const p1: AnyPromiseLike = objAD[symbolAsyncDispose](); const err1 = new $SuppressedError('err', 'suppressed', 'msg'); err1.error; @@ -65,7 +65,7 @@ objDS[symbolToStringTag] = 'foo'; $AsyncDisposableStack.prototype; const objADS = new $AsyncDisposableStack(); const disposedASD: boolean = objDS.disposed; -const rda: CoreJSPromiseLike = objADS.disposeAsync(); +const rda: AnyPromiseLike = objADS.disposeAsync(); objADS.use(objAD); objADS.use(objD); const ruseASD3: null = objADS.use(null); diff --git a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts index eb9e4daa16f8..eb14804a0e2e 100644 --- a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts @@ -1,6 +1,6 @@ import promiseAllSettled from '@core-js/pure/full/promise/all-settled'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseLike } from '../../helpers'; +import { AnyPromiseLike } from '../../helpers'; interface CoreJSPromiseResult { status: string; @@ -10,19 +10,19 @@ interface CoreJSPromiseResult { const promiseLike = { then: (cb: (val: number) => void) => cb(42) }; -const p1: CoreJSPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = +const p1: AnyPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = promiseAllSettled([promiseResolve(10), promiseResolve(20), 30]); -const p2: CoreJSPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = +const p2: AnyPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = promiseAllSettled(['a', 'b', 'c']); -const p3: CoreJSPromiseLike[]> = +const p3: AnyPromiseLike[]> = promiseAllSettled(new Set([1, 2, 3])); promiseAllSettled([promiseLike]); const emptyTuple: [] = []; -const settled6: CoreJSPromiseLike<[]> = promiseAllSettled(emptyTuple); +const settled6: AnyPromiseLike<[]> = promiseAllSettled(emptyTuple); const mixedTuple = [42, promiseResolve('bar')] as const; -const p4: CoreJSPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult]> = +const p4: AnyPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult]> = promiseAllSettled(mixedTuple); // @ts-expect-error diff --git a/tests/type-definitions/pure/proposals/promise-any.test.ts b/tests/type-definitions/pure/proposals/promise-any.test.ts index 18b5b0296b28..bb6d18b814ab 100644 --- a/tests/type-definitions/pure/proposals/promise-any.test.ts +++ b/tests/type-definitions/pure/proposals/promise-any.test.ts @@ -1,6 +1,6 @@ import promiseAny from '@core-js/pure/full/promise/any'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseLike } from '../../helpers'; +import { AnyPromiseLike } from '../../helpers'; const arr = [promiseResolve(1), promiseResolve("foo"), 3] as const; const justNumbers = [1, 2, 3]; @@ -9,16 +9,16 @@ const promiseLike = { then: (cb: (val: number) => void) => cb(123) }; const emptyTuple: [] = []; const mixed = [true, promiseResolve("z")] as const; -const any1: CoreJSPromiseLike = promiseAny(arr); -const any2: CoreJSPromiseLike = promiseAny(["x", "y", promiseResolve(5)]); -const any3: CoreJSPromiseLike = promiseAny(emptyTuple); -const any4: CoreJSPromiseLike = promiseAny(mixed); +const any1: AnyPromiseLike = promiseAny(arr); +const any2: AnyPromiseLike = promiseAny(["x", "y", promiseResolve(5)]); +const any3: AnyPromiseLike = promiseAny(emptyTuple); +const any4: AnyPromiseLike = promiseAny(mixed); -const any5: CoreJSPromiseLike = promiseAny(justNumbers); -const any6: CoreJSPromiseLike = promiseAny(setOfStrings); -const any7: CoreJSPromiseLike = promiseAny([promiseLike]); -const any8: CoreJSPromiseLike = promiseAny(new Set([1])); -const any9: CoreJSPromiseLike = promiseAny([promiseResolve()]); +const any5: AnyPromiseLike = promiseAny(justNumbers); +const any6: AnyPromiseLike = promiseAny(setOfStrings); +const any7: AnyPromiseLike = promiseAny([promiseLike]); +const any8: AnyPromiseLike = promiseAny(new Set([1])); +const any9: AnyPromiseLike = promiseAny([promiseResolve()]); // @ts-expect-error promiseAny(); diff --git a/tests/type-definitions/pure/proposals/promise-finally.test.ts b/tests/type-definitions/pure/proposals/promise-finally.test.ts index 98daf59e0c47..5913aa8d9779 100644 --- a/tests/type-definitions/pure/proposals/promise-finally.test.ts +++ b/tests/type-definitions/pure/proposals/promise-finally.test.ts @@ -1,20 +1,20 @@ import promiseFinally from '@core-js/pure/full/promise/finally'; import promiseResolve from '@core-js/pure/full/promise/resolve'; import promiseReject from '@core-js/pure/full/promise/reject'; -import { CoreJSPromiseLike } from '../../helpers'; +import { AnyPromiseLike } from '../../helpers'; -const pr1: CoreJSPromiseLike = promiseResolve(42); +const pr1: AnyPromiseLike = promiseResolve(42); declare const p1: Promise; -const pf1: CoreJSPromiseLike = promiseFinally(p1); -const pf2: CoreJSPromiseLike = promiseFinally(p1, undefined); -const pf3: CoreJSPromiseLike = promiseFinally(p1, null); -const pf4: CoreJSPromiseLike = promiseFinally(p1, () => {}); -const pf5: CoreJSPromiseLike = promiseFinally(p1, function () {}); +const pf1: AnyPromiseLike = promiseFinally(p1); +const pf2: AnyPromiseLike = promiseFinally(p1, undefined); +const pf3: AnyPromiseLike = promiseFinally(p1, null); +const pf4: AnyPromiseLike = promiseFinally(p1, () => {}); +const pf5: AnyPromiseLike = promiseFinally(p1, function () {}); -const pr2: CoreJSPromiseLike = promiseReject("err"); +const pr2: AnyPromiseLike = promiseReject("err"); declare const p2: Promise; -const pf6: CoreJSPromiseLike = promiseFinally(p2); -const pf7: CoreJSPromiseLike = promiseFinally(p2, () => {}); +const pf6: AnyPromiseLike = promiseFinally(p2); +const pf7: AnyPromiseLike = promiseFinally(p2, () => {}); // @ts-expect-error promiseFinally(p1, 123); diff --git a/tests/type-definitions/pure/proposals/promise-try.test.ts b/tests/type-definitions/pure/proposals/promise-try.test.ts index d14b4924342e..9b801374669d 100644 --- a/tests/type-definitions/pure/proposals/promise-try.test.ts +++ b/tests/type-definitions/pure/proposals/promise-try.test.ts @@ -1,19 +1,19 @@ import promiseTry from '@core-js/pure/full/promise/try'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseLike } from '../../helpers'; +import { AnyPromiseLike } from '../../helpers'; -const pt1: CoreJSPromiseLike = promiseTry(() => 42); -const pt2: CoreJSPromiseLike = promiseTry(() => promiseResolve("hi")); -const pt3: CoreJSPromiseLike = promiseTry((a: number, b: number) => a + b, 1, 2); -const pt4: CoreJSPromiseLike = promiseTry((x: string) => x + "!!", "test"); -const pt5: CoreJSPromiseLike = promiseTry(() => {}); -const pt6: CoreJSPromiseLike = promiseTry((b: boolean) => b, false); +const pt1: AnyPromiseLike = promiseTry(() => 42); +const pt2: AnyPromiseLike = promiseTry(() => promiseResolve("hi")); +const pt3: AnyPromiseLike = promiseTry((a: number, b: number) => a + b, 1, 2); +const pt4: AnyPromiseLike = promiseTry((x: string) => x + "!!", "test"); +const pt5: AnyPromiseLike = promiseTry(() => {}); +const pt6: AnyPromiseLike = promiseTry((b: boolean) => b, false); -const pt7: CoreJSPromiseLike = promiseTry((a: number, b: string, c: boolean) => c ? a : Number(b), 10, "100", true); -const pt8: CoreJSPromiseLike = promiseTry((a: string) => promiseResolve(a), "bar"); +const pt7: AnyPromiseLike = promiseTry((a: number, b: string, c: boolean) => c ? a : Number(b), 10, "100", true); +const pt8: AnyPromiseLike = promiseTry((a: string) => promiseResolve(a), "bar"); -declare function returnsPromise(): CoreJSPromiseLike; -const pt9: CoreJSPromiseLike = promiseTry(() => returnsPromise()); +declare function returnsPromise(): AnyPromiseLike; +const pt9: AnyPromiseLike = promiseTry(() => returnsPromise()); // @ts-expect-error promiseTry(); diff --git a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts index b8693b8002a2..b87d817290e4 100644 --- a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts +++ b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts @@ -1,14 +1,14 @@ import promiseWithResolvers from '@core-js/pure/full/promise/with-resolvers'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseLike } from '../../helpers'; +import { AnyPromiseLike } from '../../helpers'; const pr = promiseWithResolvers(); const pr2 = promiseWithResolvers(); const pr3 = promiseWithResolvers(); -const p1: CoreJSPromiseLike = pr.promise; -const p2: CoreJSPromiseLike = pr2.promise; -const p3: CoreJSPromiseLike = pr3.promise; +const p1: AnyPromiseLike = pr.promise; +const p2: AnyPromiseLike = pr2.promise; +const p3: AnyPromiseLike = pr3.promise; pr.resolve(42); pr.resolve(promiseResolve(43)); From 787a95f4c3c499b447adab2c9a81b44764f51f28 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 8 Jan 2026 22:43:11 +0700 Subject: [PATCH 120/315] Change returning types from Iterable to IterableIterator --- .../base/web/iterable-dom-collections.d.ts | 72 +++++++++---------- .../web/iterable-dom-collections.test.ts | 12 ++-- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts index d6b950923a61..960b6afbbb8d 100644 --- a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts +++ b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts @@ -18,19 +18,19 @@ interface DOMTokenList { // @type-options no-export /** * Returns an iterable of keys in the DOMTokenList. */ - keys(): Iterable; + keys(): IterableIterator; /** * Returns an iterable of values in the DOMTokenList. */ - values(): Iterable; + values(): IterableIterator; /** * Returns an iterable of key, value pairs in the DOMTokenList. */ - entries(): Iterable<[number, Element]>; + entries(): IterableIterator<[number, Element]>; - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface NodeList { // @type-options no-export @@ -48,85 +48,85 @@ interface NodeList { // @type-options no-export /** * Returns an iterable of keys in the NodeList. */ - keys(): Iterable; + keys(): IterableIterator; /** * Returns an iterable of values in the NodeList. */ - values(): Iterable; + values(): IterableIterator; /** * Returns an iterable of key, value pairs in the NodeList. */ - entries(): Iterable<[number, Node]>; + entries(): IterableIterator<[number, Node]>; /** * Returns an iterable of values in the NodeList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface CSSRuleList { // @type-options no-export /** * Returns an iterable of values in the CSSRuleList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface CSSStyleDeclaration { // @type-options no-export /** * Returns an iterable of values in the CSSStyleDeclaration. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface CSSValueList { // @type-options no-export /** * Returns an iterable of values in the CSSValueList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface ClientRectList { // @type-options no-export /** * Returns an iterable of values in the ClientRectList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface DOMRectList { // @type-options no-export /** * Returns an iterable of values in the DOMRectList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface DOMStringList { // @type-options no-export /** * Returns an iterable of values in the DOMStringList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface DataTransferItemList { // @type-options no-export /** * Returns an iterable of values in the DataTransferItemList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface FileList { // @type-options no-export /** * Returns an iterable of values in the FileList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface HTMLAllCollection { // @type-options no-export /** * Returns an iterable of values in the HTMLAllCollection. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface HTMLCollection { // @type-options no-export @@ -140,105 +140,105 @@ interface HTMLFormElement { // @type-options no-export /** * Returns an iterable of values in the HTMLFormElement. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface HTMLSelectElement { // @type-options no-export /** * Returns an iterable of values in the HTMLSelectElement. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface MediaList { // @type-options no-export /** * Returns an iterable of values in the MediaList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface MimeTypeArray { // @type-options no-export /** * Returns an iterable of values in the MimeTypeArray. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface NamedNodeMap { // @type-options no-export /** * Returns an iterable of values in the NamedNodeMap. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface PaintRequestList { // @type-options no-export /** * Returns an iterable of values in the PaintRequestList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface Plugin { // @type-options no-export /** * Returns an iterable of values in the Plugin. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface PluginArray { // @type-options no-export /** * Returns an iterable of values in the PluginArray. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SVGLengthList { // @type-options no-export /** * Returns an iterable of values in the SVGLengthList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SVGNumberList { // @type-options no-export /** * Returns an iterable of values in the SVGNumberList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SVGPathSegList { // @type-options no-export /** * Returns an iterable of values in the SVGPathSegList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SVGPointList { // @type-options no-export /** * Returns an iterable of values in the SVGPointList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SVGStringList { // @type-options no-export /** * Returns an iterable of values in the SVGStringList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SVGTransformList { // @type-options no-export /** * Returns an iterable of values in the SVGTransformList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SourceBufferList { // @type-options no-export /** * Returns an iterable of values in the SourceBufferList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface StyleSheetList { // @type-options no-export @@ -246,26 +246,26 @@ interface StyleSheetList { // @type-options no-export * Returns an iterable of values in the StyleSheetList. * */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface TextTrackCueList { // @type-options no-export /** * Returns an iterable of values in the TextTrackCueList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface TextTrackList { // @type-options no-export /** * Returns an iterable of values in the TextTrackList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface TouchList { // @type-options no-export /** * Returns an iterable of values in the TouchList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } diff --git a/tests/type-definitions/global/web/iterable-dom-collections.test.ts b/tests/type-definitions/global/web/iterable-dom-collections.test.ts index 6e783af5358e..899857136cae 100644 --- a/tests/type-definitions/global/web/iterable-dom-collections.test.ts +++ b/tests/type-definitions/global/web/iterable-dom-collections.test.ts @@ -6,15 +6,15 @@ nodeList.forEach((value: Node, key: number, list: NodeList): void => {}, []); // @ts-expect-error nodeList.forEach(); -const k1: Iterable = nodeList.keys(); +const k1: IterableIterator = nodeList.keys(); // @ts-expect-error nodeList.keys('string'); -const v: Iterable = nodeList.values(); +const v: IterableIterator = nodeList.values(); // @ts-expect-error nodeList.values('string'); -const e: Iterable<[number, Node]> = nodeList.entries(); +const e: IterableIterator<[number, Node]> = nodeList.entries(); // @ts-expect-error nodeList.entries('string'); @@ -25,14 +25,14 @@ domTokenList.forEach((value: Node, key: number, list: DOMTokenList): void => {}, // @ts-expect-error domTokenList.forEach(); -const fomKeys: Iterable = domTokenList.keys(); +const fomKeys: IterableIterator = domTokenList.keys(); // @ts-expect-error domTokenList.keys('string'); -const domValues: Iterable = domTokenList.values(); +const domValues: IterableIterator = domTokenList.values(); // @ts-expect-error domTokenList.values('string'); -const domEntries: Iterable<[number, Element]> = domTokenList.entries(); +const domEntries: IterableIterator<[number, Element]> = domTokenList.entries(); // @ts-expect-error domTokenList.entries('string'); From 2a96a35818397f66742d9b2e36bc7da32ea45d2b Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 8 Jan 2026 22:44:15 +0700 Subject: [PATCH 121/315] Fix Math.sumPrecise type --- packages/core-js-types/src/base/proposals/math-sum.d.ts | 4 ++-- tests/type-definitions/global/proposals/math-sum.test.ts | 7 ++++--- tests/type-definitions/pure/proposals/math-sum.test.ts | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/math-sum.d.ts b/packages/core-js-types/src/base/proposals/math-sum.d.ts index 996559f09973..45b0fddc6220 100644 --- a/packages/core-js-types/src/base/proposals/math-sum.d.ts +++ b/packages/core-js-types/src/base/proposals/math-sum.d.ts @@ -2,8 +2,8 @@ interface Math { // @type-options no-constructor /** * Returns the sum of all given values. - * @param values + * @param items * @returns The sum of all given values. */ - sumPrecise(...values: number[]): number; + sumPrecise(items: Iterable): number; } diff --git a/tests/type-definitions/global/proposals/math-sum.test.ts b/tests/type-definitions/global/proposals/math-sum.test.ts index 2b48e4628c20..0ba98a2f3222 100644 --- a/tests/type-definitions/global/proposals/math-sum.test.ts +++ b/tests/type-definitions/global/proposals/math-sum.test.ts @@ -1,12 +1,13 @@ import 'core-js/full'; function acceptsNumber(x: number) {} +declare const it: Iterable; -acceptsNumber(Math.sumPrecise(0.1, 0.2)); -acceptsNumber(Math.sumPrecise(1, 2)); +acceptsNumber(Math.sumPrecise(it)); +acceptsNumber(Math.sumPrecise([1, 2])); // @ts-expect-error Math.sumPrecise('10'); // @ts-expect-error -Math.sumPrecise([1, 2]); +Math.sumPrecise(1, 2); diff --git a/tests/type-definitions/pure/proposals/math-sum.test.ts b/tests/type-definitions/pure/proposals/math-sum.test.ts index 527fd3c9c78e..40399360a62d 100644 --- a/tests/type-definitions/pure/proposals/math-sum.test.ts +++ b/tests/type-definitions/pure/proposals/math-sum.test.ts @@ -1,12 +1,13 @@ import mathSumPrecise from '@core-js/pure/full/math/sum-precise'; function acceptsNumber(x: number) {} +declare const it: Iterable; -acceptsNumber(mathSumPrecise(0.1, 0.2)); -acceptsNumber(mathSumPrecise(1, 2)); +acceptsNumber(mathSumPrecise(it)); +acceptsNumber(mathSumPrecise([1, 2])); // @ts-expect-error mathSumPrecise('10'); // @ts-expect-error -mathSumPrecise([1, 2]); +mathSumPrecise(1, 2); From da7287eccd9b0adc5318dc72d4455c9d206952d4 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 8 Jan 2026 22:44:29 +0700 Subject: [PATCH 122/315] Self test --- tests/type-definitions/global/web/self.test.ts | 17 ++++++++--------- .../pure/proposals/self.test.ts | 8 ++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 tests/type-definitions/pure/proposals/self.test.ts diff --git a/tests/type-definitions/global/web/self.test.ts b/tests/type-definitions/global/web/self.test.ts index 3f549dbacf6f..d2a8903ee604 100644 --- a/tests/type-definitions/global/web/self.test.ts +++ b/tests/type-definitions/global/web/self.test.ts @@ -1,9 +1,8 @@ -// todo add after it becomes possible to create a type -// import 'core-js/full'; -// -// const ref: typeof globalThis = self; -// -// // @ts-expect-error -// self(); -// // @ts-expect-error -// self = {}; +import 'core-js/full'; + +const ref: typeof globalThis = self; + +// @ts-expect-error +self(); +// @ts-expect-error +self = {}; diff --git a/tests/type-definitions/pure/proposals/self.test.ts b/tests/type-definitions/pure/proposals/self.test.ts new file mode 100644 index 000000000000..26246a23ecc6 --- /dev/null +++ b/tests/type-definitions/pure/proposals/self.test.ts @@ -0,0 +1,8 @@ +import $self from '@core-js/pure/full/self'; + +const ref: typeof globalThis = $self; + +// @ts-expect-error +$self(); +// @ts-expect-error +$self = {}; From f5f803b3262adcd9fbf986ecabbb5d464b274737 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 8 Jan 2026 22:44:58 +0700 Subject: [PATCH 123/315] Fix String.dedent type --- .../src/base/proposals/string-dedent.d.ts | 15 +++++++-- .../base/pure/proposals/string-dedent.d.ts | 32 +++++++++++++++++++ .../global/proposals/string-dedent.test.ts | 8 ++--- .../pure/proposals/string-dedent.test.ts | 6 ++-- 4 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 packages/core-js-types/src/base/pure/proposals/string-dedent.d.ts diff --git a/packages/core-js-types/src/base/proposals/string-dedent.d.ts b/packages/core-js-types/src/base/proposals/string-dedent.d.ts index e5ad7c925ed2..dce7a4ae6bd9 100644 --- a/packages/core-js-types/src/base/proposals/string-dedent.d.ts +++ b/packages/core-js-types/src/base/proposals/string-dedent.d.ts @@ -4,9 +4,20 @@ interface StringConstructor { /** * Template tag that removes common leading whitespace from every line in the resulting string, * preserving relative indentation and blank lines. - * @param strings The template strings array. + * @param template The template strings array, strings array, or a single string. * @param values Values to be interpolated into the template string. * @returns The dedented string. */ - dedent(strings: TemplateStringsArray, ...values: any[]): string; + dedent(template: TemplateStringsArray | ArrayLike, ...values: any[]): string; + dedent(template: { raw: readonly string[] }, ...values: any[]): string; + dedent(template: string): string; +} + +interface String { + /** + * Template tag that removes common leading whitespace from every line in the resulting string, + * preserving relative indentation and blank lines. + * @returns The dedented string. + */ + dedent(): string; } diff --git a/packages/core-js-types/src/base/pure/proposals/string-dedent.d.ts b/packages/core-js-types/src/base/pure/proposals/string-dedent.d.ts new file mode 100644 index 000000000000..d5a2b98227f0 --- /dev/null +++ b/packages/core-js-types/src/base/pure/proposals/string-dedent.d.ts @@ -0,0 +1,32 @@ +/// + +// Motivation: We should use String without the matchAll method to avoid signature conflicts + +// https://github.com/tc39/proposal-string-dedent + +declare namespace CoreJS { + export interface CoreJSStringConstructor extends StringConstructor { + + /** + * Template tag that removes common leading whitespace from every line in the resulting string, + * preserving relative indentation and blank lines. + * @param template The template strings array, strings array, or a single string. + * @param values Values to be interpolated into the template string. + * @returns The dedented string. + */ + dedent(template: TemplateStringsArray | ArrayLike, ...values: any[]): string; + dedent(template: { raw: readonly string[] }, ...values: any[]): string; + dedent(template: string): string; + } + + var CoreJSString: CoreJSStringConstructor; + + export interface CoreJSString extends StringBase { + /** + * Template tag that removes common leading whitespace from every line in the resulting string, + * preserving relative indentation and blank lines. + * @returns The dedented string. + */ + dedent(): string; + } +} diff --git a/tests/type-definitions/global/proposals/string-dedent.test.ts b/tests/type-definitions/global/proposals/string-dedent.test.ts index 19d3004c1f13..9b7a81b29c30 100644 --- a/tests/type-definitions/global/proposals/string-dedent.test.ts +++ b/tests/type-definitions/global/proposals/string-dedent.test.ts @@ -8,9 +8,9 @@ const rdedent2: string = String.dedent`line1 const tpl = Object.assign(['foo', 'bar'], { raw: ['foo', 'bar'] }) as TemplateStringsArray; String.dedent(tpl, 1, 2); -// @ts-expect-error -String.dedent(['foo', 'bar'], 1, 2); -// @ts-expect-error -String.dedent('foo', 1, 2); +String.dedent({ raw: ["a\n b\n", "\n c\n"] }, 1, 2); + +'string\ndedent'.dedent(); + // @ts-expect-error String.dedent(); diff --git a/tests/type-definitions/pure/proposals/string-dedent.test.ts b/tests/type-definitions/pure/proposals/string-dedent.test.ts index 5c416a9bda69..b7dc6c5ce584 100644 --- a/tests/type-definitions/pure/proposals/string-dedent.test.ts +++ b/tests/type-definitions/pure/proposals/string-dedent.test.ts @@ -8,9 +8,7 @@ const rdedent2: string = stringDedent`line1 const tpl = Object.assign(['foo', 'bar'], { raw: ['foo', 'bar'] }) as TemplateStringsArray; stringDedent(tpl, 1, 2); -// @ts-expect-error -stringDedent(['foo', 'bar'], 1, 2); -// @ts-expect-error -stringDedent('foo', 1, 2); +stringDedent({ raw: ["a\n b\n", "\n c\n"] }, 1, 2); + // @ts-expect-error stringDedent(); From 4eb94d9cdf9fad61d9f8f0b7be44d980874feef2 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 9 Jan 2026 01:48:10 +0700 Subject: [PATCH 124/315] Fix CoreJSIteratorObject type & add returning types check --- .../src/base/core-js-types/core-js-types.d.ts | 2 +- .../base/core-js-types/iterator-object.d.ts | 2 +- .../proposals/iterator-helpers-custom.d.ts | 2 +- .../src/base/proposals/iterator-joint.d.ts | 16 ++------- .../src/base/proposals/iterator-range.d.ts | 36 +++++++++---------- .../pure/core-js-types/iterator-object.d.ts | 5 +++ .../proposals/async-iterator-helpers.d.ts | 2 +- .../src/base/pure/proposals/iterator.d.ts | 25 +++++-------- tests/type-definitions/helpers.ts | 6 ++-- .../pure/proposals/array-from-async.test.ts | 16 ++++----- .../proposals/async-iterator-helper.test.ts | 18 +++++----- .../pure/proposals/await-dictionary.test.ts | 6 ++-- .../explicit-resource-management.test.ts | 6 ++-- .../pure/proposals/iterator-helpers.test.ts | 17 ++++----- .../pure/proposals/iterator-joint.test.ts | 11 +++--- .../pure/proposals/iterator-range.test.ts | 3 +- .../proposals/iterator-sequencing.test.ts | 11 +++--- .../proposals/promise-all-settled.test.ts | 12 +++---- .../pure/proposals/promise-any.test.ts | 20 +++++------ .../pure/proposals/promise-finally.test.ts | 20 +++++------ .../pure/proposals/promise-try.test.ts | 22 ++++++------ .../proposals/promise-with-resolvers.test.ts | 8 ++--- 22 files changed, 125 insertions(+), 141 deletions(-) create mode 100644 packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts diff --git a/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts index fd3d36e253e2..3e2a3975c411 100644 --- a/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts +++ b/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts @@ -29,4 +29,4 @@ declare global { } } -export type CoreJSIteratorObject = IteratorObject; +export type CoreJSIteratorObject = IteratorObject; diff --git a/packages/core-js-types/src/base/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/base/core-js-types/iterator-object.d.ts index a6252f8dfbb2..e31f8f4a64f3 100644 --- a/packages/core-js-types/src/base/core-js-types/iterator-object.d.ts +++ b/packages/core-js-types/src/base/core-js-types/iterator-object.d.ts @@ -1,3 +1,3 @@ declare namespace CoreJS { - export interface CoreJSIteratorObject extends Iterator {} + export interface CoreJSIteratorObject extends Iterator {} } diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts index c543b1dd0a35..8d1bbfc4d1cf 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts @@ -9,7 +9,7 @@ declare namespace CoreJS { interface IteratorObject extends Iterator {} - export type CoreJsIteratorObject = IteratorObject; + export type CoreJsIteratorObject = IteratorObject; export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => CoreJsIteratorObject; diff --git a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts index 54411c0d5bac..c3742a2df9e0 100644 --- a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts @@ -1,5 +1,3 @@ -/// - // https://github.com/tc39/proposal-joint-iteration type ZipOptions = { @@ -18,18 +16,8 @@ interface IteratorConstructor { // @type-options no-extends * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. */ - zip(iterables: Iterable, options?: ZipOptions): CoreJS.CoreJSIteratorObject<[T, U]>; + zip(iterables: Iterable>, options?: ZipOptions): IteratorObject; // @type-options prefix-return-type - /** - * takes an object whose values are iterables and produces an iterable of objects where keys. - * correspond to keys in the passed object. - * @param iterables An Iterable of iterables. - * @param options Optional object: - * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; - * - padding: an object specifying padding values for each key when mode is 'longest'. - * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. - */ - zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJS.CoreJSIteratorObject<[number, T, U]>; /** * takes an object whose values are iterables and produces an iterable of objects where keys. * correspond to keys in the passed object. @@ -39,7 +27,7 @@ interface IteratorConstructor { // @type-options no-extends * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. */ - zipKeyed(record: Record>, options?: ZipOptions): CoreJS.CoreJSIteratorObject<[PropertyKey, T, U]>; + zipKeyed }>(record: T, options?: ZipOptions): IteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }>; // @type-options prefix-return-type } declare var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/base/proposals/iterator-range.d.ts b/packages/core-js-types/src/base/proposals/iterator-range.d.ts index 2db194f8eea3..babc6c471551 100644 --- a/packages/core-js-types/src/base/proposals/iterator-range.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-range.d.ts @@ -1,26 +1,22 @@ // https://github.com/tc39/proposal-iterator.range -declare global { - type IteratorRangeOptions = { - step?: T; +type IteratorRangeOptions = { + step?: T; - inclusive?: boolean; - }; + inclusive?: boolean; +}; - interface IteratorConstructor { // @type-options no-extends - /** - * Returns an iterator that generates a sequence of numbers or bigints within a range. - * @param start The starting value of the sequence. - * @param end The end value of the sequence (exclusive by default). - * @param options Optional object: - * - step: The difference between consecutive values (default is 1). - * - inclusive: If true, the end value is included in the range (default is false). - * @returns An iterator of numbers or bigints. - */ - range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): IteratorObject - } - - var Iterator: IteratorConstructor; +interface IteratorConstructor { // @type-options no-extends + /** + * Returns an iterator that generates a sequence of numbers or bigints within a range. + * @param start The starting value of the sequence. + * @param end The end value of the sequence (exclusive by default). + * @param options Optional object: + * - step: The difference between consecutive values (default is 1). + * - inclusive: If true, the end value is included in the range (default is false). + * @returns An iterator of numbers or bigints. + */ + range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): IteratorObject; // @type-options prefix-return-type } -export {}; +declare var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts new file mode 100644 index 000000000000..2c30f11185e5 --- /dev/null +++ b/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts @@ -0,0 +1,5 @@ +/// + +declare namespace CoreJS { + export interface CoreJSIteratorObject extends CoreJSIterator {} +} diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index c8818d83e7a7..630567175f13 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -99,7 +99,7 @@ declare namespace CoreJS { var CoreJSAsyncIterator: CoreJSAsyncIteratorConstructor; - interface CoreJSIterator extends Iterator { + interface CoreJSIterator extends Iterator { /** * Creates an `AsyncIterator` from the current `Iterator` * @returns A new `AsyncIterator` instance diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 78128a72fb02..fae79241dab9 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -1,5 +1,6 @@ /// /// +/// // Motivation: Has dependencies on internal types @@ -49,9 +50,9 @@ declare namespace CoreJS { } interface CoreJSAsyncIterator { - next(...[value]: [] | [TNext]): CoreJSPromise>; - return?(value?: TReturn | CoreJSPromiseLike): CoreJSPromise>; - throw?(e?: any): CoreJSPromise>; + next(...[value]: [] | [TNext]): CoreJS.CoreJSPromise>; + return?(value?: TReturn | CoreJSPromiseLike): CoreJS.CoreJSPromise>; + throw?(e?: any): CoreJS.CoreJSPromise>; } export interface CoreJSAsyncIteratorObject extends CoreJSAsyncIterator {} @@ -60,9 +61,9 @@ declare namespace CoreJS { [CoreJSSymbol.asyncIterator](): CoreJSAsyncIterator; } - export interface CoreJSIteratorObject extends CoreJSDisposable {} + export interface CoreJSIteratorObject extends CoreJSDisposable {} - export interface CoreJSIterator extends Iterator { + export interface CoreJSIterator extends Iterator { /** * Yields arrays containing up to the specified number of elements * chunked from the source iterator. @@ -189,18 +190,8 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. */ - zip(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[T, U]>; + zip(iterables: Iterable>, options?: ZipOptions): CoreJSIteratorObject; - /** - * takes an object whose values are iterables and produces an iterable of objects where keys. - * correspond to keys in the passed object. - * @param iterables An Iterable of iterables. - * @param options Optional object: - * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; - * - padding: an object specifying padding values for each key when mode is 'longest'. - * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. - */ - zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[number, T, U]>; /** * takes an object whose values are iterables and produces an iterable of objects where keys. * correspond to keys in the passed object. @@ -210,7 +201,7 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. */ - zipKeyed(record: Record>, options?: ZipOptions): CoreJSIteratorObject<[PropertyKey, T, U]>; + zipKeyed }>(record: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }>; /** * Returns an iterator that generates a sequence of numbers or bigints within a range. diff --git a/tests/type-definitions/helpers.ts b/tests/type-definitions/helpers.ts index 040dc8ae37c7..a422161c78c5 100644 --- a/tests/type-definitions/helpers.ts +++ b/tests/type-definitions/helpers.ts @@ -3,8 +3,7 @@ export interface CoreJSPromiseLike { finally(onfinally?: (() => void) | undefined | null): PromiseLike; } - -export type AnyPromiseLike = CoreJSPromiseLike | Promise; +export type CoreJSPromiseOrPromiseLike = CoreJSPromiseLike | Promise; export interface CoreJSMapLike extends Map { getOrInsert(key: K, value: V): V; @@ -30,7 +29,7 @@ export interface CoreJSSetLike extends Set { export interface CoreJSWeakSetLike extends WeakSet {} -export interface CoreJSIteratorLike extends Iterator { +export interface CoreJSIteratorLike extends Iterator { chunks(...args: any[]): CoreJSIteratorLike; windows(...args: any[]): CoreJSIteratorLike; map(...args: any[]): CoreJSIteratorLike; @@ -46,3 +45,4 @@ export interface CoreJSIteratorLike extends find(...args: any[]): T | undefined; join(...args: any[]): string; } +export type CoreJSIteratorOrIteratorLike = CoreJSIteratorLike | Iterator; diff --git a/tests/type-definitions/pure/proposals/array-from-async.test.ts b/tests/type-definitions/pure/proposals/array-from-async.test.ts index 30af1e2c0784..0793f7648030 100644 --- a/tests/type-definitions/pure/proposals/array-from-async.test.ts +++ b/tests/type-definitions/pure/proposals/array-from-async.test.ts @@ -1,12 +1,12 @@ import arrayFromAsync from '@core-js/pure/full/array/from-async'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { AnyPromiseLike } from '../../helpers'; +import { CoreJSPromiseOrPromiseLike } from '../../helpers'; -const p1: AnyPromiseLike = arrayFromAsync([1, 2, 3]); -const p2: AnyPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3]); -const p3: AnyPromiseLike = arrayFromAsync([1, 2, 3], (value: number, index: number) => value.toString()); -const p4: AnyPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3], (value: number) => value + 1); -const p5: AnyPromiseLike = arrayFromAsync([1, 2, 3], function (this: { foo: string }, value: number) { return value.toString(); }, { foo: 'str' }); +const p1: CoreJSPromiseOrPromiseLike = arrayFromAsync([1, 2, 3]); +const p2: CoreJSPromiseOrPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3]); +const p3: CoreJSPromiseOrPromiseLike = arrayFromAsync([1, 2, 3], (value: number, index: number) => value.toString()); +const p4: CoreJSPromiseOrPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3], (value: number) => value + 1); +const p5: CoreJSPromiseOrPromiseLike = arrayFromAsync([1, 2, 3], function (this: { foo: string }, value: number) { return value.toString(); }, { foo: 'str' }); async function t1() { const n: number[] = await arrayFromAsync([1, 2, 3]); @@ -20,8 +20,8 @@ async function t2() { } declare const arrLike: { [index: number]: PromiseLike; length: 2 }; -const p6: AnyPromiseLike = arrayFromAsync(arrLike); -const p7: AnyPromiseLike = arrayFromAsync(arrLike, (value: number) => value); +const p6: CoreJSPromiseOrPromiseLike = arrayFromAsync(arrLike); +const p7: CoreJSPromiseOrPromiseLike = arrayFromAsync(arrLike, (value: number) => value); // @ts-expect-error arrayFromAsync([1, 2, 3], (value: string) => value); diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index b7f3eb88a1b7..97b185ba4226 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -12,7 +12,7 @@ import take from '@core-js/pure/full/async-iterator/take'; import toArray from '@core-js/pure/full/async-iterator/to-array'; import toAsync from '@core-js/pure/full/iterator/to-async'; // import $AsyncIterator from '@core-js/pure/full/async-iterator'; // todo -import { AnyPromiseLike } from '../../helpers'; +import { CoreJSPromiseOrPromiseLike } from '../../helpers'; const aiton = from([1, 2, 3]); aiton.next(); @@ -41,16 +41,16 @@ toAsync(is); toAsync(itn); drop(aiton, 3); -const r2: AnyPromiseLike = every(aiton, (v: number, i: number) => v > 0); +const r2: CoreJSPromiseOrPromiseLike = every(aiton, (v: number, i: number) => v > 0); filter(aiton, (v: number, i: number) => v > 0); -const r4: AnyPromiseLike = find(aiton, (v: number, i: number) => v > 0); +const r4: CoreJSPromiseOrPromiseLike = find(aiton, (v: number, i: number) => v > 0); flatMap(aiton, (v: number, i: number) => `${v}`); -const r6: AnyPromiseLike = forEach(aiton, (v: number, i: number) => { }); +const r6: CoreJSPromiseOrPromiseLike = forEach(aiton, (v: number, i: number) => { }); map(aiton, (v: number, i: number) => v * 2); -const r8: AnyPromiseLike = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); -const r9: AnyPromiseLike = some(aiton, (v: number, i: number) => v > 0); +const r8: CoreJSPromiseOrPromiseLike = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); +const r9: CoreJSPromiseOrPromiseLike = some(aiton, (v: number, i: number) => v > 0); take(aiton, 10); -const r11: AnyPromiseLike = toArray(aiton); +const r11: CoreJSPromiseOrPromiseLike = toArray(aiton); // @ts-expect-error drop(ain); @@ -75,8 +75,8 @@ take(ain); // @ts-expect-error toArray(ain, 1); -const s0: AnyPromiseLike = toArray(aiton); -const f0: AnyPromiseLike = find(aitos, (v: string, i: number) => v.length === 1); +const s0: CoreJSPromiseOrPromiseLike = toArray(aiton); +const f0: CoreJSPromiseOrPromiseLike = find(aitos, (v: string, i: number) => v.length === 1); // @ts-expect-error map(ais, (v: string, i: number) => v.length === 1, 'extra'); diff --git a/tests/type-definitions/pure/proposals/await-dictionary.test.ts b/tests/type-definitions/pure/proposals/await-dictionary.test.ts index b5f4f272d135..c45b4b1830b0 100644 --- a/tests/type-definitions/pure/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/pure/proposals/await-dictionary.test.ts @@ -2,16 +2,16 @@ import promiseAllKeyed from '@core-js/pure/full/promise/all-keyed'; import promiseAllSettledKeyed from '@core-js/pure/full/promise/all-settled-keyed'; import promiseResolve from '@core-js/pure/full/promise/resolve'; import $Symbol from '@core-js/pure/full/symbol'; -import { AnyPromiseLike } from '../../helpers'; +import { CoreJSPromiseOrPromiseLike } from '../../helpers'; -const res: AnyPromiseLike<{ a: number, b: string, c: boolean }> = promiseAllKeyed({ +const res: CoreJSPromiseOrPromiseLike<{ a: number, b: string, c: boolean }> = promiseAllKeyed({ a: promiseResolve(1), b: promiseResolve('string'), c: promiseResolve(true), }); const sym = $Symbol('sym'); -const res2: AnyPromiseLike<{ [sym]: number }> = promiseAllKeyed({ +const res2: CoreJSPromiseOrPromiseLike<{ [sym]: number }> = promiseAllKeyed({ [sym]: promiseResolve(1) }); diff --git a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts index 20974b658bee..6a262d1488a2 100644 --- a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts @@ -7,7 +7,7 @@ import asyncIteratorFrom from '@core-js/pure/full/async-iterator/from'; import $SuppressedError from '@core-js/pure/full/suppressed-error/constructor'; import $DisposableStack from '@core-js/pure/full/disposable-stack/constructor'; import $AsyncDisposableStack from '@core-js/pure/full/async-disposable-stack/constructor'; -import { AnyPromiseLike } from '../../helpers'; +import { CoreJSPromiseOrPromiseLike } from '../../helpers'; const d: symbol = symbolDispose; const ad: symbol = symbolAsyncDispose; @@ -23,7 +23,7 @@ objD[symbolDispose](); const objAD = { [symbolAsyncDispose]() { return promiseResolve(); } } -const p1: AnyPromiseLike = objAD[symbolAsyncDispose](); +const p1: CoreJSPromiseOrPromiseLike = objAD[symbolAsyncDispose](); const err1 = new $SuppressedError('err', 'suppressed', 'msg'); err1.error; @@ -65,7 +65,7 @@ objDS[symbolToStringTag] = 'foo'; $AsyncDisposableStack.prototype; const objADS = new $AsyncDisposableStack(); const disposedASD: boolean = objDS.disposed; -const rda: AnyPromiseLike = objADS.disposeAsync(); +const rda: CoreJSPromiseOrPromiseLike = objADS.disposeAsync(); objADS.use(objAD); objADS.use(objD); const ruseASD3: null = objADS.use(null); diff --git a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts index f49c814d4bb3..4409aa074276 100644 --- a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts @@ -9,41 +9,42 @@ import iteratorForEach from '@core-js/pure/full/iterator/for-each'; import iteratorSome from '@core-js/pure/full/iterator/some'; import iteratorEvery from '@core-js/pure/full/iterator/every'; import iteratorFind from '@core-js/pure/full/iterator/find'; +import { CoreJSIteratorOrIteratorLike } from '../../helpers'; declare const it: Iterator; declare const itStr: Iterator; declare const itNumStr: Iterator; -const res: Iterator = iteratorMap(it, (v, i) => String(v)); -const mappedNum: Iterator = iteratorMap(it, n => n + 1); +const res: CoreJSIteratorOrIteratorLike = iteratorMap(it, (v, i) => String(v)); +const mappedNum: CoreJSIteratorOrIteratorLike = iteratorMap(it, n => n + 1); // @ts-expect-error iteratorMap(); // @ts-expect-error iteratorMap((v, i, extra) => v + i + extra); -const onlyEven: Iterator = iteratorFilter(it, v => v % 2 === 0); -const filtered: Iterator = iteratorFilter(it, (v): v is number => typeof v === 'number'); +const onlyEven: CoreJSIteratorOrIteratorLike = iteratorFilter(it, v => v % 2 === 0); +const filtered: CoreJSIteratorOrIteratorLike = iteratorFilter(it, (v): v is number => typeof v === 'number'); // @ts-expect-error iteratorFilter(); // @ts-expect-error iteratorFilter((v, i, extra) => true); -const taken: Iterator = iteratorTake(it, 5); +const taken: CoreJSIteratorOrIteratorLike = iteratorTake(it, 5); // @ts-expect-error iteratorTake(); // @ts-expect-error iteratorTake('5'); -const dropped: Iterator = iteratorDrop(it, 3); +const dropped: CoreJSIteratorOrIteratorLike = iteratorDrop(it, 3); // @ts-expect-error iteratorDrop('3'); -const flatMapped: Iterator = iteratorFlatMap(it, (v, i) => itStr); -const flatMapped2: Iterator = iteratorFlatMap(it, (v, i) => ({ +const flatMapped: CoreJSIteratorOrIteratorLike = iteratorFlatMap(it, (v, i) => itStr); +const flatMapped2: CoreJSIteratorOrIteratorLike = iteratorFlatMap(it, (v, i) => ({ [Symbol.iterator]: function* () { yield String(v); } diff --git a/tests/type-definitions/pure/proposals/iterator-joint.test.ts b/tests/type-definitions/pure/proposals/iterator-joint.test.ts index f132ceb083b4..6772c14375ba 100644 --- a/tests/type-definitions/pure/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-joint.test.ts @@ -1,11 +1,12 @@ import iteratorZip from '@core-js/pure/full/iterator/zip'; import iteratorZipKeyed from '@core-js/pure/full/iterator/zip-keyed'; +import { CoreJSIteratorOrIteratorLike } from '../../helpers'; -iteratorZip([[1, 2, 3], [4, 5, 6]]); -iteratorZip([['a', 'b', 'c'], ['d', 'e', 'f']]); -iteratorZip([[1, 2, 3], [4, 5, 6]], { mode: "shortest" }); -iteratorZipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); -iteratorZipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: "shortest" }); +const zipped1: CoreJSIteratorOrIteratorLike = iteratorZip([[1, 2, 3], [4, 5, 6]]); +const zipped2: CoreJSIteratorOrIteratorLike = iteratorZip([['a', 'b', 'c'], ['d', 'e', 'f']]); +const zipped3: CoreJSIteratorOrIteratorLike = iteratorZip([[1, 2, 3], [4, 5, 6]], { mode: "shortest" }); +const zipped4: CoreJSIteratorOrIteratorLike> = iteratorZipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); +const zipped5: CoreJSIteratorOrIteratorLike> = iteratorZipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: "shortest" }); // @ts-expect-error iteratorZip(true); diff --git a/tests/type-definitions/pure/proposals/iterator-range.test.ts b/tests/type-definitions/pure/proposals/iterator-range.test.ts index a2742b07802b..15a15b95b29c 100644 --- a/tests/type-definitions/pure/proposals/iterator-range.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-range.test.ts @@ -1,6 +1,7 @@ import iteratorRange from '@core-js/pure/full/iterator/range'; +import { CoreJSIteratorOrIteratorLike } from '../../helpers'; -const rir1: Iterator = iteratorRange(1, 10); +const rir1: CoreJSIteratorOrIteratorLike = iteratorRange(1, 10); iteratorRange(1, 10, 1); iteratorRange(1, 10, { step: 1 }); iteratorRange(1, 10, { inclusive: true }); diff --git a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts index 34b708962cb3..9f8ae5184c5a 100644 --- a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts @@ -1,4 +1,5 @@ import iteratorConcat from '@core-js/pure/full/iterator/concat'; +import { CoreJSIteratorOrIteratorLike } from '../../helpers'; declare const its1: Iterable; declare const arrs: string[]; @@ -6,11 +7,11 @@ declare const arrn: number[]; declare const arrb: boolean[]; declare const itb1: Iterable; -const ri1: Iterator = iteratorConcat(its1); -const ri2: Iterator = iteratorConcat(arrs); -const ri3: Iterator = iteratorConcat(arrn); -const ri4: Iterator = iteratorConcat(arrb, itb1); -const ri5: Iterator = iteratorConcat(); +const ri1: CoreJSIteratorOrIteratorLike = iteratorConcat(its1); +const ri2: CoreJSIteratorOrIteratorLike = iteratorConcat(arrs); +const ri3: CoreJSIteratorOrIteratorLike = iteratorConcat(arrn); +const ri4: CoreJSIteratorOrIteratorLike = iteratorConcat(arrb, itb1); +const ri5: CoreJSIteratorOrIteratorLike = iteratorConcat(); // @ts-expect-error iteratorConcat(1); diff --git a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts index eb14804a0e2e..3b2d05cf80cc 100644 --- a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts @@ -1,6 +1,6 @@ import promiseAllSettled from '@core-js/pure/full/promise/all-settled'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { AnyPromiseLike } from '../../helpers'; +import { CoreJSPromiseOrPromiseLike } from '../../helpers'; interface CoreJSPromiseResult { status: string; @@ -10,19 +10,19 @@ interface CoreJSPromiseResult { const promiseLike = { then: (cb: (val: number) => void) => cb(42) }; -const p1: AnyPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = +const p1: CoreJSPromiseOrPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = promiseAllSettled([promiseResolve(10), promiseResolve(20), 30]); -const p2: AnyPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = +const p2: CoreJSPromiseOrPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = promiseAllSettled(['a', 'b', 'c']); -const p3: AnyPromiseLike[]> = +const p3: CoreJSPromiseOrPromiseLike[]> = promiseAllSettled(new Set([1, 2, 3])); promiseAllSettled([promiseLike]); const emptyTuple: [] = []; -const settled6: AnyPromiseLike<[]> = promiseAllSettled(emptyTuple); +const settled6: CoreJSPromiseOrPromiseLike<[]> = promiseAllSettled(emptyTuple); const mixedTuple = [42, promiseResolve('bar')] as const; -const p4: AnyPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult]> = +const p4: CoreJSPromiseOrPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult]> = promiseAllSettled(mixedTuple); // @ts-expect-error diff --git a/tests/type-definitions/pure/proposals/promise-any.test.ts b/tests/type-definitions/pure/proposals/promise-any.test.ts index bb6d18b814ab..86288546799f 100644 --- a/tests/type-definitions/pure/proposals/promise-any.test.ts +++ b/tests/type-definitions/pure/proposals/promise-any.test.ts @@ -1,6 +1,6 @@ import promiseAny from '@core-js/pure/full/promise/any'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { AnyPromiseLike } from '../../helpers'; +import { CoreJSPromiseOrPromiseLike } from '../../helpers'; const arr = [promiseResolve(1), promiseResolve("foo"), 3] as const; const justNumbers = [1, 2, 3]; @@ -9,16 +9,16 @@ const promiseLike = { then: (cb: (val: number) => void) => cb(123) }; const emptyTuple: [] = []; const mixed = [true, promiseResolve("z")] as const; -const any1: AnyPromiseLike = promiseAny(arr); -const any2: AnyPromiseLike = promiseAny(["x", "y", promiseResolve(5)]); -const any3: AnyPromiseLike = promiseAny(emptyTuple); -const any4: AnyPromiseLike = promiseAny(mixed); +const any1: CoreJSPromiseOrPromiseLike = promiseAny(arr); +const any2: CoreJSPromiseOrPromiseLike = promiseAny(["x", "y", promiseResolve(5)]); +const any3: CoreJSPromiseOrPromiseLike = promiseAny(emptyTuple); +const any4: CoreJSPromiseOrPromiseLike = promiseAny(mixed); -const any5: AnyPromiseLike = promiseAny(justNumbers); -const any6: AnyPromiseLike = promiseAny(setOfStrings); -const any7: AnyPromiseLike = promiseAny([promiseLike]); -const any8: AnyPromiseLike = promiseAny(new Set([1])); -const any9: AnyPromiseLike = promiseAny([promiseResolve()]); +const any5: CoreJSPromiseOrPromiseLike = promiseAny(justNumbers); +const any6: CoreJSPromiseOrPromiseLike = promiseAny(setOfStrings); +const any7: CoreJSPromiseOrPromiseLike = promiseAny([promiseLike]); +const any8: CoreJSPromiseOrPromiseLike = promiseAny(new Set([1])); +const any9: CoreJSPromiseOrPromiseLike = promiseAny([promiseResolve()]); // @ts-expect-error promiseAny(); diff --git a/tests/type-definitions/pure/proposals/promise-finally.test.ts b/tests/type-definitions/pure/proposals/promise-finally.test.ts index 5913aa8d9779..5ac6cd9a4594 100644 --- a/tests/type-definitions/pure/proposals/promise-finally.test.ts +++ b/tests/type-definitions/pure/proposals/promise-finally.test.ts @@ -1,20 +1,20 @@ import promiseFinally from '@core-js/pure/full/promise/finally'; import promiseResolve from '@core-js/pure/full/promise/resolve'; import promiseReject from '@core-js/pure/full/promise/reject'; -import { AnyPromiseLike } from '../../helpers'; +import { CoreJSPromiseOrPromiseLike } from '../../helpers'; -const pr1: AnyPromiseLike = promiseResolve(42); +const pr1: CoreJSPromiseOrPromiseLike = promiseResolve(42); declare const p1: Promise; -const pf1: AnyPromiseLike = promiseFinally(p1); -const pf2: AnyPromiseLike = promiseFinally(p1, undefined); -const pf3: AnyPromiseLike = promiseFinally(p1, null); -const pf4: AnyPromiseLike = promiseFinally(p1, () => {}); -const pf5: AnyPromiseLike = promiseFinally(p1, function () {}); +const pf1: CoreJSPromiseOrPromiseLike = promiseFinally(p1); +const pf2: CoreJSPromiseOrPromiseLike = promiseFinally(p1, undefined); +const pf3: CoreJSPromiseOrPromiseLike = promiseFinally(p1, null); +const pf4: CoreJSPromiseOrPromiseLike = promiseFinally(p1, () => {}); +const pf5: CoreJSPromiseOrPromiseLike = promiseFinally(p1, function () {}); -const pr2: AnyPromiseLike = promiseReject("err"); +const pr2: CoreJSPromiseOrPromiseLike = promiseReject("err"); declare const p2: Promise; -const pf6: AnyPromiseLike = promiseFinally(p2); -const pf7: AnyPromiseLike = promiseFinally(p2, () => {}); +const pf6: CoreJSPromiseOrPromiseLike = promiseFinally(p2); +const pf7: CoreJSPromiseOrPromiseLike = promiseFinally(p2, () => {}); // @ts-expect-error promiseFinally(p1, 123); diff --git a/tests/type-definitions/pure/proposals/promise-try.test.ts b/tests/type-definitions/pure/proposals/promise-try.test.ts index 9b801374669d..149b84db24a6 100644 --- a/tests/type-definitions/pure/proposals/promise-try.test.ts +++ b/tests/type-definitions/pure/proposals/promise-try.test.ts @@ -1,19 +1,19 @@ import promiseTry from '@core-js/pure/full/promise/try'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { AnyPromiseLike } from '../../helpers'; +import { CoreJSPromiseOrPromiseLike } from '../../helpers'; -const pt1: AnyPromiseLike = promiseTry(() => 42); -const pt2: AnyPromiseLike = promiseTry(() => promiseResolve("hi")); -const pt3: AnyPromiseLike = promiseTry((a: number, b: number) => a + b, 1, 2); -const pt4: AnyPromiseLike = promiseTry((x: string) => x + "!!", "test"); -const pt5: AnyPromiseLike = promiseTry(() => {}); -const pt6: AnyPromiseLike = promiseTry((b: boolean) => b, false); +const pt1: CoreJSPromiseOrPromiseLike = promiseTry(() => 42); +const pt2: CoreJSPromiseOrPromiseLike = promiseTry(() => promiseResolve("hi")); +const pt3: CoreJSPromiseOrPromiseLike = promiseTry((a: number, b: number) => a + b, 1, 2); +const pt4: CoreJSPromiseOrPromiseLike = promiseTry((x: string) => x + "!!", "test"); +const pt5: CoreJSPromiseOrPromiseLike = promiseTry(() => {}); +const pt6: CoreJSPromiseOrPromiseLike = promiseTry((b: boolean) => b, false); -const pt7: AnyPromiseLike = promiseTry((a: number, b: string, c: boolean) => c ? a : Number(b), 10, "100", true); -const pt8: AnyPromiseLike = promiseTry((a: string) => promiseResolve(a), "bar"); +const pt7: CoreJSPromiseOrPromiseLike = promiseTry((a: number, b: string, c: boolean) => c ? a : Number(b), 10, "100", true); +const pt8: CoreJSPromiseOrPromiseLike = promiseTry((a: string) => promiseResolve(a), "bar"); -declare function returnsPromise(): AnyPromiseLike; -const pt9: AnyPromiseLike = promiseTry(() => returnsPromise()); +declare function returnsPromise(): CoreJSPromiseOrPromiseLike; +const pt9: CoreJSPromiseOrPromiseLike = promiseTry(() => returnsPromise()); // @ts-expect-error promiseTry(); diff --git a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts index b87d817290e4..6492aae20448 100644 --- a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts +++ b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts @@ -1,14 +1,14 @@ import promiseWithResolvers from '@core-js/pure/full/promise/with-resolvers'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { AnyPromiseLike } from '../../helpers'; +import { CoreJSPromiseOrPromiseLike } from '../../helpers'; const pr = promiseWithResolvers(); const pr2 = promiseWithResolvers(); const pr3 = promiseWithResolvers(); -const p1: AnyPromiseLike = pr.promise; -const p2: AnyPromiseLike = pr2.promise; -const p3: AnyPromiseLike = pr3.promise; +const p1: CoreJSPromiseOrPromiseLike = pr.promise; +const p2: CoreJSPromiseOrPromiseLike = pr2.promise; +const p3: CoreJSPromiseOrPromiseLike = pr3.promise; pr.resolve(42); pr.resolve(promiseResolve(43)); From b483ee3eb228f24cd0aa2269c23a2e2d453f9024 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 9 Jan 2026 01:51:58 +0700 Subject: [PATCH 125/315] Some fixes & improvements --- .../base/proposals/array-buffer-transfer.d.ts | 2 +- .../src/base/proposals/await-dictionary.d.ts | 2 +- .../base/pure/proposals/await-dictionary.d.ts | 29 +++++++++++++++++++ .../pure/proposals/iterator-join.test.ts | 18 ++++++------ 4 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts diff --git a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts index 8ed3ba32abaf..60fda5e3a8ee 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts @@ -5,7 +5,7 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt interface ArrayBuffer { - // todo hack for modern ts + // TODO hack for modern ts // get detached(): boolean; /** diff --git a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts index d6dbc18027d6..07cb97f81b8f 100644 --- a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts @@ -2,7 +2,7 @@ // https://github.com/tc39/proposal-await-dictionary -interface PromiseConstructor { // @type-options no-redefine +interface PromiseConstructor { /** * Takes an object of promises and returns a single Promise that resolves to an object * with the same keys and fulfilled values, or rejects as soon as any of the input promises rejects. diff --git a/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts new file mode 100644 index 000000000000..c6d659e9021f --- /dev/null +++ b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts @@ -0,0 +1,29 @@ +/// +/// + +// Motivation: Using our own Promise type in return + +// https://github.com/tc39/proposal-await-dictionary + +declare namespace CoreJS { + export interface CoreJSPromiseConstructor extends PromiseConstructor { + /** + * Takes an object of promises and returns a single Promise that resolves to an object + * with the same keys and fulfilled values, or rejects as soon as any of the input promises rejects. + * @param promises An object of promises + * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. + */ + allKeyed>>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: Awaited }>; + + /** + * Takes an object whose values are promises and returns a single `Promise` that resolves + * to an object with the same keys, after all of the input promises have settled. + * @param promises An object of promises + * @returns A new Promise that resolves to an object with the same keys as the input object, + * where each key maps to the settlement result ({ status, value } or { status, reason }) of the corresponding promise. + */ + allSettledKeyed>>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; + } + + var CoreJSPromise: CoreJSPromiseConstructor; +} diff --git a/tests/type-definitions/pure/proposals/iterator-join.test.ts b/tests/type-definitions/pure/proposals/iterator-join.test.ts index abf2761b19d1..acc0f1096f6a 100644 --- a/tests/type-definitions/pure/proposals/iterator-join.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-join.test.ts @@ -1,15 +1,15 @@ -import $join from '@core-js/pure/full/iterator/join'; +import iteratorJoin from '@core-js/pure/full/iterator/join'; declare const it: Iterator; -const res1: string = $join(it, ); -const res2: string = $join(it, ' '); -const res3: string = $join(it, 5); -const res4: string = $join(it, Symbol('x')); -const res5: string = $join(it, undefined); -const res6: string = $join(it, null); +const res1: string = iteratorJoin(it, ); +const res2: string = iteratorJoin(it, ' '); +const res3: string = iteratorJoin(it, 5); +const res4: string = iteratorJoin(it, Symbol('x')); +const res5: string = iteratorJoin(it, undefined); +const res6: string = iteratorJoin(it, null); // @ts-expect-error -$join(it, '+', '_'); +iteratorJoin(it, '+', '_'); // @ts-expect-error -const res7: number = $join(it, ); +const res7: number = iteratorJoin(it, ); From 1a3e83e2d2f968872bd98fd826614556877289c5 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 9 Jan 2026 02:41:09 +0700 Subject: [PATCH 126/315] Fix motivation comments for 5.5- pure types --- .../src/ts5-2/proposals/async-iterator-helpers.d.ts | 2 +- .../src/ts5-2/proposals/explicit-resource-management.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts index cc233d25ade1..85e0e710da26 100644 --- a/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts @@ -1,4 +1,4 @@ -// Motivation: AsyncIterator had different signatures until TS 5.7 +// Motivation: TS 5.6 changed AsyncIterator’s TNext from undefined to any // https://github.com/tc39/proposal-async-iterator-helpers diff --git a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts index ce173a996beb..fa4f77dc1f35 100644 --- a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts @@ -1,4 +1,4 @@ -// Motivation: IteratorObject, AsyncIteratorObject, and AsyncIterator had different signatures until TS 5.7 +// Motivation: IteratorObject, AsyncIteratorObject, and AsyncIterator had different signatures until TS 5.6 // https://github.com/tc39/proposal-explicit-resource-management From 4627b28d51063e67eec4b18a5cdf56be60cb7bdb Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 9 Jan 2026 03:27:17 +0700 Subject: [PATCH 127/315] Improve returning types checking & fix iterator-helpers types --- .../proposals/iterator-helpers-custom.d.ts | 6 ++-- .../proposals/iterator-helpers-custom.d.ts | 17 +++++++++++ tests/type-definitions/helpers.ts | 8 +++-- .../accessible-object-hasownproperty.test.ts | 2 +- .../pure/proposals/array-filtering.test.ts | 4 +-- .../pure/proposals/array-from-async.test.ts | 16 +++++----- .../pure/proposals/array-grouping.test.ts | 6 ++-- .../proposals/async-iterator-helper.test.ts | 18 +++++------ .../pure/proposals/await-dictionary.test.ts | 6 ++-- .../pure/proposals/collection-of-from.test.ts | 30 +++++++++---------- .../explicit-resource-management.test.ts | 6 ++-- .../pure/proposals/iterator-chunking.test.ts | 5 ++-- .../pure/proposals/iterator-helpers.test.ts | 18 +++++------ .../pure/proposals/iterator-joint.test.ts | 12 ++++---- .../pure/proposals/iterator-range.test.ts | 4 +-- .../proposals/iterator-sequencing.test.ts | 12 ++++---- .../proposals/promise-all-settled.test.ts | 12 ++++---- .../pure/proposals/promise-any.test.ts | 20 ++++++------- .../pure/proposals/promise-finally.test.ts | 20 ++++++------- .../pure/proposals/promise-try.test.ts | 22 +++++++------- .../proposals/promise-with-resolvers.test.ts | 8 ++--- .../pure/proposals/set-methods.test.ts | 24 +++++++-------- 22 files changed, 148 insertions(+), 128 deletions(-) create mode 100644 packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts index 8d1bbfc4d1cf..9eb42e21190d 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts @@ -9,11 +9,9 @@ declare namespace CoreJS { interface IteratorObject extends Iterator {} - export type CoreJsIteratorObject = IteratorObject; + export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => IteratorObject; - export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => CoreJsIteratorObject; - - export type IteratorMap = (callback: (value: T, index: number) => U) => CoreJsIteratorObject; + export type IteratorMap = (callback: (value: T, index: number) => U) => IteratorObject; export type IteratorReduce = (callback: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; } diff --git a/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts new file mode 100644 index 000000000000..28cd5e3ada67 --- /dev/null +++ b/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts @@ -0,0 +1,17 @@ +/// + +// Motivation: Using our own type for IteratorObject + +// https://github.com/tc39/proposal-iterator-helpers + +// For ensuring compatibility with TypeScript standard types, this code is aligned with: +// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + +declare namespace CoreJS { + export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => CoreJS.CoreJSIteratorObject; + + export type IteratorMap = (callback: (value: T, index: number) => U) => CoreJS.CoreJSIteratorObject; + + export type IteratorReduce = (callback: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; +} diff --git a/tests/type-definitions/helpers.ts b/tests/type-definitions/helpers.ts index a422161c78c5..77f779d9508f 100644 --- a/tests/type-definitions/helpers.ts +++ b/tests/type-definitions/helpers.ts @@ -3,19 +3,21 @@ export interface CoreJSPromiseLike { finally(onfinally?: (() => void) | undefined | null): PromiseLike; } -export type CoreJSPromiseOrPromiseLike = CoreJSPromiseLike | Promise; +export type CoreJSPromiseAndPromiseLike = CoreJSPromiseLike & Promise; export interface CoreJSMapLike extends Map { getOrInsert(key: K, value: V): V; getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } +export type CoreJSMapAndMapLike = CoreJSMapLike & Map; export interface CoreJSWeakMapLike extends WeakMap { getOrInsert(key: K, value: V): V; getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } +export type CoreJSWeakMapAndWeakMapLike = CoreJSWeakMapLike & WeakMap; export interface CoreJSSetLike extends Set { union(...args: any[]): CoreJSSetLike; @@ -26,8 +28,10 @@ export interface CoreJSSetLike extends Set { isSupersetOf(...args: any[]): boolean; isDisjointFrom(...args: any[]): boolean; } +export type CoreJSSetAndSetLike = CoreJSSetLike & Set; export interface CoreJSWeakSetLike extends WeakSet {} +export type CoreJSWeakSetAndWeakSetLike = CoreJSWeakSetLike & WeakSet; export interface CoreJSIteratorLike extends Iterator { chunks(...args: any[]): CoreJSIteratorLike; @@ -45,4 +49,4 @@ export interface CoreJSIteratorLike extends Itera find(...args: any[]): T | undefined; join(...args: any[]): string; } -export type CoreJSIteratorOrIteratorLike = CoreJSIteratorLike | Iterator; +export type CoreJSIteratorAndIteratorLike = CoreJSIteratorLike & Iterator; diff --git a/tests/type-definitions/pure/proposals/accessible-object-hasownproperty.test.ts b/tests/type-definitions/pure/proposals/accessible-object-hasownproperty.test.ts index 5ba3431548ad..d934cb37c0f0 100644 --- a/tests/type-definitions/pure/proposals/accessible-object-hasownproperty.test.ts +++ b/tests/type-definitions/pure/proposals/accessible-object-hasownproperty.test.ts @@ -1,6 +1,6 @@ import objectHasOwn from '@core-js/pure/full/object/has-own'; -objectHasOwn({a: 1}, 'a'); +const res: boolean = objectHasOwn({a: 1}, 'a'); objectHasOwn([], 0); objectHasOwn(new Date(), 'toISOString'); objectHasOwn(Object.create(null), Symbol.iterator); diff --git a/tests/type-definitions/pure/proposals/array-filtering.test.ts b/tests/type-definitions/pure/proposals/array-filtering.test.ts index bb66099f102e..3bccc321ab15 100644 --- a/tests/type-definitions/pure/proposals/array-filtering.test.ts +++ b/tests/type-definitions/pure/proposals/array-filtering.test.ts @@ -1,9 +1,9 @@ import arrayFilterReject from '@core-js/pure/full/array/filter-reject'; -arrayFilterReject([1, 2, 3], (v, i, arr) => v > 1); +const res: number[] = arrayFilterReject([1, 2, 3], (v, i, arr) => v > 1); arrayFilterReject(['a', 'b'], (v, i, arr) => v === 'a'); const arr: number[] = [1, 2, 3]; -const res: number[] = arrayFilterReject(arr, function(v) { return v < 2; }, { foo: true }); +arrayFilterReject(arr, function(v) { return v < 2; }, { foo: true }); // @ts-expect-error [1, 2, 3].arrayFilterReject((x: string) => false); diff --git a/tests/type-definitions/pure/proposals/array-from-async.test.ts b/tests/type-definitions/pure/proposals/array-from-async.test.ts index 0793f7648030..e84bf38d698e 100644 --- a/tests/type-definitions/pure/proposals/array-from-async.test.ts +++ b/tests/type-definitions/pure/proposals/array-from-async.test.ts @@ -1,12 +1,12 @@ import arrayFromAsync from '@core-js/pure/full/array/from-async'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseOrPromiseLike } from '../../helpers'; +import { CoreJSPromiseAndPromiseLike } from '../../helpers'; -const p1: CoreJSPromiseOrPromiseLike = arrayFromAsync([1, 2, 3]); -const p2: CoreJSPromiseOrPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3]); -const p3: CoreJSPromiseOrPromiseLike = arrayFromAsync([1, 2, 3], (value: number, index: number) => value.toString()); -const p4: CoreJSPromiseOrPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3], (value: number) => value + 1); -const p5: CoreJSPromiseOrPromiseLike = arrayFromAsync([1, 2, 3], function (this: { foo: string }, value: number) { return value.toString(); }, { foo: 'str' }); +const p1: CoreJSPromiseAndPromiseLike = arrayFromAsync([1, 2, 3]); +const p2: CoreJSPromiseAndPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3]); +const p3: CoreJSPromiseAndPromiseLike = arrayFromAsync([1, 2, 3], (value: number, index: number) => value.toString()); +const p4: CoreJSPromiseAndPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3], (value: number) => value + 1); +const p5: CoreJSPromiseAndPromiseLike = arrayFromAsync([1, 2, 3], function (this: { foo: string }, value: number) { return value.toString(); }, { foo: 'str' }); async function t1() { const n: number[] = await arrayFromAsync([1, 2, 3]); @@ -20,8 +20,8 @@ async function t2() { } declare const arrLike: { [index: number]: PromiseLike; length: 2 }; -const p6: CoreJSPromiseOrPromiseLike = arrayFromAsync(arrLike); -const p7: CoreJSPromiseOrPromiseLike = arrayFromAsync(arrLike, (value: number) => value); +const p6: CoreJSPromiseAndPromiseLike = arrayFromAsync(arrLike); +const p7: CoreJSPromiseAndPromiseLike = arrayFromAsync(arrLike, (value: number) => value); // @ts-expect-error arrayFromAsync([1, 2, 3], (value: string) => value); diff --git a/tests/type-definitions/pure/proposals/array-grouping.test.ts b/tests/type-definitions/pure/proposals/array-grouping.test.ts index 6da5d624772d..76b588d6afc4 100644 --- a/tests/type-definitions/pure/proposals/array-grouping.test.ts +++ b/tests/type-definitions/pure/proposals/array-grouping.test.ts @@ -1,12 +1,12 @@ import objectGroupBy from '@core-js/pure/full/object/group-by'; import mapGroupBy from '@core-js/pure/full/map/group-by'; -import { CoreJSMapLike } from '../../helpers'; +import { CoreJSMapAndMapLike } from '../../helpers'; const arr = [1, 2, 3, 4, 5]; const objGroup: Partial> = objectGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); -const mapGroup: CoreJSMapLike<'even' | 'odd', number[]> = mapGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); +const mapGroup: CoreJSMapAndMapLike<'even' | 'odd', number[]> = mapGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); const objGroup2: Partial> = objectGroupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); -const mapGroup2: CoreJSMapLike = mapGroupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); +const mapGroup2: CoreJSMapAndMapLike = mapGroupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); objectGroupBy('test', c => c); objectGroupBy(new Set([1, 2, 3]), item => item > 2 ? 'big' : 'small'); diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 97b185ba4226..7226d1256c91 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -12,7 +12,7 @@ import take from '@core-js/pure/full/async-iterator/take'; import toArray from '@core-js/pure/full/async-iterator/to-array'; import toAsync from '@core-js/pure/full/iterator/to-async'; // import $AsyncIterator from '@core-js/pure/full/async-iterator'; // todo -import { CoreJSPromiseOrPromiseLike } from '../../helpers'; +import { CoreJSPromiseAndPromiseLike } from '../../helpers'; const aiton = from([1, 2, 3]); aiton.next(); @@ -41,16 +41,16 @@ toAsync(is); toAsync(itn); drop(aiton, 3); -const r2: CoreJSPromiseOrPromiseLike = every(aiton, (v: number, i: number) => v > 0); +const r2: CoreJSPromiseAndPromiseLike = every(aiton, (v: number, i: number) => v > 0); filter(aiton, (v: number, i: number) => v > 0); -const r4: CoreJSPromiseOrPromiseLike = find(aiton, (v: number, i: number) => v > 0); +const r4: CoreJSPromiseAndPromiseLike = find(aiton, (v: number, i: number) => v > 0); flatMap(aiton, (v: number, i: number) => `${v}`); -const r6: CoreJSPromiseOrPromiseLike = forEach(aiton, (v: number, i: number) => { }); +const r6: CoreJSPromiseAndPromiseLike = forEach(aiton, (v: number, i: number) => { }); map(aiton, (v: number, i: number) => v * 2); -const r8: CoreJSPromiseOrPromiseLike = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); -const r9: CoreJSPromiseOrPromiseLike = some(aiton, (v: number, i: number) => v > 0); +const r8: CoreJSPromiseAndPromiseLike = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); +const r9: CoreJSPromiseAndPromiseLike = some(aiton, (v: number, i: number) => v > 0); take(aiton, 10); -const r11: CoreJSPromiseOrPromiseLike = toArray(aiton); +const r11: CoreJSPromiseAndPromiseLike = toArray(aiton); // @ts-expect-error drop(ain); @@ -75,8 +75,8 @@ take(ain); // @ts-expect-error toArray(ain, 1); -const s0: CoreJSPromiseOrPromiseLike = toArray(aiton); -const f0: CoreJSPromiseOrPromiseLike = find(aitos, (v: string, i: number) => v.length === 1); +const s0: CoreJSPromiseAndPromiseLike = toArray(aiton); +const f0: CoreJSPromiseAndPromiseLike = find(aitos, (v: string, i: number) => v.length === 1); // @ts-expect-error map(ais, (v: string, i: number) => v.length === 1, 'extra'); diff --git a/tests/type-definitions/pure/proposals/await-dictionary.test.ts b/tests/type-definitions/pure/proposals/await-dictionary.test.ts index c45b4b1830b0..f94f0c07816e 100644 --- a/tests/type-definitions/pure/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/pure/proposals/await-dictionary.test.ts @@ -2,16 +2,16 @@ import promiseAllKeyed from '@core-js/pure/full/promise/all-keyed'; import promiseAllSettledKeyed from '@core-js/pure/full/promise/all-settled-keyed'; import promiseResolve from '@core-js/pure/full/promise/resolve'; import $Symbol from '@core-js/pure/full/symbol'; -import { CoreJSPromiseOrPromiseLike } from '../../helpers'; +import { CoreJSPromiseAndPromiseLike } from '../../helpers'; -const res: CoreJSPromiseOrPromiseLike<{ a: number, b: string, c: boolean }> = promiseAllKeyed({ +const res: CoreJSPromiseAndPromiseLike<{ a: number, b: string, c: boolean }> = promiseAllKeyed({ a: promiseResolve(1), b: promiseResolve('string'), c: promiseResolve(true), }); const sym = $Symbol('sym'); -const res2: CoreJSPromiseOrPromiseLike<{ [sym]: number }> = promiseAllKeyed({ +const res2: CoreJSPromiseAndPromiseLike<{ [sym]: number }> = promiseAllKeyed({ [sym]: promiseResolve(1) }); diff --git a/tests/type-definitions/pure/proposals/collection-of-from.test.ts b/tests/type-definitions/pure/proposals/collection-of-from.test.ts index 47ba7a8c5426..c5a3a64a370e 100644 --- a/tests/type-definitions/pure/proposals/collection-of-from.test.ts +++ b/tests/type-definitions/pure/proposals/collection-of-from.test.ts @@ -6,10 +6,10 @@ import weakMapFrom from '@core-js/pure/full/weak-map/from'; import weakMapOf from '@core-js/pure/full/weak-map/of'; import weakSetFrom from '@core-js/pure/full/weak-set/from'; import weakSetOf from '@core-js/pure/full/weak-set/of'; -import { CoreJSMapLike, CoreJSSetLike, CoreJSWeakMapLike, CoreJSWeakSetLike } from '../../helpers'; +import { CoreJSMapAndMapLike, CoreJSSetAndSetLike, CoreJSWeakMapAndWeakMapLike, CoreJSWeakSetAndWeakSetLike } from '../../helpers'; -const rm: CoreJSMapLike = mapFrom([[1, 'a'], [2, 'b']] as [number, string][]); -const rm2: CoreJSMapLike = mapFrom([[1, 10], [2, 20]] as [number, number][], (v: number, k: number) => v + k); +const rm: CoreJSMapAndMapLike = mapFrom([[1, 'a'], [2, 'b']] as [number, string][]); +const rm2: CoreJSMapAndMapLike = mapFrom([[1, 10], [2, 20]] as [number, number][], (v: number, k: number) => v + k); mapFrom([[1, 10], [2, 20]] as [number, number][], function (this: { n: number }, v: number) { return v + this.n; }, { n: 2 }); // @ts-expect-error mapFrom([['a', 1], ['b', 2]], (v: string, k: number) => v); @@ -19,28 +19,28 @@ mapFrom([1, 2]); mapFrom(); mapOf(['a', 1], ['b', 2]); -const rm4: CoreJSMapLike = mapOf(['a', 1], ['b', 2]); +const rm4: CoreJSMapAndMapLike = mapOf(['a', 1], ['b', 2]); // @ts-expect-error mapOf([1, 2, 3]); // @ts-expect-error mapOf(1, 2); -const rs1: CoreJSSetLike = setFrom([1, 2, 3]); -const rs2: CoreJSSetLike = setFrom([1, 2, 3], x => x.toString()); -const rs3: CoreJSSetLike<[string, number]> = setFrom([['a', 1], ['b', 2]]); +const rs1: CoreJSSetAndSetLike = setFrom([1, 2, 3]); +const rs2: CoreJSSetAndSetLike = setFrom([1, 2, 3], x => x.toString()); +const rs3: CoreJSSetAndSetLike<[string, number]> = setFrom([['a', 1], ['b', 2]]); setFrom(['a', 'b'], function (this: { s: string }, value: string) { return value + this.s; }, { s: '-' }); // @ts-expect-error setFrom([1, 2, 3], (v: string) => v); // @ts-expect-error setFrom(); -const rso1: CoreJSSetLike = setOf(1, 2, 3); -const rso2: CoreJSSetLike = setOf('a', 'b', 'c'); +const rso1: CoreJSSetAndSetLike = setOf(1, 2, 3); +const rso2: CoreJSSetAndSetLike = setOf('a', 'b', 'c'); // @ts-expect-error setOf({ 'foo': 'bar' }, 2); -const rwm1: CoreJSWeakMapLike<{ a: number }, string> = weakMapFrom([[{ a: 1 }, 'x']] as [{ a: number }, string][]); -const rwm2: CoreJSWeakMapLike = weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], (v, k) => v.toString()); +const rwm1: CoreJSWeakMapAndWeakMapLike<{ a: number }, string> = weakMapFrom([[{ a: 1 }, 'x']] as [{ a: number }, string][]); +const rwm2: CoreJSWeakMapAndWeakMapLike = weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], (v, k) => v.toString()); weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], function (this: { s: string }, v: number) { return this.s + v; }, { s: '-' }); // @ts-expect-error weakMapFrom([[1, 2], [2, 3]]); @@ -51,14 +51,14 @@ weakMapFrom([1, 2]); // @ts-expect-error weakMapFrom(); -const rwmo1: CoreJSWeakMapLike = weakMapOf([{}, 2]); +const rwmo1: CoreJSWeakMapAndWeakMapLike = weakMapOf([{}, 2]); // @ts-expect-error weakMapOf([1, 2]); // @ts-expect-error weakMapOf({}); -const rws1: CoreJSWeakSetLike = weakSetFrom([{}]); -const rws2: CoreJSWeakSetLike = weakSetFrom([{}, {}], x => x); +const rws1: CoreJSWeakSetAndWeakSetLike = weakSetFrom([{}]); +const rws2: CoreJSWeakSetAndWeakSetLike = weakSetFrom([{}, {}], x => x); weakSetFrom([{}], function (this: { s: string }, obj: object) { return obj; }, { s: '-' }); // @ts-expect-error weakSetFrom([1, 2]); @@ -69,6 +69,6 @@ weakSetFrom(); // @ts-expect-error weakSetFrom([{}], x => 'not-an-object'); -const rwso1: CoreJSWeakSetLike = weakSetOf({}); +const rwso1: CoreJSWeakSetAndWeakSetLike = weakSetOf({}); // @ts-expect-error weakSetOf(1); diff --git a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts index 6a262d1488a2..987f19ae8c6c 100644 --- a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts @@ -7,7 +7,7 @@ import asyncIteratorFrom from '@core-js/pure/full/async-iterator/from'; import $SuppressedError from '@core-js/pure/full/suppressed-error/constructor'; import $DisposableStack from '@core-js/pure/full/disposable-stack/constructor'; import $AsyncDisposableStack from '@core-js/pure/full/async-disposable-stack/constructor'; -import { CoreJSPromiseOrPromiseLike } from '../../helpers'; +import { CoreJSPromiseAndPromiseLike } from '../../helpers'; const d: symbol = symbolDispose; const ad: symbol = symbolAsyncDispose; @@ -23,7 +23,7 @@ objD[symbolDispose](); const objAD = { [symbolAsyncDispose]() { return promiseResolve(); } } -const p1: CoreJSPromiseOrPromiseLike = objAD[symbolAsyncDispose](); +const p1: CoreJSPromiseAndPromiseLike = objAD[symbolAsyncDispose](); const err1 = new $SuppressedError('err', 'suppressed', 'msg'); err1.error; @@ -65,7 +65,7 @@ objDS[symbolToStringTag] = 'foo'; $AsyncDisposableStack.prototype; const objADS = new $AsyncDisposableStack(); const disposedASD: boolean = objDS.disposed; -const rda: CoreJSPromiseOrPromiseLike = objADS.disposeAsync(); +const rda: CoreJSPromiseAndPromiseLike = objADS.disposeAsync(); objADS.use(objAD); objADS.use(objD); const ruseASD3: null = objADS.use(null); diff --git a/tests/type-definitions/pure/proposals/iterator-chunking.test.ts b/tests/type-definitions/pure/proposals/iterator-chunking.test.ts index f0f3d38a5025..325d6b48b9d3 100644 --- a/tests/type-definitions/pure/proposals/iterator-chunking.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-chunking.test.ts @@ -1,12 +1,13 @@ import iteratorChunks from '@core-js/pure/full/iterator/chunks'; import iteratorWindows from '@core-js/pure/full/iterator/windows'; +import { CoreJSIteratorAndIteratorLike } from '../../helpers'; declare function getNumberIterator(): Iterator; const numbersIter = getNumberIterator(); -const chunksObj: Iterator = iteratorChunks(numbersIter, 2); -const windowsObj: Iterator = iteratorWindows(numbersIter, 4); +const chunksObj: CoreJSIteratorAndIteratorLike = iteratorChunks(numbersIter, 2); +const windowsObj: CoreJSIteratorAndIteratorLike = iteratorWindows(numbersIter, 4); const chunkNext = chunksObj.next(); const windowsNext = windowsObj.next(); diff --git a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts index 4409aa074276..dc951362d7c0 100644 --- a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts @@ -9,42 +9,42 @@ import iteratorForEach from '@core-js/pure/full/iterator/for-each'; import iteratorSome from '@core-js/pure/full/iterator/some'; import iteratorEvery from '@core-js/pure/full/iterator/every'; import iteratorFind from '@core-js/pure/full/iterator/find'; -import { CoreJSIteratorOrIteratorLike } from '../../helpers'; +import { CoreJSIteratorAndIteratorLike } from '../../helpers'; declare const it: Iterator; declare const itStr: Iterator; declare const itNumStr: Iterator; -const res: CoreJSIteratorOrIteratorLike = iteratorMap(it, (v, i) => String(v)); -const mappedNum: CoreJSIteratorOrIteratorLike = iteratorMap(it, n => n + 1); +const res: CoreJSIteratorAndIteratorLike = iteratorMap(it, (v, i) => String(v)); +const mappedNum: CoreJSIteratorAndIteratorLike = iteratorMap(it, n => n + 1); // @ts-expect-error iteratorMap(); // @ts-expect-error iteratorMap((v, i, extra) => v + i + extra); -const onlyEven: CoreJSIteratorOrIteratorLike = iteratorFilter(it, v => v % 2 === 0); -const filtered: CoreJSIteratorOrIteratorLike = iteratorFilter(it, (v): v is number => typeof v === 'number'); +const onlyEven: CoreJSIteratorAndIteratorLike = iteratorFilter(it, v => v % 2 === 0); +const filtered: CoreJSIteratorAndIteratorLike = iteratorFilter(it, (v): v is number => typeof v === 'number'); // @ts-expect-error iteratorFilter(); // @ts-expect-error iteratorFilter((v, i, extra) => true); -const taken: CoreJSIteratorOrIteratorLike = iteratorTake(it, 5); +const taken: CoreJSIteratorAndIteratorLike = iteratorTake(it, 5); // @ts-expect-error iteratorTake(); // @ts-expect-error iteratorTake('5'); -const dropped: CoreJSIteratorOrIteratorLike = iteratorDrop(it, 3); +const dropped: CoreJSIteratorAndIteratorLike = iteratorDrop(it, 3); // @ts-expect-error iteratorDrop('3'); -const flatMapped: CoreJSIteratorOrIteratorLike = iteratorFlatMap(it, (v, i) => itStr); -const flatMapped2: CoreJSIteratorOrIteratorLike = iteratorFlatMap(it, (v, i) => ({ +const flatMapped: CoreJSIteratorAndIteratorLike = iteratorFlatMap(it, (v, i) => itStr); +const flatMapped2: CoreJSIteratorAndIteratorLike = iteratorFlatMap(it, (v, i) => ({ [Symbol.iterator]: function* () { yield String(v); } diff --git a/tests/type-definitions/pure/proposals/iterator-joint.test.ts b/tests/type-definitions/pure/proposals/iterator-joint.test.ts index 6772c14375ba..e261b0d63de5 100644 --- a/tests/type-definitions/pure/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-joint.test.ts @@ -1,12 +1,12 @@ import iteratorZip from '@core-js/pure/full/iterator/zip'; import iteratorZipKeyed from '@core-js/pure/full/iterator/zip-keyed'; -import { CoreJSIteratorOrIteratorLike } from '../../helpers'; +import { CoreJSIteratorAndIteratorLike } from '../../helpers'; -const zipped1: CoreJSIteratorOrIteratorLike = iteratorZip([[1, 2, 3], [4, 5, 6]]); -const zipped2: CoreJSIteratorOrIteratorLike = iteratorZip([['a', 'b', 'c'], ['d', 'e', 'f']]); -const zipped3: CoreJSIteratorOrIteratorLike = iteratorZip([[1, 2, 3], [4, 5, 6]], { mode: "shortest" }); -const zipped4: CoreJSIteratorOrIteratorLike> = iteratorZipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); -const zipped5: CoreJSIteratorOrIteratorLike> = iteratorZipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: "shortest" }); +const zipped1: CoreJSIteratorAndIteratorLike = iteratorZip([[1, 2, 3], [4, 5, 6]]); +const zipped2: CoreJSIteratorAndIteratorLike = iteratorZip([['a', 'b', 'c'], ['d', 'e', 'f']]); +const zipped3: CoreJSIteratorAndIteratorLike = iteratorZip([[1, 2, 3], [4, 5, 6]], { mode: "shortest" }); +const zipped4: CoreJSIteratorAndIteratorLike> = iteratorZipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); +const zipped5: CoreJSIteratorAndIteratorLike> = iteratorZipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: "shortest" }); // @ts-expect-error iteratorZip(true); diff --git a/tests/type-definitions/pure/proposals/iterator-range.test.ts b/tests/type-definitions/pure/proposals/iterator-range.test.ts index 15a15b95b29c..418a6850eabc 100644 --- a/tests/type-definitions/pure/proposals/iterator-range.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-range.test.ts @@ -1,7 +1,7 @@ import iteratorRange from '@core-js/pure/full/iterator/range'; -import { CoreJSIteratorOrIteratorLike } from '../../helpers'; +import { CoreJSIteratorAndIteratorLike } from '../../helpers'; -const rir1: CoreJSIteratorOrIteratorLike = iteratorRange(1, 10); +const rir1: CoreJSIteratorAndIteratorLike = iteratorRange(1, 10); iteratorRange(1, 10, 1); iteratorRange(1, 10, { step: 1 }); iteratorRange(1, 10, { inclusive: true }); diff --git a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts index 9f8ae5184c5a..1dc7b4d2c600 100644 --- a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts @@ -1,5 +1,5 @@ import iteratorConcat from '@core-js/pure/full/iterator/concat'; -import { CoreJSIteratorOrIteratorLike } from '../../helpers'; +import { CoreJSIteratorAndIteratorLike } from '../../helpers'; declare const its1: Iterable; declare const arrs: string[]; @@ -7,11 +7,11 @@ declare const arrn: number[]; declare const arrb: boolean[]; declare const itb1: Iterable; -const ri1: CoreJSIteratorOrIteratorLike = iteratorConcat(its1); -const ri2: CoreJSIteratorOrIteratorLike = iteratorConcat(arrs); -const ri3: CoreJSIteratorOrIteratorLike = iteratorConcat(arrn); -const ri4: CoreJSIteratorOrIteratorLike = iteratorConcat(arrb, itb1); -const ri5: CoreJSIteratorOrIteratorLike = iteratorConcat(); +const ri1: CoreJSIteratorAndIteratorLike = iteratorConcat(its1); +const ri2: CoreJSIteratorAndIteratorLike = iteratorConcat(arrs); +const ri3: CoreJSIteratorAndIteratorLike = iteratorConcat(arrn); +const ri4: CoreJSIteratorAndIteratorLike = iteratorConcat(arrb, itb1); +const ri5: CoreJSIteratorAndIteratorLike = iteratorConcat(); // @ts-expect-error iteratorConcat(1); diff --git a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts index 3b2d05cf80cc..68259b568993 100644 --- a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts @@ -1,6 +1,6 @@ import promiseAllSettled from '@core-js/pure/full/promise/all-settled'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseOrPromiseLike } from '../../helpers'; +import { CoreJSPromiseAndPromiseLike } from '../../helpers'; interface CoreJSPromiseResult { status: string; @@ -10,19 +10,19 @@ interface CoreJSPromiseResult { const promiseLike = { then: (cb: (val: number) => void) => cb(42) }; -const p1: CoreJSPromiseOrPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = +const p1: CoreJSPromiseAndPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = promiseAllSettled([promiseResolve(10), promiseResolve(20), 30]); -const p2: CoreJSPromiseOrPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = +const p2: CoreJSPromiseAndPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = promiseAllSettled(['a', 'b', 'c']); -const p3: CoreJSPromiseOrPromiseLike[]> = +const p3: CoreJSPromiseAndPromiseLike[]> = promiseAllSettled(new Set([1, 2, 3])); promiseAllSettled([promiseLike]); const emptyTuple: [] = []; -const settled6: CoreJSPromiseOrPromiseLike<[]> = promiseAllSettled(emptyTuple); +const settled6: CoreJSPromiseAndPromiseLike<[]> = promiseAllSettled(emptyTuple); const mixedTuple = [42, promiseResolve('bar')] as const; -const p4: CoreJSPromiseOrPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult]> = +const p4: CoreJSPromiseAndPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult]> = promiseAllSettled(mixedTuple); // @ts-expect-error diff --git a/tests/type-definitions/pure/proposals/promise-any.test.ts b/tests/type-definitions/pure/proposals/promise-any.test.ts index 86288546799f..7c351c2a7b69 100644 --- a/tests/type-definitions/pure/proposals/promise-any.test.ts +++ b/tests/type-definitions/pure/proposals/promise-any.test.ts @@ -1,6 +1,6 @@ import promiseAny from '@core-js/pure/full/promise/any'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseOrPromiseLike } from '../../helpers'; +import { CoreJSPromiseAndPromiseLike } from '../../helpers'; const arr = [promiseResolve(1), promiseResolve("foo"), 3] as const; const justNumbers = [1, 2, 3]; @@ -9,16 +9,16 @@ const promiseLike = { then: (cb: (val: number) => void) => cb(123) }; const emptyTuple: [] = []; const mixed = [true, promiseResolve("z")] as const; -const any1: CoreJSPromiseOrPromiseLike = promiseAny(arr); -const any2: CoreJSPromiseOrPromiseLike = promiseAny(["x", "y", promiseResolve(5)]); -const any3: CoreJSPromiseOrPromiseLike = promiseAny(emptyTuple); -const any4: CoreJSPromiseOrPromiseLike = promiseAny(mixed); +const any1: CoreJSPromiseAndPromiseLike = promiseAny(arr); +const any2: CoreJSPromiseAndPromiseLike = promiseAny(["x", "y", promiseResolve(5)]); +const any3: CoreJSPromiseAndPromiseLike = promiseAny(emptyTuple); +const any4: CoreJSPromiseAndPromiseLike = promiseAny(mixed); -const any5: CoreJSPromiseOrPromiseLike = promiseAny(justNumbers); -const any6: CoreJSPromiseOrPromiseLike = promiseAny(setOfStrings); -const any7: CoreJSPromiseOrPromiseLike = promiseAny([promiseLike]); -const any8: CoreJSPromiseOrPromiseLike = promiseAny(new Set([1])); -const any9: CoreJSPromiseOrPromiseLike = promiseAny([promiseResolve()]); +const any5: CoreJSPromiseAndPromiseLike = promiseAny(justNumbers); +const any6: CoreJSPromiseAndPromiseLike = promiseAny(setOfStrings); +const any7: CoreJSPromiseAndPromiseLike = promiseAny([promiseLike]); +const any8: CoreJSPromiseAndPromiseLike = promiseAny(new Set([1])); +const any9: CoreJSPromiseAndPromiseLike = promiseAny([promiseResolve()]); // @ts-expect-error promiseAny(); diff --git a/tests/type-definitions/pure/proposals/promise-finally.test.ts b/tests/type-definitions/pure/proposals/promise-finally.test.ts index 5ac6cd9a4594..960775605f1e 100644 --- a/tests/type-definitions/pure/proposals/promise-finally.test.ts +++ b/tests/type-definitions/pure/proposals/promise-finally.test.ts @@ -1,20 +1,20 @@ import promiseFinally from '@core-js/pure/full/promise/finally'; import promiseResolve from '@core-js/pure/full/promise/resolve'; import promiseReject from '@core-js/pure/full/promise/reject'; -import { CoreJSPromiseOrPromiseLike } from '../../helpers'; +import { CoreJSPromiseAndPromiseLike } from '../../helpers'; -const pr1: CoreJSPromiseOrPromiseLike = promiseResolve(42); +const pr1: CoreJSPromiseAndPromiseLike = promiseResolve(42); declare const p1: Promise; -const pf1: CoreJSPromiseOrPromiseLike = promiseFinally(p1); -const pf2: CoreJSPromiseOrPromiseLike = promiseFinally(p1, undefined); -const pf3: CoreJSPromiseOrPromiseLike = promiseFinally(p1, null); -const pf4: CoreJSPromiseOrPromiseLike = promiseFinally(p1, () => {}); -const pf5: CoreJSPromiseOrPromiseLike = promiseFinally(p1, function () {}); +const pf1: CoreJSPromiseAndPromiseLike = promiseFinally(p1); +const pf2: CoreJSPromiseAndPromiseLike = promiseFinally(p1, undefined); +const pf3: CoreJSPromiseAndPromiseLike = promiseFinally(p1, null); +const pf4: CoreJSPromiseAndPromiseLike = promiseFinally(p1, () => {}); +const pf5: CoreJSPromiseAndPromiseLike = promiseFinally(p1, function () {}); -const pr2: CoreJSPromiseOrPromiseLike = promiseReject("err"); +const pr2: CoreJSPromiseAndPromiseLike = promiseReject("err"); declare const p2: Promise; -const pf6: CoreJSPromiseOrPromiseLike = promiseFinally(p2); -const pf7: CoreJSPromiseOrPromiseLike = promiseFinally(p2, () => {}); +const pf6: CoreJSPromiseAndPromiseLike = promiseFinally(p2); +const pf7: CoreJSPromiseAndPromiseLike = promiseFinally(p2, () => {}); // @ts-expect-error promiseFinally(p1, 123); diff --git a/tests/type-definitions/pure/proposals/promise-try.test.ts b/tests/type-definitions/pure/proposals/promise-try.test.ts index 149b84db24a6..f25e0e99801e 100644 --- a/tests/type-definitions/pure/proposals/promise-try.test.ts +++ b/tests/type-definitions/pure/proposals/promise-try.test.ts @@ -1,19 +1,19 @@ import promiseTry from '@core-js/pure/full/promise/try'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseOrPromiseLike } from '../../helpers'; +import { CoreJSPromiseAndPromiseLike } from '../../helpers'; -const pt1: CoreJSPromiseOrPromiseLike = promiseTry(() => 42); -const pt2: CoreJSPromiseOrPromiseLike = promiseTry(() => promiseResolve("hi")); -const pt3: CoreJSPromiseOrPromiseLike = promiseTry((a: number, b: number) => a + b, 1, 2); -const pt4: CoreJSPromiseOrPromiseLike = promiseTry((x: string) => x + "!!", "test"); -const pt5: CoreJSPromiseOrPromiseLike = promiseTry(() => {}); -const pt6: CoreJSPromiseOrPromiseLike = promiseTry((b: boolean) => b, false); +const pt1: CoreJSPromiseAndPromiseLike = promiseTry(() => 42); +const pt2: CoreJSPromiseAndPromiseLike = promiseTry(() => promiseResolve("hi")); +const pt3: CoreJSPromiseAndPromiseLike = promiseTry((a: number, b: number) => a + b, 1, 2); +const pt4: CoreJSPromiseAndPromiseLike = promiseTry((x: string) => x + "!!", "test"); +const pt5: CoreJSPromiseAndPromiseLike = promiseTry(() => {}); +const pt6: CoreJSPromiseAndPromiseLike = promiseTry((b: boolean) => b, false); -const pt7: CoreJSPromiseOrPromiseLike = promiseTry((a: number, b: string, c: boolean) => c ? a : Number(b), 10, "100", true); -const pt8: CoreJSPromiseOrPromiseLike = promiseTry((a: string) => promiseResolve(a), "bar"); +const pt7: CoreJSPromiseAndPromiseLike = promiseTry((a: number, b: string, c: boolean) => c ? a : Number(b), 10, "100", true); +const pt8: CoreJSPromiseAndPromiseLike = promiseTry((a: string) => promiseResolve(a), "bar"); -declare function returnsPromise(): CoreJSPromiseOrPromiseLike; -const pt9: CoreJSPromiseOrPromiseLike = promiseTry(() => returnsPromise()); +declare function returnsPromise(): CoreJSPromiseAndPromiseLike; +const pt9: CoreJSPromiseAndPromiseLike = promiseTry(() => returnsPromise()); // @ts-expect-error promiseTry(); diff --git a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts index 6492aae20448..197cf58cf3eb 100644 --- a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts +++ b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts @@ -1,14 +1,14 @@ import promiseWithResolvers from '@core-js/pure/full/promise/with-resolvers'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseOrPromiseLike } from '../../helpers'; +import { CoreJSPromiseAndPromiseLike } from '../../helpers'; const pr = promiseWithResolvers(); const pr2 = promiseWithResolvers(); const pr3 = promiseWithResolvers(); -const p1: CoreJSPromiseOrPromiseLike = pr.promise; -const p2: CoreJSPromiseOrPromiseLike = pr2.promise; -const p3: CoreJSPromiseOrPromiseLike = pr3.promise; +const p1: CoreJSPromiseAndPromiseLike = pr.promise; +const p2: CoreJSPromiseAndPromiseLike = pr2.promise; +const p3: CoreJSPromiseAndPromiseLike = pr3.promise; pr.resolve(42); pr.resolve(promiseResolve(43)); diff --git a/tests/type-definitions/pure/proposals/set-methods.test.ts b/tests/type-definitions/pure/proposals/set-methods.test.ts index a00e184bdd09..66fe451c0868 100644 --- a/tests/type-definitions/pure/proposals/set-methods.test.ts +++ b/tests/type-definitions/pure/proposals/set-methods.test.ts @@ -6,7 +6,7 @@ import setSymmetricDifference from '@core-js/pure/full/set/symmetric-difference' import setIsSubsetOf from '@core-js/pure/full/set/is-subset-of'; import setIsSupersetOf from '@core-js/pure/full/set/is-superset-of'; import setIsDisjointFrom from '@core-js/pure/full/set/is-disjoint-from'; -import { CoreJSSetLike } from '../../helpers'; +import { CoreJSSetAndSetLike } from '../../helpers'; const setA = new $Set([1, 2, 3]); const setB = new $Set(['a', 'b', 'c']); @@ -23,20 +23,20 @@ const setLikeStr = { size: 2 }; -const unionAB: CoreJSSetLike = setUnion(setA, setB); -const unionAL: CoreJSSetLike = setUnion(setA, setLike); -const unionALS: CoreJSSetLike = setUnion(setA, setLikeStr); +const unionAB: CoreJSSetAndSetLike = setUnion(setA, setB); +const unionAL: CoreJSSetAndSetLike = setUnion(setA, setLike); +const unionALS: CoreJSSetAndSetLike = setUnion(setA, setLikeStr); -const interAB: CoreJSSetLike = setIntersection(setA, setB); -const interAN: CoreJSSetLike = setIntersection(setA, setLike); -const intersectionALS: CoreJSSetLike = setIntersection(setA, setLikeStr); +const interAB: CoreJSSetAndSetLike = setIntersection(setA, setB); +const interAN: CoreJSSetAndSetLike = setIntersection(setA, setLike); +const intersectionALS: CoreJSSetAndSetLike = setIntersection(setA, setLikeStr); -const diffAB: CoreJSSetLike = setDifference(setA, setB); -const diffAN: CoreJSSetLike = setDifference(setA, setLike); -const diffALS: CoreJSSetLike = setDifference(setA, setLikeStr); +const diffAB: CoreJSSetAndSetLike = setDifference(setA, setB); +const diffAN: CoreJSSetAndSetLike = setDifference(setA, setLike); +const diffALS: CoreJSSetAndSetLike = setDifference(setA, setLikeStr); -const symdiffAB: CoreJSSetLike = setSymmetricDifference(setA, setB); -const symdiffAL: CoreJSSetLike = setSymmetricDifference(setA, setLike); +const symdiffAB: CoreJSSetAndSetLike = setSymmetricDifference(setA, setB); +const symdiffAL: CoreJSSetAndSetLike = setSymmetricDifference(setA, setLike); const sub: boolean = setIsSubsetOf(setA, setLikeStr); const superSet: boolean = setIsSupersetOf(setA, setLikeStr); From ff7d13ed50f6209497fd8c5581fe2fe299ed8b8f Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 9 Jan 2026 03:54:58 +0700 Subject: [PATCH 128/315] Fix String dedent --- .../src/base/proposals/string-dedent.d.ts | 15 +++------ .../base/pure/proposals/string-dedent.d.ts | 32 ------------------- .../global/proposals/string-dedent.test.ts | 5 ++- .../pure/proposals/string-dedent.test.ts | 4 ++- 4 files changed, 11 insertions(+), 45 deletions(-) delete mode 100644 packages/core-js-types/src/base/pure/proposals/string-dedent.d.ts diff --git a/packages/core-js-types/src/base/proposals/string-dedent.d.ts b/packages/core-js-types/src/base/proposals/string-dedent.d.ts index dce7a4ae6bd9..11e4272bee35 100644 --- a/packages/core-js-types/src/base/proposals/string-dedent.d.ts +++ b/packages/core-js-types/src/base/proposals/string-dedent.d.ts @@ -4,20 +4,13 @@ interface StringConstructor { /** * Template tag that removes common leading whitespace from every line in the resulting string, * preserving relative indentation and blank lines. - * @param template The template strings array, strings array, or a single string. + * @param template The template strings array, a single string, and function. * @param values Values to be interpolated into the template string. * @returns The dedented string. */ - dedent(template: TemplateStringsArray | ArrayLike, ...values: any[]): string; dedent(template: { raw: readonly string[] }, ...values: any[]): string; dedent(template: string): string; -} - -interface String { - /** - * Template tag that removes common leading whitespace from every line in the resulting string, - * preserving relative indentation and blank lines. - * @returns The dedented string. - */ - dedent(): string; + dedent( + fn: (template: { raw: readonly string[] }, ...values: any[]) => R + ): (template: { raw: readonly string[] }, ...values: any[]) => string; } diff --git a/packages/core-js-types/src/base/pure/proposals/string-dedent.d.ts b/packages/core-js-types/src/base/pure/proposals/string-dedent.d.ts deleted file mode 100644 index d5a2b98227f0..000000000000 --- a/packages/core-js-types/src/base/pure/proposals/string-dedent.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -/// - -// Motivation: We should use String without the matchAll method to avoid signature conflicts - -// https://github.com/tc39/proposal-string-dedent - -declare namespace CoreJS { - export interface CoreJSStringConstructor extends StringConstructor { - - /** - * Template tag that removes common leading whitespace from every line in the resulting string, - * preserving relative indentation and blank lines. - * @param template The template strings array, strings array, or a single string. - * @param values Values to be interpolated into the template string. - * @returns The dedented string. - */ - dedent(template: TemplateStringsArray | ArrayLike, ...values: any[]): string; - dedent(template: { raw: readonly string[] }, ...values: any[]): string; - dedent(template: string): string; - } - - var CoreJSString: CoreJSStringConstructor; - - export interface CoreJSString extends StringBase { - /** - * Template tag that removes common leading whitespace from every line in the resulting string, - * preserving relative indentation and blank lines. - * @returns The dedented string. - */ - dedent(): string; - } -} diff --git a/tests/type-definitions/global/proposals/string-dedent.test.ts b/tests/type-definitions/global/proposals/string-dedent.test.ts index 9b7a81b29c30..ca4cda724431 100644 --- a/tests/type-definitions/global/proposals/string-dedent.test.ts +++ b/tests/type-definitions/global/proposals/string-dedent.test.ts @@ -5,11 +5,14 @@ const rdedent2: string = String.dedent`line1 line2 line3`; -const tpl = Object.assign(['foo', 'bar'], { raw: ['foo', 'bar'] }) as TemplateStringsArray; +const tpl = Object.assign(['foo', 'bar'], { raw: ['foo', 'bar'] }); String.dedent(tpl, 1, 2); String.dedent({ raw: ["a\n b\n", "\n c\n"] }, 1, 2); +String.dedent(() => 'template string'); + +// @ts-expect-error 'string\ndedent'.dedent(); // @ts-expect-error diff --git a/tests/type-definitions/pure/proposals/string-dedent.test.ts b/tests/type-definitions/pure/proposals/string-dedent.test.ts index b7dc6c5ce584..9efeb6064b3d 100644 --- a/tests/type-definitions/pure/proposals/string-dedent.test.ts +++ b/tests/type-definitions/pure/proposals/string-dedent.test.ts @@ -5,10 +5,12 @@ const rdedent2: string = stringDedent`line1 line2 line3`; -const tpl = Object.assign(['foo', 'bar'], { raw: ['foo', 'bar'] }) as TemplateStringsArray; +const tpl = Object.assign(['foo', 'bar'], { raw: ['foo', 'bar'] }); stringDedent(tpl, 1, 2); stringDedent({ raw: ["a\n b\n", "\n c\n"] }, 1, 2); +stringDedent(() => 'template string'); + // @ts-expect-error stringDedent(); From be0a2761d76928ca3e366c5a64c3b46eeca85657 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 9 Jan 2026 22:24:07 +0700 Subject: [PATCH 129/315] Fix String dedent --- .../src/base/proposals/string-dedent.d.ts | 9 ++++----- .../global/proposals/string-dedent.test.ts | 10 ++++++++-- .../pure/proposals/string-dedent.test.ts | 10 ++++++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/string-dedent.d.ts b/packages/core-js-types/src/base/proposals/string-dedent.d.ts index 11e4272bee35..44cbb8383e7c 100644 --- a/packages/core-js-types/src/base/proposals/string-dedent.d.ts +++ b/packages/core-js-types/src/base/proposals/string-dedent.d.ts @@ -1,16 +1,15 @@ // https://github.com/tc39/proposal-string-dedent +type CoreJSTemplateTag = (template: { raw: readonly string[] }, ...values: any[]) => any; + interface StringConstructor { /** * Template tag that removes common leading whitespace from every line in the resulting string, * preserving relative indentation and blank lines. - * @param template The template strings array, a single string, and function. + * @param template The template strings array or function. * @param values Values to be interpolated into the template string. * @returns The dedented string. */ dedent(template: { raw: readonly string[] }, ...values: any[]): string; - dedent(template: string): string; - dedent( - fn: (template: { raw: readonly string[] }, ...values: any[]) => R - ): (template: { raw: readonly string[] }, ...values: any[]) => string; + dedent(tag: T): T; } diff --git a/tests/type-definitions/global/proposals/string-dedent.test.ts b/tests/type-definitions/global/proposals/string-dedent.test.ts index ca4cda724431..b4a9aab77cf6 100644 --- a/tests/type-definitions/global/proposals/string-dedent.test.ts +++ b/tests/type-definitions/global/proposals/string-dedent.test.ts @@ -8,9 +8,15 @@ const rdedent2: string = String.dedent`line1 const tpl = Object.assign(['foo', 'bar'], { raw: ['foo', 'bar'] }); String.dedent(tpl, 1, 2); -String.dedent({ raw: ["a\n b\n", "\n c\n"] }, 1, 2); +String.dedent({ raw: ['a\n b\n', '\n c\n'] }, 1, 2); -String.dedent(() => 'template string'); +const myTag = (strings: { raw: readonly string[]}, ...values: (string | number)[]) => { + return { strings, values } as const; +}; +const myAndDedent = String.dedent(myTag); +myAndDedent`line1 + line2 + line3`; // @ts-expect-error 'string\ndedent'.dedent(); diff --git a/tests/type-definitions/pure/proposals/string-dedent.test.ts b/tests/type-definitions/pure/proposals/string-dedent.test.ts index 9efeb6064b3d..3cc30cde884b 100644 --- a/tests/type-definitions/pure/proposals/string-dedent.test.ts +++ b/tests/type-definitions/pure/proposals/string-dedent.test.ts @@ -8,9 +8,15 @@ const rdedent2: string = stringDedent`line1 const tpl = Object.assign(['foo', 'bar'], { raw: ['foo', 'bar'] }); stringDedent(tpl, 1, 2); -stringDedent({ raw: ["a\n b\n", "\n c\n"] }, 1, 2); +stringDedent({ raw: ['a\n b\n', '\n c\n'] }, 1, 2); -stringDedent(() => 'template string'); +const myTag = (strings: { raw: readonly string[]}, ...values: (string | number)[]) => { + return { strings, values } as const; +}; +const myAndDedent = stringDedent(myTag); +myAndDedent`line1 + line2 + line3`; // @ts-expect-error stringDedent(); From 7b1715a31f36cbff33db9b42f87e04e3663ddf70 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 10 Jan 2026 01:09:26 +0700 Subject: [PATCH 130/315] Fix Symbols --- .../src/base/pure/proposals/symbol.d.ts | 29 ++++++++----------- .../pure/proposals/await-dictionary.test.ts | 3 +- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts index d4847d0d77ba..fb4330731c83 100644 --- a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts @@ -1,5 +1,4 @@ -// Motivation: We should use SymbolConstructor without asyncIterator, matchAll, dispose, asyncDispose, -// customMatcher, metadata properties to avoid signature conflicts +// Motivation: We should use all unique symbols in SymbolConstructor with fallback // proposal stage: 3 // https://github.com/tc39/proposal-explicit-resource-management @@ -33,24 +32,20 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt declare namespace CoreJS { - type BaseSymbolConstructor = { - (description?: string | number | symbol): symbol; - new (description?: string | number | symbol): symbol; - } & Omit< - SymbolConstructor, - 'asyncIterator' | 'matchAll' | 'dispose' | 'asyncDispose' | 'customMatcher' | 'metadata' - >; - - export interface CoreJSSymbolConstructor extends BaseSymbolConstructor { + const CoreJSFallbackSymbol: unique symbol; + type CoreJSFallbackSymbolType = typeof CoreJSFallbackSymbol; + type GetNativeWithFallback = K extends keyof T ? T[K] : CoreJSFallbackSymbolType; + + export interface CoreJSSymbolConstructor extends SymbolConstructor { /** * A method that is used to release resources held by an object. Called by the semantics of the `using` statement. */ - readonly dispose: unique symbol; + readonly dispose: GetNativeWithFallback; /** * A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement. */ - readonly asyncDispose: unique symbol; + readonly asyncDispose: GetNativeWithFallback; /** * Determines whether the given value is a registered symbol. @@ -68,13 +63,13 @@ declare namespace CoreJS { * A method that returns the default async iterator for an object. Called by the semantics of * the for-await-of statement. */ - readonly asyncIterator: unique symbol; + readonly asyncIterator: GetNativeWithFallback; - readonly customMatcher: unique symbol; + readonly customMatcher: GetNativeWithFallback; - readonly metadata: unique symbol; + readonly metadata: GetNativeWithFallback; - readonly matchAll: unique symbol; + readonly matchAll: GetNativeWithFallback; } export interface CoreJSSymbol extends Symbol { diff --git a/tests/type-definitions/pure/proposals/await-dictionary.test.ts b/tests/type-definitions/pure/proposals/await-dictionary.test.ts index f94f0c07816e..66fe4a5602d5 100644 --- a/tests/type-definitions/pure/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/pure/proposals/await-dictionary.test.ts @@ -1,7 +1,6 @@ import promiseAllKeyed from '@core-js/pure/full/promise/all-keyed'; import promiseAllSettledKeyed from '@core-js/pure/full/promise/all-settled-keyed'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import $Symbol from '@core-js/pure/full/symbol'; import { CoreJSPromiseAndPromiseLike } from '../../helpers'; const res: CoreJSPromiseAndPromiseLike<{ a: number, b: string, c: boolean }> = promiseAllKeyed({ @@ -10,7 +9,7 @@ const res: CoreJSPromiseAndPromiseLike<{ a: number, b: string, c: boolean }> = p c: promiseResolve(true), }); -const sym = $Symbol('sym'); +declare const sym: unique symbol; const res2: CoreJSPromiseAndPromiseLike<{ [sym]: number }> = promiseAllKeyed({ [sym]: promiseResolve(1) }); From fc37722f3a1f5cb4200f2a6ab77750bf3fa72587 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 10 Jan 2026 01:09:43 +0700 Subject: [PATCH 131/315] Improve type tests --- tests/type-definitions/runner.mjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 0322f4794160..7b2f9e052c91 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -123,6 +123,11 @@ await $`npx -p typescript@5.9 tsc -p tsconfig.entries.pure.json`; await $`npx -p typescript@5.9 -p @types/node@24 tsc -p tsconfig.templates.require.json`; if (!ALL_TESTS) { + await $`npx -p typescript@5.6 tsc -p pure/tsconfig.json --target es6 --lib es6`; + await $`npx -p typescript@5.6 tsc -p pure/tsconfig.json --target esnext --lib esnext`; + await $`npx -p typescript@5.6 tsc -p global/tsconfig.json --target es6 --lib es6,dom`; + await $`npx -p typescript@5.6 tsc -p global/tsconfig.json --target esnext --lib esnext,dom`; + await $`npx -p typescript@5.9 tsc -p pure/tsconfig.json --target es6 --lib es6`; await $`npx -p typescript@5.9 tsc -p pure/tsconfig.json --target es2023 --lib es2023`; await $`npx -p typescript@5.9 tsc -p pure/tsconfig.json --target esnext --lib esnext`; @@ -135,4 +140,5 @@ if (!ALL_TESTS) { await runLimited(taskConfigs, Math.max(numCPUs - 1, 1)); await clearTmpDir(); echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); + if (failed) process.exit(1); } From d6c035c9477b5b305cf784172aa74f3b321e38fd Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 10 Jan 2026 01:46:21 +0700 Subject: [PATCH 132/315] Fix unique symbols --- .../src/base/pure/proposals/symbol.d.ts | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts index fb4330731c83..a3ab365b5deb 100644 --- a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts @@ -32,20 +32,32 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt declare namespace CoreJS { - const CoreJSFallbackSymbol: unique symbol; - type CoreJSFallbackSymbolType = typeof CoreJSFallbackSymbol; - type GetNativeWithFallback = K extends keyof T ? T[K] : CoreJSFallbackSymbolType; + const CoreJSDisposeSymbol: unique symbol; + const CoreJSAsyncDisposeSymbol: unique symbol; + const CoreJSAsyncIteratorSymbol: unique symbol; + const CoreJSCustomMatcherSymbol: unique symbol; + const CoreJSMetadataSymbol: unique symbol; + const CoreJSMatchAllSymbol: unique symbol; + + type CoreJSDisposeSymbolType = typeof CoreJSDisposeSymbol; + type CoreJSAsyncDisposeSymbolType = typeof CoreJSAsyncDisposeSymbol; + type CoreJSAsyncIteratorSymbolType = typeof CoreJSAsyncIteratorSymbol; + type CoreJSCustomMatcherSymbolType = typeof CoreJSCustomMatcherSymbol; + type CoreJSMetadataSymbolType = typeof CoreJSMetadataSymbol; + type CoreJSMatchAllSymbolType = typeof CoreJSMatchAllSymbol; + + type GetNativeWithFallback = K extends keyof T ? T[K] : Fallback; export interface CoreJSSymbolConstructor extends SymbolConstructor { /** * A method that is used to release resources held by an object. Called by the semantics of the `using` statement. */ - readonly dispose: GetNativeWithFallback; + readonly dispose: GetNativeWithFallback; /** * A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement. */ - readonly asyncDispose: GetNativeWithFallback; + readonly asyncDispose: GetNativeWithFallback; /** * Determines whether the given value is a registered symbol. @@ -63,13 +75,13 @@ declare namespace CoreJS { * A method that returns the default async iterator for an object. Called by the semantics of * the for-await-of statement. */ - readonly asyncIterator: GetNativeWithFallback; + readonly asyncIterator: GetNativeWithFallback; - readonly customMatcher: GetNativeWithFallback; + readonly customMatcher: GetNativeWithFallback; - readonly metadata: GetNativeWithFallback; + readonly metadata: GetNativeWithFallback; - readonly matchAll: GetNativeWithFallback; + readonly matchAll: GetNativeWithFallback; } export interface CoreJSSymbol extends Symbol { From 3230cda7caedeb367495a5f8dce546a8807b3d71 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 10 Jan 2026 02:11:19 +0700 Subject: [PATCH 133/315] Add type check for AsyncIterator --- tests/type-definitions/helpers.ts | 14 ++++++++++++++ .../pure/proposals/async-iterator-helper.test.ts | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/type-definitions/helpers.ts b/tests/type-definitions/helpers.ts index 77f779d9508f..588f7b581cf8 100644 --- a/tests/type-definitions/helpers.ts +++ b/tests/type-definitions/helpers.ts @@ -50,3 +50,17 @@ export interface CoreJSIteratorLike extends Itera join(...args: any[]): string; } export type CoreJSIteratorAndIteratorLike = CoreJSIteratorLike & Iterator; + +export interface CoreJSAsyncIteratorLike { + drop(...args: any[]): any; + every(...args: any[]): any; + filter(...args: any[]): any; + find(...args: any[]): any; + flatMap(...args: any[]): any; + forEach(...args: any[]): any; + map(...args: any[]): any; + reduce(...args: any[]): any; + some(...args: any[]): any; + take(...args: any[]): any; + toArray(...args: any[]): any; +} diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 7226d1256c91..738d84441b9e 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -11,9 +11,9 @@ import some from '@core-js/pure/full/async-iterator/some'; import take from '@core-js/pure/full/async-iterator/take'; import toArray from '@core-js/pure/full/async-iterator/to-array'; import toAsync from '@core-js/pure/full/iterator/to-async'; -// import $AsyncIterator from '@core-js/pure/full/async-iterator'; // todo -import { CoreJSPromiseAndPromiseLike } from '../../helpers'; +import { CoreJSAsyncIteratorLike, CoreJSPromiseAndPromiseLike } from '../../helpers'; +const aitn: CoreJSAsyncIteratorLike = from([1]); const aiton = from([1, 2, 3]); aiton.next(); aiton.toArray(); From a9e91b4e226c1f85451077f53965fd778c50cc8b Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 10 Jan 2026 20:14:20 +0700 Subject: [PATCH 134/315] Fix exit in type checker --- tests/type-definitions/runner.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 7b2f9e052c91..c9d1bf94b513 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -140,5 +140,5 @@ if (!ALL_TESTS) { await runLimited(taskConfigs, Math.max(numCPUs - 1, 1)); await clearTmpDir(); echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); - if (failed) process.exit(1); + if (failed) throw new Error('Some tests have failed'); } From 83f8c55dcc39ebfc8f59b7586397428b47d796ab Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 10 Jan 2026 20:14:41 +0700 Subject: [PATCH 135/315] Improve test for AsyncIterator in pure version --- tests/type-definitions/helpers.ts | 8 +++---- .../proposals/async-iterator-helper.test.ts | 23 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/type-definitions/helpers.ts b/tests/type-definitions/helpers.ts index 588f7b581cf8..66cd0362cf2d 100644 --- a/tests/type-definitions/helpers.ts +++ b/tests/type-definitions/helpers.ts @@ -51,16 +51,16 @@ export interface CoreJSIteratorLike extends Itera } export type CoreJSIteratorAndIteratorLike = CoreJSIteratorLike & Iterator; -export interface CoreJSAsyncIteratorLike { +export interface CoreJSAsyncIteratorLike { drop(...args: any[]): any; every(...args: any[]): any; - filter(...args: any[]): any; + filter(predicate: (value: T, index: number) => boolean): CoreJSAsyncIteratorLike; find(...args: any[]): any; flatMap(...args: any[]): any; forEach(...args: any[]): any; - map(...args: any[]): any; + map(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorLike; reduce(...args: any[]): any; some(...args: any[]): any; - take(...args: any[]): any; + take(limit: number): CoreJSAsyncIteratorLike; toArray(...args: any[]): any; } diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 738d84441b9e..386bdb575b80 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -40,17 +40,18 @@ from({ next: () => 1 }); toAsync(is); toAsync(itn); -drop(aiton, 3); -const r2: CoreJSPromiseAndPromiseLike = every(aiton, (v: number, i: number) => v > 0); -filter(aiton, (v: number, i: number) => v > 0); -const r4: CoreJSPromiseAndPromiseLike = find(aiton, (v: number, i: number) => v > 0); -flatMap(aiton, (v: number, i: number) => `${v}`); -const r6: CoreJSPromiseAndPromiseLike = forEach(aiton, (v: number, i: number) => { }); -map(aiton, (v: number, i: number) => v * 2); -const r8: CoreJSPromiseAndPromiseLike = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); -const r9: CoreJSPromiseAndPromiseLike = some(aiton, (v: number, i: number) => v > 0); -take(aiton, 10); -const r11: CoreJSPromiseAndPromiseLike = toArray(aiton); +const r1: CoreJSPromiseAndPromiseLike = every(aiton, (v: number, i: number) => v > 0); +const r2: CoreJSPromiseAndPromiseLike = find(aiton, (v: number, i: number) => v > 0); +const r3: CoreJSPromiseAndPromiseLike = forEach(aiton, (v: number, i: number) => { }); +const r4: CoreJSPromiseAndPromiseLike = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); +const r5: CoreJSPromiseAndPromiseLike = some(aiton, (v: number, i: number) => v > 0); +const r6: CoreJSPromiseAndPromiseLike = toArray(aiton); + +const ait1: CoreJSAsyncIteratorLike = filter(aiton, (v: number, i: number) => v > 0); +const ait2: CoreJSAsyncIteratorLike = flatMap(aiton, (v: number, i: number) => `${v}`); +const ait3: CoreJSAsyncIteratorLike = map(aiton, (v: number, i: number) => v * 2); +const ait4: CoreJSAsyncIteratorLike = take(aiton, 10); +const ait5: CoreJSAsyncIteratorLike = drop(aiton, 3); // @ts-expect-error drop(ain); From 75a22c2d8b35ea33f4b1e4b7662805be06f5270d Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sun, 11 Jan 2026 03:39:03 +0200 Subject: [PATCH 136/315] enable base lining for ts --- package.json | 2 +- .../src/base/core-js-types/flat-array.d.ts | 2 +- .../src/base/core-js-types/map.d.ts | 3 +- .../core-js-types/promise-settled-result.d.ts | 4 +- .../src/base/core-js-types/promise.d.ts | 8 +- .../src/base/core-js-types/set.d.ts | 2 +- .../src/base/core-js-types/weak-map.d.ts | 4 +- .../src/base/core-js-types/weak-set.d.ts | 2 +- .../base/proposals/array-buffer-base64.d.ts | 6 +- .../change-array-by-copy-custom.d.ts | 2 +- .../base/proposals/decorator-metadata.d.ts | 1 + .../base/proposals/iterator-sequencing.d.ts | 2 +- .../src/base/proposals/string-cooked.d.ts | 7 - .../pure/proposals/collection-of-from.d.ts | 7 - .../src/base/web/queue-microtask.d.ts | 6 +- scripts/build-types/index.mjs | 2 +- scripts/build-types/pure.mjs | 2 +- tests/eslint/eslint.config.js | 359 +++-- tests/eslint/package-lock.json | 1262 ++++++++++++++++- tests/eslint/package.json | 3 + tests/type-definitions/compat.ts | 18 +- .../accessible-object-hasownproperty.test.ts | 8 +- .../global/proposals/array-filtering.test.ts | 41 +- .../proposals/array-find-from-last.test.ts | 30 +- .../global/proposals/array-from-async.test.ts | 8 +- .../global/proposals/array-grouping.test.ts | 10 +- .../global/proposals/array-unique.test.ts | 2 +- .../global/proposals/async-iteration.test.ts | 2 +- .../proposals/async-iterator-helper.test.ts | 14 +- .../global/proposals/await-dictionary.test.ts | 8 +- .../proposals/change-array-by-copy.test.ts | 16 +- .../proposals/collection-of-from.test.ts | 4 +- .../explicit-resource-management.test.ts | 10 +- .../global/proposals/extractors.test.ts | 2 +- .../proposals/iterator-chunking.test.ts | 2 +- .../global/proposals/iterator-helpers.test.ts | 6 +- .../global/proposals/iterator-joint.test.ts | 8 +- .../proposals/object-from-entries.test.ts | 2 +- .../proposals/object-values-entries.test.ts | 4 +- .../global/proposals/pattern-matching.test.ts | 2 +- .../proposals/promise-all-settled.test.ts | 12 +- .../global/proposals/promise-any.test.ts | 10 +- .../global/proposals/promise-finally.test.ts | 8 +- .../global/proposals/promise-try.test.ts | 12 +- .../global/proposals/regexp-escaping.test.ts | 2 +- .../proposals/regexp-named-groups.test.ts | 8 +- .../relative-indexing-method.test.ts | 20 +- .../global/proposals/set-methods.test.ts | 4 +- .../global/proposals/string-cooked.test.ts | 3 +- .../global/proposals/string-dedent.test.ts | 2 +- .../proposals/string-replace-all.test.ts | 2 +- .../type-definitions/global/web/atob.test.ts | 2 +- .../type-definitions/global/web/btoa.test.ts | 2 +- .../web/iterable-dom-collections.test.ts | 4 +- .../global/web/queue-microtask.test.ts | 2 +- .../accessible-object-hasownproperty.test.ts | 8 +- .../pure/proposals/array-filtering.test.ts | 2 +- .../proposals/array-find-from-last.test.ts | 4 +- .../pure/proposals/array-grouping.test.ts | 10 +- .../proposals/async-iterator-helper.test.ts | 2 +- .../pure/proposals/await-dictionary.test.ts | 6 +- .../proposals/change-array-by-copy.test.ts | 2 +- .../pure/proposals/collection-of-from.test.ts | 2 +- .../explicit-resource-management.test.ts | 6 +- .../pure/proposals/extractors.test.ts | 2 +- .../pure/proposals/iterator-helpers.test.ts | 6 +- .../pure/proposals/iterator-join.test.ts | 4 +- .../pure/proposals/iterator-joint.test.ts | 8 +- .../proposals/json-parse-with-source.test.ts | 4 +- .../proposals/object-from-entries.test.ts | 2 +- .../proposals/object-values-entries.test.ts | 4 +- .../pure/proposals/pattern-matching.test.ts | 2 +- .../pure/proposals/promise-any.test.ts | 10 +- .../pure/proposals/promise-finally.test.ts | 8 +- .../pure/proposals/promise-try.test.ts | 12 +- .../pure/proposals/regexp-escaping.test.ts | 2 +- .../pure/proposals/set-methods.test.ts | 4 +- .../pure/proposals/string-cooked.test.ts | 3 +- .../pure/proposals/string-dedent.test.ts | 2 +- .../pure/proposals/string-padding.test.ts | 6 +- .../pure/proposals/string-replace-all.test.ts | 2 +- tests/type-definitions/pure/web/atob.test.ts | 2 +- tests/type-definitions/pure/web/btoa.test.ts | 2 +- .../pure/web/queue-microtask.test.ts | 2 +- .../pure/web/url-search-params.test.ts | 2 +- tests/type-definitions/templates.import.ts | 8 +- 86 files changed, 1694 insertions(+), 421 deletions(-) diff --git a/package.json b/package.json index 7572d0c2ef8e..de87aab9b70d 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "lint": "run-s prepare lint-raw", "lint-raw": "run-s build-types test-eslint bundle-package test-publint", "test": "run-s prepare test-raw", - "test-raw": "run-s lint-raw test-type-definitions types-coverage bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check", + "test-raw": "run-s lint-raw types-coverage bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check", "test-eslint": "npm run zxi time tests/eslint/runner.mjs", "test-publint": "npm run zxi time tests/publint/runner.mjs", "test-unit": "run-s test-unit-karma test-unit-node test-unit-bun", diff --git a/packages/core-js-types/src/base/core-js-types/flat-array.d.ts b/packages/core-js-types/src/base/core-js-types/flat-array.d.ts index 26b52316f412..3ddfd5bb2d43 100644 --- a/packages/core-js-types/src/base/core-js-types/flat-array.d.ts +++ b/packages/core-js-types/src/base/core-js-types/flat-array.d.ts @@ -9,5 +9,5 @@ declare namespace CoreJS { done: Arr; recur: Arr extends ReadonlyArray ? CoreJSFlatArray : Arr; - }[Depth extends -1 ? "done" : "recur"]; + }[Depth extends -1 ? 'done' : 'recur']; } diff --git a/packages/core-js-types/src/base/core-js-types/map.d.ts b/packages/core-js-types/src/base/core-js-types/map.d.ts index a28355695788..d069a5cf031b 100644 --- a/packages/core-js-types/src/base/core-js-types/map.d.ts +++ b/packages/core-js-types/src/base/core-js-types/map.d.ts @@ -5,8 +5,7 @@ declare namespace CoreJS { readonly prototype: CoreJSMap; new (): CoreJSMap; - new (entries?: readonly (readonly [K, V])[] | null): CoreJSMap; - new (iterable?: Iterable | null): CoreJSMap; + new(entries?: readonly (readonly [K, V])[] | Iterable | null): CoreJSMap; } var CoreJSMap: CoreJSMapConstructor; diff --git a/packages/core-js-types/src/base/core-js-types/promise-settled-result.d.ts b/packages/core-js-types/src/base/core-js-types/promise-settled-result.d.ts index 7289ee8035cf..9d32e1439239 100644 --- a/packages/core-js-types/src/base/core-js-types/promise-settled-result.d.ts +++ b/packages/core-js-types/src/base/core-js-types/promise-settled-result.d.ts @@ -1,7 +1,7 @@ declare namespace CoreJS { - interface PromiseFulfilledResult { status: "fulfilled"; value: T; } + interface PromiseFulfilledResult { status: 'fulfilled'; value: T; } - interface PromiseRejectedResult { status: "rejected"; reason: any; } + interface PromiseRejectedResult { status: 'rejected'; reason: any; } export type CoreJSPromiseSettledResult = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020 ? O diff --git a/packages/core-js-types/src/base/core-js-types/promise.d.ts b/packages/core-js-types/src/base/core-js-types/promise.d.ts index 27d60be4f39c..5184ac8e93b8 100644 --- a/packages/core-js-types/src/base/core-js-types/promise.d.ts +++ b/packages/core-js-types/src/base/core-js-types/promise.d.ts @@ -10,7 +10,7 @@ declare namespace CoreJS { * a resolve callback used to resolve the promise with a value or the result of another promise, * and a reject callback used to reject the promise with a provided reason or error. */ - new (executor: (resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void) => void): CoreJSPromise; + new(executor: (resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void) => void): CoreJSPromise; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -40,12 +40,6 @@ declare namespace CoreJS { * @returns A resolved promise. */ resolve(): CoreJSPromise; - /** - * Creates a new resolved promise for the provided value. - * @param value A promise. - * @returns A promise whose internal state matches the provided promise. - */ - resolve(value: T): CoreJSPromise>; /** * Creates a new resolved promise for the provided value. * @param value A promise. diff --git a/packages/core-js-types/src/base/core-js-types/set.d.ts b/packages/core-js-types/src/base/core-js-types/set.d.ts index e501da3b4ce0..5d54ecf834cf 100644 --- a/packages/core-js-types/src/base/core-js-types/set.d.ts +++ b/packages/core-js-types/src/base/core-js-types/set.d.ts @@ -2,7 +2,7 @@ declare namespace CoreJS { export interface CoreJSSet extends Set {} export interface CoreJSSetConstructor extends SetConstructor { - new (values?: readonly T[] | null): CoreJSSet; + new(values?: readonly T[] | null): CoreJSSet; readonly prototype: CoreJSSet; } diff --git a/packages/core-js-types/src/base/core-js-types/weak-map.d.ts b/packages/core-js-types/src/base/core-js-types/weak-map.d.ts index cb97584d169f..ba7034267bf1 100644 --- a/packages/core-js-types/src/base/core-js-types/weak-map.d.ts +++ b/packages/core-js-types/src/base/core-js-types/weak-map.d.ts @@ -4,8 +4,8 @@ declare namespace CoreJS { export interface CoreJSWeakMapConstructor { readonly prototype: CoreJSWeakMap; - new (entries?: readonly (readonly [K, V])[] | null): CoreJSWeakMap; - new (iterable: Iterable): CoreJSWeakMap; + new(entries?: readonly (readonly [K, V])[] | null): CoreJSWeakMap; + new(iterable: Iterable): CoreJSWeakMap; } var CoreJSWeakMap: CoreJSWeakMapConstructor; diff --git a/packages/core-js-types/src/base/core-js-types/weak-set.d.ts b/packages/core-js-types/src/base/core-js-types/weak-set.d.ts index 5f938a34fc49..eaad289a7321 100644 --- a/packages/core-js-types/src/base/core-js-types/weak-set.d.ts +++ b/packages/core-js-types/src/base/core-js-types/weak-set.d.ts @@ -4,7 +4,7 @@ declare namespace CoreJS { export interface CoreJSWeakSetConstructor extends WeakSetConstructor { readonly prototype: CoreJSWeakSet; - new (values?: readonly T[] | null): CoreJSWeakSet; + new(values?: readonly T[] | null): CoreJSWeakSet; } var CoreJSWeakSet: CoreJSWeakSetConstructor; diff --git a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts index 445014236c63..71eda5c15bbd 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts @@ -11,17 +11,17 @@ type lastChunkHandling = 'loose' | 'strict' | 'stop-before-partial'; type fromBase64Options = { alphabet?: alphabet; lastChunkHandling?: lastChunkHandling; -} +}; type toBase64Options = { alphabet?: alphabet; omitPadding?: boolean; -} +}; type processMetadata = { read: number; written: number; -} +}; interface Uint8ArrayConstructor { /** diff --git a/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts b/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts index e320dd02a36d..c9f5a6cd18ce 100644 --- a/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/change-array-by-copy-custom.d.ts @@ -7,5 +7,5 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt declare namespace CoreJS { - export type ArrayToSpliced = ((start: number, deleteCount: number, ...items: T[]) => T[]) | ((start: number, deleteCount?: number)=> T[]); + export type ArrayToSpliced = ((start: number, deleteCount: number, ...items: T[]) => T[]) | ((start: number, deleteCount?: number) => T[]); } diff --git a/packages/core-js-types/src/base/proposals/decorator-metadata.d.ts b/packages/core-js-types/src/base/proposals/decorator-metadata.d.ts index e548fa96e40b..93fc1af3f423 100644 --- a/packages/core-js-types/src/base/proposals/decorator-metadata.d.ts +++ b/packages/core-js-types/src/base/proposals/decorator-metadata.d.ts @@ -7,5 +7,6 @@ interface SymbolConstructor { } interface Function { + // eslint-disable-next-line es/no-nonstandard-symbol-properties -- safe [Symbol.metadata]: CoreJS.CoreJSDecoratorMetadataObject | null; } diff --git a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts index 2d454f842b98..3da5c0cc03f6 100644 --- a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts @@ -11,4 +11,4 @@ interface IteratorConstructor { // @type-options no-extends concat(...iterators: Iterable[]): CoreJS.CoreJSIteratorObject; } -declare var Iterator: IteratorConstructor; +declare var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/base/proposals/string-cooked.d.ts b/packages/core-js-types/src/base/proposals/string-cooked.d.ts index 2bbedf148bcc..955d431908c1 100644 --- a/packages/core-js-types/src/base/proposals/string-cooked.d.ts +++ b/packages/core-js-types/src/base/proposals/string-cooked.d.ts @@ -8,11 +8,4 @@ interface StringConstructor { * @returns The processed string with escape sequences interpreted. */ cooked(template: readonly string[], ...substitutions: any[]): string; - /** - * Processes a template literal, interpreting escape sequences. - * @param template The template literal to process. - * @param substitutions The substitutions for the template literal. - * @returns The processed string with escape sequences interpreted. - */ - cooked(template: string, ...substitutions: any[]): string; } diff --git a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts index dbabf1c37057..da3878b80f9f 100644 --- a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts @@ -9,7 +9,6 @@ declare namespace CoreJS { export interface CoreJSMapConstructor extends MapConstructor { - /** * Creates a new `Map` instance from an iterable or array-like object of [key, value] pairs. * Optionally, applies a mapping function to each pair. @@ -31,9 +30,7 @@ declare namespace CoreJS { var CoreJSMap: CoreJSMapConstructor; - export interface CoreJSSetConstructor extends SetConstructor { - /** * Creates a new `Set` instance from an iterable or array-like object of [key, value] pairs. * Optionally, applies a mapping function to each pair. @@ -55,9 +52,7 @@ declare namespace CoreJS { var CoreJSSet: CoreJSSetConstructor; - export interface CoreJSWeakMapConstructor extends WeakMapConstructor { - /** * Creates a new `WeakMap` instance from an iterable or array-like object of [key, value] pairs. * Optionally, applies a mapping function to each pair. @@ -79,9 +74,7 @@ declare namespace CoreJS { var CoreJSWeakMap: CoreJSWeakMapConstructor; - export interface CoreJSWeakSetConstructor extends WeakSetConstructor { - /** * Creates a new `WeakSet` instance from an iterable or array-like object of [key, value] pairs. * Optionally, applies a mapping function to each pair. diff --git a/packages/core-js-types/src/base/web/queue-microtask.d.ts b/packages/core-js-types/src/base/web/queue-microtask.d.ts index 1b8ce4e49683..bf17341bb29c 100644 --- a/packages/core-js-types/src/base/web/queue-microtask.d.ts +++ b/packages/core-js-types/src/base/web/queue-microtask.d.ts @@ -1,9 +1,5 @@ -interface VoidFunction { // @type-options no-redefine no-prefix no-extends - (): void; -} - /** * Queues a microtask to be executed at a later time. * @param callback A function to be executed in the microtask. */ -declare function queueMicrotask(callback: VoidFunction): void; +declare function queueMicrotask(callback: () => void): void; diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index e145d9a8d559..94efaa22ce6d 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -278,4 +278,4 @@ const namespaces = { }; await buildPackageJson(TS_VERSION_BREAKPOINTS, namespaces); -echo(green('Types successfully built')); +echo(green('types successfully built')); diff --git a/scripts/build-types/pure.mjs b/scripts/build-types/pure.mjs index 45c3dc56270a..73ad52f100e2 100644 --- a/scripts/build-types/pure.mjs +++ b/scripts/build-types/pure.mjs @@ -188,7 +188,7 @@ export async function preparePureTypes(typesPath, initialPath) { const content = await fs.readFile(typePath, 'utf8'); - const result = (content.includes('declare namespace')) ? content : wrapInNamespace(content); + const result = content.includes('declare namespace') ? content : wrapInNamespace(content); await outputFile(resultFilePath, result); } diff --git a/tests/eslint/eslint.config.js b/tests/eslint/eslint.config.js index a8f0243fba68..6afca906e801 100644 --- a/tests/eslint/eslint.config.js +++ b/tests/eslint/eslint.config.js @@ -1,6 +1,7 @@ import globals from 'globals'; import confusingBrowserGlobals from 'confusing-browser-globals'; import * as parserJSONC from 'jsonc-eslint-parser'; +import parserTypeScript from '@typescript-eslint/parser'; import pluginArrayFunc from 'eslint-plugin-array-func'; import pluginASCII from 'eslint-plugin-ascii'; import pluginDepend from 'eslint-plugin-depend'; @@ -21,6 +22,8 @@ import pluginReDoS from 'eslint-plugin-redos'; import pluginRegExp from 'eslint-plugin-regexp'; import pluginSonarJS from 'eslint-plugin-sonarjs'; import pluginStylistic from '@stylistic/eslint-plugin'; +import pluginTypeScript from '@typescript-eslint/eslint-plugin'; +import pluginTSDoc from 'eslint-plugin-tsdoc'; import pluginUnicorn from 'eslint-plugin-unicorn'; import { yaml as pluginYaml } from 'eslint-yaml'; @@ -37,7 +40,157 @@ function disable(rules) { return Object.fromEntries(Object.keys(rules).map(key => [key, OFF])); } +// layout & formatting: +const baseStyle = { + // require or disallow the Unicode Byte Order Mark + 'unicode-bom': [ERROR, NEVER], + // require camel case names + camelcase: [ERROR, { + properties: NEVER, + ignoreDestructuring: true, + ignoreImports: true, + ignoreGlobals: true, + }], + // disallow use of multiline strings + 'no-multi-str': ERROR, + // enforce spacing inside array brackets + '@stylistic/array-bracket-spacing': [ERROR, NEVER], + // require parentheses around arrow function arguments + '@stylistic/arrow-parens': [ERROR, 'as-needed'], + // enforce consistent spacing before and after the arrow in arrow functions + '@stylistic/arrow-spacing': ERROR, + // enforce spacing inside single-line blocks + '@stylistic/block-spacing': [ERROR, ALWAYS], + // enforce one true brace style + '@stylistic/brace-style': [ERROR, '1tbs', { allowSingleLine: true }], + // enforce trailing commas in multiline object literals + '@stylistic/comma-dangle': [ERROR, 'always-multiline'], + // enforce spacing after comma + '@stylistic/comma-spacing': ERROR, + // enforce one true comma style + '@stylistic/comma-style': [ERROR, 'last'], + // disallow padding inside computed properties + '@stylistic/computed-property-spacing': [ERROR, NEVER], + // enforce consistent line breaks after opening and before closing braces + '@stylistic/curly-newline': [ERROR, { consistent: true }], + // enforce newline before and after dot + '@stylistic/dot-location': [ERROR, 'property'], + // enforce one newline at the end of files + '@stylistic/eol-last': [ERROR, ALWAYS], + // disallow space between function identifier and application + '@stylistic/function-call-spacing': ERROR, + // require spacing around the `*` in `function *` expressions + '@stylistic/generator-star-spacing': [ERROR, 'both'], + // enforce the location of arrow function bodies + '@stylistic/implicit-arrow-linebreak': [ERROR, 'beside'], + // enforce consistent indentation + '@stylistic/indent': [ERROR, 2, { + ignoredNodes: ['ConditionalExpression'], + SwitchCase: 1, + VariableDeclarator: 'first', + }], + // enforces spacing between keys and values in object literal properties + '@stylistic/key-spacing': [ERROR, { beforeColon: false, afterColon: true }], + // require a space before & after certain keywords + '@stylistic/keyword-spacing': [ERROR, { before: true, after: true }], + // enforce consistent linebreak style + '@stylistic/linebreak-style': [ERROR, 'unix'], + // specify the maximum length of a line in your program + '@stylistic/max-len': [ERROR, { + code: 140, + tabWidth: 2, + ignoreRegExpLiterals: true, + ignoreTemplateLiterals: true, + ignoreUrls: true, + ignorePattern: '', + }], + // enforce a maximum number of statements allowed per line + '@stylistic/max-statements-per-line': [ERROR, { max: 2 }], + // require parentheses when invoking a constructor with no arguments + '@stylistic/new-parens': ERROR, + // disallow unnecessary parentheses + '@stylistic/no-extra-parens': [ERROR, 'all', { + nestedBinaryExpressions: false, + nestedConditionalExpressions: false, + ternaryOperandBinaryExpressions: false, + }], + // disallow unnecessary semicolons + '@stylistic/no-extra-semi': ERROR, + // disallow the use of leading or trailing decimal points in numeric literals + '@stylistic/no-floating-decimal': ERROR, + // disallow mixed spaces and tabs for indentation + '@stylistic/no-mixed-spaces-and-tabs': ERROR, + // disallow use of multiple spaces + '@stylistic/no-multi-spaces': [ERROR, { ignoreEOLComments: true }], + // disallow multiple empty lines and only one newline at the end + '@stylistic/no-multiple-empty-lines': [ERROR, { max: 1, maxEOF: 1 }], + // disallow tabs + '@stylistic/no-tabs': ERROR, + // disallow trailing whitespace at the end of lines + '@stylistic/no-trailing-spaces': ERROR, + // disallow whitespace before properties + '@stylistic/no-whitespace-before-property': ERROR, + // enforce the location of single-line statements + '@stylistic/nonblock-statement-body-position': [ERROR, 'beside'], + // enforce consistent line breaks after opening and before closing braces + '@stylistic/object-curly-newline': [ERROR, { consistent: true }], + // enforce spaces inside braces + '@stylistic/object-curly-spacing': [ERROR, ALWAYS], + // require newlines around variable declarations with initializations + '@stylistic/one-var-declaration-per-line': [ERROR, 'initializations'], + // enforce padding within blocks + '@stylistic/padded-blocks': [ERROR, NEVER], + // disallow blank lines after 'use strict' + '@stylistic/padding-line-between-statements': [ERROR, { blankLine: NEVER, prev: 'directive', next: '*' }], + // require or disallow use of quotes around object literal property names + '@stylistic/quote-props': [ERROR, 'as-needed', { keywords: false }], + // specify whether double or single quotes should be used + '@stylistic/quotes': [ERROR, 'single', { avoidEscape: true }], + // enforce spacing between rest and spread operators and their expressions + '@stylistic/rest-spread-spacing': ERROR, + // require or disallow use of semicolons instead of ASI + '@stylistic/semi': [ERROR, ALWAYS], + // enforce spacing before and after semicolons + '@stylistic/semi-spacing': ERROR, + // enforce location of semicolons + '@stylistic/semi-style': [ERROR, 'last'], + // require or disallow space before blocks + '@stylistic/space-before-blocks': ERROR, + // require or disallow space before function opening parenthesis + '@stylistic/space-before-function-paren': [ERROR, { anonymous: ALWAYS, named: NEVER }], + // require or disallow spaces inside parentheses + '@stylistic/space-in-parens': ERROR, + // require spaces around operators + '@stylistic/space-infix-ops': ERROR, + // require or disallow spaces before/after unary operators + '@stylistic/space-unary-ops': ERROR, + // require or disallow a space immediately following the // or /* in a comment + '@stylistic/spaced-comment': [ERROR, ALWAYS, { + line: { exceptions: ['/'] }, + block: { exceptions: ['*'] }, + }], + // enforce spacing around colons of switch statements + '@stylistic/switch-colon-spacing': ERROR, + // require or disallow spacing around embedded expressions of template strings + '@stylistic/template-curly-spacing': [ERROR, ALWAYS], + // disallow spacing between template tags and their literals + '@stylistic/template-tag-spacing': [ERROR, NEVER], + // require spacing around the `*` in `yield *` expressions + '@stylistic/yield-star-spacing': [ERROR, 'both'], + // enforce lowercase identifier and uppercase value for number literals + 'unicorn/number-literal-case': [ERROR, { hexadecimalValue: 'uppercase' }], + // enforce the style of numeric separators by correctly grouping digits + 'unicorn/numeric-separators-style': [ERROR, { + onlyIfContainsSeparator: true, + number: { minimumDigits: 0, groupLength: 3 }, + binary: { minimumDigits: 0, groupLength: 4 }, + octal: { minimumDigits: 0, groupLength: 4 }, + hexadecimal: { minimumDigits: 0, groupLength: 2 }, + }], +}; + const base = { + ...baseStyle, // possible problems: // enforces return statements in callbacks of array's methods 'array-callback-return': ERROR, @@ -132,8 +285,6 @@ const base = { }], // disallow variable assignments when the value is not used 'no-useless-assignment': ERROR, - // require or disallow the Unicode Byte Order Mark - 'unicode-bom': [ERROR, NEVER], // disallow comparisons with the value NaN 'use-isnan': ERROR, // ensure that the results of typeof are compared against a valid string @@ -142,13 +293,6 @@ const base = { // suggestions: // enforce the use of variables within the scope they are defined 'block-scoped-var': ERROR, - // require camel case names - camelcase: [ERROR, { - properties: NEVER, - ignoreDestructuring: true, - ignoreImports: true, - ignoreGlobals: true, - }], // enforce default clauses in switch statements to be last 'default-case-last': ERROR, // enforce default parameters to be last @@ -220,8 +364,6 @@ const base = { 'no-lonely-if': ERROR, // disallow function declarations and expressions inside loop statements 'no-loop-func': OFF, - // disallow use of multiline strings - 'no-multi-str': ERROR, // disallow use of new operator when not part of the assignment or comparison 'no-new': ERROR, // disallow use of new operator for Function object @@ -342,132 +484,6 @@ const base = { // disallow "Yoda" conditions yoda: [ERROR, NEVER], - // layout & formatting: - // enforce spacing inside array brackets - '@stylistic/array-bracket-spacing': [ERROR, NEVER], - // require parentheses around arrow function arguments - '@stylistic/arrow-parens': [ERROR, 'as-needed'], - // enforce consistent spacing before and after the arrow in arrow functions - '@stylistic/arrow-spacing': ERROR, - // enforce spacing inside single-line blocks - '@stylistic/block-spacing': [ERROR, ALWAYS], - // enforce one true brace style - '@stylistic/brace-style': [ERROR, '1tbs', { allowSingleLine: true }], - // enforce trailing commas in multiline object literals - '@stylistic/comma-dangle': [ERROR, 'always-multiline'], - // enforce spacing after comma - '@stylistic/comma-spacing': ERROR, - // enforce one true comma style - '@stylistic/comma-style': [ERROR, 'last'], - // disallow padding inside computed properties - '@stylistic/computed-property-spacing': [ERROR, NEVER], - // enforce consistent line breaks after opening and before closing braces - '@stylistic/curly-newline': [ERROR, { consistent: true }], - // enforce newline before and after dot - '@stylistic/dot-location': [ERROR, 'property'], - // enforce one newline at the end of files - '@stylistic/eol-last': [ERROR, ALWAYS], - // disallow space between function identifier and application - '@stylistic/function-call-spacing': ERROR, - // require spacing around the `*` in `function *` expressions - '@stylistic/generator-star-spacing': [ERROR, 'both'], - // enforce the location of arrow function bodies - '@stylistic/implicit-arrow-linebreak': [ERROR, 'beside'], - // enforce consistent indentation - '@stylistic/indent': [ERROR, 2, { - ignoredNodes: ['ConditionalExpression'], - SwitchCase: 1, - VariableDeclarator: 'first', - }], - // enforces spacing between keys and values in object literal properties - '@stylistic/key-spacing': [ERROR, { beforeColon: false, afterColon: true }], - // require a space before & after certain keywords - '@stylistic/keyword-spacing': [ERROR, { before: true, after: true }], - // enforce consistent linebreak style - '@stylistic/linebreak-style': [ERROR, 'unix'], - // specify the maximum length of a line in your program - '@stylistic/max-len': [ERROR, { - code: 140, - tabWidth: 2, - ignoreRegExpLiterals: true, - ignoreTemplateLiterals: true, - ignoreUrls: true, - ignorePattern: '', - }], - // enforce a maximum number of statements allowed per line - '@stylistic/max-statements-per-line': [ERROR, { max: 2 }], - // require parentheses when invoking a constructor with no arguments - '@stylistic/new-parens': ERROR, - // disallow unnecessary parentheses - '@stylistic/no-extra-parens': [ERROR, 'all', { - nestedBinaryExpressions: false, - nestedConditionalExpressions: false, - ternaryOperandBinaryExpressions: false, - }], - // disallow unnecessary semicolons - '@stylistic/no-extra-semi': ERROR, - // disallow the use of leading or trailing decimal points in numeric literals - '@stylistic/no-floating-decimal': ERROR, - // disallow mixed spaces and tabs for indentation - '@stylistic/no-mixed-spaces-and-tabs': ERROR, - // disallow use of multiple spaces - '@stylistic/no-multi-spaces': [ERROR, { ignoreEOLComments: true }], - // disallow multiple empty lines and only one newline at the end - '@stylistic/no-multiple-empty-lines': [ERROR, { max: 1, maxEOF: 1 }], - // disallow tabs - '@stylistic/no-tabs': ERROR, - // disallow trailing whitespace at the end of lines - '@stylistic/no-trailing-spaces': ERROR, - // disallow whitespace before properties - '@stylistic/no-whitespace-before-property': ERROR, - // enforce the location of single-line statements - '@stylistic/nonblock-statement-body-position': [ERROR, 'beside'], - // enforce consistent line breaks after opening and before closing braces - '@stylistic/object-curly-newline': [ERROR, { consistent: true }], - // enforce spaces inside braces - '@stylistic/object-curly-spacing': [ERROR, ALWAYS], - // require newlines around variable declarations with initializations - '@stylistic/one-var-declaration-per-line': [ERROR, 'initializations'], - // enforce padding within blocks - '@stylistic/padded-blocks': [ERROR, NEVER], - // disallow blank lines after 'use strict' - '@stylistic/padding-line-between-statements': [ERROR, { blankLine: NEVER, prev: 'directive', next: '*' }], - // require or disallow use of quotes around object literal property names - '@stylistic/quote-props': [ERROR, 'as-needed', { keywords: false }], - // specify whether double or single quotes should be used - '@stylistic/quotes': [ERROR, 'single', { avoidEscape: true }], - // enforce spacing between rest and spread operators and their expressions - '@stylistic/rest-spread-spacing': ERROR, - // require or disallow use of semicolons instead of ASI - '@stylistic/semi': [ERROR, ALWAYS], - // enforce spacing before and after semicolons - '@stylistic/semi-spacing': ERROR, - // enforce location of semicolons - '@stylistic/semi-style': [ERROR, 'last'], - // require or disallow space before blocks - '@stylistic/space-before-blocks': ERROR, - // require or disallow space before function opening parenthesis - '@stylistic/space-before-function-paren': [ERROR, { anonymous: ALWAYS, named: NEVER }], - // require or disallow spaces inside parentheses - '@stylistic/space-in-parens': ERROR, - // require spaces around operators - '@stylistic/space-infix-ops': ERROR, - // require or disallow spaces before/after unary operators - '@stylistic/space-unary-ops': ERROR, - // require or disallow a space immediately following the // or /* in a comment - '@stylistic/spaced-comment': [ERROR, ALWAYS, { - line: { exceptions: ['/'] }, - block: { exceptions: ['*'] }, - }], - // enforce spacing around colons of switch statements - '@stylistic/switch-colon-spacing': ERROR, - // require or disallow spacing around embedded expressions of template strings - '@stylistic/template-curly-spacing': [ERROR, ALWAYS], - // disallow spacing between template tags and their literals - '@stylistic/template-tag-spacing': [ERROR, NEVER], - // require spacing around the `*` in `yield *` expressions - '@stylistic/yield-star-spacing': [ERROR, 'both'], - // ascii // forbid non-ascii chars in ast node names 'ascii/valid-name': ERROR, @@ -668,16 +684,6 @@ const base = { 'unicorn/no-useless-spread': ERROR, // disallow useless `case` in `switch` statements 'unicorn/no-useless-switch-case': ERROR, - // enforce lowercase identifier and uppercase value for number literals - 'unicorn/number-literal-case': [ERROR, { hexadecimalValue: 'uppercase' }], - // enforce the style of numeric separators by correctly grouping digits - 'unicorn/numeric-separators-style': [ERROR, { - onlyIfContainsSeparator: true, - number: { minimumDigits: 0, groupLength: 3 }, - binary: { minimumDigits: 0, groupLength: 4 }, - octal: { minimumDigits: 0, groupLength: 4 }, - hexadecimal: { minimumDigits: 0, groupLength: 2 }, - }], // prefer `.find()` over the first element from `.filter()` 'unicorn/prefer-array-find': [ERROR, { checkFromLast: true }], // use `.flat()` to flatten an array of arrays @@ -1897,6 +1903,47 @@ const playwright = { 'playwright/require-to-pass-timeout': ERROR, }; +const ts = { + ...disable(base), + ...baseStyle, + // validating that TypeScript doc comments conform to the TSDoc specification + 'tsdoc/syntax': OFF, + // specify the maximum length of a line in your program + '@stylistic/max-len': [OFF, { ...base['@stylistic/max-len'][1], code: 180 }], + // require consistent spacing around type annotations + '@stylistic/type-annotation-spacing': ERROR, + // enforces consistent spacing inside TypeScript type generics + '@stylistic/type-generic-spacing': ERROR, + // expect space before the type declaration in the named tuple + '@stylistic/type-named-tuple-spacing': ERROR, + // require that function overload signatures be consecutive + '@typescript-eslint/adjacent-overload-signatures': ERROR, + // enforce type definitions to consistently use either `interface` or `type` + '@typescript-eslint/consistent-type-definitions': [OFF, 'interface'], + // disallow extra non-null assertions + '@typescript-eslint/no-extra-non-null-assertion': ERROR, + // enforce the use of top-level import type qualifier when an import only has specifiers with inline type qualifiers + '@typescript-eslint/no-import-type-side-effects': ERROR, + // disallow explicit type declarations for variables or parameters initialized to a number, string, or boolean + '@typescript-eslint/no-inferrable-types': ERROR, + // disallow unnecessary constraints on generic types + '@typescript-eslint/no-unnecessary-type-constraint': ERROR, + // disallow unsafe declaration merging + '@typescript-eslint/no-unsafe-declaration-merging': ERROR, + // disallow empty exports that don't change anything in a module file + '@typescript-eslint/no-useless-empty-export': ERROR, + // enforce using function types instead of interfaces with call signatures + '@typescript-eslint/prefer-function-type': ERROR, + // require using namespace keyword over module keyword to declare custom TypeScript modules + '@typescript-eslint/prefer-namespace-keyword': ERROR, + // disallow two overloads that could be unified into one with a union or an optional / rest parameter + '@typescript-eslint/unified-signatures': OFF, +}; + +const typeDefinitionsTests = { + ...disable(forbidNonStandardBuiltIns), +}; + const yaml = { // disallow empty mapping values 'yaml/no-empty-mapping-value': ERROR, @@ -2203,6 +2250,7 @@ export default [ }, plugins: { '@stylistic': pluginStylistic, + '@typescript-eslint': pluginTypeScript, 'array-func': pluginArrayFunc, ascii: pluginASCII, depend: pluginDepend, @@ -2222,6 +2270,7 @@ export default [ redos: pluginReDoS, regexp: pluginRegExp, sonarjs: pluginSonarJS, + tsdoc: pluginTSDoc, unicorn: pluginUnicorn, yaml: pluginYaml, }, @@ -2366,6 +2415,22 @@ export default [ 'import/first': OFF, }, }, + { + files: [ + 'packages/core-js-types/src/**/*.d.ts', + 'tests/type-definitions/**/*.ts', + ], + languageOptions: { + parser: parserTypeScript, + }, + rules: ts, + }, + { + files: [ + 'tests/type-definitions/**/*.ts', + ], + rules: typeDefinitionsTests, + }, { rules: { // ensure that filenames match a convention diff --git a/tests/eslint/package-lock.json b/tests/eslint/package-lock.json index f17ad719c99f..3f3d03cab731 100644 --- a/tests/eslint/package-lock.json +++ b/tests/eslint/package-lock.json @@ -9,6 +9,8 @@ "@eslint-community/eslint-plugin-eslint-comments": "^4.6.0", "@eslint/markdown": "^7.5.1", "@stylistic/eslint-plugin": "^5.9.0", + "@typescript-eslint/eslint-plugin": "^8.56.0", + "@typescript-eslint/parser": "^8.56.0", "confusing-browser-globals": "^1.0.11", "eslint": "^10.0.1", "eslint-plugin-array-func": "^5.1.0", @@ -28,6 +30,7 @@ "eslint-plugin-redos": "^4.5.0", "eslint-plugin-regexp": "^3.0.0", "eslint-plugin-sonarjs": "^4.0.0", + "eslint-plugin-tsdoc": "^0.5.0", "eslint-plugin-unicorn": "^63.0.0", "eslint-yaml": "^0.1.0", "globals": "^17.3.0", @@ -162,6 +165,22 @@ "node": "^20.19.0 || ^22.13.0 || >=24" } }, + "node_modules/@eslint/config-array/node_modules/minimatch": { + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.2.tgz", + "integrity": "sha512-+G4CpNBxa5MprY+04MbgOw1v7So6n5JY166pFi9KfYwT78fxScCeSNQSNzp6dpPSW2rONOps6Ocam1wFhCgoVw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@eslint/config-helpers": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.5.2.tgz", @@ -201,6 +220,118 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@eslint/eslintrc": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.3.tgz", + "integrity": "sha512-Kr+LPIUVKz2qkx1HAMH8q1q6azbqBAsXJUxBl/ODDuVPX45Z9DfwB8tPjTi6nNZ8BuM3nbJxC5zCAg5elnBUTQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.1", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/eslintrc/node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/@eslint/eslintrc/node_modules/minimatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.3.tgz", + "integrity": "sha512-M2GCs7Vk83NxkUyQV1bkABc4yxgz9kILhHImZiBPAZ9ybuvCb0/H7lEl5XvIg3g+9d4eNotkZA5IWwYl0tibaA==", + "dev": true, + "license": "ISC", + "peer": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@eslint/eslintrc/node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/js": { + "version": "9.39.3", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.3.tgz", + "integrity": "sha512-1B1VkCq6FuUNlQvlBYb+1jDu/gV297TIs/OeiaSR9l1H27SVW55ONE1e1Vp16NqP683+xEGzxYtv4XCiDPaQiw==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + } + }, "node_modules/@eslint/markdown": { "version": "7.5.1", "resolved": "https://registry.npmjs.org/@eslint/markdown/-/markdown-7.5.1.tgz", @@ -301,6 +432,50 @@ "url": "https://github.com/sponsors/nzakas" } }, + "node_modules/@microsoft/tsdoc": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.16.0.tgz", + "integrity": "sha512-xgAyonlVVS+q7Vc7qLW0UrJU7rSFcETRWsqdXZtjzRU8dF+6CkozTK4V4y1LwOX7j8r/vHphjDeMeGI4tNGeGA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@microsoft/tsdoc-config": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.18.0.tgz", + "integrity": "sha512-8N/vClYyfOH+l4fLkkr9+myAoR6M7akc8ntBJ4DJdWH2b09uVfr71+LTMpNyG19fNqWDg8KEDZhx5wxuqHyGjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@microsoft/tsdoc": "0.16.0", + "ajv": "~8.12.0", + "jju": "~1.4.0", + "resolve": "~1.22.2" + } + }, + "node_modules/@microsoft/tsdoc-config/node_modules/ajv": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/@microsoft/tsdoc-config/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true, + "license": "MIT" + }, "node_modules/@napi-rs/wasm-runtime": { "version": "0.2.12", "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-0.2.12.tgz", @@ -314,6 +489,44 @@ "@tybys/wasm-util": "^0.10.0" } }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/@ota-meshi/ast-token-store": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/@ota-meshi/ast-token-store/-/ast-token-store-0.3.0.tgz", @@ -472,6 +685,142 @@ "dev": true, "license": "MIT" }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.56.0.tgz", + "integrity": "sha512-lRyPDLzNCuae71A3t9NEINBiTn7swyOhvUj3MyUOxb8x6g6vPEFoOU+ZRmGMusNC3X3YMhqMIX7i8ShqhT74Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.12.2", + "@typescript-eslint/scope-manager": "8.56.0", + "@typescript-eslint/type-utils": "8.56.0", + "@typescript-eslint/utils": "8.56.0", + "@typescript-eslint/visitor-keys": "8.56.0", + "ignore": "^7.0.5", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.56.0", + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.56.0.tgz", + "integrity": "sha512-IgSWvLobTDOjnaxAfDTIHaECbkNlAlKv2j5SjpB2v7QHKv1FIfjwMy8FsDbVfDX/KjmCmYICcw7uGaXLhtsLNg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/scope-manager": "8.56.0", + "@typescript-eslint/types": "8.56.0", + "@typescript-eslint/typescript-estree": "8.56.0", + "@typescript-eslint/visitor-keys": "8.56.0", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/project-service": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.56.0.tgz", + "integrity": "sha512-M3rnyL1vIQOMeWxTWIW096/TtVP+8W3p/XnaFflhmcFp+U4zlxUxWj4XwNs6HbDeTtN4yun0GNTTDBw/SvufKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.56.0", + "@typescript-eslint/types": "^8.56.0", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.56.0.tgz", + "integrity": "sha512-7UiO/XwMHquH+ZzfVCfUNkIXlp/yQjjnlYUyYz7pfvlK3/EyyN6BK+emDmGNyQLBtLGaYrTAI6KOw8tFucWL2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.56.0", + "@typescript-eslint/visitor-keys": "8.56.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.56.0.tgz", + "integrity": "sha512-bSJoIIt4o3lKXD3xmDh9chZcjCz5Lk8xS7Rxn+6l5/pKrDpkCwtQNQQwZ2qRPk7TkUYhrq3WPIHXOXlbXP0itg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.56.0.tgz", + "integrity": "sha512-qX2L3HWOU2nuDs6GzglBeuFXviDODreS58tLY/BALPC7iu3Fa+J7EOTwnX9PdNBxUI7Uh0ntP0YWGnxCkXzmfA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.56.0", + "@typescript-eslint/typescript-estree": "8.56.0", + "@typescript-eslint/utils": "8.56.0", + "debug": "^4.4.3", + "ts-api-utils": "^2.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, "node_modules/@typescript-eslint/types": { "version": "8.56.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.56.1.tgz", @@ -486,6 +835,89 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.56.0.tgz", + "integrity": "sha512-ex1nTUMWrseMltXUHmR2GAQ4d+WjkZCT4f+4bVsps8QEdh0vlBsaCokKTPlnqBFqqGaxilDNJG7b8dolW2m43Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.56.0", + "@typescript-eslint/tsconfig-utils": "8.56.0", + "@typescript-eslint/types": "8.56.0", + "@typescript-eslint/visitor-keys": "8.56.0", + "debug": "^4.4.3", + "minimatch": "^9.0.5", + "semver": "^7.7.3", + "tinyglobby": "^0.2.15", + "ts-api-utils": "^2.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.56.0.tgz", + "integrity": "sha512-RZ3Qsmi2nFGsS+n+kjLAYDPVlrzf7UhTffrDIKr+h2yzAlYP/y5ZulU0yeDEPItos2Ph46JAL5P/On3pe7kDIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.9.1", + "@typescript-eslint/scope-manager": "8.56.0", + "@typescript-eslint/types": "8.56.0", + "@typescript-eslint/typescript-estree": "8.56.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.56.0.tgz", + "integrity": "sha512-q+SL+b+05Ud6LbEE35qe4A99P+htKTKVbyiNEe45eCbJFyh/HVK9QXwlrbz+Q4L8SOW4roxSVwXYj4DMBT7Ieg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.56.0", + "eslint-visitor-keys": "^5.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", + "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/@unrs/resolver-binding-android-arm-eabi": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-android-arm-eabi/-/resolver-binding-android-arm-eabi-1.11.1.tgz", @@ -821,6 +1253,14 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0", + "peer": true + }, "node_modules/balanced-match": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", @@ -857,6 +1297,19 @@ "node": "18 || 20 || >=22" } }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/browserslist": { "version": "4.28.1", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.1.tgz", @@ -911,7 +1364,18 @@ "dev": true, "license": "MIT", "engines": { - "node": ">= 0.8" + "node": ">= 0.8" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=6" } }, "node_modules/caniuse-lite": { @@ -946,6 +1410,41 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/change-case": { "version": "5.4.4", "resolved": "https://registry.npmjs.org/change-case/-/change-case-5.4.4.tgz", @@ -1018,6 +1517,28 @@ "node": ">=20" } }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT", + "peer": true + }, "node_modules/comment-parser": { "version": "1.4.5", "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.5.tgz", @@ -1028,6 +1549,14 @@ "node": ">= 12.0.0" } }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT", + "peer": true + }, "node_modules/config-chain": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz", @@ -1792,24 +2321,357 @@ "ts-api-utils": "2.4.0", "typescript": ">=5" }, - "peerDependencies": { - "eslint": "^8.0.0 || ^9.0.0 || ^10.0.0" + "peerDependencies": { + "eslint": "^8.0.0 || ^9.0.0 || ^10.0.0" + } + }, + "node_modules/eslint-plugin-sonarjs/node_modules/minimatch": { + "version": "10.2.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.1.tgz", + "integrity": "sha512-MClCe8IL5nRRmawL6ib/eT4oLyeKMGCghibcDWK+J0hh0Q8kqSdia6BvbRMVk6mPa6WqUa5uR2oxt6C5jd533A==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/eslint-plugin-tsdoc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.5.0.tgz", + "integrity": "sha512-ush8ehCwub2rgE16OIgQPFyj/o0k3T8kL++9IrAI4knsmupNo8gvfO2ERgDHWWgTC5MglbwLVRswU93HyXqNpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@microsoft/tsdoc": "0.16.0", + "@microsoft/tsdoc-config": "0.18.0", + "@typescript-eslint/utils": "~8.46.0" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/config-array": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.1.tgz", + "integrity": "sha512-aw1gNayWpdI/jSYVgzN5pL0cfzU02GT3NBpeT/DXbx1/1x7ZKxFPd9bwrzygx/qiwIQiJ1sw/zD8qY/kRvlGHA==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "dependencies": { + "@eslint/object-schema": "^2.1.7", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/config-array/node_modules/minimatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.3.tgz", + "integrity": "sha512-M2GCs7Vk83NxkUyQV1bkABc4yxgz9kILhHImZiBPAZ9ybuvCb0/H7lEl5XvIg3g+9d4eNotkZA5IWwYl0tibaA==", + "dev": true, + "license": "ISC", + "peer": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/config-helpers": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.4.2.tgz", + "integrity": "sha512-gBrxN88gOIf3R7ja5K9slwNayVcZgK6SOUORm2uBzTeIEfeVaIhOpCtTox3P6R7o2jLFwLFTLnC7kU/RGcYEgw==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "dependencies": { + "@eslint/core": "^0.17.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/object-schema": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz", + "integrity": "sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/project-service": { + "version": "8.46.4", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.46.4.tgz", + "integrity": "sha512-nPiRSKuvtTN+no/2N1kt2tUh/HoFzeEgOm9fQ6XQk4/ApGqjx0zFIIaLJ6wooR1HIoozvj2j6vTi/1fgAz7UYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.46.4", + "@typescript-eslint/types": "^8.46.4", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/scope-manager": { + "version": "8.46.4", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.46.4.tgz", + "integrity": "sha512-tMDbLGXb1wC+McN1M6QeDx7P7c0UWO5z9CXqp7J8E+xGcJuUuevWKxuG8j41FoweS3+L41SkyKKkia16jpX7CA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.46.4", + "@typescript-eslint/visitor-keys": "8.46.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.46.4", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.46.4.tgz", + "integrity": "sha512-+/XqaZPIAk6Cjg7NWgSGe27X4zMGqrFqZ8atJsX3CWxH/jACqWnrWI68h7nHQld0y+k9eTTjb9r+KU4twLoo9A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/types": { + "version": "8.46.4", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.46.4.tgz", + "integrity": "sha512-USjyxm3gQEePdUwJBFjjGNG18xY9A2grDVGuk7/9AkjIF1L+ZrVnwR5VAU5JXtUnBL/Nwt3H31KlRDaksnM7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.46.4", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.46.4.tgz", + "integrity": "sha512-7oV2qEOr1d4NWNmpXLR35LvCfOkTNymY9oyW+lUHkmCno7aOmIf/hMaydnJBUTBMRCOGZh8YjkFOc8dadEoNGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.46.4", + "@typescript-eslint/tsconfig-utils": "8.46.4", + "@typescript-eslint/types": "8.46.4", + "@typescript-eslint/visitor-keys": "8.46.4", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.1.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/utils": { + "version": "8.46.4", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.46.4.tgz", + "integrity": "sha512-AbSv11fklGXV6T28dp2Me04Uw90R2iJ30g2bgLz529Koehrmkbs1r7paFqr1vPCZi7hHwYxYtxfyQMRC8QaVSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.7.0", + "@typescript-eslint/scope-manager": "8.46.4", + "@typescript-eslint/types": "8.46.4", + "@typescript-eslint/typescript-estree": "8.46.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.46.4", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.46.4.tgz", + "integrity": "sha512-/++5CYLQqsO9HFGLI7APrxBJYo+5OCMpViuhV8q5/Qa3o5mMrF//eQHks+PXcsAVaLdn817fMuS7zqoXNNZGaw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.46.4", + "eslint-visitor-keys": "^4.2.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/eslint-plugin-tsdoc/node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/eslint": { + "version": "9.39.3", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.3.tgz", + "integrity": "sha512-VmQ+sifHUbI/IcSopBCF/HO3YiHQx/AVd3UVyYL6weuwW+HvON9VYn5l6Zl1WZzPWXPNZrSQpxwkkZ/VuvJZzg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.8.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.21.1", + "@eslint/config-helpers": "^0.4.2", + "@eslint/core": "^0.17.0", + "@eslint/eslintrc": "^3.3.1", + "@eslint/js": "9.39.3", + "@eslint/plugin-kit": "^0.4.1", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.4.0", + "eslint-visitor-keys": "^4.2.1", + "espree": "^10.4.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/eslint-scope": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", + "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", + "dev": true, + "license": "BSD-2-Clause", + "peer": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint-plugin-sonarjs/node_modules/minimatch": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.1.tgz", - "integrity": "sha512-MClCe8IL5nRRmawL6ib/eT4oLyeKMGCghibcDWK+J0hh0Q8kqSdia6BvbRMVk6mPa6WqUa5uR2oxt6C5jd533A==", + "node_modules/eslint-plugin-tsdoc/node_modules/eslint/node_modules/minimatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.3.tgz", + "integrity": "sha512-M2GCs7Vk83NxkUyQV1bkABc4yxgz9kILhHImZiBPAZ9ybuvCb0/H7lEl5XvIg3g+9d4eNotkZA5IWwYl0tibaA==", "dev": true, - "license": "BlueOak-1.0.0", + "license": "ISC", + "peer": true, "dependencies": { - "brace-expansion": "^5.0.2" + "brace-expansion": "^1.1.7" }, "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" + "node": "*" + } + }, + "node_modules/eslint-plugin-tsdoc/node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 4" } }, "node_modules/eslint-plugin-unicorn": { @@ -2017,6 +2879,22 @@ "node": ">= 4" } }, + "node_modules/eslint/node_modules/minimatch": { + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.2.tgz", + "integrity": "sha512-+G4CpNBxa5MprY+04MbgOw1v7So6n5JY166pFi9KfYwT78fxScCeSNQSNzp6dpPSW2rONOps6Ocam1wFhCgoVw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/espree": { "version": "10.4.0", "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", @@ -2088,6 +2966,36 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -2102,6 +3010,16 @@ "dev": true, "license": "MIT" }, + "node_modules/fastq": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz", + "integrity": "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, "node_modules/fault": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fault/-/fault-2.0.1.tgz", @@ -2147,6 +3065,19 @@ "node": ">=16.0.0" } }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -2207,6 +3138,16 @@ "node": ">=0.4.x" } }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", @@ -2307,6 +3248,30 @@ "dev": true, "license": "ISC" }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/hosted-git-info": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-9.0.2.tgz", @@ -2330,6 +3295,24 @@ "node": ">= 4" } }, + "node_modules/import-fresh": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", + "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -2389,6 +3372,22 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-core-module": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -2412,6 +3411,16 @@ "node": ">=0.10.0" } }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, "node_modules/is-plain-obj": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", @@ -2432,6 +3441,27 @@ "dev": true, "license": "ISC" }, + "node_modules/jju": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", + "integrity": "sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/jsdoc-type-pratt-parser": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-7.1.1.tgz", @@ -2854,6 +3884,16 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, "node_modules/micromark": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", @@ -3462,17 +4502,44 @@ ], "license": "MIT" }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/micromatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/minimatch": { - "version": "10.2.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.2.tgz", - "integrity": "sha512-+G4CpNBxa5MprY+04MbgOw1v7So6n5JY166pFi9KfYwT78fxScCeSNQSNzp6dpPSW2rONOps6Ocam1wFhCgoVw==", + "version": "9.0.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.6.tgz", + "integrity": "sha512-kQAVowdR33euIqeA0+VZTDqU+qo1IeVY+hrKYtZMio3Pg0P0vuh/kwRylLUddJhB6pf3q/botcOvRtx4IN1wqQ==", "dev": true, - "license": "BlueOak-1.0.0", + "license": "ISC", "dependencies": { "brace-expansion": "^5.0.2" }, "engines": { - "node": "18 || 20 || >=22" + "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -3636,6 +4703,20 @@ "node": "^20.19.0 || ^22.12.0 || >=24.0.0" } }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -3656,6 +4737,13 @@ "node": ">=8" } }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -3723,6 +4811,27 @@ "node": ">=6" } }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", @@ -3932,6 +5041,16 @@ "regjsparser": "bin/parser" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/requireindex": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz", @@ -3942,6 +5061,38 @@ "node": ">=0.10.5" } }, + "node_modules/resolve": { + "version": "1.22.11", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz", + "integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=4" + } + }, "node_modules/resolve-pkg-maps": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", @@ -3952,6 +5103,41 @@ "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, "node_modules/scslre": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/scslre/-/scslre-0.3.0.tgz", @@ -4135,6 +5321,33 @@ "node": ">=0.10.0" } }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/synckit": { "version": "0.11.12", "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.11.12.tgz", @@ -4182,6 +5395,19 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, "node_modules/ts-api-utils": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.4.0.tgz", diff --git a/tests/eslint/package.json b/tests/eslint/package.json index 5af03d5c858b..5cc1732c302b 100644 --- a/tests/eslint/package.json +++ b/tests/eslint/package.json @@ -5,6 +5,8 @@ "@eslint/markdown": "^7.5.1", "@eslint-community/eslint-plugin-eslint-comments": "^4.6.0", "@stylistic/eslint-plugin": "^5.9.0", + "@typescript-eslint/eslint-plugin": "^8.56.0", + "@typescript-eslint/parser": "^8.56.0", "confusing-browser-globals": "^1.0.11", "eslint": "^10.0.1", "eslint-plugin-array-func": "^5.1.0", @@ -24,6 +26,7 @@ "eslint-plugin-redos": "^4.5.0", "eslint-plugin-regexp": "^3.0.0", "eslint-plugin-sonarjs": "^4.0.0", + "eslint-plugin-tsdoc": "^0.5.0", "eslint-plugin-unicorn": "^63.0.0", "eslint-yaml": "^0.1.0", "globals": "^17.3.0", diff --git a/tests/type-definitions/compat.ts b/tests/type-definitions/compat.ts index 3e7b11058d56..520a18754fe6 100644 --- a/tests/type-definitions/compat.ts +++ b/tests/type-definitions/compat.ts @@ -18,8 +18,8 @@ getModulesListForTargetVersion({ version: true }); // @ts-expect-error compat.getModulesListForTargetVersion({ version: true }); -compat.data['es.array.push'].android -compat.data['es.array.push'].firefox +compat.data['es.array.push'].android; +compat.data['es.array.push'].firefox; // @ts-expect-error compat.entries['es.array.map'][0] = 'not-a-module'; @@ -31,7 +31,7 @@ if (typeof compat.modules[0] !== 'string') { } if (!compat.entries['core-js'].includes('es.array.from')) { - console.error('Invalid') + console.error('Invalid'); } compat(); @@ -59,9 +59,9 @@ compat({ modules: 123 }); // @ts-expect-error compat({ inverse: 'incorrect' }); // @ts-expect-error -compat({ exclude: 123 }) +compat({ exclude: 123 }); // @ts-expect-error -compat({ targets: 123 }) +compat({ targets: 123 }); compat.compat(); compat.compat({}); @@ -88,9 +88,9 @@ compat.compat({ modules: 123 }); // @ts-expect-error compat.compat({ inverse: 'incorrect' }); // @ts-expect-error -compat({ exclude: 123 }) +compat({ exclude: 123 }); // @ts-expect-error -compat({ targets: 123 }) +compat({ targets: 123 }); compat2(); compat2({}); @@ -117,6 +117,6 @@ compat2({ modules: 123 }); // @ts-expect-error compat2({ inverse: 'incorrect' }); // @ts-expect-error -compat2({ exclude: 123 }) +compat2({ exclude: 123 }); // @ts-expect-error -compat2({ targets: 123 }) +compat2({ targets: 123 }); diff --git a/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts b/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts index b01a6f0c1a06..99db1af9b4a2 100644 --- a/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts +++ b/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts @@ -1,20 +1,20 @@ import 'core-js/full'; -Object.hasOwn({a: 1}, 'a'); +Object.hasOwn({ a: 1 }, 'a'); Object.hasOwn([], 0); Object.hasOwn(new Date(), 'toISOString'); Object.hasOwn(Object.create(null), Symbol.iterator); -Object.hasOwn(function(){}, 'call'); +Object.hasOwn(function () {}, 'call'); Object.hasOwn(Object.prototype, 'toString'); // @ts-expect-error Object.hasOwn(1, 'a'); // @ts-expect-error -Object.hasOwn({a: 1}, {}); +Object.hasOwn({ a: 1 }, {}); // @ts-expect-error -Object.hasOwn({a: 1}); +Object.hasOwn({ a: 1 }); // @ts-expect-error Object.hasOwn(); diff --git a/tests/type-definitions/global/proposals/array-filtering.test.ts b/tests/type-definitions/global/proposals/array-filtering.test.ts index 68fcb38cec45..85eaa9495fea 100644 --- a/tests/type-definitions/global/proposals/array-filtering.test.ts +++ b/tests/type-definitions/global/proposals/array-filtering.test.ts @@ -3,53 +3,52 @@ import 'core-js/full'; [1, 2, 3].filterReject((v, i, arr) => v > 1); ['a', 'b'].filterReject((v, i, arr) => v === 'a'); const arr: number[] = [1, 2, 3]; -const res: number[] = arr.filterReject(function(v) { return v < 2; }, { foo: true }); - -(new Int8Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); -(new Uint8Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); -(new Uint8ClampedArray([1, 2, 3])).filterReject((v, i, arr) => v > 1); -(new Int16Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); -(new Uint16Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); -(new Int32Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); -(new Uint32Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); -(new Float32Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); -(new Float64Array([1, 2, 3])).filterReject((v, i, arr) => v > 1); +const res: number[] = arr.filterReject(function (v) { return v < 2; }, { foo: true }); + +new Int8Array([1, 2, 3]).filterReject((v, i, arr) => v > 1); +new Uint8Array([1, 2, 3]).filterReject((v, i, arr) => v > 1); +new Uint8ClampedArray([1, 2, 3]).filterReject((v, i, arr) => v > 1); +new Int16Array([1, 2, 3]).filterReject((v, i, arr) => v > 1); +new Uint16Array([1, 2, 3]).filterReject((v, i, arr) => v > 1); +new Int32Array([1, 2, 3]).filterReject((v, i, arr) => v > 1); +new Uint32Array([1, 2, 3]).filterReject((v, i, arr) => v > 1); +new Float32Array([1, 2, 3]).filterReject((v, i, arr) => v > 1); +new Float64Array([1, 2, 3]).filterReject((v, i, arr) => v > 1); // todo for es6 // declare var BigInt: (value: number | string | bigint) => bigint; // (new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((v, i, arr) => v > BigInt(1)); // (new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((v, i, arr) => v > BigInt(1)); - // @ts-expect-error [1, 2, 3].filterReject((x: string) => false); // @ts-expect-error -(new Int8Array([1, 2, 3])).filterReject((x: string) => false); +new Int8Array([1, 2, 3]).filterReject((x: string) => false); // @ts-expect-error -(new Uint8Array([1, 2, 3])).filterReject((x: string) => false); +new Uint8Array([1, 2, 3]).filterReject((x: string) => false); // @ts-expect-error -(new Uint8ClampedArray([1, 2, 3])).filterReject((x: string) => false); +new Uint8ClampedArray([1, 2, 3]).filterReject((x: string) => false); // @ts-expect-error -(new Int16Array([1, 2, 3])).filterReject((x: string) => false); +new Int16Array([1, 2, 3]).filterReject((x: string) => false); // @ts-expect-error -(new Uint16Array([1, 2, 3])).filterReject((x: string) => false); +new Uint16Array([1, 2, 3]).filterReject((x: string) => false); // @ts-expect-error -(new Int32Array([1, 2, 3])).filterReject((x: string) => false); +new Int32Array([1, 2, 3]).filterReject((x: string) => false); // @ts-expect-error -(new Uint32Array([1, 2, 3])).filterReject((x: string) => false); +new Uint32Array([1, 2, 3]).filterReject((x: string) => false); // @ts-expect-error -(new Float32Array([1, 2, 3])).filterReject((x: string) => false); +new Float32Array([1, 2, 3]).filterReject((x: string) => false); // @ts-expect-error -(new Float64Array([1, 2, 3])).filterReject((x: string) => false); +new Float64Array([1, 2, 3]).filterReject((x: string) => false); // todo // // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/array-find-from-last.test.ts b/tests/type-definitions/global/proposals/array-find-from-last.test.ts index 2d3d90db1777..20cf56e4d599 100644 --- a/tests/type-definitions/global/proposals/array-find-from-last.test.ts +++ b/tests/type-definitions/global/proposals/array-find-from-last.test.ts @@ -8,16 +8,16 @@ const res: number | undefined = [1, 2, 3].findLast(v => v > 1); const nums: number[] = [1, 2, 3]; const res2: number | undefined = nums.findLast((v, i, arr) => v > 1 && arr.length > 0, {}); nums.findLastIndex((v, i, arr) => v > 0, {}); -const m = ["a", 2, 3] as (string | number)[]; -m.findLast((v): v is string => typeof v === "string"); -(new Int8Array([1, 2, 3])).findLast(v => v > 0); -(new Int8Array([1, 2, 3])).findLast((v, i, arr) => v == i && arr instanceof Int8Array); -(new Int8Array([1, 2, 3])).findLastIndex(v => v > 0); -(new Int8Array([1, 2, 3])).findLast((v): v is 2 => v === 2); -(new Uint8Array([1, 2, 3])).findLast(v => v > 0); -(new Uint8Array([1, 2, 3])).findLastIndex(v => v < 0); -(new Float64Array([1, 2, 3])).findLast(v => v > 1.1); -(new Float64Array([1, 2, 3])).findLastIndex(v => v > 100); +const m = ['a', 2, 3] as (string | number)[]; +m.findLast((v): v is string => typeof v === 'string'); +new Int8Array([1, 2, 3]).findLast(v => v > 0); +new Int8Array([1, 2, 3]).findLast((v, i, arr) => v == i && arr instanceof Int8Array); +new Int8Array([1, 2, 3]).findLastIndex(v => v > 0); +new Int8Array([1, 2, 3]).findLast((v): v is 2 => v === 2); +new Uint8Array([1, 2, 3]).findLast(v => v > 0); +new Uint8Array([1, 2, 3]).findLastIndex(v => v < 0); +new Float64Array([1, 2, 3]).findLast(v => v > 1.1); +new Float64Array([1, 2, 3]).findLastIndex(v => v > 100); // todo for es6 // (new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLast(v => v > BigInt(1)); // (new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLast((v): v is bigint => v === BigInt(2)); @@ -32,13 +32,13 @@ m.findLast((v): v is string => typeof v === "string"); [1, 2, 3].findLast('not function'); // @ts-expect-error -(new Int8Array([1, 2, 3])).findLast(); +new Int8Array([1, 2, 3]).findLast(); // @ts-expect-error -(new Int8Array([1, 2, 3])).findLast('not function'); +new Int8Array([1, 2, 3]).findLast('not function'); // @ts-expect-error -(new Int8Array([1, 2, 3])).findLast((v: string) => false); +new Int8Array([1, 2, 3]).findLast((v: string) => false); // // @ts-expect-error // (new BigInt64Array([BigInt(1)])).findLast((v: number) => false); @@ -47,7 +47,7 @@ m.findLast((v): v is string => typeof v === "string"); [1, 2, 3].findLastIndex(); // @ts-expect-error -(new Float64Array([1, 2, 3])).findLastIndex(); +new Float64Array([1, 2, 3]).findLastIndex(); // @ts-expect-error -(new Uint8Array([1, 2, 3])).findLastIndex('not function'); +new Uint8Array([1, 2, 3]).findLastIndex('not function'); diff --git a/tests/type-definitions/global/proposals/array-from-async.test.ts b/tests/type-definitions/global/proposals/array-from-async.test.ts index e035512be193..61f7e9154802 100644 --- a/tests/type-definitions/global/proposals/array-from-async.test.ts +++ b/tests/type-definitions/global/proposals/array-from-async.test.ts @@ -2,10 +2,12 @@ import 'core-js/full'; const p1: Promise = Array.fromAsync([1, 2, 3]); const p2: Promise = Array.fromAsync([Promise.resolve(1), 2, 3]); -const p3: Promise = Array.fromAsync((async function* () { yield 1; })()); +const p3: Promise = Array.fromAsync((async function * () { yield 1; })()); const p4: Promise = Array.fromAsync([1, 2, 3], (value: number, index: number) => value.toString()); const p5: Promise = Array.fromAsync([Promise.resolve(1), 2, 3], (value: number) => value + 1); -const p6: Promise = Array.fromAsync((async function* () { yield 1; })(), function (value: number) { return value * 2; }); +const p6: Promise = Array.fromAsync((async function * () { yield 1; })(), function (value: number) { + return value * 2; +}); const p7: Promise = Array.fromAsync([1, 2, 3], function (this: { foo: string }, value: number) { return value.toString(); }, { foo: 'str' }); async function t1() { @@ -32,7 +34,7 @@ Array.fromAsync(['a', 'b', 'c'], (value: number) => value); // @ts-expect-error Array.fromAsync([Promise.resolve(1), 2, 3], (value: string) => value); // @ts-expect-error -Array.fromAsync((async function* () { yield 'a'; })(), (value: number) => value); +Array.fromAsync((async function * () { yield 'a'; })(), (value: number) => value); declare const strArrLike: { [index: number]: string; length: 3 }; // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/array-grouping.test.ts b/tests/type-definitions/global/proposals/array-grouping.test.ts index 22380f95d21a..e5504ce274b7 100644 --- a/tests/type-definitions/global/proposals/array-grouping.test.ts +++ b/tests/type-definitions/global/proposals/array-grouping.test.ts @@ -16,18 +16,18 @@ Map.groupBy(new Set(['a', 'b', 'c']), (x, i) => i); // @ts-expect-error Object.groupBy(); // @ts-expect-error -Object.groupBy([1,2,3]); +Object.groupBy([1, 2, 3]); // @ts-expect-error -Object.groupBy([1,2,3], 123); +Object.groupBy([1, 2, 3], 123); // @ts-expect-error Object.groupBy(123, x => x); // @ts-expect-error -Object.groupBy([1,2,3], (a, b, c) => a); +Object.groupBy([1, 2, 3], (a, b, c) => a); // @ts-expect-error Map.groupBy(); // @ts-expect-error -Map.groupBy([1,2,3]); +Map.groupBy([1, 2, 3]); // @ts-expect-error Map.groupBy(123, x => x); // @ts-expect-error -Map.groupBy([1,2,3], (a, b, c) => a); +Map.groupBy([1, 2, 3], (a, b, c) => a); diff --git a/tests/type-definitions/global/proposals/array-unique.test.ts b/tests/type-definitions/global/proposals/array-unique.test.ts index d8501a6296a6..101233b000bc 100644 --- a/tests/type-definitions/global/proposals/array-unique.test.ts +++ b/tests/type-definitions/global/proposals/array-unique.test.ts @@ -100,7 +100,7 @@ u8c.uniqueBy(undefined, 1); // @ts-expect-error i16.uniqueBy([]); // @ts-expect-error -i16.uniqueBy(function(x: string) { return x; }); +i16.uniqueBy(function (x: string) { return x; }); // @ts-expect-error u16.uniqueBy([]); diff --git a/tests/type-definitions/global/proposals/async-iteration.test.ts b/tests/type-definitions/global/proposals/async-iteration.test.ts index b2989ab42dd2..6061830f1a4d 100644 --- a/tests/type-definitions/global/proposals/async-iteration.test.ts +++ b/tests/type-definitions/global/proposals/async-iteration.test.ts @@ -5,4 +5,4 @@ const sym: symbol = Symbol.asyncIterator; // @ts-expect-error const bad1: string = Symbol.asyncIterator; // @ts-expect-error -Symbol['asyncIterator'] = Symbol("other"); +Symbol['asyncIterator'] = Symbol('other'); diff --git a/tests/type-definitions/global/proposals/async-iterator-helper.test.ts b/tests/type-definitions/global/proposals/async-iterator-helper.test.ts index a0e0048f9ba4..e61c6d5de90a 100644 --- a/tests/type-definitions/global/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/global/proposals/async-iterator-helper.test.ts @@ -2,8 +2,11 @@ import 'core-js/full'; const res: AsyncIterator = AsyncIterator.from([1, 2, 3]); const res2: AsyncIterator = AsyncIterator.from(new Set([1, 2, 3])); -AsyncIterator.from((async function* () { yield 1; yield 2; })()); -AsyncIterator.from((function* () { yield 3; })()); +AsyncIterator.from((async function * () { + yield 1; + yield 2; +})()); +AsyncIterator.from((function * () { yield 3; })()); const res3: AsyncIterator = AsyncIterator.from('abc'); declare const ain: AsyncIteratorObject; @@ -15,7 +18,10 @@ declare const itn: Iterator; declare const ailb: AsyncIterable; AsyncIterator.from(ain); -AsyncIterator.from((async function* () { yield 1; yield 2; })()); +AsyncIterator.from((async function * () { + yield 1; + yield 2; +})()); AsyncIterator.from(ilb); AsyncIterator.from(ailb); AsyncIterator.from(aio); @@ -36,7 +42,7 @@ const r1: AsyncIterator = ain.drop(3); const r2: Promise = ain.every((v: number, i: number) => v > 0); const r3: AsyncIterator = ain.filter((v: number, i: number) => v > 0); const r4: Promise = ain.find((v: number, i: number) => v > 0); -const r5: AsyncIterator = ain.flatMap((v: number, i: number) => `${v}`); +const r5: AsyncIterator = ain.flatMap((v: number, i: number) => `${ v }`); const r6: Promise = ain.forEach((v: number, i: number) => { }); const r7: AsyncIterator = ain.map((v: number, i: number) => v * 2); const r8: Promise = ain.reduce((acc: number, v: number, i: number) => acc + v, 0); diff --git a/tests/type-definitions/global/proposals/await-dictionary.test.ts b/tests/type-definitions/global/proposals/await-dictionary.test.ts index a6aad67a8f71..d1aeb17a9f15 100644 --- a/tests/type-definitions/global/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/global/proposals/await-dictionary.test.ts @@ -8,7 +8,7 @@ const res: Promise<{ a: number, b: string, c: boolean }> = Promise.allKeyed({ const sym = Symbol('sym'); const res2: Promise<{ [sym]: number }> = Promise.allKeyed({ - [sym]: Promise.resolve(1) + [sym]: Promise.resolve(1), }); // @ts-expect-error @@ -16,7 +16,7 @@ Promise.allKeyed(); // @ts-expect-error Promise.allKeyed({ a: 1, b: Promise.resolve(2) }); // @ts-expect-error -Promise.allKeyed([ Promise.resolve(1), Promise.resolve(2) ]); +Promise.allKeyed([Promise.resolve(1), Promise.resolve(2)]); interface CoreJSPromiseResult { status: string; @@ -31,7 +31,7 @@ const resASK: Promise<{ a: CoreJSPromiseResult, b: CoreJSPromiseResult }> = Promise.allSettledKeyed({ - [sym]: Promise.resolve(1) + [sym]: Promise.resolve(1), }); // @ts-expect-error @@ -39,4 +39,4 @@ Promise.allSettledKeyed(); // @ts-expect-error Promise.allSettledKeyed({ a: 1, b: Promise.resolve(2) }); // @ts-expect-error -Promise.allSettledKeyed([ Promise.resolve(1), Promise.resolve(2) ]); +Promise.allSettledKeyed([Promise.resolve(1), Promise.resolve(2)]); diff --git a/tests/type-definitions/global/proposals/change-array-by-copy.test.ts b/tests/type-definitions/global/proposals/change-array-by-copy.test.ts index 70cb1e7971de..75947ca90b54 100644 --- a/tests/type-definitions/global/proposals/change-array-by-copy.test.ts +++ b/tests/type-definitions/global/proposals/change-array-by-copy.test.ts @@ -21,34 +21,34 @@ const i8Sorted: Int8Array = i8.toSorted(); const i8Sorted2: Int8Array = i8.toSorted((a, b) => b - a); const i8With: Int8Array = i8.with(0, 10); -const u8 = new Uint8Array([1,2,3]); +const u8 = new Uint8Array([1, 2, 3]); const u8Rev: Uint8Array = u8.toReversed(); const u8Sorted: Uint8Array = u8.toSorted(); const u8Sorted2: Uint8Array = u8.toSorted((a, b) => a - b); const u8With: Uint8Array = u8.with(1, 42); -const u8c = new Uint8ClampedArray([1,2,3]); +const u8c = new Uint8ClampedArray([1, 2, 3]); const u8cRev: Uint8ClampedArray = u8c.toReversed(); const u8cSorted: Uint8ClampedArray = u8c.toSorted(); const u8cSorted2: Uint8ClampedArray = u8c.toSorted((a, b) => b - a); const u8cWith: Uint8ClampedArray = u8c.with(1, 99); -const i16 = new Int16Array([1,2,3]); +const i16 = new Int16Array([1, 2, 3]); const i16Rev: Int16Array = i16.toReversed(); const i16Sorted: Int16Array = i16.toSorted(); const i16With: Int16Array = i16.with(1, 2); -const u16 = new Uint16Array([1,2,3]); +const u16 = new Uint16Array([1, 2, 3]); const u16Rev: Uint16Array = u16.toReversed(); const u16Sorted: Uint16Array = u16.toSorted(); const u16With: Uint16Array = u16.with(1, 2); -const i32 = new Int32Array([1,2,3]); +const i32 = new Int32Array([1, 2, 3]); const i32Rev: Int32Array = i32.toReversed(); const i32Sorted: Int32Array = i32.toSorted(); const i32With: Int32Array = i32.with(1, 2); -const u32 = new Uint32Array([1,2,3]); +const u32 = new Uint32Array([1, 2, 3]); const u32Rev: Uint32Array = u32.toReversed(); const u32Sorted: Uint32Array = u32.toSorted(); const u32With: Uint32Array = u32.with(1, 2); @@ -118,7 +118,6 @@ i8.with('1', 1); // @ts-expect-error i8.with(0, '1'); - // @ts-expect-error u8.toReversed(1); // @ts-expect-error @@ -126,7 +125,6 @@ u8.toSorted('str'); // @ts-expect-error u8.with(0, 'v'); - // @ts-expect-error u8c.toSorted('str'); // @ts-expect-error @@ -164,7 +162,7 @@ f32.toReversed('abc'); f32.with(0, 'a'); // @ts-expect-error -f64.toSorted(1,2); +f64.toSorted(1, 2); // @ts-expect-error f64.with('a', 1); diff --git a/tests/type-definitions/global/proposals/collection-of-from.test.ts b/tests/type-definitions/global/proposals/collection-of-from.test.ts index e5ac9f57c86c..0b94e79d150c 100644 --- a/tests/type-definitions/global/proposals/collection-of-from.test.ts +++ b/tests/type-definitions/global/proposals/collection-of-from.test.ts @@ -7,14 +7,14 @@ const mapFrom3: Map = Map.from(arrEntries); const mapOf: Map = Map.of(['a', 1], ['b', 2]); const setFrom: Set = Set.from(['a', 'b', 'c']); -const setFrom2: Set = Set.from([1, 2, 3], (v) => v * 2); +const setFrom2: Set = Set.from([1, 2, 3], v => v * 2); const setFrom3: Set = Set.from(['a', 'b', 'c'], String); const setOf: Set = Set.of(1, 2, 3); const ws1 = {}; const ws2 = {}; const wsArr = [ws1, ws2]; -const weakSetFrom: WeakSet<{a?: number}> = WeakSet.from(wsArr); +const weakSetFrom: WeakSet<{ a?: number }> = WeakSet.from(wsArr); const weakSetFrom2: WeakSet = WeakSet.from(wsArr, x => x); const weakSetOf: WeakSet = WeakSet.of(ws1, ws2); diff --git a/tests/type-definitions/global/proposals/explicit-resource-management.test.ts b/tests/type-definitions/global/proposals/explicit-resource-management.test.ts index b0d4a58e75d4..be7f6d605cc6 100644 --- a/tests/type-definitions/global/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/global/proposals/explicit-resource-management.test.ts @@ -6,12 +6,12 @@ const ad: symbol = Symbol.asyncDispose; // @ts-expect-error const wrong: number = Symbol.dispose; // @ts-expect-error -Symbol['dispose'] = Symbol("foo"); +Symbol['dispose'] = Symbol('foo'); // @ts-expect-error -Symbol['asyncDispose'] = Symbol("bar"); +Symbol['asyncDispose'] = Symbol('bar'); const objD: Disposable = { - [Symbol.dispose]() { /* empty */ } + [Symbol.dispose]() { /* empty */ }, }; objD[Symbol.dispose](); @@ -19,8 +19,8 @@ objD[Symbol.dispose](); objD.dispose(); const objAD: AsyncDisposable = { - [Symbol.asyncDispose]() { return Promise.resolve(); } -} + [Symbol.asyncDispose]() { return Promise.resolve(); }, +}; objAD[Symbol.asyncDispose](); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/extractors.test.ts b/tests/type-definitions/global/proposals/extractors.test.ts index 13ee20e150fe..60ccb33430b5 100644 --- a/tests/type-definitions/global/proposals/extractors.test.ts +++ b/tests/type-definitions/global/proposals/extractors.test.ts @@ -4,6 +4,6 @@ const rscs1: symbol = Symbol.customMatcher; const rscs2: typeof Symbol.customMatcher = Symbol.customMatcher; // @ts-expect-error -Symbol['customMatcher'] = Symbol("other"); +Symbol['customMatcher'] = Symbol('other'); // @ts-expect-error const n: number = Symbol.customMatcher; diff --git a/tests/type-definitions/global/proposals/iterator-chunking.test.ts b/tests/type-definitions/global/proposals/iterator-chunking.test.ts index 533ad35aa7ea..593ac5f267de 100644 --- a/tests/type-definitions/global/proposals/iterator-chunking.test.ts +++ b/tests/type-definitions/global/proposals/iterator-chunking.test.ts @@ -13,7 +13,7 @@ const windowsNext = windows.next(); // @ts-expect-error numbersIter.chunks(); // @ts-expect-error -numbersIter.chunks("2"); +numbersIter.chunks('2'); // @ts-expect-error numbersIter.chunks(2, 3); diff --git a/tests/type-definitions/global/proposals/iterator-helpers.test.ts b/tests/type-definitions/global/proposals/iterator-helpers.test.ts index 1686ac2ab661..7f70d365e58d 100644 --- a/tests/type-definitions/global/proposals/iterator-helpers.test.ts +++ b/tests/type-definitions/global/proposals/iterator-helpers.test.ts @@ -34,9 +34,9 @@ it.drop('3'); const flatMapped: Iterator = it.flatMap((v, i) => itStr); const flatMapped2: Iterator = it.flatMap((v, i) => ({ - [Symbol.iterator]: function* () { + [Symbol.iterator]: function * () { yield String(v); - } + }, })); // @ts-expect-error @@ -46,7 +46,7 @@ const sum1: number = it.reduce((a, b, c) => a + b + c); const sum2: number = it.reduce((a, b, c) => a + b + c, 0); const strReduce: string = it.reduce( (acc: string, val) => acc + val, - '' + '', ); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/iterator-joint.test.ts b/tests/type-definitions/global/proposals/iterator-joint.test.ts index 3701cbd40dcc..48a53cef92a1 100644 --- a/tests/type-definitions/global/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/global/proposals/iterator-joint.test.ts @@ -2,15 +2,15 @@ import 'core-js/full'; Iterator.zip([[1, 2, 3], [4, 5, 6]]); Iterator.zip([['a', 'b', 'c'], ['d', 'e', 'f']]); -Iterator.zip([[1, 2, 3], [4, 5, 6]], { mode: "shortest" }); +Iterator.zip([[1, 2, 3], [4, 5, 6]], { mode: 'shortest' }); Iterator.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); -Iterator.zipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: "shortest" }); +Iterator.zipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: 'shortest' }); // @ts-expect-error Iterator.zip(true); // @ts-expect-error -Iterator.zip([[1, 2, 3], [4, 5, 6]], { mode: "incorrect" }); +Iterator.zip([[1, 2, 3], [4, 5, 6]], { mode: 'incorrect' }); // @ts-expect-error Iterator.zipKeyed(42); // @ts-expect-error -Iterator.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }, { foo: "bar" }); +Iterator.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }, { foo: 'bar' }); diff --git a/tests/type-definitions/global/proposals/object-from-entries.test.ts b/tests/type-definitions/global/proposals/object-from-entries.test.ts index 3a2c20009b15..b94077437001 100644 --- a/tests/type-definitions/global/proposals/object-from-entries.test.ts +++ b/tests/type-definitions/global/proposals/object-from-entries.test.ts @@ -9,7 +9,7 @@ declare const notIterable: {}; const r1: { [k: string]: number } = Object.fromEntries(objEntries); const r2: any = Object.fromEntries(mixedEntries); const r3: any = Object.fromEntries([['a', 1], ['b', 2]]); -const r4: object = Object.fromEntries(new Map([ ['x', 1], ['y', 2] ])); +const r4: object = Object.fromEntries(new Map([['x', 1], ['y', 2]])); // @ts-expect-error Object.fromEntries(); diff --git a/tests/type-definitions/global/proposals/object-values-entries.test.ts b/tests/type-definitions/global/proposals/object-values-entries.test.ts index 08836ce7eb8e..618f329bc151 100644 --- a/tests/type-definitions/global/proposals/object-values-entries.test.ts +++ b/tests/type-definitions/global/proposals/object-values-entries.test.ts @@ -18,8 +18,8 @@ const entries3: [string, string][] = Object.entries(strArr); const entries4: [string, number][] = Object.entries(arrLike); const entries5: [string, any][] = Object.entries(emptyObj); -const valuesAnyArr: any[] = Object.values({ foo: 123, bar: "baz" }); -const entriesAnyArr: [string, any][] = Object.entries({ foo: 123, bar: "baz" }); +const valuesAnyArr: any[] = Object.values({ foo: 123, bar: 'baz' }); +const entriesAnyArr: [string, any][] = Object.entries({ foo: 123, bar: 'baz' }); // @ts-expect-error Object.values(); diff --git a/tests/type-definitions/global/proposals/pattern-matching.test.ts b/tests/type-definitions/global/proposals/pattern-matching.test.ts index 7d7f8de721aa..c5767234a166 100644 --- a/tests/type-definitions/global/proposals/pattern-matching.test.ts +++ b/tests/type-definitions/global/proposals/pattern-matching.test.ts @@ -5,4 +5,4 @@ const sym: symbol = Symbol.customMatcher; // @ts-expect-error const bad1: string = Symbol.customMatcher; // @ts-expect-error -Symbol['customMatcher'] = Symbol("other"); +Symbol.customMatcher = Symbol('other'); diff --git a/tests/type-definitions/global/proposals/promise-all-settled.test.ts b/tests/type-definitions/global/proposals/promise-all-settled.test.ts index 52aa50cbaa82..786f9f1f294d 100644 --- a/tests/type-definitions/global/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/global/proposals/promise-all-settled.test.ts @@ -1,8 +1,8 @@ import 'core-js/full'; -const promises = [Promise.resolve(1), Promise.resolve("foo"), 3] as const; +const promises = [Promise.resolve(1), Promise.resolve('foo'), 3] as const; const arr = [Promise.resolve(1), Promise.resolve(2)]; -const strArr = ["a", "b", "c"]; +const strArr = ['a', 'b', 'c']; const promiseLike = { then: (cb: (val: number) => void) => cb(42) }; interface CoreJSPromiseResult { @@ -14,7 +14,7 @@ interface CoreJSPromiseResult { const settled1: Promise<[ CoreJSPromiseResult, CoreJSPromiseResult, - CoreJSPromiseResult + CoreJSPromiseResult, ]> = Promise.allSettled(promises); const settled2: Promise[]> = Promise.allSettled([Promise.resolve(10), Promise.resolve(20), 30]); @@ -25,10 +25,10 @@ const settled5: Promise[]> = Promise.allSettled([pro const emptyTuple: [] = []; const settled6: Promise<[]> = Promise.allSettled(emptyTuple); -const mixedTuple = [42, Promise.resolve("bar")] as const; +const mixedTuple = [42, Promise.resolve('bar')] as const; const settled7: Promise<[ CoreJSPromiseResult, - CoreJSPromiseResult + CoreJSPromiseResult, ]> = Promise.allSettled(mixedTuple); // @ts-expect-error @@ -44,4 +44,4 @@ Promise.allSettled({ foo: 123 }); Promise.allSettled([1, 2], 123); // @ts-expect-error -Promise.allSettled([Promise.resolve(1)], "extra"); +Promise.allSettled([Promise.resolve(1)], 'extra'); diff --git a/tests/type-definitions/global/proposals/promise-any.test.ts b/tests/type-definitions/global/proposals/promise-any.test.ts index aa174df5ac4d..03c910826bce 100644 --- a/tests/type-definitions/global/proposals/promise-any.test.ts +++ b/tests/type-definitions/global/proposals/promise-any.test.ts @@ -1,14 +1,14 @@ import 'core-js/full'; -const arr = [Promise.resolve(1), Promise.resolve("foo"), 3] as const; +const arr = [Promise.resolve(1), Promise.resolve('foo'), 3] as const; const justNumbers = [1, 2, 3]; -const setOfStrings = new Set(["a", "b", "c"]); +const setOfStrings = new Set(['a', 'b', 'c']); const promiseLike = { then: (cb: (val: number) => void) => cb(123) }; const emptyTuple: [] = []; -const mixed = [true, Promise.resolve("z")] as const; +const mixed = [true, Promise.resolve('z')] as const; const any1: Promise = Promise.any(arr); -const any2: Promise = Promise.any(["x", "y", Promise.resolve(5)]); +const any2: Promise = Promise.any(['x', 'y', Promise.resolve(5)]); const any3: Promise = Promise.any(emptyTuple); const any4: Promise = Promise.any(mixed); @@ -31,4 +31,4 @@ Promise.any({ foo: 42 }); Promise.any([1, 2], 3); // @ts-expect-error -Promise.any(justNumbers, "extra"); +Promise.any(justNumbers, 'extra'); diff --git a/tests/type-definitions/global/proposals/promise-finally.test.ts b/tests/type-definitions/global/proposals/promise-finally.test.ts index c0923cfa112f..b1de2f6c35d0 100644 --- a/tests/type-definitions/global/proposals/promise-finally.test.ts +++ b/tests/type-definitions/global/proposals/promise-finally.test.ts @@ -7,7 +7,7 @@ const pf3: Promise = p1.finally(null); const pf4: Promise = p1.finally(() => {}); const pf5: Promise = p1.finally(function () {}); -const p2 = Promise.reject("err"); +const p2 = Promise.reject('err'); const pf6: Promise = p2.finally(); const pf7: Promise = p2.finally(() => {}); @@ -18,7 +18,7 @@ const genericF: Promise = returnsPromise().finally(() => {}); p1.finally(123); // @ts-expect-error -p1.finally("foo"); +p1.finally('foo'); // @ts-expect-error p1.finally({}); @@ -27,10 +27,10 @@ p1.finally({}); p1.finally([]); // @ts-expect-error -p1.finally(() => {}, "extra"); +p1.finally(() => {}, 'extra'); // @ts-expect-error p1.finally(true); // @ts-expect-error -p1.finally(Symbol("x")); +p1.finally(Symbol('x')); diff --git a/tests/type-definitions/global/proposals/promise-try.test.ts b/tests/type-definitions/global/proposals/promise-try.test.ts index 1268220ec85d..19e1b0f31adb 100644 --- a/tests/type-definitions/global/proposals/promise-try.test.ts +++ b/tests/type-definitions/global/proposals/promise-try.test.ts @@ -1,14 +1,14 @@ import 'core-js/full'; const pt1: Promise = Promise.try(() => 42); -const pt2: Promise = Promise.try(() => Promise.resolve("hi")); +const pt2: Promise = Promise.try(() => Promise.resolve('hi')); const pt3: Promise = Promise.try((a: number, b: number) => a + b, 1, 2); -const pt4: Promise = Promise.try((x: string) => x + "!!", "test"); +const pt4: Promise = Promise.try((x: string) => x + '!!', 'test'); const pt5: Promise = Promise.try(() => {}); const pt6: Promise = Promise.try((b: boolean) => b, false); -const pt7: Promise = Promise.try((a: number, b: string, c: boolean) => c ? a : Number(b), 10, "100", true); -const pt8: Promise = Promise.try((a: string) => Promise.resolve(a), "bar"); +const pt7: Promise = Promise.try((a: number, b: string, c: boolean) => c ? a : Number(b), 10, '100', true); +const pt8: Promise = Promise.try((a: string) => Promise.resolve(a), 'bar'); declare function returnsPromise(): Promise; const pt9: Promise = Promise.try(() => returnsPromise()); @@ -20,7 +20,7 @@ Promise.try(); Promise.try(42); // @ts-expect-error -Promise.try("callback"); +Promise.try('callback'); // @ts-expect-error Promise.try({}); @@ -29,7 +29,7 @@ Promise.try({}); Promise.try([]); // @ts-expect-error -Promise.try(() => 1, 2, "a", Symbol("x")); +Promise.try(() => 1, 2, 'a', Symbol('x')); // @ts-expect-error Promise.try((a: boolean) => a, 123); diff --git a/tests/type-definitions/global/proposals/regexp-escaping.test.ts b/tests/type-definitions/global/proposals/regexp-escaping.test.ts index 64bd78bca4dd..03fa454ee4c9 100644 --- a/tests/type-definitions/global/proposals/regexp-escaping.test.ts +++ b/tests/type-definitions/global/proposals/regexp-escaping.test.ts @@ -2,7 +2,7 @@ import 'core-js/full'; const escaped1: string = RegExp.escape('foo.*+?^${}()|[]\\'); const escaped2: string = RegExp.escape(''); -const s: string = 'abc'; +const s = 'abc'; const escaped3: string = RegExp.escape(s); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/regexp-named-groups.test.ts b/tests/type-definitions/global/proposals/regexp-named-groups.test.ts index 8ae7eae0b1fa..61fc6489298b 100644 --- a/tests/type-definitions/global/proposals/regexp-named-groups.test.ts +++ b/tests/type-definitions/global/proposals/regexp-named-groups.test.ts @@ -8,16 +8,16 @@ const matchGroups: { [key: string]: string } | undefined = matchArr.groups; if (execGroups) { const foo: string | undefined = execGroups.foo; - const bar: string | undefined = execGroups["bar"]; + const bar: string | undefined = execGroups['bar']; } if (matchGroups) { const baz: string | undefined = matchGroups.baz; - const qr: string | undefined = matchGroups["qr"]; + const qr: string | undefined = matchGroups['qr']; } if (execGroups) { - const key = "dynamic"; + const key = 'dynamic'; const dyn: string | undefined = execGroups[key]; } @@ -27,7 +27,7 @@ const mfirst: string = matchArr[0]; // @ts-expect-error execArr.groups = { foo: 123 }; // @ts-expect-error -execArr.groups = "bad"; +execArr.groups = 'bad'; // @ts-expect-error matchArr.groups = { baz: 123 }; // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/relative-indexing-method.test.ts b/tests/type-definitions/global/proposals/relative-indexing-method.test.ts index f024e486daae..1b7107a542d6 100644 --- a/tests/type-definitions/global/proposals/relative-indexing-method.test.ts +++ b/tests/type-definitions/global/proposals/relative-indexing-method.test.ts @@ -13,32 +13,32 @@ const r1: string | undefined = roArr.at(1); const r2: string | undefined = roArr.at(-3); const i8 = new Int8Array([5, 6, 7]); -const i8_1: number | undefined = i8.at(2); -const i8_2: number | undefined = i8.at(-1); +const i8$1: number | undefined = i8.at(2); +const i8$2: number | undefined = i8.at(-1); const u8 = new Uint8Array([8, 9, 10]); -const u8_1: number | undefined = u8.at(0); +const u8$1: number | undefined = u8.at(0); const u8c = new Uint8ClampedArray([15, 16, 17]); -const u8c_1: number | undefined = u8c.at(2); +const u8c$1: number | undefined = u8c.at(2); const i16 = new Int16Array([100, 200, 300]); -const i16_1: number | undefined = i16.at(1); +const i16$1: number | undefined = i16.at(1); const u16 = new Uint16Array([400, 500, 600]); -const u16_1: number | undefined = u16.at(-1); +const u16$1: number | undefined = u16.at(-1); const i32 = new Int32Array([1, 2, 3]); -const i32_1: number | undefined = i32.at(0); +const i32$1: number | undefined = i32.at(0); const u32 = new Uint32Array([7, 8, 9]); -const u32_1: number | undefined = u32.at(2); +const u32$1: number | undefined = u32.at(2); const f32 = new Float32Array([1.5, 2.5, 3.5]); -const f32_1: number | undefined = f32.at(-1); +const f32$1: number | undefined = f32.at(-1); const f64 = new Float64Array([11.1, 22.2, 33.3]); -const f64_1: number | undefined = f64.at(0); +const f64$1: number | undefined = f64.at(0); // todo for es6 // const bi64 = new (BigInt64Array as { new(arr: ArrayLike): BigInt64Array })([BigInt(1), BigInt(2), BigInt(3)]); diff --git a/tests/type-definitions/global/proposals/set-methods.test.ts b/tests/type-definitions/global/proposals/set-methods.test.ts index 5b1f3313706d..8e2b654c3975 100644 --- a/tests/type-definitions/global/proposals/set-methods.test.ts +++ b/tests/type-definitions/global/proposals/set-methods.test.ts @@ -6,13 +6,13 @@ const setB = new Set(['a', 'b', 'c']); const setLike: ReadonlySetLike = { keys() { return [1, 2, 3][Symbol.iterator](); }, has(val: number): boolean { return val === 2; }, - size: 3 + size: 3, }; const setLikeStr: ReadonlySetLike = { keys() { return ['a', 'b'][Symbol.iterator](); }, has(val: string): boolean { return val === 'a'; }, - size: 2 + size: 2, }; const arrSet: ReadonlySet = new Set([4, 5, 6]); diff --git a/tests/type-definitions/global/proposals/string-cooked.test.ts b/tests/type-definitions/global/proposals/string-cooked.test.ts index d2884ba55d55..fcd8e13bd27e 100644 --- a/tests/type-definitions/global/proposals/string-cooked.test.ts +++ b/tests/type-definitions/global/proposals/string-cooked.test.ts @@ -1,7 +1,6 @@ import 'core-js/full'; -const rcooked1: string = String.cooked('foo', 1, 2, 3); -String.cooked(['foo', 'bar'], 1, 2); +const rcooked1: string = String.cooked(['foo', 'bar'], 1, 2); String.cooked([]); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/string-dedent.test.ts b/tests/type-definitions/global/proposals/string-dedent.test.ts index b4a9aab77cf6..5d8f2b92484b 100644 --- a/tests/type-definitions/global/proposals/string-dedent.test.ts +++ b/tests/type-definitions/global/proposals/string-dedent.test.ts @@ -10,7 +10,7 @@ String.dedent(tpl, 1, 2); String.dedent({ raw: ['a\n b\n', '\n c\n'] }, 1, 2); -const myTag = (strings: { raw: readonly string[]}, ...values: (string | number)[]) => { +const myTag = (strings: { raw: readonly string[] }, ...values: (string | number)[]) => { return { strings, values } as const; }; const myAndDedent = String.dedent(myTag); diff --git a/tests/type-definitions/global/proposals/string-replace-all.test.ts b/tests/type-definitions/global/proposals/string-replace-all.test.ts index c65e1000ebdc..ac6e7ad6b449 100644 --- a/tests/type-definitions/global/proposals/string-replace-all.test.ts +++ b/tests/type-definitions/global/proposals/string-replace-all.test.ts @@ -6,7 +6,7 @@ const r1: string = s.replaceAll('foo', 'baz'); const r2: string = s.replaceAll(/foo/g, 'baz'); const r3: string = s.replaceAll('bar', (substr: string) => substr); const r4: string = s.replaceAll(/bar/g, (substr: string) => substr + 'Test'); -const r5: string = s.replaceAll('foo', function(substring: string): string { return substring + '!'; }); +const r5: string = s.replaceAll('foo', function (substring: string): string { return substring + '!'; }); const r6: string = s.replaceAll(/foo/g, (match: string, ...args: any[]) => match + args.length); // @ts-expect-error diff --git a/tests/type-definitions/global/web/atob.test.ts b/tests/type-definitions/global/web/atob.test.ts index e5095168eddf..64e5b59f7194 100644 --- a/tests/type-definitions/global/web/atob.test.ts +++ b/tests/type-definitions/global/web/atob.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; -const s: string = atob("SGVsbG8gd29ybGQ="); +const s: string = atob('SGVsbG8gd29ybGQ='); // @ts-expect-error atob(); diff --git a/tests/type-definitions/global/web/btoa.test.ts b/tests/type-definitions/global/web/btoa.test.ts index f461a900aa8b..23fd5a256318 100644 --- a/tests/type-definitions/global/web/btoa.test.ts +++ b/tests/type-definitions/global/web/btoa.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; -const s: string = btoa("SGVsbG8gd29ybGQ="); +const s: string = btoa('SGVsbG8gd29ybGQ='); // @ts-expect-error atob(); diff --git a/tests/type-definitions/global/web/iterable-dom-collections.test.ts b/tests/type-definitions/global/web/iterable-dom-collections.test.ts index 899857136cae..f84aa1caa547 100644 --- a/tests/type-definitions/global/web/iterable-dom-collections.test.ts +++ b/tests/type-definitions/global/web/iterable-dom-collections.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; -declare const nodeList: NodeList +declare const nodeList: NodeList; nodeList.forEach((value: Node, key: number, list: NodeList): void => {}); nodeList.forEach((value: Node, key: number, list: NodeList): void => {}, []); // @ts-expect-error @@ -18,7 +18,7 @@ const e: IterableIterator<[number, Node]> = nodeList.entries(); // @ts-expect-error nodeList.entries('string'); -declare const domTokenList: DOMTokenList +declare const domTokenList: DOMTokenList; domTokenList.forEach((value: Node, key: number, list: DOMTokenList): void => {}); domTokenList.forEach((value: Node, key: number, list: DOMTokenList): void => {}, []); diff --git a/tests/type-definitions/global/web/queue-microtask.test.ts b/tests/type-definitions/global/web/queue-microtask.test.ts index 4203071aaf68..0ce0553e994f 100644 --- a/tests/type-definitions/global/web/queue-microtask.test.ts +++ b/tests/type-definitions/global/web/queue-microtask.test.ts @@ -8,4 +8,4 @@ queueMicrotask(); // @ts-expect-error queueMicrotask('not a function'); // @ts-expect-error -queueMicrotask((a) => {}); +queueMicrotask(a => {}); diff --git a/tests/type-definitions/pure/proposals/accessible-object-hasownproperty.test.ts b/tests/type-definitions/pure/proposals/accessible-object-hasownproperty.test.ts index d934cb37c0f0..f37738e672c8 100644 --- a/tests/type-definitions/pure/proposals/accessible-object-hasownproperty.test.ts +++ b/tests/type-definitions/pure/proposals/accessible-object-hasownproperty.test.ts @@ -1,20 +1,20 @@ import objectHasOwn from '@core-js/pure/full/object/has-own'; -const res: boolean = objectHasOwn({a: 1}, 'a'); +const res: boolean = objectHasOwn({ a: 1 }, 'a'); objectHasOwn([], 0); objectHasOwn(new Date(), 'toISOString'); objectHasOwn(Object.create(null), Symbol.iterator); -objectHasOwn(function(){}, 'call'); +objectHasOwn(function () {}, 'call'); objectHasOwn(Object.prototype, 'toString'); // @ts-expect-error objectHasOwn(1, 'a'); // @ts-expect-error -objectHasOwn({a: 1}, {}); +objectHasOwn({ a: 1 }, {}); // @ts-expect-error -objectHasOwn({a: 1}); +objectHasOwn({ a: 1 }); // @ts-expect-error objectHasOwn(); diff --git a/tests/type-definitions/pure/proposals/array-filtering.test.ts b/tests/type-definitions/pure/proposals/array-filtering.test.ts index 3bccc321ab15..5c257715142e 100644 --- a/tests/type-definitions/pure/proposals/array-filtering.test.ts +++ b/tests/type-definitions/pure/proposals/array-filtering.test.ts @@ -3,7 +3,7 @@ import arrayFilterReject from '@core-js/pure/full/array/filter-reject'; const res: number[] = arrayFilterReject([1, 2, 3], (v, i, arr) => v > 1); arrayFilterReject(['a', 'b'], (v, i, arr) => v === 'a'); const arr: number[] = [1, 2, 3]; -arrayFilterReject(arr, function(v) { return v < 2; }, { foo: true }); +arrayFilterReject(arr, function (v) { return v < 2; }, { foo: true }); // @ts-expect-error [1, 2, 3].arrayFilterReject((x: string) => false); diff --git a/tests/type-definitions/pure/proposals/array-find-from-last.test.ts b/tests/type-definitions/pure/proposals/array-find-from-last.test.ts index 0780b370a0ff..d7ad60c91e5f 100644 --- a/tests/type-definitions/pure/proposals/array-find-from-last.test.ts +++ b/tests/type-definitions/pure/proposals/array-find-from-last.test.ts @@ -9,8 +9,8 @@ arrayFindLastIndex([1, 2, 3], v => v === 2); const nums: number[] = [1, 2, 3]; const res2: number | undefined = arrayFindLast(nums, (v, i, arr) => v > 1 && arr.length > 0, {}); arrayFindLastIndex(nums, (v, i, arr) => v > 0, {}); -const m = ["a", 2, 3] as (string | number)[]; -arrayFindLast(m, (v): v is string => typeof v === "string"); +const m = ['a', 2, 3] as (string | number)[]; +arrayFindLast(m, (v): v is string => typeof v === 'string'); // @ts-expect-error arrayFindLast([1, 2, 3]); diff --git a/tests/type-definitions/pure/proposals/array-grouping.test.ts b/tests/type-definitions/pure/proposals/array-grouping.test.ts index 76b588d6afc4..1c3680ac45a9 100644 --- a/tests/type-definitions/pure/proposals/array-grouping.test.ts +++ b/tests/type-definitions/pure/proposals/array-grouping.test.ts @@ -18,18 +18,18 @@ mapGroupBy(new Set(['a', 'b', 'c']), (x, i) => i); // @ts-expect-error objectGroupBy(); // @ts-expect-error -objectGroupBy([1,2,3]); +objectGroupBy([1, 2, 3]); // @ts-expect-error -objectGroupBy([1,2,3], 123); +objectGroupBy([1, 2, 3], 123); // @ts-expect-error objectGroupBy(123, x => x); // @ts-expect-error -objectGroupBy([1,2,3], (a, b, c) => a); +objectGroupBy([1, 2, 3], (a, b, c) => a); // @ts-expect-error mapGroupBy(); // @ts-expect-error -mapGroupBy([1,2,3]); +mapGroupBy([1, 2, 3]); // @ts-expect-error mapGroupBy(123, x => x); // @ts-expect-error -mapGroupBy([1,2,3], (a, b, c) => a); +mapGroupBy([1, 2, 3], (a, b, c) => a); diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 386bdb575b80..8bfbc072f64b 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -48,7 +48,7 @@ const r5: CoreJSPromiseAndPromiseLike = some(aiton, (v: number, i: numb const r6: CoreJSPromiseAndPromiseLike = toArray(aiton); const ait1: CoreJSAsyncIteratorLike = filter(aiton, (v: number, i: number) => v > 0); -const ait2: CoreJSAsyncIteratorLike = flatMap(aiton, (v: number, i: number) => `${v}`); +const ait2: CoreJSAsyncIteratorLike = flatMap(aiton, (v: number, i: number) => `${ v }`); const ait3: CoreJSAsyncIteratorLike = map(aiton, (v: number, i: number) => v * 2); const ait4: CoreJSAsyncIteratorLike = take(aiton, 10); const ait5: CoreJSAsyncIteratorLike = drop(aiton, 3); diff --git a/tests/type-definitions/pure/proposals/await-dictionary.test.ts b/tests/type-definitions/pure/proposals/await-dictionary.test.ts index 66fe4a5602d5..12dcd5e98409 100644 --- a/tests/type-definitions/pure/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/pure/proposals/await-dictionary.test.ts @@ -11,7 +11,7 @@ const res: CoreJSPromiseAndPromiseLike<{ a: number, b: string, c: boolean }> = p declare const sym: unique symbol; const res2: CoreJSPromiseAndPromiseLike<{ [sym]: number }> = promiseAllKeyed({ - [sym]: promiseResolve(1) + [sym]: promiseResolve(1), }); // @ts-expect-error @@ -19,11 +19,11 @@ promiseAllKeyed(); // @ts-expect-error promiseAllKeyed({ a: 1, b: promiseResolve(2) }); // @ts-expect-error -promiseAllKeyed([ promiseResolve(1), promiseResolve(2) ]); +promiseAllKeyed([promiseResolve(1), promiseResolve(2)]); // @ts-expect-error promiseAllSettledKeyed(); // @ts-expect-error promiseAllSettledKeyed({ a: 1, b: promiseResolve(2) }); // @ts-expect-error -promiseAllSettledKeyed([ promiseResolve(1), promiseResolve(2) ]); +promiseAllSettledKeyed([promiseResolve(1), promiseResolve(2)]); diff --git a/tests/type-definitions/pure/proposals/change-array-by-copy.test.ts b/tests/type-definitions/pure/proposals/change-array-by-copy.test.ts index 6e2051155916..6dfc0494fb9c 100644 --- a/tests/type-definitions/pure/proposals/change-array-by-copy.test.ts +++ b/tests/type-definitions/pure/proposals/change-array-by-copy.test.ts @@ -16,7 +16,7 @@ const sarr: string[] = ['a', 'b', 'c']; const sarrRev: string[] = arrayToReversed(sarr); const sarrSorted: string[] = arrayToSorted(sarr); const sarrWith: string[] = arrayWith(sarr, 0, 'z'); -const sarrSpliced: string[] = arrayToSpliced(sarr ,0, 1); +const sarrSpliced: string[] = arrayToSpliced(sarr, 0, 1); // @ts-expect-error arrayToReversed(arr, 1); diff --git a/tests/type-definitions/pure/proposals/collection-of-from.test.ts b/tests/type-definitions/pure/proposals/collection-of-from.test.ts index c5a3a64a370e..8fee96ad3a14 100644 --- a/tests/type-definitions/pure/proposals/collection-of-from.test.ts +++ b/tests/type-definitions/pure/proposals/collection-of-from.test.ts @@ -37,7 +37,7 @@ setFrom(); const rso1: CoreJSSetAndSetLike = setOf(1, 2, 3); const rso2: CoreJSSetAndSetLike = setOf('a', 'b', 'c'); // @ts-expect-error -setOf({ 'foo': 'bar' }, 2); +setOf({ foo: 'bar' }, 2); const rwm1: CoreJSWeakMapAndWeakMapLike<{ a: number }, string> = weakMapFrom([[{ a: 1 }, 'x']] as [{ a: number }, string][]); const rwm2: CoreJSWeakMapAndWeakMapLike = weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], (v, k) => v.toString()); diff --git a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts index 987f19ae8c6c..75b2160c70d9 100644 --- a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts @@ -16,13 +16,13 @@ const ad: symbol = symbolAsyncDispose; const wrong: number = symbolDispose; const objD = { - [symbolDispose]() { /* empty */ } + [symbolDispose]() { /* empty */ }, }; objD[symbolDispose](); const objAD = { - [symbolAsyncDispose]() { return promiseResolve(); } -} + [symbolAsyncDispose]() { return promiseResolve(); }, +}; const p1: CoreJSPromiseAndPromiseLike = objAD[symbolAsyncDispose](); const err1 = new $SuppressedError('err', 'suppressed', 'msg'); diff --git a/tests/type-definitions/pure/proposals/extractors.test.ts b/tests/type-definitions/pure/proposals/extractors.test.ts index 68ad75916647..4d79fef7a50e 100644 --- a/tests/type-definitions/pure/proposals/extractors.test.ts +++ b/tests/type-definitions/pure/proposals/extractors.test.ts @@ -5,6 +5,6 @@ const rscs1: symbol = $customMatcher; const rscs2: typeof $customMatcher = $customMatcher; // @ts-expect-error -$Symbol['customMatcher'] = $Symbol("other"); +$Symbol['customMatcher'] = $Symbol('other'); // @ts-expect-error const n: number = $customMatcher; diff --git a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts index dc951362d7c0..31fd8fac51d0 100644 --- a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts @@ -45,9 +45,9 @@ iteratorDrop('3'); const flatMapped: CoreJSIteratorAndIteratorLike = iteratorFlatMap(it, (v, i) => itStr); const flatMapped2: CoreJSIteratorAndIteratorLike = iteratorFlatMap(it, (v, i) => ({ - [Symbol.iterator]: function* () { + [Symbol.iterator]: function * () { yield String(v); - } + }, })); // @ts-expect-error @@ -58,7 +58,7 @@ const sum2: number = iteratorReduce(it, (a, b, c) => a + b + c, 0); const strReduce: string = iteratorReduce( it, (acc: string, val) => acc + val, - '' + '', ); // @ts-expect-error diff --git a/tests/type-definitions/pure/proposals/iterator-join.test.ts b/tests/type-definitions/pure/proposals/iterator-join.test.ts index acc0f1096f6a..6738482b3476 100644 --- a/tests/type-definitions/pure/proposals/iterator-join.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-join.test.ts @@ -2,7 +2,7 @@ import iteratorJoin from '@core-js/pure/full/iterator/join'; declare const it: Iterator; -const res1: string = iteratorJoin(it, ); +const res1: string = iteratorJoin(it); const res2: string = iteratorJoin(it, ' '); const res3: string = iteratorJoin(it, 5); const res4: string = iteratorJoin(it, Symbol('x')); @@ -12,4 +12,4 @@ const res6: string = iteratorJoin(it, null); // @ts-expect-error iteratorJoin(it, '+', '_'); // @ts-expect-error -const res7: number = iteratorJoin(it, ); +const res7: number = iteratorJoin(it); diff --git a/tests/type-definitions/pure/proposals/iterator-joint.test.ts b/tests/type-definitions/pure/proposals/iterator-joint.test.ts index e261b0d63de5..ad856ff10a57 100644 --- a/tests/type-definitions/pure/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-joint.test.ts @@ -4,15 +4,15 @@ import { CoreJSIteratorAndIteratorLike } from '../../helpers'; const zipped1: CoreJSIteratorAndIteratorLike = iteratorZip([[1, 2, 3], [4, 5, 6]]); const zipped2: CoreJSIteratorAndIteratorLike = iteratorZip([['a', 'b', 'c'], ['d', 'e', 'f']]); -const zipped3: CoreJSIteratorAndIteratorLike = iteratorZip([[1, 2, 3], [4, 5, 6]], { mode: "shortest" }); +const zipped3: CoreJSIteratorAndIteratorLike = iteratorZip([[1, 2, 3], [4, 5, 6]], { mode: 'shortest' }); const zipped4: CoreJSIteratorAndIteratorLike> = iteratorZipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); -const zipped5: CoreJSIteratorAndIteratorLike> = iteratorZipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: "shortest" }); +const zipped5: CoreJSIteratorAndIteratorLike> = iteratorZipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: 'shortest' }); // @ts-expect-error iteratorZip(true); // @ts-expect-error -iteratorZip([[1, 2, 3], [4, 5, 6]], { mode: "incorrect" }); +iteratorZip([[1, 2, 3], [4, 5, 6]], { mode: 'incorrect' }); // @ts-expect-error iteratorZipKeyed(42); // @ts-expect-error -iteratorZipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }, { foo: "bar" }); +iteratorZipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }, { foo: 'bar' }); diff --git a/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts b/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts index c70d5b13e15c..35f24d61cb72 100644 --- a/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts +++ b/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts @@ -4,11 +4,11 @@ import $parse from '@core-js/pure/full/json/parse'; declare type CoreJSRawJSON = { rawJSON: string; -} +}; declare type CoreJSReviverContext = { source: string; -} +}; const r: CoreJSRawJSON = $rawJSON('{"a":123}'); diff --git a/tests/type-definitions/pure/proposals/object-from-entries.test.ts b/tests/type-definitions/pure/proposals/object-from-entries.test.ts index ca8d30a934bc..fcf8db04689d 100644 --- a/tests/type-definitions/pure/proposals/object-from-entries.test.ts +++ b/tests/type-definitions/pure/proposals/object-from-entries.test.ts @@ -9,7 +9,7 @@ declare const notIterable: {}; const r1: { [k: string]: number } = objectFromEntries(objEntries); const r2: any = objectFromEntries(mixedEntries); const r3: any = objectFromEntries([['a', 1], ['b', 2]]); -const r4: object = objectFromEntries(new Map([ ['x', 1], ['y', 2] ])); +const r4: object = objectFromEntries(new Map([['x', 1], ['y', 2]])); // @ts-expect-error objectFromEntries(); diff --git a/tests/type-definitions/pure/proposals/object-values-entries.test.ts b/tests/type-definitions/pure/proposals/object-values-entries.test.ts index ba56cb8aff6b..2ac45d2beb76 100644 --- a/tests/type-definitions/pure/proposals/object-values-entries.test.ts +++ b/tests/type-definitions/pure/proposals/object-values-entries.test.ts @@ -19,8 +19,8 @@ const entries3: [string, string][] = objectEntries(strArr); const entries4: [string, number][] = objectEntries(arrLike); const entries5: [string, any][] = objectEntries(emptyObj); -const valuesAnyArr: any[] = objectValues({ foo: 123, bar: "baz" }); -const entriesAnyArr: [string, any][] = objectEntries({ foo: 123, bar: "baz" }); +const valuesAnyArr: any[] = objectValues({ foo: 123, bar: 'baz' }); +const entriesAnyArr: [string, any][] = objectEntries({ foo: 123, bar: 'baz' }); // @ts-expect-error objectValues(); diff --git a/tests/type-definitions/pure/proposals/pattern-matching.test.ts b/tests/type-definitions/pure/proposals/pattern-matching.test.ts index aa13232b3450..0b302a7e9f1e 100644 --- a/tests/type-definitions/pure/proposals/pattern-matching.test.ts +++ b/tests/type-definitions/pure/proposals/pattern-matching.test.ts @@ -5,4 +5,4 @@ const sym: symbol = $Symbol.customMatcher; // @ts-expect-error const bad1: string = $Symbol.customMatcher; // @ts-expect-error -$Symbol['customMatcher'] = $Symbol("other"); +$Symbol.customMatcher = $Symbol('other'); diff --git a/tests/type-definitions/pure/proposals/promise-any.test.ts b/tests/type-definitions/pure/proposals/promise-any.test.ts index 7c351c2a7b69..115e2112f1cd 100644 --- a/tests/type-definitions/pure/proposals/promise-any.test.ts +++ b/tests/type-definitions/pure/proposals/promise-any.test.ts @@ -2,15 +2,15 @@ import promiseAny from '@core-js/pure/full/promise/any'; import promiseResolve from '@core-js/pure/full/promise/resolve'; import { CoreJSPromiseAndPromiseLike } from '../../helpers'; -const arr = [promiseResolve(1), promiseResolve("foo"), 3] as const; +const arr = [promiseResolve(1), promiseResolve('foo'), 3] as const; const justNumbers = [1, 2, 3]; -const setOfStrings = new Set(["a", "b", "c"]); +const setOfStrings = new Set(['a', 'b', 'c']); const promiseLike = { then: (cb: (val: number) => void) => cb(123) }; const emptyTuple: [] = []; -const mixed = [true, promiseResolve("z")] as const; +const mixed = [true, promiseResolve('z')] as const; const any1: CoreJSPromiseAndPromiseLike = promiseAny(arr); -const any2: CoreJSPromiseAndPromiseLike = promiseAny(["x", "y", promiseResolve(5)]); +const any2: CoreJSPromiseAndPromiseLike = promiseAny(['x', 'y', promiseResolve(5)]); const any3: CoreJSPromiseAndPromiseLike = promiseAny(emptyTuple); const any4: CoreJSPromiseAndPromiseLike = promiseAny(mixed); @@ -33,4 +33,4 @@ promiseAny({ foo: 42 }); promiseAny([1, 2], 3); // @ts-expect-error -promiseAny(justNumbers, "extra"); +promiseAny(justNumbers, 'extra'); diff --git a/tests/type-definitions/pure/proposals/promise-finally.test.ts b/tests/type-definitions/pure/proposals/promise-finally.test.ts index 960775605f1e..5a05e4309143 100644 --- a/tests/type-definitions/pure/proposals/promise-finally.test.ts +++ b/tests/type-definitions/pure/proposals/promise-finally.test.ts @@ -11,7 +11,7 @@ const pf3: CoreJSPromiseAndPromiseLike = promiseFinally(p1, null); const pf4: CoreJSPromiseAndPromiseLike = promiseFinally(p1, () => {}); const pf5: CoreJSPromiseAndPromiseLike = promiseFinally(p1, function () {}); -const pr2: CoreJSPromiseAndPromiseLike = promiseReject("err"); +const pr2: CoreJSPromiseAndPromiseLike = promiseReject('err'); declare const p2: Promise; const pf6: CoreJSPromiseAndPromiseLike = promiseFinally(p2); const pf7: CoreJSPromiseAndPromiseLike = promiseFinally(p2, () => {}); @@ -20,7 +20,7 @@ const pf7: CoreJSPromiseAndPromiseLike = promiseFinally(p2, () => {}); promiseFinally(p1, 123); // @ts-expect-error -promiseFinally(p1, "foo"); +promiseFinally(p1, 'foo'); // @ts-expect-error promiseFinally(p1, {}); @@ -29,10 +29,10 @@ promiseFinally(p1, {}); promiseFinally(p1, []); // @ts-expect-error -promiseFinally(p1, () => {}, "extra"); +promiseFinally(p1, () => {}, 'extra'); // @ts-expect-error promiseFinally(p1, true); // @ts-expect-error -promiseFinally(p1, Symbol("x")); +promiseFinally(p1, Symbol('x')); diff --git a/tests/type-definitions/pure/proposals/promise-try.test.ts b/tests/type-definitions/pure/proposals/promise-try.test.ts index f25e0e99801e..8ea9b4416003 100644 --- a/tests/type-definitions/pure/proposals/promise-try.test.ts +++ b/tests/type-definitions/pure/proposals/promise-try.test.ts @@ -3,14 +3,14 @@ import promiseResolve from '@core-js/pure/full/promise/resolve'; import { CoreJSPromiseAndPromiseLike } from '../../helpers'; const pt1: CoreJSPromiseAndPromiseLike = promiseTry(() => 42); -const pt2: CoreJSPromiseAndPromiseLike = promiseTry(() => promiseResolve("hi")); +const pt2: CoreJSPromiseAndPromiseLike = promiseTry(() => promiseResolve('hi')); const pt3: CoreJSPromiseAndPromiseLike = promiseTry((a: number, b: number) => a + b, 1, 2); -const pt4: CoreJSPromiseAndPromiseLike = promiseTry((x: string) => x + "!!", "test"); +const pt4: CoreJSPromiseAndPromiseLike = promiseTry((x: string) => x + '!!', 'test'); const pt5: CoreJSPromiseAndPromiseLike = promiseTry(() => {}); const pt6: CoreJSPromiseAndPromiseLike = promiseTry((b: boolean) => b, false); -const pt7: CoreJSPromiseAndPromiseLike = promiseTry((a: number, b: string, c: boolean) => c ? a : Number(b), 10, "100", true); -const pt8: CoreJSPromiseAndPromiseLike = promiseTry((a: string) => promiseResolve(a), "bar"); +const pt7: CoreJSPromiseAndPromiseLike = promiseTry((a: number, b: string, c: boolean) => c ? a : Number(b), 10, '100', true); +const pt8: CoreJSPromiseAndPromiseLike = promiseTry((a: string) => promiseResolve(a), 'bar'); declare function returnsPromise(): CoreJSPromiseAndPromiseLike; const pt9: CoreJSPromiseAndPromiseLike = promiseTry(() => returnsPromise()); @@ -22,7 +22,7 @@ promiseTry(); promiseTry(42); // @ts-expect-error -promiseTry("callback"); +promiseTry('callback'); // @ts-expect-error promiseTry({}); @@ -31,7 +31,7 @@ promiseTry({}); promiseTry([]); // @ts-expect-error -promiseTry(() => 1, 2, "a", Symbol("x")); +promiseTry(() => 1, 2, 'a', Symbol('x')); // @ts-expect-error promiseTry((a: boolean) => a, 123); diff --git a/tests/type-definitions/pure/proposals/regexp-escaping.test.ts b/tests/type-definitions/pure/proposals/regexp-escaping.test.ts index da34a159082a..234ac1da5372 100644 --- a/tests/type-definitions/pure/proposals/regexp-escaping.test.ts +++ b/tests/type-definitions/pure/proposals/regexp-escaping.test.ts @@ -2,7 +2,7 @@ import regexpEscape from '@core-js/pure/full/regexp/escape'; const escaped1: string = regexpEscape('foo.*+?^${}()|[]\\'); const escaped2: string = regexpEscape(''); -const s: string = 'abc'; +const s = 'abc'; const escaped3: string = regexpEscape(s); // @ts-expect-error diff --git a/tests/type-definitions/pure/proposals/set-methods.test.ts b/tests/type-definitions/pure/proposals/set-methods.test.ts index 66fe451c0868..37dcd242bc3a 100644 --- a/tests/type-definitions/pure/proposals/set-methods.test.ts +++ b/tests/type-definitions/pure/proposals/set-methods.test.ts @@ -14,13 +14,13 @@ const setB = new $Set(['a', 'b', 'c']); const setLike = { keys() { return [1, 2, 3][Symbol.iterator](); }, has(val: number): boolean { return val === 2; }, - size: 3 + size: 3, }; const setLikeStr = { keys() { return ['a', 'b'][Symbol.iterator](); }, has(val: string): boolean { return val === 'a'; }, - size: 2 + size: 2, }; const unionAB: CoreJSSetAndSetLike = setUnion(setA, setB); diff --git a/tests/type-definitions/pure/proposals/string-cooked.test.ts b/tests/type-definitions/pure/proposals/string-cooked.test.ts index 4178bd702f8a..46e23805b698 100644 --- a/tests/type-definitions/pure/proposals/string-cooked.test.ts +++ b/tests/type-definitions/pure/proposals/string-cooked.test.ts @@ -1,7 +1,6 @@ import stringCooked from '@core-js/pure/full/string/cooked'; -const rcooked1: string = stringCooked('foo', 1, 2, 3); -stringCooked(['foo', 'bar'], 1, 2); +const rcooked1: string = stringCooked(['foo', 'bar'], 1, 2); stringCooked([]); // @ts-expect-error diff --git a/tests/type-definitions/pure/proposals/string-dedent.test.ts b/tests/type-definitions/pure/proposals/string-dedent.test.ts index 3cc30cde884b..4059c9147a27 100644 --- a/tests/type-definitions/pure/proposals/string-dedent.test.ts +++ b/tests/type-definitions/pure/proposals/string-dedent.test.ts @@ -10,7 +10,7 @@ stringDedent(tpl, 1, 2); stringDedent({ raw: ['a\n b\n', '\n c\n'] }, 1, 2); -const myTag = (strings: { raw: readonly string[]}, ...values: (string | number)[]) => { +const myTag = (strings: { raw: readonly string[] }, ...values: (string | number)[]) => { return { strings, values } as const; }; const myAndDedent = stringDedent(myTag); diff --git a/tests/type-definitions/pure/proposals/string-padding.test.ts b/tests/type-definitions/pure/proposals/string-padding.test.ts index d78e278b68e6..40a13b08da8e 100644 --- a/tests/type-definitions/pure/proposals/string-padding.test.ts +++ b/tests/type-definitions/pure/proposals/string-padding.test.ts @@ -2,16 +2,16 @@ import stringPadStart from '@core-js/pure/full/string/pad-start'; import stringPadEnd from '@core-js/pure/full/string/pad-end'; const s = 'foo'; -const str: string = ''; +const str = ''; const p1: string = stringPadStart(s, 5); const p2: string = stringPadStart(s, 10, '0'); const p3: string = stringPadEnd(s, 8); const p4: string = stringPadEnd(s, 4, '-'); // @ts-expect-error -stringPadStart(s, ); +stringPadStart(s); // @ts-expect-error -stringPadEnd(s, ); +stringPadEnd(s); // @ts-expect-error stringPadStart(s, '10'); // @ts-expect-error diff --git a/tests/type-definitions/pure/proposals/string-replace-all.test.ts b/tests/type-definitions/pure/proposals/string-replace-all.test.ts index 5ad8ad6ef59a..cabedf9ad151 100644 --- a/tests/type-definitions/pure/proposals/string-replace-all.test.ts +++ b/tests/type-definitions/pure/proposals/string-replace-all.test.ts @@ -6,7 +6,7 @@ const r1: string = stringReplaceAll(s, 'foo', 'baz'); const r2: string = stringReplaceAll(s, /foo/g, 'baz'); const r3: string = stringReplaceAll(s, 'bar', (substr: string) => substr); const r4: string = stringReplaceAll(s, /bar/g, (substr: string) => substr + 'Test'); -const r5: string = stringReplaceAll(s, 'foo', function(substring: string): string { return substring + '!'; }); +const r5: string = stringReplaceAll(s, 'foo', function (substring: string): string { return substring + '!'; }); const r6: string = stringReplaceAll(s, /foo/g, (match: string, ...args: any[]) => match + args.length); // @ts-expect-error diff --git a/tests/type-definitions/pure/web/atob.test.ts b/tests/type-definitions/pure/web/atob.test.ts index 2dd8cd14b1e3..7ce44646586b 100644 --- a/tests/type-definitions/pure/web/atob.test.ts +++ b/tests/type-definitions/pure/web/atob.test.ts @@ -1,6 +1,6 @@ import $atob from '@core-js/pure/full/atob'; -const s: string = $atob("SGVsbG8gd29ybGQ="); +const s: string = $atob('SGVsbG8gd29ybGQ='); // @ts-expect-error $atob(); diff --git a/tests/type-definitions/pure/web/btoa.test.ts b/tests/type-definitions/pure/web/btoa.test.ts index 83238bb9a719..51c535bf5f88 100644 --- a/tests/type-definitions/pure/web/btoa.test.ts +++ b/tests/type-definitions/pure/web/btoa.test.ts @@ -1,6 +1,6 @@ import $btoa from '@core-js/pure/full/btoa'; -const s: string = $btoa("SGVsbG8gd29ybGQ="); +const s: string = $btoa('SGVsbG8gd29ybGQ='); // @ts-expect-error $btoa(); diff --git a/tests/type-definitions/pure/web/queue-microtask.test.ts b/tests/type-definitions/pure/web/queue-microtask.test.ts index 11455ee2f708..b485bf35a8fb 100644 --- a/tests/type-definitions/pure/web/queue-microtask.test.ts +++ b/tests/type-definitions/pure/web/queue-microtask.test.ts @@ -8,4 +8,4 @@ $queueMicrotask(); // @ts-expect-error $queueMicrotask('not a function'); // @ts-expect-error -$queueMicrotask((a) => {}); +$queueMicrotask(a => {}); diff --git a/tests/type-definitions/pure/web/url-search-params.test.ts b/tests/type-definitions/pure/web/url-search-params.test.ts index 79702a604394..f06c0bc0a2c4 100644 --- a/tests/type-definitions/pure/web/url-search-params.test.ts +++ b/tests/type-definitions/pure/web/url-search-params.test.ts @@ -4,7 +4,7 @@ const ps1 = new $URLSearchParams(); new $URLSearchParams('a=1&b=2'); new $URLSearchParams([['a', '1'], ['b', '2']]); new $URLSearchParams(ps1); -new $URLSearchParams({ foo: "bar" }); +new $URLSearchParams({ foo: 'bar' }); // @ts-expect-error new $URLSearchParams(42); diff --git a/tests/type-definitions/templates.import.ts b/tests/type-definitions/templates.import.ts index 2543ebc8d7b0..fe810aee7ac5 100644 --- a/tests/type-definitions/templates.import.ts +++ b/tests/type-definitions/templates.import.ts @@ -42,8 +42,8 @@ arrayVirtualIterator.call([1, 2, 3], 1); // $uncurried import arrayAt from '@core-js/pure/full/array/at'; -const arrayAtResult1: number|undefined = arrayAt([1, 2, 3], -2); -const arrayAtResult2: string|undefined = arrayAt(['a', 'b'], -2); +const arrayAtResult1: number | undefined = arrayAt([1, 2, 3], -2); +const arrayAtResult2: string | undefined = arrayAt(['a', 'b'], -2); const arrayAtResult3: undefined = arrayAt([], 1); // @ts-expect-error arrayAt([1, 2], 'string'); @@ -60,7 +60,7 @@ arrayIterator(); // $static import arrayFrom from '@core-js/pure/full/array/from'; -arrayFrom('qwe', (it) => it.toUpperCase(), {}); +arrayFrom('qwe', it => it.toUpperCase(), {}); // @ts-expect-error arrayFrom(1); // @ts-expect-error @@ -74,7 +74,7 @@ allSettled(1); // $patchableStatic import stringify from '@core-js/pure/full/json/stringify'; -stringify({ a: 1, b: 2, c: 'asd'}, (_key, val) => typeof val === 'number' ? val * 2 : val, 4); +stringify({ a: 1, b: 2, c: 'asd' }, (_key, val) => typeof val === 'number' ? val * 2 : val, 4); // @ts-expect-error stringify([1], 1); From 34019891982ae5455d8d592517792e08ceb05365 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sun, 11 Jan 2026 14:41:03 +0700 Subject: [PATCH 137/315] Error cause --- .../src/base/proposals/error-cause.d.ts | 4 ++-- scripts/build-entries/entries-definitions.mjs | 8 +++++--- .../global/proposals/error-cause.test.ts | 4 ++++ tests/type-definitions/helpers.ts | 3 +++ .../pure/proposals/error-cause.test.ts | 16 ++++++++++++++++ tests/type-definitions/templates.import.ts | 10 +++++----- 6 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 tests/type-definitions/pure/proposals/error-cause.test.ts diff --git a/packages/core-js-types/src/base/proposals/error-cause.d.ts b/packages/core-js-types/src/base/proposals/error-cause.d.ts index 7593a5d6735e..072aaad33f46 100644 --- a/packages/core-js-types/src/base/proposals/error-cause.d.ts +++ b/packages/core-js-types/src/base/proposals/error-cause.d.ts @@ -61,8 +61,8 @@ interface AggregateError extends Error { // @type-options no-redefine } interface AggregateErrorConstructor extends ErrorConstructor { - new (errors: Iterable, message?: string): AggregateError; - (errors: Iterable, message?: string): AggregateError; + new (errors: Iterable, message?: string, options?: ErrorOptions): AggregateError; + (errors: Iterable, message?: string, options?: ErrorOptions): AggregateError; readonly prototype: AggregateError; } diff --git a/scripts/build-entries/entries-definitions.mjs b/scripts/build-entries/entries-definitions.mjs index 36c0d97516c0..aa6a7d586b42 100644 --- a/scripts/build-entries/entries-definitions.mjs +++ b/scripts/build-entries/entries-definitions.mjs @@ -894,11 +894,13 @@ export const features = { }, 'error/index': { modules: [/^(?:es|esnext)\.error\./], - template: $path, + template: $namespace, + name: 'Error', }, 'error/constructor': { - modules: ['es.error.cause'], - template: $path, // !!!!!!! + modules: [/^(?:es|esnext)\.error\./], + template: $namespace, + name: 'Error', }, 'error/is-error': { modules: ['es.error.is-error'], diff --git a/tests/type-definitions/global/proposals/error-cause.test.ts b/tests/type-definitions/global/proposals/error-cause.test.ts index 099e6283e8da..2391674bce08 100644 --- a/tests/type-definitions/global/proposals/error-cause.test.ts +++ b/tests/type-definitions/global/proposals/error-cause.test.ts @@ -29,3 +29,7 @@ const resTE3: TypeError = new TypeError('Error with cause', { cause: 'prev reaso const resUE1: URIError = new URIError('Error with cause', { cause: prevError }); const resUE2: URIError = new URIError('Error with cause', { cause: null }); const resUE3: URIError = new URIError('Error with cause', { cause: 'prev reason' }); + +const resAE1: AggregateError = new AggregateError([resUE1, resUE2], 'Error with cause', { cause: prevError }); +const resAE2: AggregateError = new AggregateError([resUE1, resUE2], 'Error with cause', { cause: null }); +const resAE3: AggregateError = new AggregateError([resUE1, resUE2], 'Error with cause', { cause: 'prev reason' }); diff --git a/tests/type-definitions/helpers.ts b/tests/type-definitions/helpers.ts index 66cd0362cf2d..c7550ca3c6f2 100644 --- a/tests/type-definitions/helpers.ts +++ b/tests/type-definitions/helpers.ts @@ -64,3 +64,6 @@ export interface CoreJSAsyncIteratorLike { take(limit: number): CoreJSAsyncIteratorLike; toArray(...args: any[]): any; } + +type HasCause = 'cause' extends keyof T ? T : never; +export function assertHasCause(value: T): asserts value is HasCause & { cause: unknown } {} diff --git a/tests/type-definitions/pure/proposals/error-cause.test.ts b/tests/type-definitions/pure/proposals/error-cause.test.ts new file mode 100644 index 000000000000..05249ff96f90 --- /dev/null +++ b/tests/type-definitions/pure/proposals/error-cause.test.ts @@ -0,0 +1,16 @@ +import $AggregateError from '@core-js/pure/full/aggregate-error'; +import $Error from '@core-js/pure/full/error'; +import { assertHasCause } from '../../helpers'; + +const prevError = new $Error('Prev error'); +const someError = new $Error('Some error'); +assertHasCause(someError); + +// todo other errors + +const resAE1 = new $AggregateError([someError], 'Error with cause', { cause: prevError }); +assertHasCause(resAE1); +const resAE2 = new $AggregateError([someError], 'Error with cause', { cause: null }); +assertHasCause(resAE2); +const resAE3 = new $AggregateError([someError], 'Error with cause', { cause: 'prev reason' }); +assertHasCause(resAE3); diff --git a/tests/type-definitions/templates.import.ts b/tests/type-definitions/templates.import.ts index fe810aee7ac5..5722486d9add 100644 --- a/tests/type-definitions/templates.import.ts +++ b/tests/type-definitions/templates.import.ts @@ -90,11 +90,11 @@ getIterator([]).next().value; // @ts-expect-error getIterator(); -// $path -import errorConstructor from '@core-js/pure/full/error/constructor'; -new errorConstructor.Error('er'); -// @ts-expect-error -errorConstructor(); +// $path just typed arrays +// import errorConstructor from '@core-js/pure/full/error/constructor'; +// new errorConstructor.Error('er'); +// // @ts-expect-error +// errorConstructor(); // $instanceArray import iConcat from '@core-js/pure/full/instance/concat'; From 77f862c083697a58d0d39a79dca2034ef9b249a5 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sun, 11 Jan 2026 20:39:12 +0700 Subject: [PATCH 138/315] Rollback Error entry point --- scripts/build-entries/entries-definitions.mjs | 8 +++----- .../type-definitions/pure/proposals/error-cause.test.ts | 9 ++++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/scripts/build-entries/entries-definitions.mjs b/scripts/build-entries/entries-definitions.mjs index aa6a7d586b42..36c0d97516c0 100644 --- a/scripts/build-entries/entries-definitions.mjs +++ b/scripts/build-entries/entries-definitions.mjs @@ -894,13 +894,11 @@ export const features = { }, 'error/index': { modules: [/^(?:es|esnext)\.error\./], - template: $namespace, - name: 'Error', + template: $path, }, 'error/constructor': { - modules: [/^(?:es|esnext)\.error\./], - template: $namespace, - name: 'Error', + modules: ['es.error.cause'], + template: $path, // !!!!!!! }, 'error/is-error': { modules: ['es.error.is-error'], diff --git a/tests/type-definitions/pure/proposals/error-cause.test.ts b/tests/type-definitions/pure/proposals/error-cause.test.ts index 05249ff96f90..9dfc20693a1f 100644 --- a/tests/type-definitions/pure/proposals/error-cause.test.ts +++ b/tests/type-definitions/pure/proposals/error-cause.test.ts @@ -1,12 +1,11 @@ import $AggregateError from '@core-js/pure/full/aggregate-error'; -import $Error from '@core-js/pure/full/error'; +// import $Error from '@core-js/pure/full/error'; TODO separated entry points import { assertHasCause } from '../../helpers'; -const prevError = new $Error('Prev error'); -const someError = new $Error('Some error'); -assertHasCause(someError); +const prevError = new Error('Prev error'); +const someError = new Error('Some error'); -// todo other errors +// TODO other errors after separating Error entry points const resAE1 = new $AggregateError([someError], 'Error with cause', { cause: prevError }); assertHasCause(resAE1); From 9bb17a02767705c731e70af06222f7408a5a7a0a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sun, 11 Jan 2026 20:42:33 +0700 Subject: [PATCH 139/315] Add toAsync type checking --- .../pure/proposals/async-iterator-helper.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 8bfbc072f64b..124986f70c98 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -37,9 +37,6 @@ from(); // @ts-expect-error from({ next: () => 1 }); -toAsync(is); -toAsync(itn); - const r1: CoreJSPromiseAndPromiseLike = every(aiton, (v: number, i: number) => v > 0); const r2: CoreJSPromiseAndPromiseLike = find(aiton, (v: number, i: number) => v > 0); const r3: CoreJSPromiseAndPromiseLike = forEach(aiton, (v: number, i: number) => { }); @@ -52,6 +49,9 @@ const ait2: CoreJSAsyncIteratorLike = flatMap(aiton, (v: number, i: numb const ait3: CoreJSAsyncIteratorLike = map(aiton, (v: number, i: number) => v * 2); const ait4: CoreJSAsyncIteratorLike = take(aiton, 10); const ait5: CoreJSAsyncIteratorLike = drop(aiton, 3); +const ait6: CoreJSAsyncIteratorLike = toAsync(itn); + +toAsync(is); // @ts-expect-error drop(ain); From ad395d9a4b8b624c2ac1dae714088c92aa7b74ba Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sun, 11 Jan 2026 22:28:51 +0700 Subject: [PATCH 140/315] Add async iteration test & move core-js types for pure version to correct folder --- .../src/base/core-js-types/async-iterator-object.d.ts | 3 --- .../base/{ => pure}/core-js-types/async-iterable.d.ts | 0 .../pure/core-js-types/async-iterator-object.d.ts | 8 ++++++++ .../src/base/pure/core-js-types/async-iterator.d.ts | 11 +++++++++++ .../src/base/{ => pure}/core-js-types/map.d.ts | 0 .../src/base/{ => pure}/core-js-types/promise.d.ts | 0 .../src/base/{ => pure}/core-js-types/set.d.ts | 0 .../base/{ => pure}/core-js-types/string-base.d.ts | 0 .../src/base/{ => pure}/core-js-types/weak-map.d.ts | 0 .../src/base/{ => pure}/core-js-types/weak-set.d.ts | 0 .../src/base/pure/proposals/array-constructor.d.ts | 4 ++-- .../base/pure/proposals/async-iterator-helpers.d.ts | 6 +++--- .../src/base/pure/proposals/await-dictionary.d.ts | 2 +- .../src/base/pure/proposals/collection-of-from.d.ts | 8 ++++---- .../src/base/pure/proposals/iterator.d.ts | 6 +++--- .../base/pure/proposals/relative-indexing-method.d.ts | 2 +- .../src/base/pure/proposals/set-methods-custom.d.ts | 2 +- .../base/pure/proposals/string-left-right-trim.d.ts | 2 +- .../src/base/pure/proposals/string-match-all.d.ts | 2 +- .../src/base/pure/proposals/string-padding.d.ts | 2 +- .../src/base/pure/proposals/string-replace-all.d.ts | 2 +- .../pure/proposals/well-formed-unicode-strings.d.ts | 2 +- tests/type-definitions/pure/async-iteration.test.ts | 5 +++++ .../pure/tsconfig.async-iterable.json | 7 +++++++ tests/type-definitions/pure/tsconfig.json | 1 + tests/type-definitions/runner.mjs | 9 +++++++++ 26 files changed, 61 insertions(+), 23 deletions(-) delete mode 100644 packages/core-js-types/src/base/core-js-types/async-iterator-object.d.ts rename packages/core-js-types/src/base/{ => pure}/core-js-types/async-iterable.d.ts (100%) create mode 100644 packages/core-js-types/src/base/pure/core-js-types/async-iterator-object.d.ts create mode 100644 packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts rename packages/core-js-types/src/base/{ => pure}/core-js-types/map.d.ts (100%) rename packages/core-js-types/src/base/{ => pure}/core-js-types/promise.d.ts (100%) rename packages/core-js-types/src/base/{ => pure}/core-js-types/set.d.ts (100%) rename packages/core-js-types/src/base/{ => pure}/core-js-types/string-base.d.ts (100%) rename packages/core-js-types/src/base/{ => pure}/core-js-types/weak-map.d.ts (100%) rename packages/core-js-types/src/base/{ => pure}/core-js-types/weak-set.d.ts (100%) create mode 100644 tests/type-definitions/pure/async-iteration.test.ts create mode 100644 tests/type-definitions/pure/tsconfig.async-iterable.json diff --git a/packages/core-js-types/src/base/core-js-types/async-iterator-object.d.ts b/packages/core-js-types/src/base/core-js-types/async-iterator-object.d.ts deleted file mode 100644 index f25d309513f5..000000000000 --- a/packages/core-js-types/src/base/core-js-types/async-iterator-object.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare namespace CoreJS { - export interface CoreJSAsyncIteratorObject {} -} diff --git a/packages/core-js-types/src/base/core-js-types/async-iterable.d.ts b/packages/core-js-types/src/base/pure/core-js-types/async-iterable.d.ts similarity index 100% rename from packages/core-js-types/src/base/core-js-types/async-iterable.d.ts rename to packages/core-js-types/src/base/pure/core-js-types/async-iterable.d.ts diff --git a/packages/core-js-types/src/base/pure/core-js-types/async-iterator-object.d.ts b/packages/core-js-types/src/base/pure/core-js-types/async-iterator-object.d.ts new file mode 100644 index 000000000000..25f3fbc18591 --- /dev/null +++ b/packages/core-js-types/src/base/pure/core-js-types/async-iterator-object.d.ts @@ -0,0 +1,8 @@ +/// +/// + +declare namespace CoreJS { + export interface CoreJSAsyncIteratorObject extends CoreJS.CoreJSAsyncIterator { + [CoreJS.CoreJSSymbol.asyncIterator](): CoreJSAsyncIteratorObject; + } +} diff --git a/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts b/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts new file mode 100644 index 000000000000..d53cff67a235 --- /dev/null +++ b/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts @@ -0,0 +1,11 @@ +/// + +declare namespace CoreJS { + export interface CoreJSAsyncIterator { + next(...[value]: [] | [TNext]): CoreJS.CoreJSPromise>; + + return?(value?: TReturn | PromiseLike): CoreJS.CoreJSPromise>; + + throw?(e?: any): CoreJS.CoreJSPromise>; + } +} diff --git a/packages/core-js-types/src/base/core-js-types/map.d.ts b/packages/core-js-types/src/base/pure/core-js-types/map.d.ts similarity index 100% rename from packages/core-js-types/src/base/core-js-types/map.d.ts rename to packages/core-js-types/src/base/pure/core-js-types/map.d.ts diff --git a/packages/core-js-types/src/base/core-js-types/promise.d.ts b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts similarity index 100% rename from packages/core-js-types/src/base/core-js-types/promise.d.ts rename to packages/core-js-types/src/base/pure/core-js-types/promise.d.ts diff --git a/packages/core-js-types/src/base/core-js-types/set.d.ts b/packages/core-js-types/src/base/pure/core-js-types/set.d.ts similarity index 100% rename from packages/core-js-types/src/base/core-js-types/set.d.ts rename to packages/core-js-types/src/base/pure/core-js-types/set.d.ts diff --git a/packages/core-js-types/src/base/core-js-types/string-base.d.ts b/packages/core-js-types/src/base/pure/core-js-types/string-base.d.ts similarity index 100% rename from packages/core-js-types/src/base/core-js-types/string-base.d.ts rename to packages/core-js-types/src/base/pure/core-js-types/string-base.d.ts diff --git a/packages/core-js-types/src/base/core-js-types/weak-map.d.ts b/packages/core-js-types/src/base/pure/core-js-types/weak-map.d.ts similarity index 100% rename from packages/core-js-types/src/base/core-js-types/weak-map.d.ts rename to packages/core-js-types/src/base/pure/core-js-types/weak-map.d.ts diff --git a/packages/core-js-types/src/base/core-js-types/weak-set.d.ts b/packages/core-js-types/src/base/pure/core-js-types/weak-set.d.ts similarity index 100% rename from packages/core-js-types/src/base/core-js-types/weak-set.d.ts rename to packages/core-js-types/src/base/pure/core-js-types/weak-set.d.ts diff --git a/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts b/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts index 6bb842db288f..4f1c3e5b8a1e 100644 --- a/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// // Motivation: We must omit methods `fromAsync` and `isTemplateObject` because they cause a signature mismatch error. diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index 630567175f13..9e7034db0147 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -1,6 +1,6 @@ -/// -/// -/// +/// +/// +/// // Motivation: Has dependencies on internal types, e.g. AsyncIterable, AsyncIteratorObject diff --git a/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts index c6d659e9021f..9aa39f74fcaa 100644 --- a/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts @@ -1,5 +1,5 @@ /// -/// +/// // Motivation: Using our own Promise type in return diff --git a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts index da3878b80f9f..026690b54ed6 100644 --- a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts @@ -1,7 +1,7 @@ -/// -/// -/// -/// +/// +/// +/// +/// // Motivation: import our own Map/Set/WeakMap/WeakSet types & redefine return types diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index fae79241dab9..80721b4cf43c 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -1,6 +1,6 @@ -/// -/// -/// +/// +/// +/// // Motivation: Has dependencies on internal types diff --git a/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts index f70291a97038..f3a2b224d76c 100644 --- a/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: We should use String without the matchAll method to avoid signature conflicts diff --git a/packages/core-js-types/src/base/pure/proposals/set-methods-custom.d.ts b/packages/core-js-types/src/base/pure/proposals/set-methods-custom.d.ts index a21a82be77e7..444a27fda980 100644 --- a/packages/core-js-types/src/base/pure/proposals/set-methods-custom.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/set-methods-custom.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: Custom type needed to keep generics strict & return our CoreJSSet type diff --git a/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts index 3cb8577d3012..33625af56374 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: We should use String without the matchAll method to avoid signature conflicts diff --git a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts index 30d4c2fbf555..0ced186b744b 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts @@ -1,4 +1,4 @@ -/// +/// /// // Motivation: We should use String without the matchAll method to avoid signature conflicts diff --git a/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts b/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts index e290a8e2f641..71f2158dc228 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: We should use String without the matchAll method to avoid signature conflicts diff --git a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts index 2e34179c0147..984c3e50a53a 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: We should use String without the matchAll method to avoid signature conflicts diff --git a/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts index fd642df57393..c85a165d89ac 100644 --- a/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: We should use String without the matchAll method to avoid signature conflicts diff --git a/tests/type-definitions/pure/async-iteration.test.ts b/tests/type-definitions/pure/async-iteration.test.ts new file mode 100644 index 000000000000..0efadaa41395 --- /dev/null +++ b/tests/type-definitions/pure/async-iteration.test.ts @@ -0,0 +1,5 @@ +import from from '@core-js/pure/full/async-iterator/from'; + +const aitn = from([1]); +for await (const v of aitn) { +} diff --git a/tests/type-definitions/pure/tsconfig.async-iterable.json b/tests/type-definitions/pure/tsconfig.async-iterable.json new file mode 100644 index 000000000000..d2a9f0fdda7e --- /dev/null +++ b/tests/type-definitions/pure/tsconfig.async-iterable.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig.json", + "include": ["./async-iteration.test.ts"], + "compilerOptions": { + "types": ["@core-js/types/pure"] + } +} diff --git a/tests/type-definitions/pure/tsconfig.json b/tests/type-definitions/pure/tsconfig.json index 3e633c7056c8..fe3fbca4ae2c 100644 --- a/tests/type-definitions/pure/tsconfig.json +++ b/tests/type-definitions/pure/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../tsconfig.json", "include": ["./**/*.ts"], + "exclude": ["./async-iteration.test.ts"], "compilerOptions": { "types": ["@core-js/types/pure"] } diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index c9d1bf94b513..747c416fc87a 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -123,6 +123,11 @@ await $`npx -p typescript@5.9 tsc -p tsconfig.entries.pure.json`; await $`npx -p typescript@5.9 -p @types/node@24 tsc -p tsconfig.templates.require.json`; if (!ALL_TESTS) { + await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iterable.json --target es2023 --lib es2023`; + await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iterable.json --target esnext --lib esnext`; + await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iterable.json --target es2023 --lib es2023`; + await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iterable.json --target esnext --lib esnext`; + await $`npx -p typescript@5.6 tsc -p pure/tsconfig.json --target es6 --lib es6`; await $`npx -p typescript@5.6 tsc -p pure/tsconfig.json --target esnext --lib esnext`; await $`npx -p typescript@5.6 tsc -p global/tsconfig.json --target es6 --lib es6,dom`; @@ -141,4 +146,8 @@ if (!ALL_TESTS) { await clearTmpDir(); echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); if (failed) throw new Error('Some tests have failed'); + await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iterable.json --target es2023 --lib es2023`; + await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iterable.json --target esnext --lib esnext`; + await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iterable.json --target es2023 --lib es2023`; + await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iterable.json --target esnext --lib esnext`; } From c21dbb3a5abe4bbfe91936022d299ac56992e7e1 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sun, 11 Jan 2026 22:38:08 +0700 Subject: [PATCH 141/315] Improve async iteration test --- .../pure/async-iteration.test.ts | 28 +++++++++++++++++-- ...ble.json => tsconfig.async-iteration.json} | 0 tests/type-definitions/pure/tsconfig.json | 2 +- tests/type-definitions/runner.mjs | 15 ++++------ 4 files changed, 33 insertions(+), 12 deletions(-) rename tests/type-definitions/pure/{tsconfig.async-iterable.json => tsconfig.async-iteration.json} (100%) diff --git a/tests/type-definitions/pure/async-iteration.test.ts b/tests/type-definitions/pure/async-iteration.test.ts index 0efadaa41395..40aa60f9c955 100644 --- a/tests/type-definitions/pure/async-iteration.test.ts +++ b/tests/type-definitions/pure/async-iteration.test.ts @@ -1,5 +1,29 @@ import from from '@core-js/pure/full/async-iterator/from'; +import filter from '@core-js/pure/full/async-iterator/filter'; +import flatMap from '@core-js/pure/full/async-iterator/flat-map'; +import map from '@core-js/pure/full/async-iterator/map'; +import take from '@core-js/pure/full/async-iterator/take'; +import drop from '@core-js/pure/full/async-iterator/drop'; +import toAsync from '@core-js/pure/full/iterator/to-async'; const aitn = from([1]); -for await (const v of aitn) { -} +for await (const v of aitn) {} + +const ait1 = filter(aitn, (v: number, i: number) => v > 0); +for await (const v of ait1) {} + +const ait2 = flatMap(aitn, (v: number, i: number) => `${ v }`); +for await (const v of ait2) {} + +const ait3 = map(aitn, (v: number, i: number) => v * 2); +for await (const v of ait3) {} + +const ait4 = take(aitn, 10); +for await (const v of ait4) {} + +const ait5 = drop(aitn, 3); +for await (const v of ait5) {} + +declare const itn: Iterator; +const ait6 = toAsync(itn); +for await (const v of ait6) {} diff --git a/tests/type-definitions/pure/tsconfig.async-iterable.json b/tests/type-definitions/pure/tsconfig.async-iteration.json similarity index 100% rename from tests/type-definitions/pure/tsconfig.async-iterable.json rename to tests/type-definitions/pure/tsconfig.async-iteration.json diff --git a/tests/type-definitions/pure/tsconfig.json b/tests/type-definitions/pure/tsconfig.json index fe3fbca4ae2c..d9ea8e5590ed 100644 --- a/tests/type-definitions/pure/tsconfig.json +++ b/tests/type-definitions/pure/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../tsconfig.json", "include": ["./**/*.ts"], - "exclude": ["./async-iteration.test.ts"], + "exclude": ["async-iteration.test.ts"], "compilerOptions": { "types": ["@core-js/types/pure"] } diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 747c416fc87a..5a11b42986e6 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -111,6 +111,7 @@ async function prepareEnvironment(environments, coreJsTypes) { await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.json`), { extends: '../../tsconfig.json', include: [`../../${ type }/**/*.ts`], + exclude: [`../../${ type }/async-iteration.test.ts`], }); } } @@ -122,12 +123,12 @@ await $`npx -p typescript@5.9 tsc -p tsconfig.entries.json`; await $`npx -p typescript@5.9 tsc -p tsconfig.entries.pure.json`; await $`npx -p typescript@5.9 -p @types/node@24 tsc -p tsconfig.templates.require.json`; -if (!ALL_TESTS) { - await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iterable.json --target es2023 --lib es2023`; - await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iterable.json --target esnext --lib esnext`; - await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iterable.json --target es2023 --lib es2023`; - await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iterable.json --target esnext --lib esnext`; +await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iteration.json --target es2023 --lib es2023`; +await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iteration.json --target esnext --lib esnext`; +await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iteration.json --target es2023 --lib es2023`; +await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iteration.json --target esnext --lib esnext`; +if (!ALL_TESTS) { await $`npx -p typescript@5.6 tsc -p pure/tsconfig.json --target es6 --lib es6`; await $`npx -p typescript@5.6 tsc -p pure/tsconfig.json --target esnext --lib esnext`; await $`npx -p typescript@5.6 tsc -p global/tsconfig.json --target es6 --lib es6,dom`; @@ -146,8 +147,4 @@ if (!ALL_TESTS) { await clearTmpDir(); echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); if (failed) throw new Error('Some tests have failed'); - await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iterable.json --target es2023 --lib es2023`; - await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iterable.json --target esnext --lib esnext`; - await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iterable.json --target es2023 --lib es2023`; - await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iterable.json --target esnext --lib esnext`; } From d5ed61b600e5af1292180e799030d8599187f789 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 12 Jan 2026 01:04:51 +0700 Subject: [PATCH 142/315] Add types for ReadonlyArray methods --- .../src/base/proposals/array-filtering.d.ts | 11 +++++ .../base/proposals/array-find-from-last.d.ts | 25 +++++++++++ .../src/base/proposals/array-flat-map.d.ts | 20 +++++++++ .../src/base/proposals/array-includes.d.ts | 9 ++++ .../src/base/proposals/array-unique.d.ts | 10 +++++ .../base/proposals/change-array-by-copy.d.ts | 45 +++++++++++++++++++ .../proposals/relative-indexing-method.d.ts | 28 ++++++------ 7 files changed, 134 insertions(+), 14 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/array-filtering.d.ts b/packages/core-js-types/src/base/proposals/array-filtering.d.ts index 72ffc75f7045..0fc3ba0d73c9 100644 --- a/packages/core-js-types/src/base/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/base/proposals/array-filtering.d.ts @@ -11,6 +11,17 @@ interface Array { // @type-options no-redefine filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; } +interface ReadonlyArray { // @type-options no-export + /** + * Removes the items that return true + * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * callbackFn function one time for each element in the array. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; +} + interface Int8Array { // @type-options no-export /** * Removes the items that return true diff --git a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts index ede80b55905b..3e0e80ba998d 100644 --- a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts @@ -29,6 +29,31 @@ interface Array { // @type-options no-redefine findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; } +interface ReadonlyArray { // @type-options no-export + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; + findLast(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T | undefined; + + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; +} + interface Int8Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined diff --git a/packages/core-js-types/src/base/proposals/array-flat-map.d.ts b/packages/core-js-types/src/base/proposals/array-flat-map.d.ts index 52f4cbc1ddfa..81cac12771fc 100644 --- a/packages/core-js-types/src/base/proposals/array-flat-map.d.ts +++ b/packages/core-js-types/src/base/proposals/array-flat-map.d.ts @@ -25,3 +25,23 @@ interface Array { // @type-options no-redefine */ flat(this: A, depth?: D): CoreJS.CoreJSFlatArray[]; } + +interface ReadonlyArray { // @type-options no-export + /** + * 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 callback 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 this keyword can refer in the callback function. If + * thisArg is omitted, undefined is used as this value. + */ + flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): 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(this: A, depth?: D): CoreJS.CoreJSFlatArray[]; +} diff --git a/packages/core-js-types/src/base/proposals/array-includes.d.ts b/packages/core-js-types/src/base/proposals/array-includes.d.ts index 1fe1656df03a..6700ccfd47e8 100644 --- a/packages/core-js-types/src/base/proposals/array-includes.d.ts +++ b/packages/core-js-types/src/base/proposals/array-includes.d.ts @@ -13,6 +13,15 @@ interface Array { // @type-options no-redefine includes(searchElement: T, fromIndex?: number): boolean; } +interface ReadonlyArray { // @type-options no-export + /** + * 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(searchElement: T, fromIndex?: number): boolean; +} + interface Int8Array { // @type-options no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. diff --git a/packages/core-js-types/src/base/proposals/array-unique.d.ts b/packages/core-js-types/src/base/proposals/array-unique.d.ts index f1c1f4f64ea1..097767680c86 100644 --- a/packages/core-js-types/src/base/proposals/array-unique.d.ts +++ b/packages/core-js-types/src/base/proposals/array-unique.d.ts @@ -10,6 +10,16 @@ interface Array { // @type-options no-redefine uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; } +interface ReadonlyArray { // @type-options no-export + /** + * Returns a new array with unique items, determined by the resolver function or property key + * @param resolver A function that resolves the value to check uniqueness against, + * or a property key to compare the value from each item + * @returns A new `Array` with unique items + */ + uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; +} + interface Int8Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key diff --git a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts index a3ea5c2a7767..b1da2eb8e08b 100644 --- a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts +++ b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts @@ -49,6 +49,51 @@ interface Array { // @type-options no-redefine with(index: number, value: T): T[]; } +interface ReadonlyArray { // @type-options no-export + /** + * @returns A copy of an array with its elements reversed. + */ + toReversed(): T[]; + + /** + * Returns a copy of an array with its elements sorted. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. + * ```ts + * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. + * @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 copied array in place of the deleted elements. + * @returns The copied array. + */ + toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; + /** + * Copies an array and removes elements while returning the remaining 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 A copy of the original array with the remaining elements. + */ + toSpliced(start: number, deleteCount?: number): T[]; + + /** + * Copies an array, then overwrites the value at the provided index with the + * given value. If the index is negative, then it replaces from the end + * of the array. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to write into the copied array. + * @returns The copied array with the updated value. + */ + with(index: number, value: T): T[]; +} + interface Int8Array { // @type-options no-export /** * @returns A copy of an array with its elements reversed. diff --git a/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts index 4cb92a07f4b6..d163898f2484 100644 --- a/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts @@ -5,7 +5,7 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2022.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface String { // @type-options no-export +interface String { /** * Returns a new String consisting of the single UTF-16 code unit located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -13,7 +13,7 @@ interface String { // @type-options no-export at(index: number): string | undefined; } -interface Array { // @type-options no-export +interface Array { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -21,7 +21,7 @@ interface Array { // @type-options no-export at(index: number): T | undefined; } -interface ReadonlyArray { // @type-options no-export +interface ReadonlyArray { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -29,7 +29,7 @@ interface ReadonlyArray { // @type-options no-export at(index: number): T | undefined; } -interface Int8Array { // @type-options no-export +interface Int8Array { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -37,7 +37,7 @@ interface Int8Array { // @type-options no-export at(index: number): number | undefined; } -interface Uint8Array { // @type-options no-export +interface Uint8Array { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -45,7 +45,7 @@ interface Uint8Array { // @type-options no-export at(index: number): number | undefined; } -interface Uint8ClampedArray { // @type-options no-export +interface Uint8ClampedArray { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -53,7 +53,7 @@ interface Uint8ClampedArray { // @type-options no-export at(index: number): number | undefined; } -interface Int16Array { // @type-options no-export +interface Int16Array { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -61,7 +61,7 @@ interface Int16Array { // @type-options no-export at(index: number): number | undefined; } -interface Uint16Array { // @type-options no-export +interface Uint16Array { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -69,7 +69,7 @@ interface Uint16Array { // @type-options no-export at(index: number): number | undefined; } -interface Int32Array { // @type-options no-export +interface Int32Array { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -77,7 +77,7 @@ interface Int32Array { // @type-options no-export at(index: number): number | undefined; } -interface Uint32Array { // @type-options no-export +interface Uint32Array { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -85,7 +85,7 @@ interface Uint32Array { // @type-options no-export at(index: number): number | undefined; } -interface Float32Array { // @type-options no-export +interface Float32Array { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -93,7 +93,7 @@ interface Float32Array { // @type-options no-export at(index: number): number | undefined; } -interface Float64Array { // @type-options no-export +interface Float64Array { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -101,7 +101,7 @@ interface Float64Array { // @type-options no-export at(index: number): number | undefined; } -interface BigInt64Array { // @type-options no-export +interface BigInt64Array { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -109,7 +109,7 @@ interface BigInt64Array { // @type-options no-export at(index: number): bigint | undefined; } -interface BigUint64Array { // @type-options no-export +interface BigUint64Array { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. From 574072247eb1e5cf98ca845b1a3a5e5b0ca91076 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 12 Jan 2026 01:58:01 +0700 Subject: [PATCH 143/315] Specific tests for some envs --- .../async-iterator-helper.es2018.test.ts | 23 ++++++++ .../type-definitions/global/tsconfig.es6.json | 8 +++ .../async-iterator-helper.es2018.test.ts} | 0 ...async-iteration.json => tsconfig.es6.json} | 3 +- tests/type-definitions/pure/tsconfig.json | 1 - tests/type-definitions/runner.mjs | 59 ++++++++++--------- 6 files changed, 65 insertions(+), 29 deletions(-) create mode 100644 tests/type-definitions/global/proposals/async-iterator-helper.es2018.test.ts create mode 100644 tests/type-definitions/global/tsconfig.es6.json rename tests/type-definitions/pure/{async-iteration.test.ts => proposals/async-iterator-helper.es2018.test.ts} (100%) rename tests/type-definitions/pure/{tsconfig.async-iteration.json => tsconfig.es6.json} (60%) diff --git a/tests/type-definitions/global/proposals/async-iterator-helper.es2018.test.ts b/tests/type-definitions/global/proposals/async-iterator-helper.es2018.test.ts new file mode 100644 index 000000000000..13cf8ce18a97 --- /dev/null +++ b/tests/type-definitions/global/proposals/async-iterator-helper.es2018.test.ts @@ -0,0 +1,23 @@ +import 'core-js/full'; + +const aitn = AsyncIterator.from([1]); +for await (const v of aitn) {} + +const ait1 = aitn.filter((v: number, i: number) => v > 0); +for await (const v of ait1) {} + +const ait2 = aitn.flatMap((v: number, i: number) => `${ v }`); +for await (const v of ait2) {} + +const ait3 = aitn.map((v: number, i: number) => v * 2); +for await (const v of ait3) {} + +const ait4 = aitn.take(10); +for await (const v of ait4) {} + +const ait5 = aitn.drop(3); +for await (const v of ait5) {} + +declare const itn: Iterator; +const ait6 = itn.toAsync(); +for await (const v of ait6) {} diff --git a/tests/type-definitions/global/tsconfig.es6.json b/tests/type-definitions/global/tsconfig.es6.json new file mode 100644 index 000000000000..83daa53abbba --- /dev/null +++ b/tests/type-definitions/global/tsconfig.es6.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.json", + "include": ["./**/*.ts"], + "exclude": ["./**/*es2018*test.ts"], + "compilerOptions": { + "types": ["@core-js/types"] + } +} diff --git a/tests/type-definitions/pure/async-iteration.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.es2018.test.ts similarity index 100% rename from tests/type-definitions/pure/async-iteration.test.ts rename to tests/type-definitions/pure/proposals/async-iterator-helper.es2018.test.ts diff --git a/tests/type-definitions/pure/tsconfig.async-iteration.json b/tests/type-definitions/pure/tsconfig.es6.json similarity index 60% rename from tests/type-definitions/pure/tsconfig.async-iteration.json rename to tests/type-definitions/pure/tsconfig.es6.json index d2a9f0fdda7e..9e1b4ef64d9a 100644 --- a/tests/type-definitions/pure/tsconfig.async-iteration.json +++ b/tests/type-definitions/pure/tsconfig.es6.json @@ -1,6 +1,7 @@ { "extends": "../tsconfig.json", - "include": ["./async-iteration.test.ts"], + "include": ["./**/*.ts"], + "exclude": ["./**/*es2018*test.ts"], "compilerOptions": { "types": ["@core-js/types/pure"] } diff --git a/tests/type-definitions/pure/tsconfig.json b/tests/type-definitions/pure/tsconfig.json index d9ea8e5590ed..3e633c7056c8 100644 --- a/tests/type-definitions/pure/tsconfig.json +++ b/tests/type-definitions/pure/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "../tsconfig.json", "include": ["./**/*.ts"], - "exclude": ["async-iteration.test.ts"], "compilerOptions": { "types": ["@core-js/types/pure"] } diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 5a11b42986e6..1b413ea2db13 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -5,12 +5,12 @@ const { mkdir, writeJson } = fs; const TMP_DIR = './tmp/'; const ALL_TESTS = process.env.ALL_TYPE_DEFINITIONS_TESTS === '1'; -const targets = [ +const TARGETS = [ 'esnext', 'es2022', 'es6', ]; -const typeScriptVersions = [ +const TYPE_SCRIPT_VERSIONS = [ '5.9', '5.8', '5.7', @@ -20,7 +20,7 @@ const typeScriptVersions = [ // '5.3', // '5.2', ]; -const envs = [ +const ENVS = [ null, '@types/node@24', '@types/node@20', @@ -29,14 +29,17 @@ const envs = [ // '@types/node@15', // fails // '@types/bun@latest', // conflicts with DOM types (TextDecorator, SharedArrayBuffer...) ]; -const types = [ +const TYPES = [ 'global', 'pure', ]; -const libs = [ +const LIBS = [ 'dom', // null, // fails on web types ]; +const TARGET_EXCLUDES = { + 'es6': ['**/*es2018*test.ts'], +} let tested = 0; let failed = 0; @@ -49,20 +52,21 @@ function getEnvPath(env) { async function runTestsOnEnv({ typeScriptVersion, target, type, env, lib }) { $.verbose = false; const envLibName = env ? env.substring(0, env.lastIndexOf('@')) : ''; + const tsConfigPostfix = TARGET_EXCLUDES[target] ? `.${ target }` : ''; const command = `npx -p typescript@${ typeScriptVersion }${ - env ? ` -p ${ env }` : '' } tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target }${ lib ? `,${ lib }` : '' }${ + env ? ` -p ${ env }` : '' } tsc -p ${ type }/tsconfig${ tsConfigPostfix }.json --target ${ target } --lib ${ target }${ lib ? `,${ lib }` : '' }${ env ? ` --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }` : '' }`; echo(`$ ${ command }`); try { tested++; if (env && lib) { - await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target },${ lib } --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }`.quiet(); + await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }${ tsConfigPostfix }.json --target ${ target } --lib ${ target },${ lib } --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }`.quiet(); } else if (env) { - await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }.json --target ${ target } --lib ${ target } --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }`.quiet(); + await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }${ tsConfigPostfix }.json --target ${ target } --lib ${ target } --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }`.quiet(); } else if (lib) { - await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target },${ lib }`.quiet(); + await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig${ tsConfigPostfix }.json --target ${ target } --lib ${ target },${ lib }`.quiet(); } else { - await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig.json --target ${ target } --lib ${ target }`.quiet(); + await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig${ tsConfigPostfix }.json --target ${ target } --lib ${ target }`.quiet(); } echo(chalk.green(`$ ${ command }`)); } catch (error) { @@ -83,11 +87,11 @@ async function runLimited(configs, limit) { } const taskConfigs = []; -for (const type of types) { - for (const target of targets) { - for (const typeScriptVersion of typeScriptVersions) { - for (const env of envs) { - for (const lib of libs) { +for (const type of TYPES) { + for (const target of TARGETS) { + for (const typeScriptVersion of TYPE_SCRIPT_VERSIONS) { + for (const env of ENVS) { + for (const lib of LIBS) { taskConfigs.push({ env, lib, target, type, typeScriptVersion }); } } @@ -99,7 +103,7 @@ async function clearTmpDir() { await $`rm -rf ${ TMP_DIR }`; } -async function prepareEnvironment(environments, coreJsTypes) { +async function prepareEnvironment(environments, coreJsTypes, targetExcludes) { await clearTmpDir(); for (const env of environments) { if (!env) continue; @@ -111,8 +115,14 @@ async function prepareEnvironment(environments, coreJsTypes) { await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.json`), { extends: '../../tsconfig.json', include: [`../../${ type }/**/*.ts`], - exclude: [`../../${ type }/async-iteration.test.ts`], }); + for (const [target, patterns] of Object.entries(targetExcludes)) { + await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.${ target }.json`), { + extends: '../../tsconfig.json', + include: [`../../${ type }/**/*.ts`], + exclude: patterns.map(pattern => `../../${ pattern }`), + }); + } } } } @@ -123,26 +133,21 @@ await $`npx -p typescript@5.9 tsc -p tsconfig.entries.json`; await $`npx -p typescript@5.9 tsc -p tsconfig.entries.pure.json`; await $`npx -p typescript@5.9 -p @types/node@24 tsc -p tsconfig.templates.require.json`; -await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iteration.json --target es2023 --lib es2023`; -await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iteration.json --target esnext --lib esnext`; -await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iteration.json --target es2023 --lib es2023`; -await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iteration.json --target esnext --lib esnext`; - if (!ALL_TESTS) { - await $`npx -p typescript@5.6 tsc -p pure/tsconfig.json --target es6 --lib es6`; + await $`npx -p typescript@5.6 tsc -p pure/tsconfig.es6.json --target es6 --lib es6`; await $`npx -p typescript@5.6 tsc -p pure/tsconfig.json --target esnext --lib esnext`; - await $`npx -p typescript@5.6 tsc -p global/tsconfig.json --target es6 --lib es6,dom`; + await $`npx -p typescript@5.6 tsc -p global/tsconfig.es6.json --target es6 --lib es6,dom`; await $`npx -p typescript@5.6 tsc -p global/tsconfig.json --target esnext --lib esnext,dom`; - await $`npx -p typescript@5.9 tsc -p pure/tsconfig.json --target es6 --lib es6`; + await $`npx -p typescript@5.9 tsc -p pure/tsconfig.es6.json --target es6 --lib es6`; await $`npx -p typescript@5.9 tsc -p pure/tsconfig.json --target es2023 --lib es2023`; await $`npx -p typescript@5.9 tsc -p pure/tsconfig.json --target esnext --lib esnext`; - await $`npx -p typescript@5.9 tsc -p global/tsconfig.json --target es6 --lib es6,dom`; + await $`npx -p typescript@5.9 tsc -p global/tsconfig.es6.json --target es6 --lib es6,dom`; await $`npx -p typescript@5.9 tsc -p global/tsconfig.json --target es2023 --lib es2023,dom`; await $`npx -p typescript@5.9 tsc -p global/tsconfig.json --target esnext --lib esnext,dom`; } else { const numCPUs = os.cpus().length; - await prepareEnvironment(envs, types); + await prepareEnvironment(ENVS, TYPES, TARGET_EXCLUDES); await runLimited(taskConfigs, Math.max(numCPUs - 1, 1)); await clearTmpDir(); echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); From 2381e23686d363ebabf9448ed8875966785a9e98 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 12 Jan 2026 02:06:39 +0700 Subject: [PATCH 144/315] Type tests folder refactoring --- tests/type-definitions/{ => global}/entries.ts | 0 tests/type-definitions/{ => pure}/entries.pure.ts | 0 tests/type-definitions/runner.mjs | 10 ++++------ .../{ => templates}/templates.import.ts | 0 .../{ => templates}/templates.require.ts | 0 .../tsconfig.json} | 2 +- .../tsconfig.require.json} | 2 +- tests/type-definitions/tsconfig.entries.json | 13 ------------- tests/type-definitions/tsconfig.entries.pure.json | 14 -------------- 9 files changed, 6 insertions(+), 35 deletions(-) rename tests/type-definitions/{ => global}/entries.ts (100%) rename tests/type-definitions/{ => pure}/entries.pure.ts (100%) rename tests/type-definitions/{ => templates}/templates.import.ts (100%) rename tests/type-definitions/{ => templates}/templates.require.ts (100%) rename tests/type-definitions/{tsconfig.templates.import.json => templates/tsconfig.json} (79%) rename tests/type-definitions/{tsconfig.templates.require.json => templates/tsconfig.require.json} (81%) delete mode 100644 tests/type-definitions/tsconfig.entries.json delete mode 100644 tests/type-definitions/tsconfig.entries.pure.json diff --git a/tests/type-definitions/entries.ts b/tests/type-definitions/global/entries.ts similarity index 100% rename from tests/type-definitions/entries.ts rename to tests/type-definitions/global/entries.ts diff --git a/tests/type-definitions/entries.pure.ts b/tests/type-definitions/pure/entries.pure.ts similarity index 100% rename from tests/type-definitions/entries.pure.ts rename to tests/type-definitions/pure/entries.pure.ts diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 1b413ea2db13..38a7b27d982f 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -38,8 +38,8 @@ const LIBS = [ // null, // fails on web types ]; const TARGET_EXCLUDES = { - 'es6': ['**/*es2018*test.ts'], -} + es6: ['**/*es2018*test.ts'], +}; let tested = 0; let failed = 0; @@ -128,10 +128,8 @@ async function prepareEnvironment(environments, coreJsTypes, targetExcludes) { } await $`npx -p typescript@5.9 tsc`; -await $`npx -p typescript@5.9 tsc -p tsconfig.templates.import.json`; -await $`npx -p typescript@5.9 tsc -p tsconfig.entries.json`; -await $`npx -p typescript@5.9 tsc -p tsconfig.entries.pure.json`; -await $`npx -p typescript@5.9 -p @types/node@24 tsc -p tsconfig.templates.require.json`; +await $`npx -p typescript@5.9 tsc -p templates/tsconfig.json`; +await $`npx -p typescript@5.9 -p @types/node@24 tsc -p templates/tsconfig.require.json`; if (!ALL_TESTS) { await $`npx -p typescript@5.6 tsc -p pure/tsconfig.es6.json --target es6 --lib es6`; diff --git a/tests/type-definitions/templates.import.ts b/tests/type-definitions/templates/templates.import.ts similarity index 100% rename from tests/type-definitions/templates.import.ts rename to tests/type-definitions/templates/templates.import.ts diff --git a/tests/type-definitions/templates.require.ts b/tests/type-definitions/templates/templates.require.ts similarity index 100% rename from tests/type-definitions/templates.require.ts rename to tests/type-definitions/templates/templates.require.ts diff --git a/tests/type-definitions/tsconfig.templates.import.json b/tests/type-definitions/templates/tsconfig.json similarity index 79% rename from tests/type-definitions/tsconfig.templates.import.json rename to tests/type-definitions/templates/tsconfig.json index ab3afdcf0c25..d7735c61adee 100644 --- a/tests/type-definitions/tsconfig.templates.import.json +++ b/tests/type-definitions/templates/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "./tsconfig.json", + "extends": "../tsconfig.json", "compilerOptions": { "types": [ "@core-js/types/pure" diff --git a/tests/type-definitions/tsconfig.templates.require.json b/tests/type-definitions/templates/tsconfig.require.json similarity index 81% rename from tests/type-definitions/tsconfig.templates.require.json rename to tests/type-definitions/templates/tsconfig.require.json index 731c86753476..cd0a338ab089 100644 --- a/tests/type-definitions/tsconfig.templates.require.json +++ b/tests/type-definitions/templates/tsconfig.require.json @@ -1,5 +1,5 @@ { - "extends": "./tsconfig.json", + "extends": "../tsconfig.json", "compilerOptions": { "types": [ "@core-js/types/pure", diff --git a/tests/type-definitions/tsconfig.entries.json b/tests/type-definitions/tsconfig.entries.json deleted file mode 100644 index 020b54ec0ab8..000000000000 --- a/tests/type-definitions/tsconfig.entries.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "target": "esnext", - "module": "esnext", - "esModuleInterop": true, - "moduleResolution": "node", - "noEmit": true - }, - "include": [ - "./entries.ts" - ] -} diff --git a/tests/type-definitions/tsconfig.entries.pure.json b/tests/type-definitions/tsconfig.entries.pure.json deleted file mode 100644 index 3eadb96fea85..000000000000 --- a/tests/type-definitions/tsconfig.entries.pure.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "target": "esnext", - "module": "esnext", - "esModuleInterop": true, - "moduleResolution": "node", - "noEmit": true, - "types": ["@core-js/types/pure"] - }, - "include": [ - "./entries.pure.ts" - ] -} From 3df1518958ac14b8b73c55271278c647f91eb45f Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 12 Jan 2026 03:04:41 +0700 Subject: [PATCH 145/315] Type definitions contributing skeleton --- CONTRIBUTING.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e3066e91127b..6cc765d7be1e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,6 +65,29 @@ engine | how to run tests | base data inherits from | mandatory ch If you have no access to all required browsers / versions of browsers, use [Sauce Labs](https://saucelabs.com/), [BrowserStack](https://www.browserstack.com/) or [Cloud Browser](https://ieonchrome.com/). +## How to add new TypeScript definitions + +- TypeScript definitions should be added to the [`packages/core-js-types/src/base`](./packages/core-js-types/src/base) directory. +- Our type definitions are built on top of ES6. If any related type is missing in ES6, it must be added to the [`packages/core-js-types/src/base/core-js-types`](./packages/core-js-types/src/base/core-js-types) directory and imported via triple-slash directives in your type definition file. +- Place your type definition into the folder that matches its kind ([`packages/core-js-types/src/base/proposals`](./packages/core-js-types/src/base/proposals), [`packages/core-js-types/src/base/web`](./packages/core-js-types/src/base/web)). +- Type definitions for the pure version are either generated from the global version types or created manually in the [`packages/core-js-types/src/base/pure`](./packages/core-js-types/src/base/pure) folder. Type build rules for the pure version can be modified using the `@type-options` directive: + - `no-extends` – do not extend the base type when adding a prefix to the type/interface + - `no-prefix` – do not add a prefix to the type/interface name + - `no-constructor` – use it when the type has no constructor (for example, `Math`) + - `export-base-constructor` – export the base type’s constructor instead of the prefixed one + - `no-export` – do not export this type + - `no-redefine` – do not redefine the type’s constructor + - `prefix-return-type` – add a prefix to the return type +- All type definitions must be covered by TSC tests. Add them to the [`tests/type-definitions`](./tests/type-definitions) directory. +- To build the types, run the command: + ```sh + npm run build-types + ``` +- To test the types, run the command: + ```sh + npm run test-type-definitions + ``` + ## Style and standards The coding style should follow our [`eslint.config.js`](./tests/eslint/eslint.config.js). You can test it by calling [`npm run lint`](#testing). Different places have different syntax and standard library limitations: From b3fd1a8d3024a5d231e0b89ee92842bb9082a61f Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 12 Jan 2026 17:03:29 +0700 Subject: [PATCH 146/315] Running local type tests in parallel --- tests/type-definitions/runner.mjs | 47 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 38a7b27d982f..b89ddbfa19ec 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -86,17 +86,20 @@ async function runLimited(configs, limit) { await Promise.all(Array.from({ length: limit }, worker)); } -const taskConfigs = []; -for (const type of TYPES) { - for (const target of TARGETS) { - for (const typeScriptVersion of TYPE_SCRIPT_VERSIONS) { - for (const env of ENVS) { - for (const lib of LIBS) { - taskConfigs.push({ env, lib, target, type, typeScriptVersion }); +function buildTasksConfigs(types, targets, typeScriptVersions, envs, libs) { + const taskConfigs = []; + for (const type of types) { + for (const target of targets) { + for (const typeScriptVersion of typeScriptVersions) { + for (const env of envs) { + for (const lib of libs) { + taskConfigs.push({ env, lib, target, type, typeScriptVersion }); + } } } } } + return taskConfigs; } async function clearTmpDir() { @@ -131,23 +134,17 @@ await $`npx -p typescript@5.9 tsc`; await $`npx -p typescript@5.9 tsc -p templates/tsconfig.json`; await $`npx -p typescript@5.9 -p @types/node@24 tsc -p templates/tsconfig.require.json`; -if (!ALL_TESTS) { - await $`npx -p typescript@5.6 tsc -p pure/tsconfig.es6.json --target es6 --lib es6`; - await $`npx -p typescript@5.6 tsc -p pure/tsconfig.json --target esnext --lib esnext`; - await $`npx -p typescript@5.6 tsc -p global/tsconfig.es6.json --target es6 --lib es6,dom`; - await $`npx -p typescript@5.6 tsc -p global/tsconfig.json --target esnext --lib esnext,dom`; - - await $`npx -p typescript@5.9 tsc -p pure/tsconfig.es6.json --target es6 --lib es6`; - await $`npx -p typescript@5.9 tsc -p pure/tsconfig.json --target es2023 --lib es2023`; - await $`npx -p typescript@5.9 tsc -p pure/tsconfig.json --target esnext --lib esnext`; - await $`npx -p typescript@5.9 tsc -p global/tsconfig.es6.json --target es6 --lib es6,dom`; - await $`npx -p typescript@5.9 tsc -p global/tsconfig.json --target es2023 --lib es2023,dom`; - await $`npx -p typescript@5.9 tsc -p global/tsconfig.json --target esnext --lib esnext,dom`; +let taskConfigs, envs; +if (ALL_TESTS) { + envs = ENVS; + taskConfigs = buildTasksConfigs(TYPES, TARGETS, TYPE_SCRIPT_VERSIONS, ENVS, LIBS); } else { - const numCPUs = os.cpus().length; - await prepareEnvironment(ENVS, TYPES, TARGET_EXCLUDES); - await runLimited(taskConfigs, Math.max(numCPUs - 1, 1)); - await clearTmpDir(); - echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); - if (failed) throw new Error('Some tests have failed'); + envs = [null]; + taskConfigs = buildTasksConfigs(TYPES, ['esnext', 'es2022', 'es6'], ['5.9', '5.6'], envs, ['dom']); } +const numCPUs = os.cpus().length; +await prepareEnvironment(envs, TYPES, TARGET_EXCLUDES); +await runLimited(taskConfigs, Math.max(numCPUs - 1, 1)); +await clearTmpDir(); +echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); +if (failed) throw new Error('Some tests have failed'); From 3a01e6a9508f51b2d2a699f3a6330783cc91a56b Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 12 Jan 2026 19:57:30 +0700 Subject: [PATCH 147/315] Add async iteration test for pure version --- .../pure/proposals/async-iteration.es2018.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/type-definitions/pure/proposals/async-iteration.es2018.test.ts diff --git a/tests/type-definitions/pure/proposals/async-iteration.es2018.test.ts b/tests/type-definitions/pure/proposals/async-iteration.es2018.test.ts new file mode 100644 index 000000000000..cf327adc8455 --- /dev/null +++ b/tests/type-definitions/pure/proposals/async-iteration.es2018.test.ts @@ -0,0 +1,12 @@ +import $Symbol from '@core-js/pure/full/symbol/index'; + +async function * makeAsyncIterable() { + yield 1; + yield 2; +} + +for await (const x of { + [$Symbol.asyncIterator]: makeAsyncIterable, +}) { + const n: number = x; +} From ddeb9a921866e15be1fd3aa37629360cf9482c5c Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 14 Jan 2026 00:39:56 +0700 Subject: [PATCH 148/315] Fallbacks for DOM --- .../src/base/core-js-modules/url.d.ts | 91 +++++++++++++++++++ .../url-search-params.d.ts | 0 .../src/base/pure/core-js-types/url.d.ts | 64 +++++++++++++ .../src/base/pure/{common => web}/self.d.ts | 0 .../src/base/pure/web/url-parse.d.ts | 2 +- .../core-js-types/src/base/pure/web/url.d.ts | 65 +------------ .../src/base/web/dom-exception.d.ts | 69 ++++++++++++++ .../base/web/iterable-dom-collections.d.ts | 6 ++ packages/core-js-types/src/base/web/self.d.ts | 7 ++ .../core-js-types/src/base/web/url-parse.d.ts | 7 +- packages/core-js-types/src/base/web/url.d.ts | 14 +++ .../modules/web.dom-exception.constructor.js | 2 +- .../modules/web.dom-exception.stack.js | 2 +- .../web.dom-exception.to-string-tag.js | 2 +- packages/core-js/modules/web.self.js | 2 +- .../core-js/modules/web.url.constructor.js | 2 +- scripts/build-entries/entries-definitions.mjs | 4 +- scripts/build-entries/templates.mjs | 16 ---- .../type-definitions/global/tsconfig.dom.json | 7 ++ .../global/tsconfig.es6.dom.json | 8 ++ .../type-definitions/global/tsconfig.es6.json | 5 +- tests/type-definitions/global/tsconfig.json | 1 + ...s => iterable-dom-collections.dom.test.ts} | 0 .../web/{self.test.ts => self.dom.test.ts} | 0 .../global/web/url-parse.test.ts | 17 ++++ tests/type-definitions/pure/tsconfig.dom.json | 7 ++ .../pure/tsconfig.es6.dom.json | 8 ++ tests/type-definitions/pure/tsconfig.es6.json | 5 +- tests/type-definitions/pure/tsconfig.json | 1 + .../pure/web/url-parse.test.ts | 2 - .../pure/web/{url.test.ts => url.dom.test.ts} | 0 tests/type-definitions/runner.mjs | 34 ++++--- 32 files changed, 340 insertions(+), 110 deletions(-) create mode 100644 packages/core-js-types/src/base/core-js-modules/url.d.ts rename packages/core-js-types/src/base/pure/{web => core-js-types}/url-search-params.d.ts (100%) create mode 100644 packages/core-js-types/src/base/pure/core-js-types/url.d.ts rename packages/core-js-types/src/base/pure/{common => web}/self.d.ts (100%) create mode 100644 packages/core-js-types/src/base/web/dom-exception.d.ts create mode 100644 packages/core-js-types/src/base/web/self.d.ts create mode 100644 packages/core-js-types/src/base/web/url.d.ts create mode 100644 tests/type-definitions/global/tsconfig.dom.json create mode 100644 tests/type-definitions/global/tsconfig.es6.dom.json rename tests/type-definitions/global/web/{iterable-dom-collections.test.ts => iterable-dom-collections.dom.test.ts} (100%) rename tests/type-definitions/global/web/{self.test.ts => self.dom.test.ts} (100%) create mode 100644 tests/type-definitions/global/web/url-parse.test.ts create mode 100644 tests/type-definitions/pure/tsconfig.dom.json create mode 100644 tests/type-definitions/pure/tsconfig.es6.dom.json rename tests/type-definitions/pure/web/{url.test.ts => url.dom.test.ts} (100%) diff --git a/packages/core-js-types/src/base/core-js-modules/url.d.ts b/packages/core-js-types/src/base/core-js-modules/url.d.ts new file mode 100644 index 000000000000..3a0f0ba2509c --- /dev/null +++ b/packages/core-js-types/src/base/core-js-modules/url.d.ts @@ -0,0 +1,91 @@ +declare module 'core-js/internals/web/url' { + interface URL { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */ + hash: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */ + host: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */ + hostname: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */ + href: string; + + toString(): string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin) */ + readonly origin: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */ + password: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */ + pathname: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */ + port: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */ + protocol: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */ + search: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams) */ + readonly searchParams: URLSearchParams; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */ + username: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON) */ + toJSON(): string; + } + + interface URLConstructor { + prototype: URL; + + new(url: string | URL, base?: string | URL): URL; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */ + canParse(url: string | URL, base?: string | URL): boolean; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) */ + createObjectURL(obj: any): string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static) */ + parse(url: string | URL, base?: string | URL): URL | null; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) */ + revokeObjectURL(url: string): void; + } + + var URL: URLConstructor; + + interface URLSearchParams { + readonly size: number; + append(name: string, value: string): void; + delete(name: string, value?: string): void; + get(name: string): string | null; + getAll(name: string): string[]; + has(name: string, value?: string): boolean; + set(name: string, value: string): void; + sort(): void; + forEach(callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any): void; + [Symbol.iterator](): URLSearchParamsIterator<[string, string]>; + entries(): URLSearchParamsIterator<[string, string]>; + keys(): URLSearchParamsIterator; + values(): URLSearchParamsIterator; + } + + interface URLSearchParamsConstructor { + prototype: URLSearchParams; + new(init?: string[][] | Record | string | URLSearchParams): URLSearchParams; + } + + var URLSearchParams: URLSearchParamsConstructor; + + interface URLSearchParamsIterator extends IteratorObject { + [Symbol.iterator](): URLSearchParamsIterator; + } +} diff --git a/packages/core-js-types/src/base/pure/web/url-search-params.d.ts b/packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts similarity index 100% rename from packages/core-js-types/src/base/pure/web/url-search-params.d.ts rename to packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts diff --git a/packages/core-js-types/src/base/pure/core-js-types/url.d.ts b/packages/core-js-types/src/base/pure/core-js-types/url.d.ts new file mode 100644 index 000000000000..b97a0234865e --- /dev/null +++ b/packages/core-js-types/src/base/pure/core-js-types/url.d.ts @@ -0,0 +1,64 @@ +/// + +declare namespace CoreJS { + export interface CoreJSURL { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */ + hash: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */ + host: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */ + hostname: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */ + href: string; + + toString(): string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin) */ + readonly origin: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */ + password: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */ + pathname: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */ + port: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */ + protocol: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */ + search: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams) */ + readonly searchParams: CoreJSURLSearchParams; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */ + username: string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON) */ + toJSON(): string; + } + + export interface CoreJSURLConstructor { + new(url: string, base?: string): CoreJSURL; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */ + canParse(url: string, base?: string): boolean; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) */ + createObjectURL(obj: any): string; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static) */ + parse(url: string, base?: string): CoreJSURL | null; + + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) */ + revokeObjectURL(url: string): void; + } + + var CoreJSURL: CoreJSURLConstructor; +} diff --git a/packages/core-js-types/src/base/pure/common/self.d.ts b/packages/core-js-types/src/base/pure/web/self.d.ts similarity index 100% rename from packages/core-js-types/src/base/pure/common/self.d.ts rename to packages/core-js-types/src/base/pure/web/self.d.ts diff --git a/packages/core-js-types/src/base/pure/web/url-parse.d.ts b/packages/core-js-types/src/base/pure/web/url-parse.d.ts index 92c42199fbe3..52c2a94052c3 100644 --- a/packages/core-js-types/src/base/pure/web/url-parse.d.ts +++ b/packages/core-js-types/src/base/pure/web/url-parse.d.ts @@ -1,4 +1,4 @@ -/// +/// declare namespace CoreJS { export type URLParse = (url: string | CoreJSURL, base?: string | CoreJSURL) => CoreJSURL | null; diff --git a/packages/core-js-types/src/base/pure/web/url.d.ts b/packages/core-js-types/src/base/pure/web/url.d.ts index b97a0234865e..638cd455eeb4 100644 --- a/packages/core-js-types/src/base/pure/web/url.d.ts +++ b/packages/core-js-types/src/base/pure/web/url.d.ts @@ -1,64 +1 @@ -/// - -declare namespace CoreJS { - export interface CoreJSURL { - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */ - hash: string; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */ - host: string; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */ - hostname: string; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */ - href: string; - - toString(): string; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin) */ - readonly origin: string; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */ - password: string; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */ - pathname: string; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */ - port: string; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */ - protocol: string; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */ - search: string; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams) */ - readonly searchParams: CoreJSURLSearchParams; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */ - username: string; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON) */ - toJSON(): string; - } - - export interface CoreJSURLConstructor { - new(url: string, base?: string): CoreJSURL; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */ - canParse(url: string, base?: string): boolean; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) */ - createObjectURL(obj: any): string; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static) */ - parse(url: string, base?: string): CoreJSURL | null; - - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) */ - revokeObjectURL(url: string): void; - } - - var CoreJSURL: CoreJSURLConstructor; -} +/// diff --git a/packages/core-js-types/src/base/web/dom-exception.d.ts b/packages/core-js-types/src/base/web/dom-exception.d.ts new file mode 100644 index 000000000000..ce420a7e27fe --- /dev/null +++ b/packages/core-js-types/src/base/web/dom-exception.d.ts @@ -0,0 +1,69 @@ +type _DOMException = typeof globalThis extends { onmessage: any } ? {} : DOMException; +interface DOMException extends Error { + readonly code: number; + readonly message: string; + readonly name: string; + readonly INDEX_SIZE_ERR: 1; + readonly DOMSTRING_SIZE_ERR: 2; + readonly HIERARCHY_REQUEST_ERR: 3; + readonly WRONG_DOCUMENT_ERR: 4; + readonly INVALID_CHARACTER_ERR: 5; + readonly NO_DATA_ALLOWED_ERR: 6; + readonly NO_MODIFICATION_ALLOWED_ERR: 7; + readonly NOT_FOUND_ERR: 8; + readonly NOT_SUPPORTED_ERR: 9; + readonly INUSE_ATTRIBUTE_ERR: 10; + readonly INVALID_STATE_ERR: 11; + readonly SYNTAX_ERR: 12; + readonly INVALID_MODIFICATION_ERR: 13; + readonly NAMESPACE_ERR: 14; + readonly INVALID_ACCESS_ERR: 15; + readonly VALIDATION_ERR: 16; + readonly TYPE_MISMATCH_ERR: 17; + readonly SECURITY_ERR: 18; + readonly NETWORK_ERR: 19; + readonly ABORT_ERR: 20; + readonly URL_MISMATCH_ERR: 21; + readonly QUOTA_EXCEEDED_ERR: 22; + readonly TIMEOUT_ERR: 23; + readonly INVALID_NODE_TYPE_ERR: 24; + readonly DATA_CLONE_ERR: 25; +} + +declare global { + interface DOMException extends _DOMException {} + + var DOMException: typeof globalThis extends { onmessage: any; DOMException: infer T } ? T + : { + prototype: DOMException; + new(message?: string, name?: string): DOMException; + new(message?: string, options?: { name?: string; cause?: unknown }): DOMException; + readonly INDEX_SIZE_ERR: 1; + readonly DOMSTRING_SIZE_ERR: 2; + readonly HIERARCHY_REQUEST_ERR: 3; + readonly WRONG_DOCUMENT_ERR: 4; + readonly INVALID_CHARACTER_ERR: 5; + readonly NO_DATA_ALLOWED_ERR: 6; + readonly NO_MODIFICATION_ALLOWED_ERR: 7; + readonly NOT_FOUND_ERR: 8; + readonly NOT_SUPPORTED_ERR: 9; + readonly INUSE_ATTRIBUTE_ERR: 10; + readonly INVALID_STATE_ERR: 11; + readonly SYNTAX_ERR: 12; + readonly INVALID_MODIFICATION_ERR: 13; + readonly NAMESPACE_ERR: 14; + readonly INVALID_ACCESS_ERR: 15; + readonly VALIDATION_ERR: 16; + readonly TYPE_MISMATCH_ERR: 17; + readonly SECURITY_ERR: 18; + readonly NETWORK_ERR: 19; + readonly ABORT_ERR: 20; + readonly URL_MISMATCH_ERR: 21; + readonly QUOTA_EXCEEDED_ERR: 22; + readonly TIMEOUT_ERR: 23; + readonly INVALID_NODE_TYPE_ERR: 24; + readonly DATA_CLONE_ERR: 25; + }; +} + +export {}; diff --git a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts index 960b6afbbb8d..36fe3aa76cfc 100644 --- a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts +++ b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts @@ -1,4 +1,10 @@ // use only with DOM lib + +// Fallbacks for DOM types +interface Element {} // @type-options no-export +interface Node {} // @type-options no-export +interface HTMLOptionElement {} // @type-options no-export + interface ArrayIterator extends IteratorObject { // @type-options no-export [Symbol.iterator](): ArrayIterator; } diff --git a/packages/core-js-types/src/base/web/self.d.ts b/packages/core-js-types/src/base/web/self.d.ts new file mode 100644 index 000000000000..26edef8ac99a --- /dev/null +++ b/packages/core-js-types/src/base/web/self.d.ts @@ -0,0 +1,7 @@ +declare global { + var self: typeof globalThis extends { onmessage: any; self: infer T } ? T : { + URL?: typeof URL; + }; +} + +export {}; diff --git a/packages/core-js-types/src/base/web/url-parse.d.ts b/packages/core-js-types/src/base/web/url-parse.d.ts index a5a72eca2fe4..2ec27ec39d3c 100644 --- a/packages/core-js-types/src/base/web/url-parse.d.ts +++ b/packages/core-js-types/src/base/web/url-parse.d.ts @@ -1,5 +1,2 @@ -/// - -declare namespace CoreJS { - export type URLParse = (url: string | CoreJSURL, base?: string | CoreJSURL) => CoreJSURL | null; -} +// empty +// Moved to ../core-js-modules/url.d.ts diff --git a/packages/core-js-types/src/base/web/url.d.ts b/packages/core-js-types/src/base/web/url.d.ts new file mode 100644 index 000000000000..1206af12c5ee --- /dev/null +++ b/packages/core-js-types/src/base/web/url.d.ts @@ -0,0 +1,14 @@ +/// + +import * as url from 'core-js/internals/web/url'; + +declare global { + interface URL extends url.URL {} + var URL: typeof globalThis extends { onmessage: any; URL: infer T } ? T : typeof url.URL; + + interface URLSearchParams extends url.URLSearchParams {} + var URLSearchParams: typeof globalThis extends { onmessage: any; URLSearchParams: infer T } ? T + : typeof url.URLSearchParams; +} + +export {}; diff --git a/packages/core-js/modules/web.dom-exception.constructor.js b/packages/core-js/modules/web.dom-exception.constructor.js index 073c9dd49c95..e791505c67e3 100644 --- a/packages/core-js/modules/web.dom-exception.constructor.js +++ b/packages/core-js/modules/web.dom-exception.constructor.js @@ -1,4 +1,4 @@ -// no types: has types only for the pure version +// types: web/dom-exception 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/web.dom-exception.stack.js b/packages/core-js/modules/web.dom-exception.stack.js index 3cda15508db7..cc83550c8f0b 100644 --- a/packages/core-js/modules/web.dom-exception.stack.js +++ b/packages/core-js/modules/web.dom-exception.stack.js @@ -1,4 +1,4 @@ -// no types: has types only for the pure version +// types: web/dom-exception 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.dom-exception.to-string-tag.js b/packages/core-js/modules/web.dom-exception.to-string-tag.js index 707d3ce7760d..3f3bd1df5ba5 100644 --- a/packages/core-js/modules/web.dom-exception.to-string-tag.js +++ b/packages/core-js/modules/web.dom-exception.to-string-tag.js @@ -1,4 +1,4 @@ -// no types: has types only for the pure version +// types: web/dom-exception 'use strict'; var getBuiltIn = require('../internals/get-built-in'); var setToStringTag = require('../internals/set-to-string-tag'); diff --git a/packages/core-js/modules/web.self.js b/packages/core-js/modules/web.self.js index fd6d6cae4f36..795dfb0a9fe0 100644 --- a/packages/core-js/modules/web.self.js +++ b/packages/core-js/modules/web.self.js @@ -1,4 +1,4 @@ -// no types: because of a conflict with lib.dom.d.ts +// types: web/self 'use strict'; var globalThis = require('../internals/global-this'); var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); diff --git a/packages/core-js/modules/web.url.constructor.js b/packages/core-js/modules/web.url.constructor.js index 140963961e8d..c5bf702ecf02 100644 --- a/packages/core-js/modules/web.url.constructor.js +++ b/packages/core-js/modules/web.url.constructor.js @@ -1,4 +1,4 @@ -// no types: because of a conflict with lib.dom.d.ts +// types: web/url 'use strict'; var $ = require('../internals/export'); var USE_NATIVE_URL = require('../internals/url-constructor-detection'); diff --git a/scripts/build-entries/entries-definitions.mjs b/scripts/build-entries/entries-definitions.mjs index 36c0d97516c0..70649bea5e85 100644 --- a/scripts/build-entries/entries-definitions.mjs +++ b/scripts/build-entries/entries-definitions.mjs @@ -6,7 +6,6 @@ import { $prototypeIterator, $static, $staticWithContext, - $staticWithCustomType, $patchableStatic, $namespace, $helper, @@ -3094,10 +3093,9 @@ export const features = { }, 'url/parse': { modules: ['web.url.parse'], - template: $staticWithCustomType, + template: $static, namespace: 'URL', name: 'parse', - customType: 'web/url-parse', }, 'url/to-json': { modules: ['web.url.to-json'], diff --git a/scripts/build-entries/templates.mjs b/scripts/build-entries/templates.mjs index 1dbf3408612c..db3dd23ad83f 100644 --- a/scripts/build-entries/templates.mjs +++ b/scripts/build-entries/templates.mjs @@ -212,22 +212,6 @@ export const $staticWithContext = p => ({ `, }); -export const $staticWithCustomType = p => ({ - entry: dedent` - ${ importModules(p) } - - var getBuiltInStaticMethod = ${ importInternal('get-built-in-static-method', p.level) } - - module.exports = getBuiltInStaticMethod('${ p.namespace }', '${ p.name }'); - `, - types: dedent` - declare module '${ buildModulePath(p) }' { - const method: ${ buildCoreJSTypeName(p.namespace, p.name) }; - export = method; - } - `, -}); - export const $patchableStatic = p => ({ entry: dedent` ${ importModules(p) } diff --git a/tests/type-definitions/global/tsconfig.dom.json b/tests/type-definitions/global/tsconfig.dom.json new file mode 100644 index 000000000000..b6c25f529ba1 --- /dev/null +++ b/tests/type-definitions/global/tsconfig.dom.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig.json", + "include": ["./**/*.ts"], + "compilerOptions": { + "types": ["@core-js/types"] + } +} diff --git a/tests/type-definitions/global/tsconfig.es6.dom.json b/tests/type-definitions/global/tsconfig.es6.dom.json new file mode 100644 index 000000000000..83daa53abbba --- /dev/null +++ b/tests/type-definitions/global/tsconfig.es6.dom.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.json", + "include": ["./**/*.ts"], + "exclude": ["./**/*es2018*test.ts"], + "compilerOptions": { + "types": ["@core-js/types"] + } +} diff --git a/tests/type-definitions/global/tsconfig.es6.json b/tests/type-definitions/global/tsconfig.es6.json index 83daa53abbba..0166c8be8e39 100644 --- a/tests/type-definitions/global/tsconfig.es6.json +++ b/tests/type-definitions/global/tsconfig.es6.json @@ -1,7 +1,10 @@ { "extends": "../tsconfig.json", "include": ["./**/*.ts"], - "exclude": ["./**/*es2018*test.ts"], + "exclude": [ + "./**/*es2018*test.ts", + "./**/*dom*test.ts" + ], "compilerOptions": { "types": ["@core-js/types"] } diff --git a/tests/type-definitions/global/tsconfig.json b/tests/type-definitions/global/tsconfig.json index 19ebf579cb23..2a9c23e61713 100644 --- a/tests/type-definitions/global/tsconfig.json +++ b/tests/type-definitions/global/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../tsconfig.json", "include": ["./**/*.ts"], + "exclude": ["./**/*dom*test.ts"], "compilerOptions": { "types": [ "@core-js/types" diff --git a/tests/type-definitions/global/web/iterable-dom-collections.test.ts b/tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts similarity index 100% rename from tests/type-definitions/global/web/iterable-dom-collections.test.ts rename to tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts diff --git a/tests/type-definitions/global/web/self.test.ts b/tests/type-definitions/global/web/self.dom.test.ts similarity index 100% rename from tests/type-definitions/global/web/self.test.ts rename to tests/type-definitions/global/web/self.dom.test.ts diff --git a/tests/type-definitions/global/web/url-parse.test.ts b/tests/type-definitions/global/web/url-parse.test.ts new file mode 100644 index 000000000000..181b041ebc6c --- /dev/null +++ b/tests/type-definitions/global/web/url-parse.test.ts @@ -0,0 +1,17 @@ +import 'core-js/full'; + +const u1: URL | null = URL.parse('https://example.com/path?name=value#hash'); +URL.parse('/path', 'https://example.com'); + +if (u1) { + let str: string; + str = u1.pathname; + str = u1.hostname; + str = u1.pathname; + + str = u1.toJSON(); + str = u1.toString(); +} + +// @ts-expect-error +URL.parse(null); diff --git a/tests/type-definitions/pure/tsconfig.dom.json b/tests/type-definitions/pure/tsconfig.dom.json new file mode 100644 index 000000000000..3e633c7056c8 --- /dev/null +++ b/tests/type-definitions/pure/tsconfig.dom.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig.json", + "include": ["./**/*.ts"], + "compilerOptions": { + "types": ["@core-js/types/pure"] + } +} diff --git a/tests/type-definitions/pure/tsconfig.es6.dom.json b/tests/type-definitions/pure/tsconfig.es6.dom.json new file mode 100644 index 000000000000..9e1b4ef64d9a --- /dev/null +++ b/tests/type-definitions/pure/tsconfig.es6.dom.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.json", + "include": ["./**/*.ts"], + "exclude": ["./**/*es2018*test.ts"], + "compilerOptions": { + "types": ["@core-js/types/pure"] + } +} diff --git a/tests/type-definitions/pure/tsconfig.es6.json b/tests/type-definitions/pure/tsconfig.es6.json index 9e1b4ef64d9a..31e076ae0120 100644 --- a/tests/type-definitions/pure/tsconfig.es6.json +++ b/tests/type-definitions/pure/tsconfig.es6.json @@ -1,7 +1,10 @@ { "extends": "../tsconfig.json", "include": ["./**/*.ts"], - "exclude": ["./**/*es2018*test.ts"], + "exclude": [ + "./**/*es2018*test.ts", + "./**/*dom*test.ts" + ], "compilerOptions": { "types": ["@core-js/types/pure"] } diff --git a/tests/type-definitions/pure/tsconfig.json b/tests/type-definitions/pure/tsconfig.json index 3e633c7056c8..6bda323fe73e 100644 --- a/tests/type-definitions/pure/tsconfig.json +++ b/tests/type-definitions/pure/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../tsconfig.json", "include": ["./**/*.ts"], + "exclude": ["./**/*dom*test.ts"], "compilerOptions": { "types": ["@core-js/types/pure"] } diff --git a/tests/type-definitions/pure/web/url-parse.test.ts b/tests/type-definitions/pure/web/url-parse.test.ts index d1a0a98ad037..48239bb7f38e 100644 --- a/tests/type-definitions/pure/web/url-parse.test.ts +++ b/tests/type-definitions/pure/web/url-parse.test.ts @@ -4,8 +4,6 @@ const u1 = $parse('https://example.com/path?name=value#hash'); $parse('/path', 'https://example.com'); if (u1) { - $parse(u1); - let str: string; str = u1.pathname; str = u1.hostname; diff --git a/tests/type-definitions/pure/web/url.test.ts b/tests/type-definitions/pure/web/url.dom.test.ts similarity index 100% rename from tests/type-definitions/pure/web/url.test.ts rename to tests/type-definitions/pure/web/url.dom.test.ts diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index b89ddbfa19ec..4faa1eaf8ba6 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -37,8 +37,9 @@ const LIBS = [ 'dom', // null, // fails on web types ]; -const TARGET_EXCLUDES = { +const EXCLUDE_RULES = { es6: ['**/*es2018*test.ts'], + dom: ['**/*dom*test.ts'], }; let tested = 0; @@ -52,7 +53,8 @@ function getEnvPath(env) { async function runTestsOnEnv({ typeScriptVersion, target, type, env, lib }) { $.verbose = false; const envLibName = env ? env.substring(0, env.lastIndexOf('@')) : ''; - const tsConfigPostfix = TARGET_EXCLUDES[target] ? `.${ target }` : ''; + let tsConfigPostfix = EXCLUDE_RULES[target] ? `.${ target }` : ''; + tsConfigPostfix = lib && EXCLUDE_RULES[lib] ? `${ tsConfigPostfix }.${ lib }` : tsConfigPostfix; const command = `npx -p typescript@${ typeScriptVersion }${ env ? ` -p ${ env }` : '' } tsc -p ${ type }/tsconfig${ tsConfigPostfix }.json --target ${ target } --lib ${ target }${ lib ? `,${ lib }` : '' }${ env ? ` --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }` : '' }`; @@ -106,7 +108,7 @@ async function clearTmpDir() { await $`rm -rf ${ TMP_DIR }`; } -async function prepareEnvironment(environments, coreJsTypes, targetExcludes) { +async function prepareEnvironment(environments, coreJsTypes) { await clearTmpDir(); for (const env of environments) { if (!env) continue; @@ -118,14 +120,22 @@ async function prepareEnvironment(environments, coreJsTypes, targetExcludes) { await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.json`), { extends: '../../tsconfig.json', include: [`../../${ type }/**/*.ts`], + exclude: [`../../${ type }/**/${ EXCLUDE_RULES.dom }`], + }); + await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.dom.json`), { + extends: '../../tsconfig.json', + include: [`../../${ type }/**/*.ts`], + }); + await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.es6.json`), { + extends: '../../tsconfig.json', + include: [`../../${ type }/**/*.ts`], + exclude: [`../../${ type }/**/${ EXCLUDE_RULES.es6 }`, `../../${ type }/${ EXCLUDE_RULES.dom }`], + }); + await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.es6.dom.json`), { + extends: '../../tsconfig.json', + include: [`../../${ type }/**/*.ts`], + exclude: [`../../${ type }/**/${ EXCLUDE_RULES.es6 }`], }); - for (const [target, patterns] of Object.entries(targetExcludes)) { - await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.${ target }.json`), { - extends: '../../tsconfig.json', - include: [`../../${ type }/**/*.ts`], - exclude: patterns.map(pattern => `../../${ pattern }`), - }); - } } } } @@ -140,10 +150,10 @@ if (ALL_TESTS) { taskConfigs = buildTasksConfigs(TYPES, TARGETS, TYPE_SCRIPT_VERSIONS, ENVS, LIBS); } else { envs = [null]; - taskConfigs = buildTasksConfigs(TYPES, ['esnext', 'es2022', 'es6'], ['5.9', '5.6'], envs, ['dom']); + taskConfigs = buildTasksConfigs(TYPES, ['esnext', 'es2022', 'es6'], ['5.9', '5.6'], envs, ['dom', null]); } const numCPUs = os.cpus().length; -await prepareEnvironment(envs, TYPES, TARGET_EXCLUDES); +await prepareEnvironment(envs, TYPES); await runLimited(taskConfigs, Math.max(numCPUs - 1, 1)); await clearTmpDir(); echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); From e9f9b99294681b1d1445dff3317e3563901ee388 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 15 Jan 2026 16:40:48 +0700 Subject: [PATCH 149/315] Enable URLSearchParams tests & some web types & tests improvements --- packages/core-js-types/src/base/web/url-to-json.d.ts | 8 ++------ .../global/web/url-search-params.dom.test.ts | 11 +++++++++++ .../global/web/url-search-params.test.ts | 12 ------------ .../{url-to-json.test.ts => url-to-json.dom.test.ts} | 0 4 files changed, 13 insertions(+), 18 deletions(-) create mode 100644 tests/type-definitions/global/web/url-search-params.dom.test.ts delete mode 100644 tests/type-definitions/global/web/url-search-params.test.ts rename tests/type-definitions/global/web/{url-to-json.test.ts => url-to-json.dom.test.ts} (100%) diff --git a/packages/core-js-types/src/base/web/url-to-json.d.ts b/packages/core-js-types/src/base/web/url-to-json.d.ts index 316729dc8419..2ec27ec39d3c 100644 --- a/packages/core-js-types/src/base/web/url-to-json.d.ts +++ b/packages/core-js-types/src/base/web/url-to-json.d.ts @@ -1,6 +1,2 @@ -interface URL { // @type-options no-extends - /** - * Returns a JSON representation of the URL. - */ - toJSON(): string; -} +// empty +// Moved to ../core-js-modules/url.d.ts diff --git a/tests/type-definitions/global/web/url-search-params.dom.test.ts b/tests/type-definitions/global/web/url-search-params.dom.test.ts new file mode 100644 index 000000000000..ea10547dd1a1 --- /dev/null +++ b/tests/type-definitions/global/web/url-search-params.dom.test.ts @@ -0,0 +1,11 @@ +import 'core-js/full'; + +const u0 = new URLSearchParams(); +const u1 = new URLSearchParams('a=1&b=2'); +const u2 = new URLSearchParams([['a', '1'], ['b', '2']]); +const u3 = new URLSearchParams({ a: '1', b: '2' }); + +// @ts-expect-error +new URLSearchParams(123); +// @ts-expect-error +new URLSearchParams([1, 2, 3]); diff --git a/tests/type-definitions/global/web/url-search-params.test.ts b/tests/type-definitions/global/web/url-search-params.test.ts deleted file mode 100644 index 0cecd6b72e60..000000000000 --- a/tests/type-definitions/global/web/url-search-params.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -// todo add after it becomes possible to create a type -// import 'core-js/full'; -// -// const u0 = new URLSearchParams(); -// const u1 = new URLSearchParams('a=1&b=2'); -// const u2 = new URLSearchParams([['a', '1'], ['b', '2']]); -// const u3 = new URLSearchParams({ a: '1', b: '2' }); -// -// // @ts-expect-error -// new URLSearchParams(123); -// // @ts-expect-error -// new URLSearchParams([1, 2, 3]); diff --git a/tests/type-definitions/global/web/url-to-json.test.ts b/tests/type-definitions/global/web/url-to-json.dom.test.ts similarity index 100% rename from tests/type-definitions/global/web/url-to-json.test.ts rename to tests/type-definitions/global/web/url-to-json.dom.test.ts From 582e63ddd1e5571fd2f63571d9a1d81e7ecb9110 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 15 Jan 2026 23:33:49 +0700 Subject: [PATCH 150/315] Type tests runner refactoring --- tests/type-definitions/runner.mjs | 106 +++++++++++++++++------------- 1 file changed, 62 insertions(+), 44 deletions(-) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 4faa1eaf8ba6..ea5e2fb397c9 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -37,8 +37,11 @@ const LIBS = [ 'dom', // null, // fails on web types ]; -const EXCLUDE_RULES = { +const TARGET_RULES = { es6: ['**/*es2018*test.ts'], +}; + +const LIB_RULES = { dom: ['**/*dom*test.ts'], }; @@ -50,58 +53,70 @@ function getEnvPath(env) { return path.join(TMP_DIR, env.replaceAll('/', '-').replaceAll('@', '')); } -async function runTestsOnEnv({ typeScriptVersion, target, type, env, lib }) { +async function runLimited(tasks, limit) { + let i = 0; + async function worker() { + while (i < tasks.length) { + const idx = i++; + await runTask(tasks[idx]); + } + } + await Promise.all(Array.from({ length: limit }, worker)); +} + +async function runTask(config) { $.verbose = false; - const envLibName = env ? env.substring(0, env.lastIndexOf('@')) : ''; - let tsConfigPostfix = EXCLUDE_RULES[target] ? `.${ target }` : ''; - tsConfigPostfix = lib && EXCLUDE_RULES[lib] ? `${ tsConfigPostfix }.${ lib }` : tsConfigPostfix; - const command = `npx -p typescript@${ typeScriptVersion }${ - env ? ` -p ${ env }` : '' } tsc -p ${ type }/tsconfig${ tsConfigPostfix }.json --target ${ target } --lib ${ target }${ lib ? `,${ lib }` : '' }${ - env ? ` --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }` : '' }`; - echo(`$ ${ command }`); + const command = `$ ${ config.cmd } ${ config.args.join(' ') }`; try { tested++; - if (env && lib) { - await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }${ tsConfigPostfix }.json --target ${ target } --lib ${ target },${ lib } --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }`.quiet(); - } else if (env) { - await $({ cwd: getEnvPath(env) })`npx -p typescript@${ typeScriptVersion } tsc -p ./tsconfig.${ type }${ tsConfigPostfix }.json --target ${ target } --lib ${ target } --types @core-js/types${ type === 'pure' ? '/pure' : '' },${ envLibName }`.quiet(); - } else if (lib) { - await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig${ tsConfigPostfix }.json --target ${ target } --lib ${ target },${ lib }`.quiet(); + echo(command); + if (config.cwd) { + await $({ cwd: config.cwd })`${ config.cmd } ${ config.args }`.quiet(); } else { - await $`npx -p typescript@${ typeScriptVersion } tsc -p ${ type }/tsconfig${ tsConfigPostfix }.json --target ${ target } --lib ${ target }`.quiet(); + await $`${ config.cmd } ${ config.args }`.quiet(); } - echo(chalk.green(`$ ${ command }`)); + echo(chalk.green(command)); } catch (error) { failed++; - echo(`$ ${ chalk.red(command) }\n ${ error }`); + echo(chalk.red(`${ command }\n ${ error }`)); } } -async function runLimited(configs, limit) { - let i = 0; - async function worker() { - while (i < configs.length) { - const idx = i++; - await runTestsOnEnv(configs[idx]); - } - } - await Promise.all(Array.from({ length: limit }, worker)); -} - -function buildTasksConfigs(types, targets, typeScriptVersions, envs, libs) { - const taskConfigs = []; +function buildTasks(types, targets, typeScriptVersions, envs, libs) { + const tasks = []; for (const type of types) { for (const target of targets) { for (const typeScriptVersion of typeScriptVersions) { for (const env of envs) { for (const lib of libs) { - taskConfigs.push({ env, lib, target, type, typeScriptVersion }); + let tsConfigPostfix = TARGET_RULES[target] ? `.${ target }` : ''; + tsConfigPostfix += lib && LIB_RULES[lib] ? `.${ lib }` : ''; + const libsStr = lib ? `${ target },${ lib }` : target; + const tsConfigPath = env ? `./tsconfig.${ type }${ tsConfigPostfix }.json` : `${ type }/tsconfig${ tsConfigPostfix }.json`; + const taskConfig = { + cmd: 'npx', + cwd: getEnvPath(env), + args: [ + '-p', `typescript@${ typeScriptVersion }`, + 'tsc', + '-p', tsConfigPath, + '--target', target, + '--lib', `${ libsStr }`, + ], + }; + // eslint-disable-next-line max-depth -- it's needed here + if (type) { + const typesSuffix = type === 'pure' ? '/pure' : ''; + const envLibName = env ? `,${ env.substring(0, env.lastIndexOf('@')) }` : ''; + taskConfig.args.push('--types', `@core-js/types${ typesSuffix }${ envLibName }`); + } + tasks.push(taskConfig); } } } } } - return taskConfigs; + return tasks; } async function clearTmpDir() { @@ -120,7 +135,7 @@ async function prepareEnvironment(environments, coreJsTypes) { await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.json`), { extends: '../../tsconfig.json', include: [`../../${ type }/**/*.ts`], - exclude: [`../../${ type }/**/${ EXCLUDE_RULES.dom }`], + exclude: [`../../${ type }/**/${ LIB_RULES.dom }`], }); await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.dom.json`), { extends: '../../tsconfig.json', @@ -129,32 +144,35 @@ async function prepareEnvironment(environments, coreJsTypes) { await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.es6.json`), { extends: '../../tsconfig.json', include: [`../../${ type }/**/*.ts`], - exclude: [`../../${ type }/**/${ EXCLUDE_RULES.es6 }`, `../../${ type }/${ EXCLUDE_RULES.dom }`], + exclude: [`../../${ type }/**/${ TARGET_RULES.es6 }`, `../../${ type }/${ LIB_RULES.dom }`], }); await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.es6.dom.json`), { extends: '../../tsconfig.json', include: [`../../${ type }/**/*.ts`], - exclude: [`../../${ type }/**/${ EXCLUDE_RULES.es6 }`], + exclude: [`../../${ type }/**/${ TARGET_RULES.es6 }`], }); } } } -await $`npx -p typescript@5.9 tsc`; -await $`npx -p typescript@5.9 tsc -p templates/tsconfig.json`; -await $`npx -p typescript@5.9 -p @types/node@24 tsc -p templates/tsconfig.require.json`; +let tasks = []; +tasks.push( + { cmd: 'npx', args: ['-p', 'typescript@5.9', 'tsc'] }, + { cmd: 'npx', args: ['-p', 'typescript@5.9', 'tsc', '-p', 'templates/tsconfig.json'] }, + { cmd: 'npx', args: ['-p', 'typescript@5.9', '-p', '@types/node@24', 'tsc', '-p', 'templates/tsconfig.require.json'] }, +); -let taskConfigs, envs; +let envs; if (ALL_TESTS) { envs = ENVS; - taskConfigs = buildTasksConfigs(TYPES, TARGETS, TYPE_SCRIPT_VERSIONS, ENVS, LIBS); + tasks = [...tasks, ...buildTasks(TYPES, TARGETS, TYPE_SCRIPT_VERSIONS, envs, LIBS)]; } else { - envs = [null]; - taskConfigs = buildTasksConfigs(TYPES, ['esnext', 'es2022', 'es6'], ['5.9', '5.6'], envs, ['dom', null]); + envs = [null, '@types/node@24']; + tasks = [...tasks, ...buildTasks(TYPES, ['esnext', 'es2022', 'es6'], ['5.9', '5.6'], envs, ['dom', null])]; } const numCPUs = os.cpus().length; await prepareEnvironment(envs, TYPES); -await runLimited(taskConfigs, Math.max(numCPUs - 1, 1)); +await runLimited(tasks, Math.max(numCPUs - 1, 1)); await clearTmpDir(); echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); if (failed) throw new Error('Some tests have failed'); From 8c914bd96e33f83f069afd9429d0b31e485fe31c Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 20 Jan 2026 00:29:12 +0700 Subject: [PATCH 151/315] Type tests runner refactoring --- tests/type-definitions/runner.mjs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index ea5e2fb397c9..77615c4832e4 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -66,14 +66,14 @@ async function runLimited(tasks, limit) { async function runTask(config) { $.verbose = false; - const command = `$ ${ config.cmd } ${ config.args.join(' ') }`; + const command = `$ npx ${ config.args.join(' ') }`; try { tested++; echo(command); if (config.cwd) { - await $({ cwd: config.cwd })`${ config.cmd } ${ config.args }`.quiet(); + await $({ cwd: config.cwd })`npx ${ config.args }`.quiet(); } else { - await $`${ config.cmd } ${ config.args }`.quiet(); + await $`npx ${ config.args }`.quiet(); } echo(chalk.green(command)); } catch (error) { @@ -94,7 +94,6 @@ function buildTasks(types, targets, typeScriptVersions, envs, libs) { const libsStr = lib ? `${ target },${ lib }` : target; const tsConfigPath = env ? `./tsconfig.${ type }${ tsConfigPostfix }.json` : `${ type }/tsconfig${ tsConfigPostfix }.json`; const taskConfig = { - cmd: 'npx', cwd: getEnvPath(env), args: [ '-p', `typescript@${ typeScriptVersion }`, @@ -157,9 +156,9 @@ async function prepareEnvironment(environments, coreJsTypes) { let tasks = []; tasks.push( - { cmd: 'npx', args: ['-p', 'typescript@5.9', 'tsc'] }, - { cmd: 'npx', args: ['-p', 'typescript@5.9', 'tsc', '-p', 'templates/tsconfig.json'] }, - { cmd: 'npx', args: ['-p', 'typescript@5.9', '-p', '@types/node@24', 'tsc', '-p', 'templates/tsconfig.require.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'templates/tsconfig.json'] }, + { args: ['-p', 'typescript@5.9', '-p', '@types/node@24', 'tsc', '-p', 'templates/tsconfig.require.json'] }, ); let envs; From 21a5da817b6bc660da30a39c86d68d4de5e4fed1 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Wed, 21 Jan 2026 18:41:13 +0200 Subject: [PATCH 152/315] update dependencies From 53e963a1946e2ff5b69bffa99a738f660c196c1f Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 22 Jan 2026 20:36:48 +0700 Subject: [PATCH 153/315] Types linting: interfaces --- .../src/base/proposals/array-buffer-base64.d.ts | 12 ++++++------ .../src/base/proposals/iterator-joint.d.ts | 4 ++-- .../src/base/proposals/iterator-range.d.ts | 4 ++-- .../src/base/pure/proposals/iterator.d.ts | 8 ++++---- .../src/ts5-2/pure/proposals/iterator.d.ts | 8 ++++---- tests/eslint/eslint.config.js | 2 +- .../global/proposals/array-unique.test.ts | 5 ++++- .../global/proposals/decorator-metadata.test.ts | 4 ++-- .../pure/proposals/array-unique.test.ts | 5 ++++- .../pure/proposals/decorator-metadata.test.ts | 4 ++-- .../pure/proposals/json-parse-with-source.test.ts | 8 ++++---- 11 files changed, 35 insertions(+), 29 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts index 71eda5c15bbd..3556606ffff6 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts @@ -8,20 +8,20 @@ type alphabet = 'base64' | 'base64url'; type lastChunkHandling = 'loose' | 'strict' | 'stop-before-partial'; -type fromBase64Options = { +interface fromBase64Options { alphabet?: alphabet; lastChunkHandling?: lastChunkHandling; -}; +} -type toBase64Options = { +interface toBase64Options { alphabet?: alphabet; omitPadding?: boolean; -}; +} -type processMetadata = { +interface processMetadata { read: number; written: number; -}; +} interface Uint8ArrayConstructor { /** diff --git a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts index c3742a2df9e0..9559fe9fb048 100644 --- a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts @@ -1,10 +1,10 @@ // https://github.com/tc39/proposal-joint-iteration -type ZipOptions = { +interface ZipOptions { mode?: 'shortest' | 'longest' | 'strict'; padding?: object; -}; +} interface IteratorConstructor { // @type-options no-extends /** diff --git a/packages/core-js-types/src/base/proposals/iterator-range.d.ts b/packages/core-js-types/src/base/proposals/iterator-range.d.ts index babc6c471551..3dd51c6de211 100644 --- a/packages/core-js-types/src/base/proposals/iterator-range.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-range.d.ts @@ -1,10 +1,10 @@ // https://github.com/tc39/proposal-iterator.range -type IteratorRangeOptions = { +interface IteratorRangeOptions { step?: T; inclusive?: boolean; -}; +} interface IteratorConstructor { // @type-options no-extends /** diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 80721b4cf43c..7fd6aa97d0ca 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -27,17 +27,17 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt declare namespace CoreJS { - type ZipOptions = { + interface ZipOptions { mode?: 'shortest' | 'longest' | 'strict'; padding?: object; - }; + } - type IteratorRangeOptions = { + interface IteratorRangeOptions { step?: T; inclusive?: boolean; - }; + } interface CoreJSPromiseLike { /** diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index 231bcfdc2afa..bc2a71f1df0a 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -27,17 +27,17 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt declare namespace CoreJS { - type ZipOptions = { + interface ZipOptions { mode?: 'shortest' | 'longest' | 'strict'; padding?: object; - }; + } - type IteratorRangeOptions = { + interface IteratorRangeOptions { step?: T; inclusive?: boolean; - }; + } interface CoreJSPromiseLike { /** diff --git a/tests/eslint/eslint.config.js b/tests/eslint/eslint.config.js index 6afca906e801..a58d526b9923 100644 --- a/tests/eslint/eslint.config.js +++ b/tests/eslint/eslint.config.js @@ -1919,7 +1919,7 @@ const ts = { // require that function overload signatures be consecutive '@typescript-eslint/adjacent-overload-signatures': ERROR, // enforce type definitions to consistently use either `interface` or `type` - '@typescript-eslint/consistent-type-definitions': [OFF, 'interface'], + '@typescript-eslint/consistent-type-definitions': [ERROR, 'interface'], // disallow extra non-null assertions '@typescript-eslint/no-extra-non-null-assertion': ERROR, // enforce the use of top-level import type qualifier when an import only has specifiers with inline type qualifiers diff --git a/tests/type-definitions/global/proposals/array-unique.test.ts b/tests/type-definitions/global/proposals/array-unique.test.ts index 101233b000bc..45b560ed927d 100644 --- a/tests/type-definitions/global/proposals/array-unique.test.ts +++ b/tests/type-definitions/global/proposals/array-unique.test.ts @@ -1,6 +1,9 @@ import 'core-js/full'; -type Obj = { a: number; b: string }; +interface Obj { + a: number; + b: string +} const arr: Obj[] = [{ a: 1, b: 'x' }, { a: 2, b: 'y' }]; const arrRes: Obj[] = arr.uniqueBy(); const arrRes2: Obj[] = arr.uniqueBy('a'); diff --git a/tests/type-definitions/global/proposals/decorator-metadata.test.ts b/tests/type-definitions/global/proposals/decorator-metadata.test.ts index 4abbf2decd7d..0709439a8442 100644 --- a/tests/type-definitions/global/proposals/decorator-metadata.test.ts +++ b/tests/type-definitions/global/proposals/decorator-metadata.test.ts @@ -3,9 +3,9 @@ import 'core-js/full'; const rsmd1: symbol = Symbol.metadata; const rsmd2: typeof Symbol.metadata = Symbol.metadata; -type T = { +interface T { [Symbol.metadata]?: object; -}; +} const obj: T = {}; obj[Symbol.metadata] = { foo: 1 }; diff --git a/tests/type-definitions/pure/proposals/array-unique.test.ts b/tests/type-definitions/pure/proposals/array-unique.test.ts index 3981bb477115..bffb7e4b4864 100644 --- a/tests/type-definitions/pure/proposals/array-unique.test.ts +++ b/tests/type-definitions/pure/proposals/array-unique.test.ts @@ -1,6 +1,9 @@ import arrayUniqueBy from '@core-js/pure/full/array/unique-by'; -type Obj = { a: number; b: string }; +interface Obj { + a: number; + b: string +} const arr: Obj[] = [{ a: 1, b: 'x' }, { a: 2, b: 'y' }]; const arrRes: Obj[] = arrayUniqueBy(arr); const arrRes2: Obj[] = arrayUniqueBy(arr, 'a'); diff --git a/tests/type-definitions/pure/proposals/decorator-metadata.test.ts b/tests/type-definitions/pure/proposals/decorator-metadata.test.ts index 8b12f522c44a..eacd41c149fb 100644 --- a/tests/type-definitions/pure/proposals/decorator-metadata.test.ts +++ b/tests/type-definitions/pure/proposals/decorator-metadata.test.ts @@ -3,9 +3,9 @@ import metadata from '@core-js/pure/full/symbol/metadata'; const rsmd1: symbol = metadata; const rsmd2: typeof metadata = metadata; -type T = { +interface T { [metadata]?: object; -}; +} const obj: T = {}; obj[metadata] = { foo: 1 }; diff --git a/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts b/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts index 35f24d61cb72..b78ee7698a1d 100644 --- a/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts +++ b/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts @@ -2,13 +2,13 @@ import $rawJSON from '@core-js/pure/full/json/raw-json'; import $isRawJSON from '@core-js/pure/full/json/is-raw-json'; import $parse from '@core-js/pure/full/json/parse'; -declare type CoreJSRawJSON = { +interface CoreJSRawJSON { rawJSON: string; -}; +} -declare type CoreJSReviverContext = { +interface CoreJSReviverContext { source: string; -}; +} const r: CoreJSRawJSON = $rawJSON('{"a":123}'); From 7065a3cef8701163e4e87177bbf452c62ca9c888 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 22 Jan 2026 21:54:53 +0700 Subject: [PATCH 154/315] Types linting: TSDocs --- .../src/base/annex-b/object-proto.d.ts | 2 +- .../accessible-object-hasownproperty.d.ts | 4 +- .../base/proposals/array-buffer-base64.d.ts | 16 +-- .../base/proposals/array-buffer-transfer.d.ts | 10 +- .../src/base/proposals/array-filtering.d.ts | 52 ++++----- .../base/proposals/array-find-from-last.d.ts | 100 +++++++++--------- .../src/base/proposals/array-flat-map.d.ts | 12 +-- .../src/base/proposals/array-from-async.d.ts | 8 +- .../src/base/proposals/array-grouping.d.ts | 8 +- .../src/base/proposals/array-includes.d.ts | 52 ++++----- .../proposals/array-is-template-object.d.ts | 2 +- .../src/base/proposals/array-unique.d.ts | 26 ++--- .../proposals/async-iterator-helpers.d.ts | 24 ++--- .../src/base/proposals/await-dictionary.d.ts | 6 +- .../base/proposals/change-array-by-copy.d.ts | 98 ++++++++--------- .../base/proposals/collection-of-from.d.ts | 48 ++++----- .../data-view-get-set-uint8-clamped.d.ts | 6 +- .../explicit-resource-management.d.ts | 12 +-- .../src/base/proposals/float16.d.ts | 12 +-- .../base/proposals/function-demethodize.d.ts | 2 +- .../src/base/proposals/iterator-chunking.d.ts | 6 +- .../src/base/proposals/iterator-helpers.d.ts | 32 +++--- .../src/base/proposals/iterator-join.d.ts | 2 +- .../src/base/proposals/iterator-joint.d.ts | 8 +- .../src/base/proposals/iterator-range.d.ts | 6 +- .../base/proposals/iterator-sequencing.d.ts | 2 +- .../proposals/json-parse-with-source.d.ts | 10 +- .../src/base/proposals/map-upsert.d.ts | 16 +-- .../src/base/proposals/math-sum.d.ts | 2 +- .../src/base/proposals/number-clamp.d.ts | 4 +- .../base/proposals/object-from-entries.d.ts | 4 +- .../object-get-own-property-descriptors.d.ts | 2 +- .../base/proposals/object-values-entries.d.ts | 8 +- .../base/proposals/promise-all-settled.d.ts | 4 +- .../src/base/proposals/promise-any.d.ts | 4 +- .../src/base/proposals/promise-finally.d.ts | 2 +- .../src/base/proposals/promise-try.d.ts | 4 +- .../src/base/proposals/regexp-escaping.d.ts | 2 +- .../proposals/relative-indexing-method.d.ts | 28 ++--- .../src/base/proposals/string-cooked.d.ts | 4 +- .../src/base/proposals/string-dedent.d.ts | 4 +- .../src/base/proposals/string-match-all.d.ts | 2 +- .../src/base/proposals/string-padding.d.ts | 8 +- .../base/proposals/string-replace-all.d.ts | 8 +- .../src/base/proposals/symbol-predicates.d.ts | 4 +- .../src/base/pure/common/reflect.d.ts | 58 +++++----- .../src/base/pure/core-js-types/promise.d.ts | 10 +- .../pure/proposals/array-buffer-transfer.d.ts | 10 +- .../pure/proposals/array-constructor.d.ts | 10 +- .../proposals/async-iterator-helpers.d.ts | 24 ++--- .../base/pure/proposals/await-dictionary.d.ts | 6 +- .../pure/proposals/collection-of-from.d.ts | 48 ++++----- .../explicit-resource-management.d.ts | 12 +-- .../src/base/pure/proposals/iterator.d.ts | 58 +++++----- .../proposals/relative-indexing-method.d.ts | 4 +- .../base/pure/proposals/string-match-all.d.ts | 2 +- .../base/pure/proposals/string-padding.d.ts | 8 +- .../pure/proposals/string-replace-all.d.ts | 8 +- .../src/base/pure/proposals/symbol.d.ts | 4 +- .../core-js-types/src/base/web/atob-btoa.d.ts | 4 +- .../base/web/efficient-script-yielding.d.ts | 6 +- .../base/web/iterable-dom-collections.d.ts | 8 +- .../src/base/web/queue-microtask.d.ts | 2 +- .../src/base/web/structured-clone.d.ts | 4 +- .../proposals/async-iterator-helpers.d.ts | 24 ++--- .../explicit-resource-management.d.ts | 12 +-- .../src/ts5-2/proposals/iterator-helpers.d.ts | 32 +++--- .../src/ts5-2/proposals/string-match-all.d.ts | 2 +- .../src/ts5-2/pure/proposals/iterator.d.ts | 62 +++++------ .../ts5-2/web/iterable-dom-collections.d.ts | 8 +- tests/eslint/eslint.config.js | 2 +- 71 files changed, 553 insertions(+), 551 deletions(-) diff --git a/packages/core-js-types/src/base/annex-b/object-proto.d.ts b/packages/core-js-types/src/base/annex-b/object-proto.d.ts index 6bc651664631..d1142b9d2386 100644 --- a/packages/core-js-types/src/base/annex-b/object-proto.d.ts +++ b/packages/core-js-types/src/base/annex-b/object-proto.d.ts @@ -1,7 +1,7 @@ interface Object { /** * Accessor to [[Prototype]]. - * This is non-standard and deprecated; prefer { Object, Reflect }.{ getPrototypeOf, setPrototypeOf } + * This is non-standard and deprecated; prefer `{ Object, Reflect }.{ getPrototypeOf, setPrototypeOf }` */ __proto__: object | null; } diff --git a/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts b/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts index 364c1f717e59..734205128d83 100644 --- a/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts +++ b/packages/core-js-types/src/base/proposals/accessible-object-hasownproperty.d.ts @@ -7,8 +7,8 @@ interface ObjectConstructor { /** * Determines whether an object has a property with the specified name. - * @param o An object. - * @param v A property name. + * @param o - An object. + * @param v - A property name. */ hasOwn(o: object, v: PropertyKey): boolean; } diff --git a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts index 3556606ffff6..d86e71111870 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts @@ -26,10 +26,10 @@ interface processMetadata { interface Uint8ArrayConstructor { /** * Creates a new `Uint8Array` from a base64-encoded string. - * @param string The base64-encoded string. - * @param options If provided, specifies the alphabet and handling of the last chunk. + * @param string - The base64-encoded string. + * @param options - If provided, specifies the alphabet and handling of the last chunk. * @returns A new `Uint8Array` instance. - * @throws {SyntaxError} If the input string contains characters outside the specified alphabet, or if the last + * @throws SyntaxError If the input string contains characters outside the specified alphabet, or if the last * chunk is inconsistent with the `lastChunkHandling` option. */ fromBase64(string: string, options?: fromBase64Options): Uint8Array; @@ -44,24 +44,24 @@ interface Uint8ArrayConstructor { interface Uint8Array { /** * Sets the `Uint8Array` from a base64-encoded string. - * @param string The base64-encoded string. - * @param options If provided, specifies the alphabet and handling of the last chunk. + * @param string - The base64-encoded string. + * @param options - If provided, specifies the alphabet and handling of the last chunk. * @returns An object containing the number of bytes read and written. - * @throws {SyntaxError} If the input string contains characters outside the specified alphabet, or if the last + * @throws SyntaxError If the input string contains characters outside the specified alphabet, or if the last * chunk is inconsistent with the `lastChunkHandling` option. */ setFromBase64(string: string, options?: fromBase64Options): processMetadata; /** * Sets the `Uint8Array` from a base16-encoded string. - * @param string The base16-encoded string. + * @param string - The base16-encoded string. * @returns An object containing the number of bytes read and written. */ setFromHex(string: string): processMetadata; /** * Converts the `Uint8Array` to a base64-encoded string. - * @param options If provided, sets the alphabet and padding behavior used. + * @param options - If provided, sets the alphabet and padding behavior used. * @returns A base64-encoded string. */ toBase64(options?: toBase64Options): string; diff --git a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts index 60fda5e3a8ee..83a70998ae2f 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts @@ -10,17 +10,17 @@ interface ArrayBuffer { /** * Creates a new `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. - * @param newByteLength If provided, specifies the `byteLength` of the new `ArrayBuffer` - * @throws {RangeError} If this `ArrayBuffer` is resizable and newByteLength is greater than the `maxByteLength` of this `ArrayBuffer` - * @throws {TypeError} If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @param newByteLength - If provided, specifies the `byteLength` of the new `ArrayBuffer` + * @throws RangeError If this `ArrayBuffer` is resizable and newByteLength is greater than the `maxByteLength` of this `ArrayBuffer` + * @throws TypeError If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations * @returns A new `ArrayBuffer` object */ transfer(newByteLength?: number): ArrayBuffer; /** * Creates a new non-resizable `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. - * @param newByteLength If provided, specifies the `byteLength` of the new `ArrayBuffer` - * @throws {TypeError} If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @param newByteLength - If provided, specifies the `byteLength` of the new `ArrayBuffer` + * @throws TypeError If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations * @returns A new `ArrayBuffer` object */ transferToFixedLength(newByteLength?: number): ArrayBuffer; diff --git a/packages/core-js-types/src/base/proposals/array-filtering.d.ts b/packages/core-js-types/src/base/proposals/array-filtering.d.ts index 0fc3ba0d73c9..15a42b610b63 100644 --- a/packages/core-js-types/src/base/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/base/proposals/array-filtering.d.ts @@ -3,9 +3,9 @@ interface Array { // @type-options no-redefine /** * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; @@ -14,9 +14,9 @@ interface Array { // @type-options no-redefine interface ReadonlyArray { // @type-options no-export /** * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; @@ -25,9 +25,9 @@ interface ReadonlyArray { // @type-options no-export interface Int8Array { // @type-options no-export /** * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Int8Array) => boolean, thisArg?: any): Int8Array; @@ -36,9 +36,9 @@ interface Int8Array { // @type-options no-export interface Uint8Array { // @type-options no-export /** * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Uint8Array) => boolean, thisArg?: any): Uint8Array; @@ -47,9 +47,9 @@ interface Uint8Array { // @type-options no-export interface Uint8ClampedArray { // @type-options no-export /** * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; @@ -58,9 +58,9 @@ interface Uint8ClampedArray { // @type-options no-export interface Int16Array { // @type-options no-export /** * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Int16Array) => boolean, thisArg?: any): Int16Array; @@ -69,9 +69,9 @@ interface Int16Array { // @type-options no-export interface Uint16Array { // @type-options no-export /** * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Uint16Array) => boolean, thisArg?: any): Uint16Array; @@ -80,9 +80,9 @@ interface Uint16Array { // @type-options no-export interface Int32Array { // @type-options no-export /** * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Int32Array) => boolean, thisArg?: any): Int32Array; @@ -91,9 +91,9 @@ interface Int32Array { // @type-options no-export interface Uint32Array { // @type-options no-export /** * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Uint32Array) => boolean, thisArg?: any): Uint32Array; @@ -102,9 +102,9 @@ interface Uint32Array { // @type-options no-export interface Float32Array { // @type-options no-export /** * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Float32Array) => boolean, thisArg?: any): Float32Array; @@ -113,9 +113,9 @@ interface Float32Array { // @type-options no-export interface Float64Array { // @type-options no-export /** * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Float64Array) => boolean, thisArg?: any): Float64Array; @@ -124,9 +124,9 @@ interface Float64Array { // @type-options no-export interface BigInt64Array { // @type-options no-export /** * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array; @@ -135,9 +135,9 @@ interface BigInt64Array { // @type-options no-export interface BigUint64Array { // @type-options no-export /** * Removes the items that return true - * @param callbackFn A function that accepts up to three arguments. The filterReject method calls the + * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: bigint, index: number, target: BigUint64Array) => boolean, thisArg?: any): BigUint64Array; diff --git a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts index 3e0e80ba998d..168e5a5f8104 100644 --- a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts @@ -8,10 +8,10 @@ interface Array { // @type-options no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending + * @param predicate - findLast calls predicate once for each element of the array, in descending * order, until it finds one where predicate returns true. If such an element is found, findLast * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; @@ -20,10 +20,10 @@ interface Array { // @type-options no-redefine /** * Returns the index of the last element in the array where predicate is true, and -1 * otherwise. - * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * @param predicate - findLastIndex calls predicate once for each element of the array, in descending * 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 this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; @@ -33,10 +33,10 @@ interface ReadonlyArray { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending + * @param predicate - findLast calls predicate once for each element of the array, in descending * order, until it finds one where predicate returns true. If such an element is found, findLast * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; @@ -45,10 +45,10 @@ interface ReadonlyArray { // @type-options no-export /** * Returns the index of the last element in the array where predicate is true, and -1 * otherwise. - * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * @param predicate - findLastIndex calls predicate once for each element of the array, in descending * 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 this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; @@ -58,10 +58,10 @@ interface Int8Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending + * @param predicate - findLast calls predicate once for each element of the array, in descending * order, until it finds one where predicate returns true. If such an element is found, findLast * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; @@ -70,10 +70,10 @@ interface Int8Array { // @type-options no-export /** * Returns the index of the last element in the array where predicate is true, and -1 * otherwise. - * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * @param predicate - findLastIndex calls predicate once for each element of the array, in descending * 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 this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; @@ -83,10 +83,10 @@ interface Uint8Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending + * @param predicate - findLast calls predicate once for each element of the array, in descending * order, until it finds one where predicate returns true. If such an element is found, findLast * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; @@ -95,10 +95,10 @@ interface Uint8Array { // @type-options no-export /** * Returns the index of the last element in the array where predicate is true, and -1 * otherwise. - * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * @param predicate - findLastIndex calls predicate once for each element of the array, in descending * 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 this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; @@ -108,10 +108,10 @@ interface Uint8ClampedArray { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending + * @param predicate - findLast calls predicate once for each element of the array, in descending * order, until it finds one where predicate returns true. If such an element is found, findLast * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; @@ -120,10 +120,10 @@ interface Uint8ClampedArray { // @type-options no-export /** * Returns the index of the last element in the array where predicate is true, and -1 * otherwise. - * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * @param predicate - findLastIndex calls predicate once for each element of the array, in descending * 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 this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; @@ -133,10 +133,10 @@ interface Int16Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending + * @param predicate - findLast calls predicate once for each element of the array, in descending * order, until it finds one where predicate returns true. If such an element is found, findLast * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; @@ -145,10 +145,10 @@ interface Int16Array { // @type-options no-export /** * Returns the index of the last element in the array where predicate is true, and -1 * otherwise. - * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * @param predicate - findLastIndex calls predicate once for each element of the array, in descending * 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 this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; @@ -158,10 +158,10 @@ interface Uint16Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending + * @param predicate - findLast calls predicate once for each element of the array, in descending * order, until it finds one where predicate returns true. If such an element is found, findLast * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; @@ -170,10 +170,10 @@ interface Uint16Array { // @type-options no-export /** * Returns the index of the last element in the array where predicate is true, and -1 * otherwise. - * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * @param predicate - findLastIndex calls predicate once for each element of the array, in descending * 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 this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; @@ -183,10 +183,10 @@ interface Int32Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending + * @param predicate - findLast calls predicate once for each element of the array, in descending * order, until it finds one where predicate returns true. If such an element is found, findLast * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; @@ -195,10 +195,10 @@ interface Int32Array { // @type-options no-export /** * Returns the index of the last element in the array where predicate is true, and -1 * otherwise. - * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * @param predicate - findLastIndex calls predicate once for each element of the array, in descending * 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 this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; @@ -208,10 +208,10 @@ interface Uint32Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending + * @param predicate - findLast calls predicate once for each element of the array, in descending * order, until it finds one where predicate returns true. If such an element is found, findLast * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; @@ -220,10 +220,10 @@ interface Uint32Array { // @type-options no-export /** * Returns the index of the last element in the array where predicate is true, and -1 * otherwise. - * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * @param predicate - findLastIndex calls predicate once for each element of the array, in descending * 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 this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; @@ -233,10 +233,10 @@ interface Float32Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending + * @param predicate - findLast calls predicate once for each element of the array, in descending * order, until it finds one where predicate returns true. If such an element is found, findLast * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; @@ -245,10 +245,10 @@ interface Float32Array { // @type-options no-export /** * Returns the index of the last element in the array where predicate is true, and -1 * otherwise. - * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * @param predicate - findLastIndex calls predicate once for each element of the array, in descending * 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 this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; @@ -258,10 +258,10 @@ interface Float64Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending + * @param predicate - findLast calls predicate once for each element of the array, in descending * order, until it finds one where predicate returns true. If such an element is found, findLast * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; @@ -274,10 +274,10 @@ interface BigInt64Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending + * @param predicate - findLast calls predicate once for each element of the array, in descending * order, until it finds one where predicate returns true. If such an element is found, findLast * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; @@ -286,10 +286,10 @@ interface BigInt64Array { // @type-options no-export /** * Returns the index of the last element in the array where predicate is true, and -1 * otherwise. - * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * @param predicate - findLastIndex calls predicate once for each element of the array, in descending * 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 this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; @@ -299,10 +299,10 @@ interface BigUint64Array { // @type-options no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. - * @param predicate findLast calls predicate once for each element of the array, in descending + * @param predicate - findLast calls predicate once for each element of the array, in descending * order, until it finds one where predicate returns true. If such an element is found, findLast * immediately returns that element value. Otherwise, findLast returns undefined. - * @param thisArg If provided, it will be used as this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLast(predicate: (value: bigint, index: number, array: this) => value is S, thisArg?: any): S | undefined; @@ -311,10 +311,10 @@ interface BigUint64Array { // @type-options no-export /** * Returns the index of the last element in the array where predicate is true, and -1 * otherwise. - * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * @param predicate - findLastIndex calls predicate once for each element of the array, in descending * 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 this value for each invocation of + * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; diff --git a/packages/core-js-types/src/base/proposals/array-flat-map.d.ts b/packages/core-js-types/src/base/proposals/array-flat-map.d.ts index 81cac12771fc..d046a2d03f58 100644 --- a/packages/core-js-types/src/base/proposals/array-flat-map.d.ts +++ b/packages/core-js-types/src/base/proposals/array-flat-map.d.ts @@ -11,9 +11,9 @@ interface Array { // @type-options no-redefine * 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 callback A function that accepts up to three arguments. The flatMap method calls the + * @param callback - 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 this keyword can refer in the callback function. If + * @param thisArg - An object to which this keyword can refer in the callback function. If * thisArg is omitted, undefined is used as this value. */ flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): U[]; @@ -21,7 +21,7 @@ interface Array { // @type-options no-redefine /** * Returns a new array with all sub-array elements concatenated into it recursively up to the * specified depth. - * @param depth The maximum recursion depth + * @param depth - The maximum recursion depth */ flat(this: A, depth?: D): CoreJS.CoreJSFlatArray[]; } @@ -31,9 +31,9 @@ interface ReadonlyArray { // @type-options no-export * 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 callback A function that accepts up to three arguments. The flatMap method calls the + * @param callback - 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 this keyword can refer in the callback function. If + * @param thisArg - An object to which this keyword can refer in the callback function. If * thisArg is omitted, undefined is used as this value. */ flatMap(callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This): U[]; @@ -41,7 +41,7 @@ interface ReadonlyArray { // @type-options no-export /** * Returns a new array with all sub-array elements concatenated into it recursively up to the * specified depth. - * @param depth The maximum recursion depth + * @param depth - The maximum recursion depth */ flat(this: A, depth?: D): CoreJS.CoreJSFlatArray[]; } diff --git a/packages/core-js-types/src/base/proposals/array-from-async.d.ts b/packages/core-js-types/src/base/proposals/array-from-async.d.ts index a0eac4c32b63..5bd012b78002 100644 --- a/packages/core-js-types/src/base/proposals/array-from-async.d.ts +++ b/packages/core-js-types/src/base/proposals/array-from-async.d.ts @@ -7,17 +7,17 @@ interface ArrayConstructor { /** * Creates an array from an async iterator or iterable object. - * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. + * @param iterableOrArrayLike - An async iterator or array-like object to convert to an array. */ fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; // @type-options prefix-return-type /** * Creates an array from an async iterator or iterable object. * - * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. - * @param mapFn A mapping function to call on every element of iterableOrArrayLike. + * @param iterableOrArrayLike - An async iterator or array-like object to convert to an array. + * @param mapFn - A mapping function to call on every element of iterableOrArrayLike. * Each return value is awaited before being added to result array. - * @param thisArg Value of 'this' used when executing mapFn. + * @param thisArg - Value of 'this' used when executing mapFn. */ fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; // @type-options prefix-return-type } diff --git a/packages/core-js-types/src/base/proposals/array-grouping.d.ts b/packages/core-js-types/src/base/proposals/array-grouping.d.ts index c37f9ca26dbf..c5f5def164e3 100644 --- a/packages/core-js-types/src/base/proposals/array-grouping.d.ts +++ b/packages/core-js-types/src/base/proposals/array-grouping.d.ts @@ -8,8 +8,8 @@ interface ObjectConstructor { /** * 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. + * @param items - An iterable. + * @param keySelector - A callback which will be invoked for each item in items. */ groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Partial>; } @@ -17,8 +17,8 @@ interface ObjectConstructor { interface MapConstructor { /** * 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. + * @param items - An iterable. + * @param keySelector - A callback which will be invoked for each item in items. */ groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Map; // @type-options prefix-return-type } diff --git a/packages/core-js-types/src/base/proposals/array-includes.d.ts b/packages/core-js-types/src/base/proposals/array-includes.d.ts index 6700ccfd47e8..a9cae03d56bf 100644 --- a/packages/core-js-types/src/base/proposals/array-includes.d.ts +++ b/packages/core-js-types/src/base/proposals/array-includes.d.ts @@ -7,8 +7,8 @@ interface Array { // @type-options no-redefine /** * 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. + * @param searchElement - The element to search for. + * @param fromIndex - The position in this array at which to begin searching for searchElement. */ includes(searchElement: T, fromIndex?: number): boolean; } @@ -16,8 +16,8 @@ interface Array { // @type-options no-redefine interface ReadonlyArray { // @type-options no-export /** * 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. + * @param searchElement - The element to search for. + * @param fromIndex - The position in this array at which to begin searching for searchElement. */ includes(searchElement: T, fromIndex?: number): boolean; } @@ -25,8 +25,8 @@ interface ReadonlyArray { // @type-options no-export interface Int8Array { // @type-options no-export /** * 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. + * @param searchElement - The element to search for. + * @param fromIndex - The position in this array at which to begin searching for searchElement. */ includes(searchElement: number, fromIndex?: number): boolean; } @@ -34,8 +34,8 @@ interface Int8Array { // @type-options no-export interface Uint8Array { // @type-options no-export /** * 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. + * @param searchElement - The element to search for. + * @param fromIndex - The position in this array at which to begin searching for searchElement. */ includes(searchElement: number, fromIndex?: number): boolean; } @@ -43,8 +43,8 @@ interface Uint8Array { // @type-options no-export interface Uint8ClampedArray { // @type-options no-export /** * 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. + * @param searchElement - The element to search for. + * @param fromIndex - The position in this array at which to begin searching for searchElement. */ includes(searchElement: number, fromIndex?: number): boolean; } @@ -52,8 +52,8 @@ interface Uint8ClampedArray { // @type-options no-export interface Int16Array { // @type-options no-export /** * 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. + * @param searchElement - The element to search for. + * @param fromIndex - The position in this array at which to begin searching for searchElement. */ includes(searchElement: number, fromIndex?: number): boolean; } @@ -61,8 +61,8 @@ interface Int16Array { // @type-options no-export interface Uint16Array { // @type-options no-export /** * 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. + * @param searchElement - The element to search for. + * @param fromIndex - The position in this array at which to begin searching for searchElement. */ includes(searchElement: number, fromIndex?: number): boolean; } @@ -70,8 +70,8 @@ interface Uint16Array { // @type-options no-export interface Int32Array { // @type-options no-export /** * 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. + * @param searchElement - The element to search for. + * @param fromIndex - The position in this array at which to begin searching for searchElement. */ includes(searchElement: number, fromIndex?: number): boolean; } @@ -79,8 +79,8 @@ interface Int32Array { // @type-options no-export interface Uint32Array { // @type-options no-export /** * 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. + * @param searchElement - The element to search for. + * @param fromIndex - The position in this array at which to begin searching for searchElement. */ includes(searchElement: number, fromIndex?: number): boolean; } @@ -88,8 +88,8 @@ interface Uint32Array { // @type-options no-export interface Float32Array { // @type-options no-export /** * 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. + * @param searchElement - The element to search for. + * @param fromIndex - The position in this array at which to begin searching for searchElement. */ includes(searchElement: number, fromIndex?: number): boolean; } @@ -97,8 +97,8 @@ interface Float32Array { // @type-options no-export interface Float64Array { // @type-options no-export /** * 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. + * @param searchElement - The element to search for. + * @param fromIndex - The position in this array at which to begin searching for searchElement. */ includes(searchElement: number, fromIndex?: number): boolean; } @@ -106,8 +106,8 @@ interface Float64Array { // @type-options no-export interface BigInt64Array { // @type-options no-export /** * 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. + * @param searchElement - The element to search for. + * @param fromIndex - The position in this array at which to begin searching for searchElement. */ includes(searchElement: bigint, fromIndex?: number): boolean; } @@ -115,8 +115,8 @@ interface BigInt64Array { // @type-options no-export interface BigUint64Array { // @type-options no-export /** * 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. + * @param searchElement - The element to search for. + * @param fromIndex - The position in this array at which to begin searching for searchElement. */ includes(searchElement: bigint, fromIndex?: number): boolean; } diff --git a/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts b/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts index c886aa131f4a..736f9dbf2f1a 100644 --- a/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts +++ b/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts @@ -3,7 +3,7 @@ interface ArrayConstructor { // @type-options no-export /** * Determines whether an `value` is a `TemplateStringsArray` - * @param value + * @param value - The value to be checked * @returns `true` if `value` is a `TemplateStringsArray`, otherwise `false` */ isTemplateObject(value: any): value is TemplateStringsArray; diff --git a/packages/core-js-types/src/base/proposals/array-unique.d.ts b/packages/core-js-types/src/base/proposals/array-unique.d.ts index 097767680c86..6d8826bcec04 100644 --- a/packages/core-js-types/src/base/proposals/array-unique.d.ts +++ b/packages/core-js-types/src/base/proposals/array-unique.d.ts @@ -3,7 +3,7 @@ interface Array { // @type-options no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, + * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item * @returns A new `Array` with unique items */ @@ -13,7 +13,7 @@ interface Array { // @type-options no-redefine interface ReadonlyArray { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, + * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item * @returns A new `Array` with unique items */ @@ -23,7 +23,7 @@ interface ReadonlyArray { // @type-options no-export interface Int8Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, + * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item * @returns A new `Array` with unique items */ @@ -33,7 +33,7 @@ interface Int8Array { // @type-options no-export interface Uint8Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, + * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item * @returns A new `Array` with unique items */ @@ -43,7 +43,7 @@ interface Uint8Array { // @type-options no-export interface Uint8ClampedArray { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, + * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item * @returns A new `Array` with unique items */ @@ -53,7 +53,7 @@ interface Uint8ClampedArray { // @type-options no-export interface Int16Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, + * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item * @returns A new `Array` with unique items */ @@ -63,7 +63,7 @@ interface Int16Array { // @type-options no-export interface Uint16Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, + * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item * @returns A new `Array` with unique items */ @@ -73,7 +73,7 @@ interface Uint16Array { // @type-options no-export interface Int32Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, + * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item * @returns A new `Array` with unique items */ @@ -83,7 +83,7 @@ interface Int32Array { // @type-options no-export interface Uint32Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, + * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item * @returns A new `Array` with unique items */ @@ -93,7 +93,7 @@ interface Uint32Array { // @type-options no-export interface Float32Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, + * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item * @returns A new `Array` with unique items */ @@ -103,7 +103,7 @@ interface Float32Array { // @type-options no-export interface Float64Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, + * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item * @returns A new `Array` with unique items */ @@ -113,7 +113,7 @@ interface Float64Array { // @type-options no-export interface BigInt64Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, + * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item * @returns A new `Array` with unique items */ @@ -123,7 +123,7 @@ interface BigInt64Array { // @type-options no-export interface BigUint64Array { // @type-options no-export /** * Returns a new array with unique items, determined by the resolver function or property key - * @param resolver A function that resolves the value to check uniqueness against, + * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item * @returns A new `Array` with unique items */ diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index c13250b5a9d2..ae81238635fc 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -3,7 +3,7 @@ interface AsyncIteratorConstructor { /** * Creates an `AsyncIterator` from an iterable object - * @param iterable An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` + * @param iterable - An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` * @returns A new `AsyncIterator` instance */ from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; @@ -14,71 +14,71 @@ declare var AsyncIterator: AsyncIteratorConstructor; interface AsyncIterator { /** * Drops elements from the iterator until the limit is reached - * @param limit The number of elements to drop + * @param limit - The number of elements to drop * @returns A new `AsyncIterator` */ drop(limit: number): AsyncIteratorObject; /** * Check if every value generated by the iterator passes the `predicate` function. - * @param predicate A function that tests each element of the iterator + * @param predicate - A function that tests each element of the iterator * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` */ every(predicate: (value: T, index: number) => boolean): Promise; /** * Creates a new `AsyncIterator` that contains only the elements that pass the `predicate` function. - * @param predicate A function that tests each element of the iterator + * @param predicate - A function that tests each element of the iterator * @returns A new `AsyncIterator` */ filter(predicate: (value: T, index: number) => boolean): AsyncIteratorObject; /** * Finds the first element in the iterator that satisfies the `predicate` function. - * @param predicate A function that tests each element of the iterator + * @param predicate - A function that tests each element of the iterator * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` */ find(predicate: (value: T, index: number) => boolean): Promise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. - * @param mapper A function that transforms each element of the iterator + * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ flatMap(mapper: (value: T, index: number) => any): AsyncIteratorObject; /** * Executes a provided function once for each element in the iterator. - * @param callbackFn A function that is called for each element of the iterator + * @param callbackFn - A function that is called for each element of the iterator * @returns A `Promise` that resolves when all elements have been processed */ forEach(callbackFn: (value: T, index: number) => void): Promise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. - * @param mapper A function that transforms each element of the iterator + * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ map(mapper: (value: T, index: number) => any): AsyncIteratorObject; /** * Reduces the elements of the iterator to a single value using the `reducer` function. - * @param reducer A function that combines two elements of the iterator - * @param initialValue An optional initial value to start the reduction + * @param reducer - A function that combines two elements of the iterator + * @param initialValue - An optional initial value to start the reduction * @returns A `Promise` that resolves to the reduced value */ reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; /** * Checks if any value in the iterator matches a given `predicate` - * @param predicate A function that tests each element of the iterator + * @param predicate - A function that tests each element of the iterator * @returns A `Promise` that resolves to `true` if any element passes the `predicate`, otherwise `false` */ some(predicate: (value: T, index: number) => boolean): Promise; /** * Creates a new `AsyncIterator` that yields only the first `limit` elements from the original iterator. - * @param limit The maximum number of elements to take + * @param limit - The maximum number of elements to take * @returns A new `AsyncIterator` */ take(limit: number): AsyncIteratorObject; diff --git a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts index 07cb97f81b8f..d42ed20ab767 100644 --- a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts @@ -6,7 +6,7 @@ interface PromiseConstructor { /** * Takes an object of promises and returns a single Promise that resolves to an object * with the same keys and fulfilled values, or rejects as soon as any of the input promises rejects. - * @param promises An object of promises + * @param promises - An object of promises * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. */ allKeyed>>(promises: D): Promise <{ [k in keyof D]: Awaited }>; @@ -14,9 +14,9 @@ interface PromiseConstructor { /** * Takes an object whose values are promises and returns a single `Promise` that resolves * to an object with the same keys, after all of the input promises have settled. - * @param promises An object of promises + * @param promises - An object of promises * @returns A new Promise that resolves to an object with the same keys as the input object, - * where each key maps to the settlement result ({ status, value } or { status, reason }) of the corresponding promise. + * where each key maps to the settlement result (`{ status, value }` or `{ status, reason }`) of the corresponding promise. */ allSettledKeyed>>(promises: D): Promise <{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; } diff --git a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts index b1da2eb8e08b..369d82ebded1 100644 --- a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts +++ b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts @@ -12,7 +12,7 @@ interface Array { // @type-options no-redefine /** * Returns a copy of an array with its elements sorted. - * @param compareFn Function used to determine the order of the elements. It is expected to return + * @param compareFn - Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. * ```ts @@ -23,16 +23,16 @@ interface Array { // @type-options no-redefine /** * Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. - * @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 copied array in place of 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 copied array in place of the deleted elements. * @returns The copied array. */ toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; /** * Copies an array and removes elements while returning the remaining 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 start - The zero-based location in the array from which to start removing elements. + * @param deleteCount - The number of elements to remove. * @returns A copy of the original array with the remaining elements. */ toSpliced(start: number, deleteCount?: number): T[]; @@ -41,9 +41,9 @@ interface Array { // @type-options no-redefine * Copies an array, then overwrites the value at the provided index with the * given value. If the index is negative, then it replaces from the end * of the array. - * @param index The index of the value to overwrite. If the index is + * @param index - The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. - * @param value The value to write into the copied array. + * @param value - The value to write into the copied array. * @returns The copied array with the updated value. */ with(index: number, value: T): T[]; @@ -57,7 +57,7 @@ interface ReadonlyArray { // @type-options no-export /** * Returns a copy of an array with its elements sorted. - * @param compareFn Function used to determine the order of the elements. It is expected to return + * @param compareFn - Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. * ```ts @@ -68,16 +68,16 @@ interface ReadonlyArray { // @type-options no-export /** * Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. - * @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 copied array in place of 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 copied array in place of the deleted elements. * @returns The copied array. */ toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; /** * Copies an array and removes elements while returning the remaining 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 start - The zero-based location in the array from which to start removing elements. + * @param deleteCount - The number of elements to remove. * @returns A copy of the original array with the remaining elements. */ toSpliced(start: number, deleteCount?: number): T[]; @@ -86,9 +86,9 @@ interface ReadonlyArray { // @type-options no-export * Copies an array, then overwrites the value at the provided index with the * given value. If the index is negative, then it replaces from the end * of the array. - * @param index The index of the value to overwrite. If the index is + * @param index - The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. - * @param value The value to write into the copied array. + * @param value - The value to write into the copied array. * @returns The copied array with the updated value. */ with(index: number, value: T): T[]; @@ -102,7 +102,7 @@ interface Int8Array { // @type-options no-export /** * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return + * @param compareFn - Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts @@ -114,9 +114,9 @@ interface Int8Array { // @type-options no-export /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is + * @param index - The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. + * @param value - The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ with(index: number, value: number): Int8Array; @@ -130,7 +130,7 @@ interface Uint8Array { // @type-options no-export /** * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return + * @param compareFn - Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts @@ -142,9 +142,9 @@ interface Uint8Array { // @type-options no-export /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is + * @param index - The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. + * @param value - The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ with(index: number, value: number): Uint8Array; @@ -158,7 +158,7 @@ interface Uint8ClampedArray { // @type-options no-export /** * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return + * @param compareFn - Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts @@ -170,9 +170,9 @@ interface Uint8ClampedArray { // @type-options no-export /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is + * @param index - The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. + * @param value - The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ with(index: number, value: number): Uint8ClampedArray; @@ -186,7 +186,7 @@ interface Int16Array { // @type-options no-export /** * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return + * @param compareFn - Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts @@ -198,9 +198,9 @@ interface Int16Array { // @type-options no-export /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is + * @param index - The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. + * @param value - The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ with(index: number, value: number): Int16Array; @@ -214,7 +214,7 @@ interface Uint16Array { // @type-options no-export /** * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return + * @param compareFn - Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts @@ -226,9 +226,9 @@ interface Uint16Array { // @type-options no-export /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is + * @param index - The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. + * @param value - The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ with(index: number, value: number): Uint16Array; @@ -242,7 +242,7 @@ interface Int32Array { // @type-options no-export /** * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return + * @param compareFn - Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts @@ -254,9 +254,9 @@ interface Int32Array { // @type-options no-export /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is + * @param index - The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. + * @param value - The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ with(index: number, value: number): Int32Array; @@ -270,7 +270,7 @@ interface Uint32Array { // @type-options no-export /** * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return + * @param compareFn - Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts @@ -282,9 +282,9 @@ interface Uint32Array { // @type-options no-export /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is + * @param index - The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. + * @param value - The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ with(index: number, value: number): Uint32Array; @@ -298,7 +298,7 @@ interface Float32Array { // @type-options no-export /** * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return + * @param compareFn - Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts @@ -310,9 +310,9 @@ interface Float32Array { // @type-options no-export /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is + * @param index - The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. + * @param value - The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ with(index: number, value: number): Float32Array; @@ -326,7 +326,7 @@ interface Float64Array { // @type-options no-export /** * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return + * @param compareFn - Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts @@ -338,9 +338,9 @@ interface Float64Array { // @type-options no-export /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. If the index is + * @param index - The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. + * @param value - The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ with(index: number, value: number): Float64Array; @@ -354,7 +354,7 @@ interface BigInt64Array { // @type-options no-export /** * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return + * @param compareFn - Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts @@ -366,9 +366,9 @@ interface BigInt64Array { // @type-options no-export /** * Copies the array and inserts the given bigint at the provided index. - * @param index The index of the value to overwrite. If the index is + * @param index - The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. + * @param value - The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ with(index: number, value: bigint): BigInt64Array; @@ -382,7 +382,7 @@ interface BigUint64Array { // @type-options no-export /** * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return + * @param compareFn - Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts @@ -394,9 +394,9 @@ interface BigUint64Array { // @type-options no-export /** * Copies the array and inserts the given bigint at the provided index. - * @param index The index of the value to overwrite. If the index is + * @param index - The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. - * @param value The value to insert into the copied array. + * @param value - The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ with(index: number, value: bigint): BigUint64Array; diff --git a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts index f488fd7211b4..34d92e0824d0 100644 --- a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts @@ -4,18 +4,18 @@ interface MapConstructor { /** * Creates a new `Map` instance from an iterable or array-like object of [key, value] pairs. * Optionally, applies a mapping function to each pair. - * @param source Iterable or array-like object of [key, value] pairs. - * @param mapFn Function to call on every [key, value] pair before adding to the `Map`. - * @param thisArg Value to use as this when executing mapFn. - * @return A new `Map` instance. + * @param source - Iterable or array-like object of [key, value] pairs. + * @param mapFn - Function to call on every [key, value] pair before adding to the `Map`. + * @param thisArg - Value to use as this when executing mapFn. + * @returns A new `Map` instance. */ from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): Map; /** * Creates a new `Map` instance from a variable number of arguments, * where each pair of arguments is interpreted as a key and a value. - * @param items An even number of arguments representing key-value pairs. - * @return A new `Map` instance. + * @param items - An even number of arguments representing key-value pairs. + * @returns A new `Map` instance. */ of(...items: [K, V][]): Map; } @@ -26,18 +26,18 @@ interface SetConstructor { /** * Creates a new `Set` instance from an iterable or array-like object of [key, value] pairs. * Optionally, applies a mapping function to each pair. - * @param source Iterable or array-like object of [key, value] pairs. - * @param mapFn Function to call on every [key, value] pair before adding to the `Set`. - * @param thisArg Value to use as this when executing mapFn. - * @return A new `Set` instance. + * @param source - Iterable or array-like object of [key, value] pairs. + * @param mapFn - Function to call on every [key, value] pair before adding to the `Set`. + * @param thisArg - Value to use as this when executing mapFn. + * @returns A new `Set` instance. */ from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): Set; /** * Creates a new `Set` instance from a variable number of arguments, * where each pair of arguments is interpreted as a key and a value. - * @param items An even number of arguments representing key-value pairs. - * @return A new `Set` instance. + * @param items - An even number of arguments representing key-value pairs. + * @returns A new `Set` instance. */ of(...items: T[]): Set; } @@ -48,18 +48,18 @@ interface WeakMapConstructor { /** * Creates a new `WeakMap` instance from an iterable or array-like object of [key, value] pairs. * Optionally, applies a mapping function to each pair. - * @param source Iterable or array-like object of [key, value] pairs. - * @param mapFn Function to call on every [key, value] pair before adding to the `WeakMap`. - * @param thisArg Value to use as this when executing mapFn. - * @return A new `WeakMap` instance. + * @param source - Iterable or array-like object of [key, value] pairs. + * @param mapFn - Function to call on every [key, value] pair before adding to the `WeakMap`. + * @param thisArg - Value to use as this when executing mapFn. + * @returns A new `WeakMap` instance. */ from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): WeakMap; /** * Creates a new `WeakMap` instance from a variable number of arguments, * where each pair of arguments is interpreted as a key and a value. - * @param items An even number of arguments representing key-value pairs. - * @return A new `Weak` instance. + * @param items - An even number of arguments representing key-value pairs. + * @returns A new `Weak` instance. */ of(...items: [K, V][]): WeakMap; } @@ -70,18 +70,18 @@ interface WeakSetConstructor { /** * Creates a new `WeakSet` instance from an iterable or array-like object of [key, value] pairs. * Optionally, applies a mapping function to each pair. - * @param source Iterable or array-like object of [key, value] pairs. - * @param mapFn Function to call on every [key, value] pair before adding to the `WeakSet`. - * @param thisArg Value to use as this when executing mapFn. - * @return A new `WeakSet` instance. + * @param source - Iterable or array-like object of [key, value] pairs. + * @param mapFn - Function to call on every [key, value] pair before adding to the `WeakSet`. + * @param thisArg - Value to use as this when executing mapFn. + * @returns A new `WeakSet` instance. */ from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): WeakSet; /** * Creates a new `WeakSet` instance from a variable number of arguments, * where each pair of arguments is interpreted as a key and a value. - * @param items An even number of arguments representing key-value pairs. - * @return A new `WeakSet` instance. + * @param items - An even number of arguments representing key-value pairs. + * @returns A new `WeakSet` instance. */ of(...items: T[]): WeakSet; } diff --git a/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts index 039340d59ffb..e8e16f5841e3 100644 --- a/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts +++ b/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts @@ -4,7 +4,7 @@ interface DataView { // @type-options no-constructor /** * Reads an unsigned 8-bit integer at the specified byte offset from the DataView, * interpreting the byte as a clamped 8-bit unsigned value (same as Uint8ClampedArray). - * @param byteOffset The offset, in bytes, from the start of the DataView. + * @param byteOffset - The offset, in bytes, from the start of the DataView. * @returns The unsigned 8-bit integer at the given offset. */ getUint8Clamped(byteOffset: number): number; @@ -12,8 +12,8 @@ interface DataView { // @type-options no-constructor /** * Stores a value as an unsigned 8-bit integer at the specified byte offset in the DataView, * clamping the input to the 0–255 range and rounding to the nearest integer as per Uint8ClampedArray behavior. - * @param byteOffset The offset, in bytes, from the start of the DataView. - * @param value The value to store; it will be clamped to the range 0–255 and rounded to the nearest integer. + * @param byteOffset - The offset, in bytes, from the start of the DataView. + * @param value - The value to store; it will be clamped to the range 0–255 and rounded to the nearest integer. */ setUint8Clamped(byteOffset: number, value: number): void; } diff --git a/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts index af3220e4767d..5c1ab0eb9888 100644 --- a/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts @@ -52,15 +52,15 @@ interface DisposableStack { /** * Adds a disposable resource to the stack, returning the resource. - * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @param value - The resource to add. `null` and `undefined` will not be added, but will be returned. * @returns The provided {@link value}. */ use(value: T): T; /** * Adds a value and associated disposal callback as a resource to the stack. - * @param value The value to add. - * @param onDispose The callback to use in place of a `[Symbol.dispose]()` method. Will be invoked with `value` + * @param value - The value to add. + * @param onDispose - The callback to use in place of a `[Symbol.dispose]()` method. Will be invoked with `value` * as the first parameter. * @returns The provided {@link value}. */ @@ -128,15 +128,15 @@ interface AsyncDisposableStack { /** * Adds a disposable resource to the stack, returning the resource. - * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @param value - The resource to add. `null` and `undefined` will not be added, but will be returned. * @returns The provided {@link value}. */ use(value: T): T; /** * Adds a value and associated disposal callback as a resource to the stack. - * @param value The value to add. - * @param onDisposeAsync The callback to use in place of a `[Symbol.asyncDispose]()` method. Will be invoked with `value` + * @param value - The value to add. + * @param onDisposeAsync - The callback to use in place of a `[Symbol.asyncDispose]()` method. Will be invoked with `value` * as the first parameter. * @returns The provided {@link value}. */ diff --git a/packages/core-js-types/src/base/proposals/float16.d.ts b/packages/core-js-types/src/base/proposals/float16.d.ts index 8f791c2cf5f8..f99539b3de55 100644 --- a/packages/core-js-types/src/base/proposals/float16.d.ts +++ b/packages/core-js-types/src/base/proposals/float16.d.ts @@ -7,7 +7,7 @@ interface Math { // @type-options no-constructor /** * Returns the nearest half precision float representation of a number. - * @param x A numeric expression. + * @param x - A numeric expression. */ f16round(x: number): number; } @@ -16,16 +16,16 @@ interface DataView { // @type-options no-constructor /** * Gets the Float16 value at the specified byte offset from the start of the view. There is * no alignment constraint; multibyte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - * @param littleEndian If false or undefined, a big-endian value should be read. + * @param byteOffset - The place in the buffer at which the value should be retrieved. + * @param littleEndian - If false or undefined, a big-endian value should be read. */ getFloat16(byteOffset: number, littleEndian?: boolean): number; /** * Stores a Float16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written. + * @param byteOffset - The place in the buffer at which the value should be set. + * @param value - The value to set. + * @param littleEndian - If false or undefined, a big-endian value should be written. */ setFloat16(byteOffset: number, value: number, littleEndian?: boolean): void; } diff --git a/packages/core-js-types/src/base/proposals/function-demethodize.d.ts b/packages/core-js-types/src/base/proposals/function-demethodize.d.ts index 37568d4d18a8..d50d1d6f4da2 100644 --- a/packages/core-js-types/src/base/proposals/function-demethodize.d.ts +++ b/packages/core-js-types/src/base/proposals/function-demethodize.d.ts @@ -3,7 +3,7 @@ interface Function { // @type-options no-constructor /** * Creates a function that calls the original with its first argument as `this` and the rest as regular arguments. - * @returns {Function} A new function that applies the original function with its `this` set to the first argument. + * @returns A new function that applies the original function with its `this` set to the first argument. */ demethodize(this: (this: T, ...args: Args) => R): (thisArg: T, ...args: Args) => R; } diff --git a/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts b/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts index 6d83a8005baa..c5c121ed044c 100644 --- a/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts @@ -6,15 +6,15 @@ interface Iterator { /** * Yields arrays containing up to the specified number of elements * chunked from the source iterator. - * @param chunkSize The maximum number of elements per chunk. Must be a positive integer. + * @param chunkSize - The maximum number of elements per chunk. Must be a positive integer. * @returns An iterator yielding arrays of at most `chunkSize` elements from the source iterator. */ chunks(chunkSize: number): CoreJS.CoreJSIteratorObject; /** * Yields overlapping arrays (windows) of the given size from the iterator. - * @param windowSize The size of each window. Must be a positive integer. - * @param undersized 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. + * @param windowSize - The size of each window. Must be a positive integer. + * @param undersized - 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. * @returns An iterator yielding arrays of the specified window size. */ windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJS.CoreJSIteratorObject; diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts index bd9433a175e3..5300b83d9c25 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts @@ -10,54 +10,54 @@ declare global { interface Iterator { /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator. - * @param callbackfn A function that accepts up to two arguments to be used to transform values from the underlying iterator. + * @param callbackfn - A function that accepts up to two arguments to be used to transform values from the underlying iterator. */ map(callbackfn: (value: T, index: number) => U): CoreJSIteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. - * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. */ filter(predicate: (value: T, index: number) => value is S): CoreJSIteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. - * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. */ filter(predicate: (value: T, index: number) => unknown): CoreJSIteratorObject; /** * Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached. - * @param limit The maximum number of values to yield. + * @param limit - The maximum number of values to yield. */ take(limit: number): CoreJSIteratorObject; /** * Creates an iterator whose values are the values from this iterator after skipping the provided count. - * @param count The number of values to drop. + * @param count - The number of values to drop. */ drop(count: number): CoreJSIteratorObject; /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. - * @param callback A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. + * @param callback - A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. */ flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; // ts < 5.6 Iterable /** * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @param callbackfn - A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; /** * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. - * @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 a value from the iterator. + * @param callbackfn - A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; /** * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. - * @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 a value from the iterator. + * @param callbackfn - A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. */ reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; @@ -68,13 +68,13 @@ declare global { /** * Performs the specified action for each element in the iterator. - * @param callbackfn A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. + * @param callbackfn - A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. */ forEach(callbackfn: (value: T, index: number) => void): void; /** * Determines whether the specified callback function returns true for any element of this iterator. - * @param predicate A function that accepts up to two arguments. The `some` method calls + * @param predicate - A function that accepts up to two arguments. The `some` method calls * the predicate function for each element in this iterator until the predicate returns a value * true, or until the end of the iterator. */ @@ -82,7 +82,7 @@ declare global { /** * Determines whether all the members of this iterator satisfy the specified test. - * @param predicate A function that accepts up to two arguments. The every method calls + * @param predicate - A function that accepts up to two arguments. The every method calls * the predicate function for each element in this iterator until the predicate returns * false, or until the end of this iterator. */ @@ -91,7 +91,7 @@ declare global { /** * Returns the value of the first element in this iterator where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of this iterator, in + * @param predicate - find calls predicate once for each element of this iterator, in * 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. */ @@ -103,7 +103,7 @@ declare global { /** * Creates a native iterator from an iterator or iterable object. * Returns its input if the input already inherits from the built-in Iterator class. - * @param value An iterator or iterable object to convert a native iterator. + * @param value - An iterator or iterable object to convert a native iterator. */ from(value: Iterator | Iterable): CoreJSIteratorObject; } diff --git a/packages/core-js-types/src/base/proposals/iterator-join.d.ts b/packages/core-js-types/src/base/proposals/iterator-join.d.ts index 1564e6a8495e..29fc4f2dda57 100644 --- a/packages/core-js-types/src/base/proposals/iterator-join.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-join.d.ts @@ -3,7 +3,7 @@ interface Iterator { /** * Creates a string by concatenating all elements provided by the iterator, separated by the specified separator. - * @param separator + * @param separator - A string to separate each element. If omitted, the elements are separated by commas. */ join(separator?: unknown): string; } diff --git a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts index 9559fe9fb048..90d85a1fdada 100644 --- a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts @@ -10,8 +10,8 @@ interface IteratorConstructor { // @type-options no-extends /** * Takes an iterable of iterables and produces an iterable of arrays where position corresponds * to position in the passed iterable. - * @param iterables An Iterable of iterables. - * @param options Optional object: + * @param iterables - An Iterable of iterables. + * @param options - Optional object: * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. @@ -21,8 +21,8 @@ interface IteratorConstructor { // @type-options no-extends /** * takes an object whose values are iterables and produces an iterable of objects where keys. * correspond to keys in the passed object. - * @param record An object of iterables. - * @param options Optional object: + * @param record - An object of iterables. + * @param options - Optional object: * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. diff --git a/packages/core-js-types/src/base/proposals/iterator-range.d.ts b/packages/core-js-types/src/base/proposals/iterator-range.d.ts index 3dd51c6de211..d681df44e58a 100644 --- a/packages/core-js-types/src/base/proposals/iterator-range.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-range.d.ts @@ -9,9 +9,9 @@ interface IteratorRangeOptions { interface IteratorConstructor { // @type-options no-extends /** * Returns an iterator that generates a sequence of numbers or bigints within a range. - * @param start The starting value of the sequence. - * @param end The end value of the sequence (exclusive by default). - * @param options Optional object: + * @param start - The starting value of the sequence. + * @param end - The end value of the sequence (exclusive by default). + * @param options - Optional object: * - step: The difference between consecutive values (default is 1). * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of numbers or bigints. diff --git a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts index 3da5c0cc03f6..55410a65fc51 100644 --- a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts @@ -5,7 +5,7 @@ interface IteratorConstructor { // @type-options no-extends /** * Creates an iterator that sequentially yields values from the provided iterables. - * @param iterators The iterables to concatenate. + * @param iterators - The iterables to concatenate. * @returns An iterator yielding values from each input iterable in sequence. */ concat(...iterators: Iterable[]): CoreJS.CoreJSIteratorObject; diff --git a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts index 270afe8a1083..15229bf407ce 100644 --- a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts +++ b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts @@ -15,15 +15,16 @@ interface CoreJSRawJSON { // @type-options no-extends,no-prefix interface JSON { // @type-options no-constructor /** * Determines whether a value is a RawJSON object. - * @param value + * @param value - The value to check. + * @returns True if the value is a RawJSON object; otherwise, false. */ isRawJSON(value: any): value is CoreJSRawJSON; /** * Parses a JSON string, allowing the reviver function to access * the exact source text and position of each parsed value. - * @param text The JSON string to parse. - * @param reviver A function that transforms the results. It is called for each member of the object. + * @param text - The JSON string to parse. + * @param reviver - A function that transforms the results. It is called for each member of the object. * The function receives three arguments: the key, the value, and a context object * containing the source text and position. * @returns Parsed JavaScript value. @@ -32,7 +33,8 @@ interface JSON { // @type-options no-constructor /** * Creates a RawJSON object from a JSON string. - * @param value + * @param value - The JSON string. + * @returns A RawJSON object encapsulating the provided JSON string. */ rawJSON(value: string): CoreJSRawJSON; } diff --git a/packages/core-js-types/src/base/proposals/map-upsert.d.ts b/packages/core-js-types/src/base/proposals/map-upsert.d.ts index ec5915e4fd2c..45fe878a391f 100644 --- a/packages/core-js-types/src/base/proposals/map-upsert.d.ts +++ b/packages/core-js-types/src/base/proposals/map-upsert.d.ts @@ -3,8 +3,8 @@ interface Map { // @type-options no-redefine /** * Gets the value for the given key. If the key does not exist, inserts the provided value and returns it. - * @param key - * @param value + * @param key - The key to look up. + * @param value - The value to insert if the key does not exist. * @returns The existing or inserted value. */ getOrInsert(key: K, value: V): V; @@ -12,8 +12,8 @@ interface Map { // @type-options no-redefine /** * Gets the value for the given key. If the key does not exist, * computes the value using the provided callback function, inserts it, and returns it. - * @param key - * @param callbackFn A function that computes the value to insert if the key does not exist. + * @param key - The key to look up. + * @param callbackFn - A function that computes the value to insert if the key does not exist. * @returns The existing or computed and inserted value. */ getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; @@ -22,8 +22,8 @@ interface Map { // @type-options no-redefine interface WeakMap { // @type-options no-redefine /** * Gets the value for the given key. If the key does not exist, inserts the provided value and returns it. - * @param key - * @param value + * @param key - The key to look up. + * @param value - The value to insert if the key does not exist. * @returns The existing or inserted value. */ getOrInsert(key: K, value: V): V; @@ -31,8 +31,8 @@ interface WeakMap { // @type-options no-redefine /** * Gets the value for the given key. If the key does not exist, * computes the value using the provided callback function, inserts it, and returns it. - * @param key - * @param callbackFn A function that computes the value to insert if the key does not exist. + * @param key - The key to look up. + * @param callbackFn - A function that computes the value to insert if the key does not exist. * @returns The existing or computed and inserted value. */ getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; diff --git a/packages/core-js-types/src/base/proposals/math-sum.d.ts b/packages/core-js-types/src/base/proposals/math-sum.d.ts index 45b0fddc6220..13d257a31748 100644 --- a/packages/core-js-types/src/base/proposals/math-sum.d.ts +++ b/packages/core-js-types/src/base/proposals/math-sum.d.ts @@ -2,7 +2,7 @@ interface Math { // @type-options no-constructor /** * Returns the sum of all given values. - * @param items + * @param items - An iterable of numbers to sum. * @returns The sum of all given values. */ sumPrecise(items: Iterable): number; diff --git a/packages/core-js-types/src/base/proposals/number-clamp.d.ts b/packages/core-js-types/src/base/proposals/number-clamp.d.ts index 021463de0a47..f6c82c36adca 100644 --- a/packages/core-js-types/src/base/proposals/number-clamp.d.ts +++ b/packages/core-js-types/src/base/proposals/number-clamp.d.ts @@ -3,8 +3,8 @@ interface Number { // @type-options export-base-constructor /** * Clamps the number within the inclusive lower and upper bounds. - * @param lower - * @param upper + * @param lower - The lower bound. + * @param upper - The upper bound. * @returns The clamped number. */ clamp(lower: number, upper: number): number; diff --git a/packages/core-js-types/src/base/proposals/object-from-entries.d.ts b/packages/core-js-types/src/base/proposals/object-from-entries.d.ts index 1b764764712e..a47651b17412 100644 --- a/packages/core-js-types/src/base/proposals/object-from-entries.d.ts +++ b/packages/core-js-types/src/base/proposals/object-from-entries.d.ts @@ -7,13 +7,13 @@ interface ObjectConstructor { /** * 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. + * @param entries - An iterable object that contains key-value entries for properties and methods. */ fromEntries(entries: Iterable): { [k: string]: 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. + * @param entries - An iterable object that contains key-value entries for properties and methods. */ fromEntries(entries: Iterable): any; } diff --git a/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts b/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts index 53171639804e..d4827790665c 100644 --- a/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts +++ b/packages/core-js-types/src/base/proposals/object-get-own-property-descriptors.d.ts @@ -7,7 +7,7 @@ interface ObjectConstructor { /** * 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. + * @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/packages/core-js-types/src/base/proposals/object-values-entries.d.ts b/packages/core-js-types/src/base/proposals/object-values-entries.d.ts index 6030b53d54ad..12fb5ad4d235 100644 --- a/packages/core-js-types/src/base/proposals/object-values-entries.d.ts +++ b/packages/core-js-types/src/base/proposals/object-values-entries.d.ts @@ -7,23 +7,23 @@ interface ObjectConstructor { /** * Returns an array of values of the enumerable own 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. + * @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: { [s: string]: T; } | ArrayLike): T[]; /** * Returns an array of values of the enumerable own 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. + * @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: {}): any[]; /** * Returns an array of key/values of the enumerable own 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. + * @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: { [s: string]: T; } | ArrayLike): [string, T][]; /** * Returns an array of key/values of the enumerable own 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. + * @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][]; } diff --git a/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts index d919489e5b88..ab51fdf89fe9 100644 --- a/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts @@ -10,7 +10,7 @@ interface PromiseConstructor { /** * Creates a Promise that is resolved with an array of results when all * of the provided Promises resolve or reject. - * @param values An array of Promises. + * @param values - An array of Promises. * @returns A new Promise. */ allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJS.CoreJSPromiseSettledResult>; }>; // @type-options prefix-return-type @@ -18,7 +18,7 @@ interface PromiseConstructor { /** * Creates a Promise that is resolved with an array of results when all * of the provided Promises resolve or reject. - * @param values An array of Promises. + * @param values - An array of Promises. * @returns A new Promise. */ allSettled(values: Iterable>): Promise>[]>; // @type-options prefix-return-type diff --git a/packages/core-js-types/src/base/proposals/promise-any.d.ts b/packages/core-js-types/src/base/proposals/promise-any.d.ts index 62f71b9577a0..720b443ebfa8 100644 --- a/packages/core-js-types/src/base/proposals/promise-any.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-any.d.ts @@ -7,14 +7,14 @@ interface PromiseConstructor { /** * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. - * @param values An array or iterable of Promises. + * @param values - An array or iterable of Promises. * @returns A new Promise. */ any(values: T): Promise>; // @type-options prefix-return-type /** * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. - * @param values An array or iterable of Promises. + * @param values - An array or iterable of Promises. * @returns A new Promise. */ any(values: Iterable>): Promise>; // @type-options prefix-return-type diff --git a/packages/core-js-types/src/base/proposals/promise-finally.d.ts b/packages/core-js-types/src/base/proposals/promise-finally.d.ts index 6c73d23c10b4..e7410569e361 100644 --- a/packages/core-js-types/src/base/proposals/promise-finally.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-finally.d.ts @@ -8,7 +8,7 @@ interface Promise { /** * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The * resolved value cannot be modified from the callback. - * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). + * @param onfinally - The callback to execute when the Promise is settled (fulfilled or rejected). * @returns A Promise for the completion of the callback. */ finally(onfinally?: (() => void) | undefined | null): Promise; // @type-options prefix-return-type diff --git a/packages/core-js-types/src/base/proposals/promise-try.d.ts b/packages/core-js-types/src/base/proposals/promise-try.d.ts index 178a3d3de67d..adda8b3f5269 100644 --- a/packages/core-js-types/src/base/proposals/promise-try.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-try.d.ts @@ -9,9 +9,9 @@ interface PromiseConstructor { * Takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result * in a Promise. * - * @param callbackFn A function that is called synchronously. It can do anything: either return + * @param callbackFn - A function that is called synchronously. It can do anything: either return * a value, throw an error, or return a promise. - * @param args Additional arguments, that will be passed to the callback. + * @param args - Additional arguments, that will be passed to the callback. * * @returns A Promise that is: * - Already fulfilled, if the callback synchronously returns a value. diff --git a/packages/core-js-types/src/base/proposals/regexp-escaping.d.ts b/packages/core-js-types/src/base/proposals/regexp-escaping.d.ts index 2e396fb86b51..cb71a638fc0a 100644 --- a/packages/core-js-types/src/base/proposals/regexp-escaping.d.ts +++ b/packages/core-js-types/src/base/proposals/regexp-escaping.d.ts @@ -3,7 +3,7 @@ interface RegExpConstructor { /** * Escapes a string to be used in a regular expression. - * @param string + * @param string - The string to escape. * @returns The escaped string. */ escape(string: string): string; diff --git a/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts index d163898f2484..b657a7a19a5a 100644 --- a/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/base/proposals/relative-indexing-method.d.ts @@ -8,7 +8,7 @@ interface String { /** * Returns a new String consisting of the single UTF-16 code unit located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): string | undefined; } @@ -16,7 +16,7 @@ interface String { interface Array { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): T | undefined; } @@ -24,7 +24,7 @@ interface Array { interface ReadonlyArray { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): T | undefined; } @@ -32,7 +32,7 @@ interface ReadonlyArray { interface Int8Array { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): number | undefined; } @@ -40,7 +40,7 @@ interface Int8Array { interface Uint8Array { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): number | undefined; } @@ -48,7 +48,7 @@ interface Uint8Array { interface Uint8ClampedArray { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): number | undefined; } @@ -56,7 +56,7 @@ interface Uint8ClampedArray { interface Int16Array { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): number | undefined; } @@ -64,7 +64,7 @@ interface Int16Array { interface Uint16Array { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): number | undefined; } @@ -72,7 +72,7 @@ interface Uint16Array { interface Int32Array { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): number | undefined; } @@ -80,7 +80,7 @@ interface Int32Array { interface Uint32Array { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): number | undefined; } @@ -88,7 +88,7 @@ interface Uint32Array { interface Float32Array { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): number | undefined; } @@ -96,7 +96,7 @@ interface Float32Array { interface Float64Array { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): number | undefined; } @@ -104,7 +104,7 @@ interface Float64Array { interface BigInt64Array { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): bigint | undefined; } @@ -112,7 +112,7 @@ interface BigInt64Array { interface BigUint64Array { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): bigint | undefined; } diff --git a/packages/core-js-types/src/base/proposals/string-cooked.d.ts b/packages/core-js-types/src/base/proposals/string-cooked.d.ts index 955d431908c1..fe8d714a2e16 100644 --- a/packages/core-js-types/src/base/proposals/string-cooked.d.ts +++ b/packages/core-js-types/src/base/proposals/string-cooked.d.ts @@ -3,8 +3,8 @@ interface StringConstructor { /** * Processes a template literal, interpreting escape sequences. - * @param template Array of string literals. - * @param substitutions The substitutions for the template literal. + * @param template - Array of string literals. + * @param substitutions - The substitutions for the template literal. * @returns The processed string with escape sequences interpreted. */ cooked(template: readonly string[], ...substitutions: any[]): string; diff --git a/packages/core-js-types/src/base/proposals/string-dedent.d.ts b/packages/core-js-types/src/base/proposals/string-dedent.d.ts index 44cbb8383e7c..e075cea7ee0d 100644 --- a/packages/core-js-types/src/base/proposals/string-dedent.d.ts +++ b/packages/core-js-types/src/base/proposals/string-dedent.d.ts @@ -6,8 +6,8 @@ interface StringConstructor { /** * Template tag that removes common leading whitespace from every line in the resulting string, * preserving relative indentation and blank lines. - * @param template The template strings array or function. - * @param values Values to be interpolated into the template string. + * @param template - The template strings array or function. + * @param values - Values to be interpolated into the template string. * @returns The dedented string. */ dedent(template: { raw: readonly string[] }, ...values: any[]): string; diff --git a/packages/core-js-types/src/base/proposals/string-match-all.d.ts b/packages/core-js-types/src/base/proposals/string-match-all.d.ts index 8fc417ec2270..68287f3be217 100644 --- a/packages/core-js-types/src/base/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/base/proposals/string-match-all.d.ts @@ -12,7 +12,7 @@ interface String { /** * Matches a string with a regular expression, and returns an iterable of matches * containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. + * @param regexp - A variable name or string literal containing the regular expression pattern and flags. */ matchAll(regexp: RegExp): RegExpStringIterator; } diff --git a/packages/core-js-types/src/base/proposals/string-padding.d.ts b/packages/core-js-types/src/base/proposals/string-padding.d.ts index 44f082fdeaa7..5530217e16c1 100644 --- a/packages/core-js-types/src/base/proposals/string-padding.d.ts +++ b/packages/core-js-types/src/base/proposals/string-padding.d.ts @@ -9,10 +9,10 @@ interface String { // @type-options no-redefine * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. * The padding is applied from the start (left) of the current string. * - * @param maxLength The length of the resulting string once the current string has been padded. + * @param maxLength - The length of the resulting string once the current string has been padded. * If this parameter is smaller than the current string's length, the current string will be returned as it is. * - * @param fillString The string to pad the current string with. + * @param fillString - The string to pad the current string with. * If this string is too long, it will be truncated and the left-most part will be applied. * The default value for this parameter is " " (U+0020). */ @@ -22,10 +22,10 @@ interface String { // @type-options no-redefine * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. * The padding is applied from the end (right) of the current string. * - * @param maxLength The length of the resulting string once the current string has been padded. + * @param maxLength - The length of the resulting string once the current string has been padded. * If this parameter is smaller than the current string's length, the current string will be returned as it is. * - * @param fillString The string to pad the current string with. + * @param fillString - The string to pad the current string with. * If this string is too long, it will be truncated and the left-most part will be applied. * The default value for this parameter is " " (U+0020). */ diff --git a/packages/core-js-types/src/base/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/proposals/string-replace-all.d.ts index 4a8ff7d6b96d..afcf2458b660 100644 --- a/packages/core-js-types/src/base/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/base/proposals/string-replace-all.d.ts @@ -7,15 +7,15 @@ interface String { // @type-options no-redefine /** * Replace all instances of a substring in a string, using a regular expression or search string. - * @param searchValue A string to search for. - * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + * @param searchValue - A string to search for. + * @param replaceValue - A string containing the text to replace for every successful match of searchValue in this string. */ replaceAll(searchValue: string | RegExp, replaceValue: string): string; /** * Replace all instances of a substring in a string, using a regular expression or search string. - * @param searchValue A string to search for. - * @param replacer A function that returns the replacement text. + * @param searchValue - A string to search for. + * @param replacer - A function that returns the replacement text. */ replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } diff --git a/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts b/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts index d842ff0bd6cf..29db7391b64c 100644 --- a/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts +++ b/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts @@ -3,13 +3,13 @@ interface SymbolConstructor { /** * Determines whether the given value is a registered symbol. - * @param value + * @param value - The value to check. */ isRegisteredSymbol(value: any): boolean; /** * Determines whether the given value is a well-known symbol. - * @param value + * @param value - The value to check. */ isWellKnownSymbol(value: any): boolean; } diff --git a/packages/core-js-types/src/base/pure/common/reflect.d.ts b/packages/core-js-types/src/base/pure/common/reflect.d.ts index 7a5c15638da1..2d852ad8d462 100644 --- a/packages/core-js-types/src/base/pure/common/reflect.d.ts +++ b/packages/core-js-types/src/base/pure/common/reflect.d.ts @@ -7,9 +7,9 @@ declare namespace CoreJS { /** * Calls the function with the specified object as the this value * and the elements of specified array as the arguments. - * @param target The function to call. - * @param thisArgument The object to be used as the this object. - * @param argumentsList An array of argument values to be passed to the function. + * @param target - The function to call. + * @param thisArgument - The object to be used as the this object. + * @param argumentsList - An array of argument values to be passed to the function. */ apply( target: (this: T, ...args: A) => R, @@ -21,9 +21,9 @@ declare namespace CoreJS { /** * Constructs the target with the elements of specified array as the arguments * and the specified constructor as the `new.target` value. - * @param target The constructor to invoke. - * @param argumentsList An array of argument values to be passed to the constructor. - * @param newTarget The constructor to be used as the `new.target` object. + * @param target - The constructor to invoke. + * @param argumentsList - An array of argument values to be passed to the constructor. + * @param newTarget - The constructor to be used as the `new.target` object. */ construct( target: new (...args: A) => R, @@ -34,26 +34,26 @@ declare namespace CoreJS { /** * Adds a property to an object, or modifies attributes of an existing property. - * @param target Object on which to add or modify the property. This can be a native JavaScript object + * @param target - 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 propertyKey The property name. - * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + * @param propertyKey - The property name. + * @param attributes - Descriptor for the property. It can be for a data property or an accessor property. */ defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor & ThisType): boolean; /** * Removes a property from an object, equivalent to `delete target[propertyKey]`, * except it won't throw if `target[propertyKey]` is non-configurable. - * @param target Object from which to remove the own property. - * @param propertyKey The property name. + * @param target - Object from which to remove the own property. + * @param propertyKey - The property name. */ deleteProperty(target: object, propertyKey: PropertyKey): boolean; /** * Gets the property of target, equivalent to `target[propertyKey]` when `receiver === target`. - * @param target Object that contains the property on itself or in its prototype chain. - * @param propertyKey The property name. - * @param receiver The reference to use as the `this` value in the getter function, + * @param target - Object that contains the property on itself or in its prototype chain. + * @param propertyKey - The property name. + * @param receiver - The reference to use as the `this` value in the getter function, * if `target[propertyKey]` is an accessor property. */ get( @@ -65,8 +65,8 @@ declare namespace CoreJS { /** * 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 target Object that contains the property. - * @param propertyKey The property name. + * @param target - Object that contains the property. + * @param propertyKey - The property name. */ getOwnPropertyDescriptor( target: T, @@ -75,42 +75,42 @@ declare namespace CoreJS { /** * Returns the prototype of an object. - * @param target The object that references the prototype. + * @param target - The object that references the prototype. */ getPrototypeOf(target: object): object | null; /** * Equivalent to `propertyKey in target`. - * @param target Object that contains the property on itself or in its prototype chain. - * @param propertyKey Name of the property. + * @param target - Object that contains the property on itself or in its prototype chain. + * @param propertyKey - Name of the property. */ has(target: object, propertyKey: PropertyKey): boolean; /** * Returns a value that indicates whether new properties can be added to an object. - * @param target Object to test. + * @param target - Object to test. */ isExtensible(target: object): boolean; /** * Returns the string and symbol keys 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. - * @param target Object that contains the own properties. + * @param target - Object that contains the own properties. */ ownKeys(target: object): (string | symbol)[]; /** * Prevents the addition of new properties to an object. - * @param target Object to make non-extensible. - * @return Whether the object has been made non-extensible. + * @param target - Object to make non-extensible. + * @returns Whether the object has been made non-extensible. */ preventExtensions(target: object): boolean; /** * Sets the property of target, equivalent to `target[propertyKey] = value` when `receiver === target`. - * @param target Object that contains the property on itself or in its prototype chain. - * @param propertyKey Name of the property. - * @param receiver The reference to use as the `this` value in the setter function, + * @param target - Object that contains the property on itself or in its prototype chain. + * @param propertyKey - Name of the property. + * @param receiver - The reference to use as the `this` value in the setter function, * if `target[propertyKey]` is an accessor property. */ set( @@ -123,9 +123,9 @@ declare namespace CoreJS { /** * Sets the prototype of a specified object o to object proto or null. - * @param target The object to change its prototype. - * @param proto The value of the new prototype or null. - * @return Whether setting the prototype was successful. + * @param target - The object to change its prototype. + * @param proto - The value of the new prototype or null. + * @returns Whether setting the prototype was successful. */ setPrototypeOf(target: object, proto: object | null): boolean; } diff --git a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts index 5184ac8e93b8..4cebdda161bd 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts @@ -6,7 +6,7 @@ declare namespace CoreJS { /** * Creates a new Promise. - * @param executor A callback used to initialize the promise. This callback is passed two arguments: + * @param executor - A callback used to initialize the promise. This callback is passed two arguments: * a resolve callback used to resolve the promise with a value or the result of another promise, * and a reject callback used to reject the promise with a provided reason or error. */ @@ -15,7 +15,7 @@ declare namespace CoreJS { /** * Creates a Promise that is resolved with an array of results when all of the provided Promises * resolve, or rejected when any Promise is rejected. - * @param values An array of Promises. + * @param values - An array of Promises. * @returns A new Promise. */ all(values: T): CoreJSPromise<{ -readonly [P in keyof T]: Awaited; }>; @@ -23,14 +23,14 @@ declare namespace CoreJS { /** * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved * or rejected. - * @param values An array of Promises. + * @param values - An array of Promises. * @returns A new Promise. */ race(values: T): CoreJSPromise>; /** * Creates a new rejected promise for the provided reason. - * @param reason The reason the promise was rejected. + * @param reason - The reason the promise was rejected. * @returns A new rejected Promise. */ reject(reason?: any): CoreJSPromise; @@ -42,7 +42,7 @@ declare namespace CoreJS { resolve(): CoreJSPromise; /** * Creates a new resolved promise for the provided value. - * @param value A promise. + * @param value - A promise. * @returns A promise whose internal state matches the provided promise. */ resolve(value: T | PromiseLike): CoreJSPromise>; diff --git a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts index f44beae65df9..1e8eee89bce4 100644 --- a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts @@ -14,17 +14,17 @@ declare namespace CoreJS { /** * Creates a new `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. - * @param newByteLength If provided, specifies the `byteLength` of the new `ArrayBuffer` - * @throws {RangeError} If this `ArrayBuffer` is resizable and newByteLength is greater than the `maxByteLength` of this `ArrayBuffer` - * @throws {TypeError} If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @param newByteLength - If provided, specifies the `byteLength` of the new `ArrayBuffer` + * @throws `RangeError` If this `ArrayBuffer` is resizable and newByteLength is greater than the `maxByteLength` of this `ArrayBuffer` + * @throws `TypeError` If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations * @returns A new `ArrayBuffer` object */ transfer(newByteLength?: number): CoreJSArrayBuffer; /** * Creates a new non-resizable `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. - * @param newByteLength If provided, specifies the `byteLength` of the new `ArrayBuffer` - * @throws {TypeError} If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @param newByteLength - If provided, specifies the `byteLength` of the new `ArrayBuffer` + * @throws `TypeError` If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations * @returns A new `ArrayBuffer` object */ transferToFixedLength(newByteLength?: number): CoreJSArrayBuffer; diff --git a/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts b/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts index 4f1c3e5b8a1e..57013547682f 100644 --- a/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts @@ -19,23 +19,23 @@ declare namespace CoreJS { export interface CoreJSArrayConstructor extends ArrayConstructorBase { /** * Creates an array from an async iterator or iterable object. - * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. + * @param iterableOrArrayLike - An async iterator or array-like object to convert to an array. */ fromAsync(iterableOrArrayLike: CoreJSAsyncIterable | Iterable> | ArrayLike>): CoreJSPromise; /** * Creates an array from an async iterator or iterable object. * - * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. - * @param mapFn A mapping function to call on every element of iterableOrArrayLike. + * @param iterableOrArrayLike - An async iterator or array-like object to convert to an array. + * @param mapFn - A mapping function to call on every element of iterableOrArrayLike. * Each return value is awaited before being added to result array. - * @param thisArg Value of 'this' used when executing mapFn. + * @param thisArg - Value of 'this' used when executing mapFn. */ fromAsync(iterableOrArrayLike: CoreJSAsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): CoreJSPromise[]>; /** * Determines whether an `value` is a `TemplateStringsArray` - * @param value + * @param value - The value to be checked * @returns `true` if `value` is a `TemplateStringsArray`, otherwise `false` */ isTemplateObject(value: any): value is TemplateStringsArray; diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index 9e7034db0147..00d4e7e70f18 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -11,7 +11,7 @@ declare namespace CoreJS { export interface CoreJSAsyncIteratorConstructor { /** * Creates an `AsyncIterator` from an iterable object - * @param iterable An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` + * @param iterable - An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` * @returns A new `AsyncIterator` instance */ from(iterable: CoreJSAsyncIterable | Iterable | CoreJSAsyncIteratorObject): CoreJSAsyncIteratorObject; @@ -21,71 +21,71 @@ declare namespace CoreJS { /** * Drops elements from the iterator until the limit is reached - * @param limit The number of elements to drop + * @param limit - The number of elements to drop * @returns A new `AsyncIterator` */ drop(limit: number): CoreJSAsyncIteratorObject; /** * Check if every value generated by the iterator passes the `predicate` function. - * @param predicate A function that tests each element of the iterator + * @param predicate - A function that tests each element of the iterator * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` */ every(predicate: (value: T, index: number) => boolean): CoreJSPromise; /** * Creates a new `AsyncIterator` that contains only the elements that pass the `predicate` function. - * @param predicate A function that tests each element of the iterator + * @param predicate - A function that tests each element of the iterator * @returns A new `AsyncIterator` */ filter(predicate: (value: T, index: number) => boolean): CoreJSAsyncIteratorObject; /** * Finds the first element in the iterator that satisfies the `predicate` function. - * @param predicate A function that tests each element of the iterator + * @param predicate - A function that tests each element of the iterator * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` */ find(predicate: (value: T, index: number) => boolean): CoreJSPromise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. - * @param mapper A function that transforms each element of the iterator + * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ flatMap(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorObject; /** * Executes a provided function once for each element in the iterator. - * @param callbackFn A function that is called for each element of the iterator + * @param callbackFn - A function that is called for each element of the iterator * @returns A `Promise` that resolves when all elements have been processed */ forEach(callbackFn: (value: T, index: number) => void): CoreJSPromise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. - * @param mapper A function that transforms each element of the iterator + * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ map(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorObject; /** * Reduces the elements of the iterator to a single value using the `reducer` function. - * @param reducer A function that combines two elements of the iterator - * @param initialValue An optional initial value to start the reduction + * @param reducer - A function that combines two elements of the iterator + * @param initialValue - An optional initial value to start the reduction * @returns A `Promise` that resolves to the reduced value */ reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): CoreJSPromise; /** * Checks if any value in the iterator matches a given `predicate` - * @param predicate A function that tests each element of the iterator + * @param predicate - A function that tests each element of the iterator * @returns A `Promise` that resolves to `true` if any element passes the `predicate`, otherwise `false` */ some(predicate: (value: T, index: number) => boolean): CoreJSPromise; /** * Creates a new `AsyncIterator` that yields only the first `limit` elements from the original iterator. - * @param limit The maximum number of elements to take + * @param limit - The maximum number of elements to take * @returns A new `AsyncIterator` */ take(limit: number): CoreJSAsyncIteratorObject; diff --git a/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts index 9aa39f74fcaa..1e94c9d386fb 100644 --- a/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts @@ -10,7 +10,7 @@ declare namespace CoreJS { /** * Takes an object of promises and returns a single Promise that resolves to an object * with the same keys and fulfilled values, or rejects as soon as any of the input promises rejects. - * @param promises An object of promises + * @param promises - An object of promises * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. */ allKeyed>>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: Awaited }>; @@ -18,9 +18,9 @@ declare namespace CoreJS { /** * Takes an object whose values are promises and returns a single `Promise` that resolves * to an object with the same keys, after all of the input promises have settled. - * @param promises An object of promises + * @param promises - An object of promises * @returns A new Promise that resolves to an object with the same keys as the input object, - * where each key maps to the settlement result ({ status, value } or { status, reason }) of the corresponding promise. + * where each key maps to the settlement result (`{ status, value }` or `{ status, reason }`) of the corresponding promise. */ allSettledKeyed>>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; } diff --git a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts index 026690b54ed6..01666876bfb3 100644 --- a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts @@ -12,18 +12,18 @@ declare namespace CoreJS { /** * Creates a new `Map` instance from an iterable or array-like object of [key, value] pairs. * Optionally, applies a mapping function to each pair. - * @param source Iterable or array-like object of [key, value] pairs. - * @param mapFn Function to call on every [key, value] pair before adding to the `Map`. - * @param thisArg Value to use as this when executing mapFn. - * @return A new `Map` instance. + * @param source - Iterable or array-like object of [key, value] pairs. + * @param mapFn - Function to call on every [key, value] pair before adding to the `Map`. + * @param thisArg - Value to use as this when executing mapFn. + * @returns A new `Map` instance. */ from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): CoreJS.CoreJSMap; /** * Creates a new `Map` instance from a variable number of arguments, * where each pair of arguments is interpreted as a key and a value. - * @param items An even number of arguments representing key-value pairs. - * @return A new `Map` instance. + * @param items - An even number of arguments representing key-value pairs. + * @returns A new `Map` instance. */ of(...items: [K, V][]): CoreJS.CoreJSMap; } @@ -34,18 +34,18 @@ declare namespace CoreJS { /** * Creates a new `Set` instance from an iterable or array-like object of [key, value] pairs. * Optionally, applies a mapping function to each pair. - * @param source Iterable or array-like object of [key, value] pairs. - * @param mapFn Function to call on every [key, value] pair before adding to the `Set`. - * @param thisArg Value to use as this when executing mapFn. - * @return A new `Set` instance. + * @param source - Iterable or array-like object of [key, value] pairs. + * @param mapFn - Function to call on every [key, value] pair before adding to the `Set`. + * @param thisArg - Value to use as this when executing mapFn. + * @returns A new `Set` instance. */ from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): CoreJS.CoreJSSet; /** * Creates a new `Set` instance from a variable number of arguments, * where each pair of arguments is interpreted as a key and a value. - * @param items An even number of arguments representing key-value pairs. - * @return A new `Set` instance. + * @param items - An even number of arguments representing key-value pairs. + * @returns A new `Set` instance. */ of(...items: T[]): CoreJS.CoreJSSet; } @@ -56,18 +56,18 @@ declare namespace CoreJS { /** * Creates a new `WeakMap` instance from an iterable or array-like object of [key, value] pairs. * Optionally, applies a mapping function to each pair. - * @param source Iterable or array-like object of [key, value] pairs. - * @param mapFn Function to call on every [key, value] pair before adding to the `WeakMap`. - * @param thisArg Value to use as this when executing mapFn. - * @return A new `WeakMap` instance. + * @param source - Iterable or array-like object of [key, value] pairs. + * @param mapFn - Function to call on every [key, value] pair before adding to the `WeakMap`. + * @param thisArg - Value to use as this when executing mapFn. + * @returns A new `WeakMap` instance. */ from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): CoreJS.CoreJSWeakMap; /** * Creates a new `WeakMap` instance from a variable number of arguments, * where each pair of arguments is interpreted as a key and a value. - * @param items An even number of arguments representing key-value pairs. - * @return A new `Weak` instance. + * @param items - An even number of arguments representing key-value pairs. + * @returns A new `Weak` instance. */ of(...items: [K, V][]): CoreJS.CoreJSWeakMap; } @@ -78,18 +78,18 @@ declare namespace CoreJS { /** * Creates a new `WeakSet` instance from an iterable or array-like object of [key, value] pairs. * Optionally, applies a mapping function to each pair. - * @param source Iterable or array-like object of [key, value] pairs. - * @param mapFn Function to call on every [key, value] pair before adding to the `WeakSet`. - * @param thisArg Value to use as this when executing mapFn. - * @return A new `WeakSet` instance. + * @param source - Iterable or array-like object of [key, value] pairs. + * @param mapFn - Function to call on every [key, value] pair before adding to the `WeakSet`. + * @param thisArg - Value to use as this when executing mapFn. + * @returns A new `WeakSet` instance. */ from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): CoreJS.CoreJSWeakSet; /** * Creates a new `WeakSet` instance from a variable number of arguments, * where each pair of arguments is interpreted as a key and a value. - * @param items An even number of arguments representing key-value pairs. - * @return A new `WeakSet` instance. + * @param items - An even number of arguments representing key-value pairs. + * @returns A new `WeakSet` instance. */ of(...items: T[]): CoreJS.CoreJSWeakSet; } diff --git a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts index 6931268116fb..4f6c020fb91d 100644 --- a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts @@ -53,15 +53,15 @@ declare namespace CoreJS { /** * Adds a disposable resource to the stack, returning the resource. - * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @param value - The resource to add. `null` and `undefined` will not be added, but will be returned. * @returns The provided {@link value}. */ use(value: T): T; /** * Adds a value and associated disposal callback as a resource to the stack. - * @param value The value to add. - * @param onDispose The callback to use in place of a `[CoreJSSymbol.dispose]()` method. Will be invoked with `value` + * @param value - The value to add. + * @param onDispose - The callback to use in place of a `[CoreJSSymbol.dispose]()` method. Will be invoked with `value` * as the first parameter. * @returns The provided {@link value}. */ @@ -129,15 +129,15 @@ declare namespace CoreJS { /** * Adds a disposable resource to the stack, returning the resource. - * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @param value - The resource to add. `null` and `undefined` will not be added, but will be returned. * @returns The provided {@link value}. */ use(value: T): T; /** * Adds a value and associated disposal callback as a resource to the stack. - * @param value The value to add. - * @param onDisposeAsync The callback to use in place of a `[CoreJSSymbol.asyncDispose]()` method. Will be invoked with `value` + * @param value - The value to add. + * @param onDisposeAsync - The callback to use in place of a `[CoreJSSymbol.asyncDispose]()` method. Will be invoked with `value` * as the first parameter. * @returns The provided {@link value}. */ diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 7fd6aa97d0ca..27b05913b0dd 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -42,8 +42,8 @@ declare namespace CoreJS { interface CoreJSPromiseLike { /** * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. + * @param onfulfilled - The callback to execute when the Promise is resolved. + * @param onrejected - The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ then(onfulfilled?: ((value: T) => TResult1 | CoreJSPromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | CoreJSPromiseLike) | undefined | null): CoreJSPromiseLike; @@ -67,69 +67,69 @@ declare namespace CoreJS { /** * Yields arrays containing up to the specified number of elements * chunked from the source iterator. - * @param chunkSize The maximum number of elements per chunk. Must be a positive integer. + * @param chunkSize - The maximum number of elements per chunk. Must be a positive integer. * @returns An iterator yielding arrays of at most `chunkSize` elements from the source iterator. */ chunks(chunkSize: number): CoreJSIteratorObject; /** * Yields overlapping arrays (windows) of the given size from the iterator. - * @param windowSize The size of each window. Must be a positive integer. - * @param undersized 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. + * @param windowSize - The size of each window. Must be a positive integer. + * @param undersized - 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. * @returns An iterator yielding arrays of the specified window size. */ windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJSIteratorObject; /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator. - * @param callbackfn A function that accepts up to two arguments to be used to transform values from the underlying iterator. + * @param callbackfn - A function that accepts up to two arguments to be used to transform values from the underlying iterator. */ map(callbackfn: (value: T, index: number) => U): CoreJSIteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. - * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. */ filter(predicate: (value: T, index: number) => value is S): CoreJSIteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. - * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. */ filter(predicate: (value: T, index: number) => unknown): CoreJSIteratorObject; /** * Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached. - * @param limit The maximum number of values to yield. + * @param limit - The maximum number of values to yield. */ take(limit: number): CoreJSIteratorObject; /** * Creates an iterator whose values are the values from this iterator after skipping the provided count. - * @param count The number of values to drop. + * @param count - The number of values to drop. */ drop(count: number): CoreJSIteratorObject; /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. - * @param callback A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. + * @param callback - A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. */ flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; // ts < 5.6 Iterable /** * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @param callbackfn - A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; /** * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. - * @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 a value from the iterator. + * @param callbackfn - A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; /** * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. - * @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 a value from the iterator. + * @param callbackfn - A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. */ reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; @@ -140,13 +140,13 @@ declare namespace CoreJS { /** * Performs the specified action for each element in the iterator. - * @param callbackfn A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. + * @param callbackfn - A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. */ forEach(callbackfn: (value: T, index: number) => void): void; /** * Determines whether the specified callback function returns true for any element of this iterator. - * @param predicate A function that accepts up to two arguments. The `some` method calls + * @param predicate - A function that accepts up to two arguments. The `some` method calls * the predicate function for each element in this iterator until the predicate returns a value * true, or until the end of the iterator. */ @@ -154,7 +154,7 @@ declare namespace CoreJS { /** * Determines whether all the members of this iterator satisfy the specified test. - * @param predicate A function that accepts up to two arguments. The every method calls + * @param predicate - A function that accepts up to two arguments. The every method calls * the predicate function for each element in this iterator until the predicate returns * false, or until the end of this iterator. */ @@ -163,7 +163,7 @@ declare namespace CoreJS { /** * Returns the value of the first element in this iterator where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of this iterator, in + * @param predicate - find calls predicate once for each element of this iterator, in * 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. */ @@ -177,15 +177,15 @@ declare namespace CoreJS { /** * Creates a native iterator from an iterator or iterable object. * Returns its input if the input already inherits from the built-in Iterator class. - * @param value An iterator or iterable object to convert a native iterator. + * @param value - An iterator or iterable object to convert a native iterator. */ from(value: Iterator | Iterable): CoreJSIteratorObject; /** * Takes an iterable of iterables and produces an iterable of arrays where position corresponds * to position in the passed iterable. - * @param iterables An Iterable of iterables. - * @param options Optional object: + * @param iterables - An Iterable of iterables. + * @param options - Optional object: * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. @@ -195,8 +195,8 @@ declare namespace CoreJS { /** * takes an object whose values are iterables and produces an iterable of objects where keys. * correspond to keys in the passed object. - * @param record An object of iterables. - * @param options Optional object: + * @param record - An object of iterables. + * @param options - Optional object: * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. @@ -205,9 +205,9 @@ declare namespace CoreJS { /** * Returns an iterator that generates a sequence of numbers or bigints within a range. - * @param start The starting value of the sequence. - * @param end The end value of the sequence (exclusive by default). - * @param options Optional object: + * @param start - The starting value of the sequence. + * @param end - The end value of the sequence (exclusive by default). + * @param options - Optional object: * - step: The difference between consecutive values (default is 1). * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of numbers or bigints. @@ -216,7 +216,7 @@ declare namespace CoreJS { /** * Creates an iterator that sequentially yields values from the provided iterables. - * @param iterators The iterables to concatenate. + * @param iterators - The iterables to concatenate. * @returns An iterator yielding values from each input iterable in sequence. */ concat(...iterators: Iterable[]): CoreJSIteratorObject; diff --git a/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts index f3a2b224d76c..81ce831156a9 100644 --- a/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts @@ -14,7 +14,7 @@ declare namespace CoreJS { interface CoreJSString extends StringBase { /** * Returns a new String consisting of the single UTF-16 code unit located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): string | undefined; } @@ -22,7 +22,7 @@ declare namespace CoreJS { interface CoreJSArray extends Array { /** * Returns the item located at the specified index. - * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + * @param index - The zero-based index of the desired code unit. A negative index will count back from the last item. */ at(index: number): T | undefined; } diff --git a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts index 0ced186b744b..a9e97cc1bcc0 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts @@ -20,7 +20,7 @@ declare namespace CoreJS { /** * Matches a string with a regular expression, and returns an iterable of matches * containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. + * @param regexp - A variable name or string literal containing the regular expression pattern and flags. */ matchAll(regexp: RegExp): CoreJSRegExpStringIterator; } diff --git a/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts b/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts index 71f2158dc228..db24740db9af 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts @@ -16,10 +16,10 @@ declare namespace CoreJS { * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. * The padding is applied from the start (left) of the current string. * - * @param maxLength The length of the resulting string once the current string has been padded. + * @param maxLength - The length of the resulting string once the current string has been padded. * If this parameter is smaller than the current string's length, the current string will be returned as it is. * - * @param fillString The string to pad the current string with. + * @param fillString - The string to pad the current string with. * If this string is too long, it will be truncated and the left-most part will be applied. * The default value for this parameter is " " (U+0020). */ @@ -29,10 +29,10 @@ declare namespace CoreJS { * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. * The padding is applied from the end (right) of the current string. * - * @param maxLength The length of the resulting string once the current string has been padded. + * @param maxLength - The length of the resulting string once the current string has been padded. * If this parameter is smaller than the current string's length, the current string will be returned as it is. * - * @param fillString The string to pad the current string with. + * @param fillString - The string to pad the current string with. * If this string is too long, it will be truncated and the left-most part will be applied. * The default value for this parameter is " " (U+0020). */ diff --git a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts index 984c3e50a53a..0216028ffac4 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts @@ -14,15 +14,15 @@ declare namespace CoreJS { /** * Replace all instances of a substring in a string, using a regular expression or search string. - * @param searchValue A string to search for. - * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + * @param searchValue - A string to search for. + * @param replaceValue - A string containing the text to replace for every successful match of searchValue in this string. */ replaceAll(searchValue: string | RegExp, replaceValue: string): string; /** * Replace all instances of a substring in a string, using a regular expression or search string. - * @param searchValue A string to search for. - * @param replacer A function that returns the replacement text. + * @param searchValue - A string to search for. + * @param replacer - A function that returns the replacement text. */ replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } diff --git a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts index a3ab365b5deb..02be9fd600d6 100644 --- a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts @@ -61,13 +61,13 @@ declare namespace CoreJS { /** * Determines whether the given value is a registered symbol. - * @param value + * @param value - The value to be checked. */ isRegisteredSymbol(value: any): boolean; /** * Determines whether the given value is a well-known symbol. - * @param value + * @param value - The value to be checked. */ isWellKnownSymbol(value: any): boolean; diff --git a/packages/core-js-types/src/base/web/atob-btoa.d.ts b/packages/core-js-types/src/base/web/atob-btoa.d.ts index e4fc647b51a0..48748e31123d 100644 --- a/packages/core-js-types/src/base/web/atob-btoa.d.ts +++ b/packages/core-js-types/src/base/web/atob-btoa.d.ts @@ -1,6 +1,6 @@ /** * Decodes a string of data which has been encoded using Base64 encoding. - * @param data A base64-encoded string, using the alphabet produced by btoa(). + * @param data - A base64-encoded string, using the alphabet produced by btoa(). * @returns A binary string containing raw bytes decoded from encodedData. */ declare function atob(data: string): string; @@ -8,7 +8,7 @@ declare function atob(data: string): string; /** * Creates a Base64-encoded ASCII string from a binary string * (i.e., a string in which each character in the string is treated as a byte of binary data) - * @param data The binary string to encode + * @param data - The binary string to encode * @returns An ASCII string containing the Base64 representation of data */ declare function btoa(data: string): string; diff --git a/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts b/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts index 4415724fa281..50e65953c948 100644 --- a/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts +++ b/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts @@ -2,14 +2,14 @@ type Immediate = number | object; /** * Schedules the execution of a function as soon as possible after the current script yields. - * @param handler The function to execute. - * @param args Arguments to pass to the handler function. + * @param handler - The function to execute. + * @param args - Arguments to pass to the handler function. * @returns An identifier that can be used to cancel the scheduled function. */ declare function setImmediate(handler: (...args: any[]) => void, ...args: any[]): Immediate; /** * Cancels a function scheduled with setImmediate. - * @param immediate The identifier of the scheduled function to cancel. + * @param immediate - The identifier of the scheduled function to cancel. */ declare function clearImmediate(immediate: Immediate | undefined): void; // For compatibility with Node, `undefined` has been added diff --git a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts index 36fe3aa76cfc..6fb8ad96aef2 100644 --- a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts +++ b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts @@ -13,8 +13,8 @@ interface DOMTokenList { // @type-options no-export /** * Calls a defined callback function on each element of the DOMTokenList, * passing the element, its index, and the entire DOMTokenList as arguments. - * @param callbackfn - * @param thisArg + * @param callbackfn - The function to execute for each element. + * @param thisArg - Value to use as this when executing `callbackfn`. */ forEach( callbackfn: (value: Element, index: number, collection: DOMTokenList) => void, @@ -43,8 +43,8 @@ interface NodeList { // @type-options no-export /** * Calls a defined callback function on each element of the NodeList, * passing the element, its index, and the entire NodeList as arguments. - * @param callbackfn - * @param thisArg + * @param callbackfn - The function to execute for each element. + * @param thisArg - Value to use as this when executing `callbackfn`. */ forEach( callbackfn: (value: Node, index: number, collection: NodeList) => void, diff --git a/packages/core-js-types/src/base/web/queue-microtask.d.ts b/packages/core-js-types/src/base/web/queue-microtask.d.ts index bf17341bb29c..9fe3babcfc43 100644 --- a/packages/core-js-types/src/base/web/queue-microtask.d.ts +++ b/packages/core-js-types/src/base/web/queue-microtask.d.ts @@ -1,5 +1,5 @@ /** * Queues a microtask to be executed at a later time. - * @param callback A function to be executed in the microtask. + * @param callback - A function to be executed in the microtask. */ declare function queueMicrotask(callback: () => void): void; diff --git a/packages/core-js-types/src/base/web/structured-clone.d.ts b/packages/core-js-types/src/base/web/structured-clone.d.ts index 4cecad3e499a..8a521894949c 100644 --- a/packages/core-js-types/src/base/web/structured-clone.d.ts +++ b/packages/core-js-types/src/base/web/structured-clone.d.ts @@ -6,8 +6,8 @@ interface CoreJSStructuredSerializeOptions { // @type-options no-extends, no-pre /** * Creates a deep clone of a given value using the structured clone algorithm. - * @param value The value to be cloned. - * @param options An optional object that may contain a transfer property, + * @param value - The value to be cloned. + * @param options - An optional object that may contain a transfer property, * which is an array of transferable objects to be transferred rather than cloned. * @returns A deep clone of the provided value. */ diff --git a/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts index 85e0e710da26..01a42fb583af 100644 --- a/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts @@ -5,7 +5,7 @@ interface AsyncIteratorConstructor { /** * Creates an `AsyncIterator` from an iterable object - * @param iterable An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` + * @param iterable - An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` * @returns A new `AsyncIterator` instance */ from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; @@ -16,71 +16,71 @@ declare var AsyncIterator: AsyncIteratorConstructor; interface AsyncIterator { /** * Drops elements from the iterator until the limit is reached - * @param limit The number of elements to drop + * @param limit - The number of elements to drop * @returns A new `AsyncIterator` */ drop(limit: number): AsyncIteratorObject; /** * Check if every value generated by the iterator passes the `predicate` function. - * @param predicate A function that tests each element of the iterator + * @param predicate - A function that tests each element of the iterator * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` */ every(predicate: (value: T, index: number) => boolean): Promise; /** * Creates a new `AsyncIterator` that contains only the elements that pass the `predicate` function. - * @param predicate A function that tests each element of the iterator + * @param predicate - A function that tests each element of the iterator * @returns A new `AsyncIterator` */ filter(predicate: (value: T, index: number) => boolean): AsyncIteratorObject; /** * Finds the first element in the iterator that satisfies the `predicate` function. - * @param predicate A function that tests each element of the iterator + * @param predicate - A function that tests each element of the iterator * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` */ find(predicate: (value: T, index: number) => boolean): Promise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. - * @param mapper A function that transforms each element of the iterator + * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ flatMap(mapper: (value: T, index: number) => any): AsyncIteratorObject; /** * Executes a provided function once for each element in the iterator. - * @param callbackFn A function that is called for each element of the iterator + * @param callbackFn - A function that is called for each element of the iterator * @returns A `Promise` that resolves when all elements have been processed */ forEach(callbackFn: (value: T, index: number) => void): Promise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. - * @param mapper A function that transforms each element of the iterator + * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ map(mapper: (value: T, index: number) => any): AsyncIteratorObject; /** * Reduces the elements of the iterator to a single value using the `reducer` function. - * @param reducer A function that combines two elements of the iterator - * @param initialValue An optional initial value to start the reduction + * @param reducer - A function that combines two elements of the iterator + * @param initialValue - An optional initial value to start the reduction * @returns A `Promise` that resolves to the reduced value */ reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; /** * Checks if any value in the iterator matches a given `predicate` - * @param predicate A function that tests each element of the iterator + * @param predicate - A function that tests each element of the iterator * @returns A `Promise` that resolves to `true` if any element passes the `predicate`, otherwise `false` */ some(predicate: (value: T, index: number) => boolean): Promise; /** * Creates a new `AsyncIterator` that yields only the first `limit` elements from the original iterator. - * @param limit The maximum number of elements to take + * @param limit - The maximum number of elements to take * @returns A new `AsyncIterator` */ take(limit: number): AsyncIteratorObject; diff --git a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts index fa4f77dc1f35..68ded576f8b3 100644 --- a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts @@ -54,15 +54,15 @@ interface DisposableStack { /** * Adds a disposable resource to the stack, returning the resource. - * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @param value - The resource to add. `null` and `undefined` will not be added, but will be returned. * @returns The provided {@link value}. */ use(value: T): T; /** * Adds a value and associated disposal callback as a resource to the stack. - * @param value The value to add. - * @param onDispose The callback to use in place of a `[Symbol.dispose]()` method. Will be invoked with `value` + * @param value - The value to add. + * @param onDispose - The callback to use in place of a `[Symbol.dispose]()` method. Will be invoked with `value` * as the first parameter. * @returns The provided {@link value}. */ @@ -130,15 +130,15 @@ interface AsyncDisposableStack { /** * Adds a disposable resource to the stack, returning the resource. - * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @param value - The resource to add. `null` and `undefined` will not be added, but will be returned. * @returns The provided {@link value}. */ use(value: T): T; /** * Adds a value and associated disposal callback as a resource to the stack. - * @param value The value to add. - * @param onDisposeAsync The callback to use in place of a `[Symbol.asyncDispose]()` method. Will be invoked with `value` + * @param value - The value to add. + * @param onDisposeAsync - The callback to use in place of a `[Symbol.asyncDispose]()` method. Will be invoked with `value` * as the first parameter. * @returns The provided {@link value}. */ diff --git a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts index a72c23651942..7681173eb43a 100644 --- a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts @@ -12,54 +12,54 @@ declare global { interface Iterator { /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator. - * @param callbackfn A function that accepts up to two arguments to be used to transform values from the underlying iterator. + * @param callbackfn - A function that accepts up to two arguments to be used to transform values from the underlying iterator. */ map(callbackfn: (value: T, index: number) => U): CoreJSIteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. - * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. */ filter(predicate: (value: T, index: number) => value is S): CoreJSIteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. - * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. */ filter(predicate: (value: T, index: number) => unknown): CoreJSIteratorObject; /** * Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached. - * @param limit The maximum number of values to yield. + * @param limit - The maximum number of values to yield. */ take(limit: number): CoreJSIteratorObject; /** * Creates an iterator whose values are the values from this iterator after skipping the provided count. - * @param count The number of values to drop. + * @param count - The number of values to drop. */ drop(count: number): CoreJSIteratorObject; /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. - * @param callback A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. + * @param callback - A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. */ flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; /** * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @param callbackfn - A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; /** * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. - * @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 a value from the iterator. + * @param callbackfn - A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; /** * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. - * @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 a value from the iterator. + * @param callbackfn - A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. */ reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; @@ -70,13 +70,13 @@ declare global { /** * Performs the specified action for each element in the iterator. - * @param callbackfn A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. + * @param callbackfn - A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. */ forEach(callbackfn: (value: T, index: number) => void): void; /** * Determines whether the specified callback function returns true for any element of this iterator. - * @param predicate A function that accepts up to two arguments. The `some` method calls + * @param predicate - A function that accepts up to two arguments. The `some` method calls * the predicate function for each element in this iterator until the predicate returns a value * true, or until the end of the iterator. */ @@ -84,7 +84,7 @@ declare global { /** * Determines whether all the members of this iterator satisfy the specified test. - * @param predicate A function that accepts up to two arguments. The every method calls + * @param predicate - A function that accepts up to two arguments. The every method calls * the predicate function for each element in this iterator until the predicate returns * false, or until the end of this iterator. */ @@ -93,7 +93,7 @@ declare global { /** * Returns the value of the first element in this iterator where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of this iterator, in + * @param predicate - find calls predicate once for each element of this iterator, in * 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. */ @@ -105,7 +105,7 @@ declare global { /** * Creates a native iterator from an iterator or iterable object. * Returns its input if the input already inherits from the built-in Iterator class. - * @param value An iterator or iterable object to convert a native iterator. + * @param value - An iterator or iterable object to convert a native iterator. */ from(value: Iterator | Iterable): CoreJSIteratorObject; } diff --git a/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts b/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts index 544c84df57ed..3d3f4ca467c0 100644 --- a/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/string-match-all.d.ts @@ -14,7 +14,7 @@ interface String { /** * Matches a string with a regular expression, and returns an iterable of matches * containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. + * @param regexp - A variable name or string literal containing the regular expression pattern and flags. */ matchAll(regexp: RegExp): RegExpStringIterator; } diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index bc2a71f1df0a..61b866a42141 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -42,8 +42,8 @@ declare namespace CoreJS { interface CoreJSPromiseLike { /** * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. + * @param onfulfilled - The callback to execute when the Promise is resolved. + * @param onrejected - The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ then(onfulfilled?: ((value: T) => TResult1 | CoreJSPromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | CoreJSPromiseLike) | undefined | null): CoreJSPromiseLike; @@ -67,69 +67,69 @@ declare namespace CoreJS { /** * Yields arrays containing up to the specified number of elements * chunked from the source iterator. - * @param chunkSize The maximum number of elements per chunk. Must be a positive integer. + * @param chunkSize - The maximum number of elements per chunk. Must be a positive integer. * @returns An iterator yielding arrays of at most `chunkSize` elements from the source iterator. */ chunks(chunkSize: number): CoreJSIteratorObject; /** * Yields overlapping arrays (windows) of the given size from the iterator. - * @param windowSize The size of each window. Must be a positive integer. - * @param undersized 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. + * @param windowSize - The size of each window. Must be a positive integer. + * @param undersized - 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. * @returns An iterator yielding arrays of the specified window size. */ windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJSIteratorObject; /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator. - * @param callbackfn A function that accepts up to two arguments to be used to transform values from the underlying iterator. + * @param callbackfn - A function that accepts up to two arguments to be used to transform values from the underlying iterator. */ map(callbackfn: (value: T, index: number) => U): CoreJSIteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. - * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. */ filter(predicate: (value: T, index: number) => value is S): CoreJSIteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. - * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. + * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. */ filter(predicate: (value: T, index: number) => unknown): CoreJSIteratorObject; /** * Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached. - * @param limit The maximum number of values to yield. + * @param limit - The maximum number of values to yield. */ take(limit: number): CoreJSIteratorObject; /** * Creates an iterator whose values are the values from this iterator after skipping the provided count. - * @param count The number of values to drop. + * @param count - The number of values to drop. */ drop(count: number): CoreJSIteratorObject; /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. - * @param callback A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. + * @param callback - A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. */ flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; /** * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @param callbackfn - A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; /** * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. - * @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 a value from the iterator. + * @param callbackfn - A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; /** * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. - * @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 a value from the iterator. + * @param callbackfn - A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. */ reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; @@ -140,13 +140,13 @@ declare namespace CoreJS { /** * Performs the specified action for each element in the iterator. - * @param callbackfn A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. + * @param callbackfn - A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. */ forEach(callbackfn: (value: T, index: number) => void): void; /** * Determines whether the specified callback function returns true for any element of this iterator. - * @param predicate A function that accepts up to two arguments. The `some` method calls + * @param predicate - A function that accepts up to two arguments. The `some` method calls * the predicate function for each element in this iterator until the predicate returns a value * true, or until the end of the iterator. */ @@ -154,7 +154,7 @@ declare namespace CoreJS { /** * Determines whether all the members of this iterator satisfy the specified test. - * @param predicate A function that accepts up to two arguments. The every method calls + * @param predicate - A function that accepts up to two arguments. The every method calls * the predicate function for each element in this iterator until the predicate returns * false, or until the end of this iterator. */ @@ -163,7 +163,7 @@ declare namespace CoreJS { /** * Returns the value of the first element in this iterator where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of this iterator, in + * @param predicate - find calls predicate once for each element of this iterator, in * 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. */ @@ -177,15 +177,15 @@ declare namespace CoreJS { /** * Creates a native iterator from an iterator or iterable object. * Returns its input if the input already inherits from the built-in Iterator class. - * @param value An iterator or iterable object to convert a native iterator. + * @param value - An iterator or iterable object to convert a native iterator. */ from(value: Iterator | Iterable): CoreJSIteratorObject; /** * Takes an iterable of iterables and produces an iterable of arrays where position corresponds * to position in the passed iterable. - * @param iterables An Iterable of iterables. - * @param options Optional object: + * @param iterables - An Iterable of iterables. + * @param options - Optional object: * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. @@ -195,8 +195,8 @@ declare namespace CoreJS { /** * takes an object whose values are iterables and produces an iterable of objects where keys. * correspond to keys in the passed object. - * @param iterables An Iterable of iterables. - * @param options Optional object: + * @param iterables - An Iterable of iterables. + * @param options - Optional object: * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. @@ -205,8 +205,8 @@ declare namespace CoreJS { /** * takes an object whose values are iterables and produces an iterable of objects where keys. * correspond to keys in the passed object. - * @param record An object of iterables. - * @param options Optional object: + * @param record - An object of iterables. + * @param options - Optional object: * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. @@ -215,9 +215,9 @@ declare namespace CoreJS { /** * Returns an iterator that generates a sequence of numbers or bigints within a range. - * @param start The starting value of the sequence. - * @param end The end value of the sequence (exclusive by default). - * @param options Optional object: + * @param start - The starting value of the sequence. + * @param end - The end value of the sequence (exclusive by default). + * @param options - Optional object: * - step: The difference between consecutive values (default is 1). * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of numbers or bigints. @@ -226,7 +226,7 @@ declare namespace CoreJS { /** * Creates an iterator that sequentially yields values from the provided iterables. - * @param iterators The iterables to concatenate. + * @param iterators - The iterables to concatenate. * @returns An iterator yielding values from each input iterable in sequence. */ concat(...iterators: Iterable[]): CoreJSIteratorObject; diff --git a/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts index 7af333d593a4..23ce781ca483 100644 --- a/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts +++ b/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts @@ -7,8 +7,8 @@ interface DOMTokenList { // @type-options no-export /** * Calls a defined callback function on each element of the DOMTokenList, * passing the element, its index, and the entire DOMTokenList as arguments. - * @param callbackfn - * @param thisArg + * @param callbackfn - The function to execute for each element. + * @param thisArg - Value to use as this when executing `callbackfn`. */ forEach( callbackfn: (value: Element, index: number, collection: DOMTokenList) => void, @@ -37,8 +37,8 @@ interface NodeList { // @type-options no-export /** * Calls a defined callback function on each element of the NodeList, * passing the element, its index, and the entire NodeList as arguments. - * @param callbackfn - * @param thisArg + * @param callbackfn - The function to execute for each element. + * @param thisArg - Value to use as this when executing `callbackfn`. */ forEach( callbackfn: (value: Node, index: number, collection: NodeList) => void, diff --git a/tests/eslint/eslint.config.js b/tests/eslint/eslint.config.js index a58d526b9923..e4b6991824ca 100644 --- a/tests/eslint/eslint.config.js +++ b/tests/eslint/eslint.config.js @@ -1907,7 +1907,7 @@ const ts = { ...disable(base), ...baseStyle, // validating that TypeScript doc comments conform to the TSDoc specification - 'tsdoc/syntax': OFF, + 'tsdoc/syntax': ERROR, // specify the maximum length of a line in your program '@stylistic/max-len': [OFF, { ...base['@stylistic/max-len'][1], code: 180 }], // require consistent spacing around type annotations From ed781781b1989fdad813c15ad04ad0d05ab2129a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 23 Jan 2026 22:37:45 +0700 Subject: [PATCH 155/315] Exclude type's export ability --- packages/core-js-types/src/base/web/self.d.ts | 4 +-- packages/core-js-types/src/base/web/url.d.ts | 29 +++++++-------- .../core-js/modules/web.url.constructor.js | 2 +- scripts/build-entries/entries-definitions.mjs | 7 ++++ scripts/build-types/index.mjs | 18 +++++++--- .../global/web/dom-exception.test.ts | 21 ++++++----- .../global/web/url-parse.test.ts | 35 ++++++++++--------- .../global/web/url-search-params.dom.test.ts | 23 ++++++------ .../global/web/url-to-json.dom.test.ts | 20 +++++------ 9 files changed, 88 insertions(+), 71 deletions(-) diff --git a/packages/core-js-types/src/base/web/self.d.ts b/packages/core-js-types/src/base/web/self.d.ts index 26edef8ac99a..c3bc4f88e9df 100644 --- a/packages/core-js-types/src/base/web/self.d.ts +++ b/packages/core-js-types/src/base/web/self.d.ts @@ -1,7 +1,5 @@ declare global { - var self: typeof globalThis extends { onmessage: any; self: infer T } ? T : { - URL?: typeof URL; - }; + var self: typeof globalThis extends { onmessage: any; self: infer T } ? T : {}; } export {}; diff --git a/packages/core-js-types/src/base/web/url.d.ts b/packages/core-js-types/src/base/web/url.d.ts index 1206af12c5ee..00dcefb8a546 100644 --- a/packages/core-js-types/src/base/web/url.d.ts +++ b/packages/core-js-types/src/base/web/url.d.ts @@ -1,14 +1,15 @@ -/// - -import * as url from 'core-js/internals/web/url'; - -declare global { - interface URL extends url.URL {} - var URL: typeof globalThis extends { onmessage: any; URL: infer T } ? T : typeof url.URL; - - interface URLSearchParams extends url.URLSearchParams {} - var URLSearchParams: typeof globalThis extends { onmessage: any; URLSearchParams: infer T } ? T - : typeof url.URLSearchParams; -} - -export {}; +// URL has conflicts with @types/node +// /// + +// import * as url from 'core-js/internals/web/url'; +// +// declare global { +// interface URL extends url.URL {} +// var URL: typeof globalThis extends { onmessage: any; URL: infer T } ? T : typeof url.URL; +// +// interface URLSearchParams extends url.URLSearchParams {} +// var URLSearchParams: typeof globalThis extends { onmessage: any; URLSearchParams: infer T } ? T +// : typeof url.URLSearchParams; +// } +// +// export {}; diff --git a/packages/core-js/modules/web.url.constructor.js b/packages/core-js/modules/web.url.constructor.js index c5bf702ecf02..0021e54ee9a3 100644 --- a/packages/core-js/modules/web.url.constructor.js +++ b/packages/core-js/modules/web.url.constructor.js @@ -1,4 +1,4 @@ -// types: web/url +// no types: because of a conflict with @types/node 'use strict'; var $ = require('../internals/export'); var USE_NATIVE_URL = require('../internals/url-constructor-detection'); diff --git a/scripts/build-entries/entries-definitions.mjs b/scripts/build-entries/entries-definitions.mjs index 70649bea5e85..b39c9c6e29a0 100644 --- a/scripts/build-entries/entries-definitions.mjs +++ b/scripts/build-entries/entries-definitions.mjs @@ -3079,37 +3079,44 @@ export const features = { modules: [/^web\.url(?:-search-params)?\./], template: $namespace, name: 'URL', + globalType: false, }, 'url/constructor': { modules: ['web.url.constructor', 'web.url.to-json', /^web\.url-search-params\./], template: $namespace, name: 'URL', + globalType: false, }, 'url/can-parse': { modules: ['web.url.can-parse'], template: $static, namespace: 'URL', name: 'canParse', + globalType: false, }, 'url/parse': { modules: ['web.url.parse'], template: $static, namespace: 'URL', name: 'parse', + globalType: false, }, 'url/to-json': { modules: ['web.url.to-json'], template: $justImport, + globalType: false, }, 'url-search-params/index': { modules: [/^web\.url-search-params\./], template: $namespace, name: 'URLSearchParams', + globalType: false, }, 'url-search-params/constructor': { modules: [/^web\.url-search-params\./], template: $namespace, name: 'URLSearchParams', + globalType: false, }, 'weak-map/index': { modules: [/^(?:es|esnext)\.weak-map\./], diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 94efaa22ce6d..95b481dd0b4b 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -29,6 +29,10 @@ const imports = { let outputFiles = {}; function addType(tsVersion, subset, template, options) { + const exportGlobalType = options.globalType ?? true; + if (!exportGlobalType && subset !== 'pure') { + return; + } const filePath = buildFilePath(tsVersion, subset); if (!outputFiles[filePath]) outputFiles[filePath] = ''; const entryWithTypes = template(options); @@ -44,6 +48,8 @@ async function buildType(entry, options) { let { entryFromNamespace, subset = entryFromNamespace ?? 'full', + globalType, + exportGlobalType = globalType ?? true, template, templateStable, templateActual, templateFull, filter, modules, enforceEntryCreation, customType, tsVersion, proposal, types, ownEntryPoint, } = options; @@ -77,14 +83,18 @@ async function buildType(entry, options) { } types.forEach(type => { - imports.index.add(type); - imports[subset].add(type); + if (exportGlobalType) { + imports.index.add(type); + imports[subset].add(type); + } imports.pure.add(path.join('pure', type)); }); if (customType) { - imports.index.add(customType); - imports[subset].add(customType); + if (exportGlobalType) { + imports.index.add(customType); + imports[subset].add(customType); + } imports.pure.add(path.join('pure', customType)); } options = { ...options, modules, level, entry, types }; diff --git a/tests/type-definitions/global/web/dom-exception.test.ts b/tests/type-definitions/global/web/dom-exception.test.ts index 5c01c8848e6e..b57c58ee4abc 100644 --- a/tests/type-definitions/global/web/dom-exception.test.ts +++ b/tests/type-definitions/global/web/dom-exception.test.ts @@ -1,11 +1,10 @@ -// todo add after it becomes possible to create a type -// import 'core-js/full'; -// -// const ex1 = new DOMException(); -// const ex2 = new DOMException('Some message'); -// const ex3 = new DOMException('Some message', 'SyntaxError'); -// -// // @ts-expect-error -// // DOMException(); -// // @ts-expect-error -// DOMException(123); +import 'core-js/full'; + +const ex1 = new DOMException(); +const ex2 = new DOMException('Some message'); +const ex3 = new DOMException('Some message', 'SyntaxError'); + +// @ts-expect-error +DOMException(); +// @ts-expect-error +DOMException(123); diff --git a/tests/type-definitions/global/web/url-parse.test.ts b/tests/type-definitions/global/web/url-parse.test.ts index 181b041ebc6c..ce4bae440a05 100644 --- a/tests/type-definitions/global/web/url-parse.test.ts +++ b/tests/type-definitions/global/web/url-parse.test.ts @@ -1,17 +1,18 @@ -import 'core-js/full'; - -const u1: URL | null = URL.parse('https://example.com/path?name=value#hash'); -URL.parse('/path', 'https://example.com'); - -if (u1) { - let str: string; - str = u1.pathname; - str = u1.hostname; - str = u1.pathname; - - str = u1.toJSON(); - str = u1.toString(); -} - -// @ts-expect-error -URL.parse(null); +// URL has conflicts with @types/node +// import 'core-js/full'; +// +// const u1: URL | null = URL.parse('https://example.com/path?name=value#hash'); +// URL.parse('/path', 'https://example.com'); +// +// if (u1) { +// let str: string; +// str = u1.pathname; +// str = u1.hostname; +// str = u1.pathname; +// +// str = u1.toJSON(); +// str = u1.toString(); +// } +// +// // @ts-expect-error +// URL.parse(null); diff --git a/tests/type-definitions/global/web/url-search-params.dom.test.ts b/tests/type-definitions/global/web/url-search-params.dom.test.ts index ea10547dd1a1..361e93aaf7af 100644 --- a/tests/type-definitions/global/web/url-search-params.dom.test.ts +++ b/tests/type-definitions/global/web/url-search-params.dom.test.ts @@ -1,11 +1,12 @@ -import 'core-js/full'; - -const u0 = new URLSearchParams(); -const u1 = new URLSearchParams('a=1&b=2'); -const u2 = new URLSearchParams([['a', '1'], ['b', '2']]); -const u3 = new URLSearchParams({ a: '1', b: '2' }); - -// @ts-expect-error -new URLSearchParams(123); -// @ts-expect-error -new URLSearchParams([1, 2, 3]); +// URL has conflicts with @types/node +// import 'core-js/full'; +// +// const u0 = new URLSearchParams(); +// const u1 = new URLSearchParams('a=1&b=2'); +// const u2 = new URLSearchParams([['a', '1'], ['b', '2']]); +// const u3 = new URLSearchParams({ a: '1', b: '2' }); +// +// // @ts-expect-error +// new URLSearchParams(123); +// // @ts-expect-error +// new URLSearchParams([1, 2, 3]); diff --git a/tests/type-definitions/global/web/url-to-json.dom.test.ts b/tests/type-definitions/global/web/url-to-json.dom.test.ts index 4bbbec16a6b0..49812eee97fe 100644 --- a/tests/type-definitions/global/web/url-to-json.dom.test.ts +++ b/tests/type-definitions/global/web/url-to-json.dom.test.ts @@ -1,14 +1,14 @@ -import 'core-js/full'; - -declare const urlLike: URL; -const str: string = urlLike.toJSON(); - -// @ts-expect-error -const num: number = urlLike.toJSON(); -// @ts-expect-error -urlLike.toJSON('param'); +// URL has conflicts with @types/node +// import 'core-js/full'; +// +// declare const urlLike: URL; +// const str: string = urlLike.toJSON(); +// +// // @ts-expect-error +// const num: number = urlLike.toJSON(); +// // @ts-expect-error +// urlLike.toJSON('param'); -// todo add after URL becomes constructable in types // const url1 = new URL('https://example.com'); // new URL('page', 'https://example.com'); // new URL('/path', url1); From 8f17ab3e2511e6fe09309104aee6214a7c957c9e Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 26 Jan 2026 23:55:26 +0700 Subject: [PATCH 156/315] Improve types tests & fix Iterator#concat type --- .../base/proposals/iterator-sequencing.d.ts | 2 +- .../src/base/pure/proposals/iterator.d.ts | 2 +- tests/type-definitions/helpers.ts | 17 +++---- .../pure/proposals/array-from-async.test.ts | 23 +++++---- .../pure/proposals/array-grouping.test.ts | 8 ++-- .../proposals/async-iterator-helper.test.ts | 47 ++++++++++++------- .../pure/proposals/await-dictionary.test.ts | 8 ++-- .../pure/proposals/collection-of-from.test.ts | 44 +++++++++++------ .../explicit-resource-management.test.ts | 8 ++-- .../pure/proposals/iterator-chunking.test.ts | 8 ++-- .../pure/proposals/iterator-helpers.test.ts | 26 ++++++---- .../pure/proposals/iterator-joint.test.ts | 17 ++++--- .../pure/proposals/iterator-range.test.ts | 5 +- .../proposals/iterator-sequencing.test.ts | 17 ++++--- .../proposals/promise-all-settled.test.ts | 21 +++++---- .../pure/proposals/promise-any.test.ts | 31 +++++++----- .../pure/proposals/promise-finally.test.ts | 31 +++++++----- .../pure/proposals/promise-try.test.ts | 36 ++++++++------ .../proposals/promise-with-resolvers.test.ts | 11 +++-- .../pure/proposals/set-methods.test.ts | 35 +++++++++----- 20 files changed, 251 insertions(+), 146 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts index 55410a65fc51..eb0b64da077f 100644 --- a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts @@ -8,7 +8,7 @@ interface IteratorConstructor { // @type-options no-extends * @param iterators - The iterables to concatenate. * @returns An iterator yielding values from each input iterable in sequence. */ - concat(...iterators: Iterable[]): CoreJS.CoreJSIteratorObject; + concat(...iterators: Iterable[]): CoreJS.CoreJSIteratorObject; } declare var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 27b05913b0dd..b6bed732c488 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -219,7 +219,7 @@ declare namespace CoreJS { * @param iterators - The iterables to concatenate. * @returns An iterator yielding values from each input iterable in sequence. */ - concat(...iterators: Iterable[]): CoreJSIteratorObject; + concat(...iterators: Iterable[]): CoreJSIteratorObject; } var CoreJSIterator: CoreJSIteratorConstructor; diff --git a/tests/type-definitions/helpers.ts b/tests/type-definitions/helpers.ts index c7550ca3c6f2..601c422f0597 100644 --- a/tests/type-definitions/helpers.ts +++ b/tests/type-definitions/helpers.ts @@ -1,23 +1,23 @@ -export interface CoreJSPromiseLike { +interface CoreJSPromiseLike { then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; finally(onfinally?: (() => void) | undefined | null): PromiseLike; } -export type CoreJSPromiseAndPromiseLike = CoreJSPromiseLike & Promise; +export function assertCoreJSPromiseLike(value: CoreJSPromiseLike): asserts value is CoreJSPromiseLike {} export interface CoreJSMapLike extends Map { getOrInsert(key: K, value: V): V; getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } -export type CoreJSMapAndMapLike = CoreJSMapLike & Map; +export function assertCoreJSMapLike(value: CoreJSMapLike): asserts value is CoreJSMapLike {} export interface CoreJSWeakMapLike extends WeakMap { getOrInsert(key: K, value: V): V; getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } -export type CoreJSWeakMapAndWeakMapLike = CoreJSWeakMapLike & WeakMap; +export function assertCoreJSWeakMapLike(value: CoreJSWeakMapLike): asserts value is CoreJSWeakMapLike {} export interface CoreJSSetLike extends Set { union(...args: any[]): CoreJSSetLike; @@ -28,10 +28,10 @@ export interface CoreJSSetLike extends Set { isSupersetOf(...args: any[]): boolean; isDisjointFrom(...args: any[]): boolean; } -export type CoreJSSetAndSetLike = CoreJSSetLike & Set; +export function assertCoreJSSetLike(value: CoreJSSetLike): asserts value is CoreJSSetLike {} export interface CoreJSWeakSetLike extends WeakSet {} -export type CoreJSWeakSetAndWeakSetLike = CoreJSWeakSetLike & WeakSet; +export function assertCoreJSWeakSetLike(value: CoreJSWeakSetLike): asserts value is CoreJSWeakSetLike {} export interface CoreJSIteratorLike extends Iterator { chunks(...args: any[]): CoreJSIteratorLike; @@ -49,9 +49,9 @@ export interface CoreJSIteratorLike extends Itera find(...args: any[]): T | undefined; join(...args: any[]): string; } -export type CoreJSIteratorAndIteratorLike = CoreJSIteratorLike & Iterator; +export function assertCoreJSIteratorLike(value: CoreJSIteratorLike): asserts value is CoreJSIteratorLike {} -export interface CoreJSAsyncIteratorLike { +interface CoreJSAsyncIteratorLike { drop(...args: any[]): any; every(...args: any[]): any; filter(predicate: (value: T, index: number) => boolean): CoreJSAsyncIteratorLike; @@ -64,6 +64,7 @@ export interface CoreJSAsyncIteratorLike { take(limit: number): CoreJSAsyncIteratorLike; toArray(...args: any[]): any; } +export function assertCoreJSAsyncIteratorLike(value: CoreJSAsyncIteratorLike): asserts value is CoreJSAsyncIteratorLike {} type HasCause = 'cause' extends keyof T ? T : never; export function assertHasCause(value: T): asserts value is HasCause & { cause: unknown } {} diff --git a/tests/type-definitions/pure/proposals/array-from-async.test.ts b/tests/type-definitions/pure/proposals/array-from-async.test.ts index e84bf38d698e..bed6815b8dd9 100644 --- a/tests/type-definitions/pure/proposals/array-from-async.test.ts +++ b/tests/type-definitions/pure/proposals/array-from-async.test.ts @@ -1,12 +1,17 @@ import arrayFromAsync from '@core-js/pure/full/array/from-async'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseAndPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers'; -const p1: CoreJSPromiseAndPromiseLike = arrayFromAsync([1, 2, 3]); -const p2: CoreJSPromiseAndPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3]); -const p3: CoreJSPromiseAndPromiseLike = arrayFromAsync([1, 2, 3], (value: number, index: number) => value.toString()); -const p4: CoreJSPromiseAndPromiseLike = arrayFromAsync([promiseResolve(1), 2, 3], (value: number) => value + 1); -const p5: CoreJSPromiseAndPromiseLike = arrayFromAsync([1, 2, 3], function (this: { foo: string }, value: number) { return value.toString(); }, { foo: 'str' }); +const p1 = arrayFromAsync([1, 2, 3]); +assertCoreJSPromiseLike(p1); +const p2 = arrayFromAsync([promiseResolve(1), 2, 3]); +assertCoreJSPromiseLike(p2); +const p3 = arrayFromAsync([1, 2, 3], (value: number, index: number) => value.toString()); +assertCoreJSPromiseLike(p3); +const p4 = arrayFromAsync([promiseResolve(1), 2, 3], (value: number) => value + 1); +assertCoreJSPromiseLike(p4); +const p5 = arrayFromAsync([1, 2, 3], function (this: { foo: string }, value: number) { return value.toString(); }, { foo: 'str' }); +assertCoreJSPromiseLike(p5); async function t1() { const n: number[] = await arrayFromAsync([1, 2, 3]); @@ -20,8 +25,10 @@ async function t2() { } declare const arrLike: { [index: number]: PromiseLike; length: 2 }; -const p6: CoreJSPromiseAndPromiseLike = arrayFromAsync(arrLike); -const p7: CoreJSPromiseAndPromiseLike = arrayFromAsync(arrLike, (value: number) => value); +const p6 = arrayFromAsync(arrLike); +assertCoreJSPromiseLike(p6); +const p7 = arrayFromAsync(arrLike, (value: number) => value); +assertCoreJSPromiseLike(p7); // @ts-expect-error arrayFromAsync([1, 2, 3], (value: string) => value); diff --git a/tests/type-definitions/pure/proposals/array-grouping.test.ts b/tests/type-definitions/pure/proposals/array-grouping.test.ts index 1c3680ac45a9..dc9ad1d3b48e 100644 --- a/tests/type-definitions/pure/proposals/array-grouping.test.ts +++ b/tests/type-definitions/pure/proposals/array-grouping.test.ts @@ -1,12 +1,14 @@ import objectGroupBy from '@core-js/pure/full/object/group-by'; import mapGroupBy from '@core-js/pure/full/map/group-by'; -import { CoreJSMapAndMapLike } from '../../helpers'; +import { assertCoreJSMapLike } from '../../helpers'; const arr = [1, 2, 3, 4, 5]; const objGroup: Partial> = objectGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); -const mapGroup: CoreJSMapAndMapLike<'even' | 'odd', number[]> = mapGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); +const mapGroup = mapGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); +assertCoreJSMapLike<'even' | 'odd', number[]>(mapGroup); const objGroup2: Partial> = objectGroupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); -const mapGroup2: CoreJSMapAndMapLike = mapGroupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); +const mapGroup2 = mapGroupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); +assertCoreJSMapLike(mapGroup2); objectGroupBy('test', c => c); objectGroupBy(new Set([1, 2, 3]), item => item > 2 ? 'big' : 'small'); diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 124986f70c98..c621397cbb9b 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -11,9 +11,10 @@ import some from '@core-js/pure/full/async-iterator/some'; import take from '@core-js/pure/full/async-iterator/take'; import toArray from '@core-js/pure/full/async-iterator/to-array'; import toAsync from '@core-js/pure/full/iterator/to-async'; -import { CoreJSAsyncIteratorLike, CoreJSPromiseAndPromiseLike } from '../../helpers'; +import { assertCoreJSAsyncIteratorLike, assertCoreJSPromiseLike } from '../../helpers'; -const aitn: CoreJSAsyncIteratorLike = from([1]); +const aitn = from([1]); +assertCoreJSAsyncIteratorLike(aitn); const aiton = from([1, 2, 3]); aiton.next(); aiton.toArray(); @@ -37,19 +38,31 @@ from(); // @ts-expect-error from({ next: () => 1 }); -const r1: CoreJSPromiseAndPromiseLike = every(aiton, (v: number, i: number) => v > 0); -const r2: CoreJSPromiseAndPromiseLike = find(aiton, (v: number, i: number) => v > 0); -const r3: CoreJSPromiseAndPromiseLike = forEach(aiton, (v: number, i: number) => { }); -const r4: CoreJSPromiseAndPromiseLike = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); -const r5: CoreJSPromiseAndPromiseLike = some(aiton, (v: number, i: number) => v > 0); -const r6: CoreJSPromiseAndPromiseLike = toArray(aiton); +const r1 = every(aiton, (v: number, i: number) => v > 0); +assertCoreJSPromiseLike(r1); +const r2 = find(aiton, (v: number, i: number) => v > 0); +assertCoreJSPromiseLike(r2); +const r3 = forEach(aiton, (v: number, i: number) => { }); +assertCoreJSPromiseLike(r3); +const r4 = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); +assertCoreJSPromiseLike(r4); +const r5 = some(aiton, (v: number, i: number) => v > 0); +assertCoreJSPromiseLike(r5); +const r6 = toArray(aiton); +assertCoreJSPromiseLike(r6); -const ait1: CoreJSAsyncIteratorLike = filter(aiton, (v: number, i: number) => v > 0); -const ait2: CoreJSAsyncIteratorLike = flatMap(aiton, (v: number, i: number) => `${ v }`); -const ait3: CoreJSAsyncIteratorLike = map(aiton, (v: number, i: number) => v * 2); -const ait4: CoreJSAsyncIteratorLike = take(aiton, 10); -const ait5: CoreJSAsyncIteratorLike = drop(aiton, 3); -const ait6: CoreJSAsyncIteratorLike = toAsync(itn); +const ait1 = filter(aiton, (v: number, i: number) => v > 0); +assertCoreJSAsyncIteratorLike(ait1); +const ait2 = flatMap(aiton, (v: number, i: number) => `${ v }`); +assertCoreJSAsyncIteratorLike(ait2); +const ait3 = map(aiton, (v: number, i: number) => v * 2); +assertCoreJSAsyncIteratorLike(ait3); +const ait4 = take(aiton, 10); +assertCoreJSAsyncIteratorLike(ait4); +const ait5 = drop(aiton, 3); +assertCoreJSAsyncIteratorLike(ait5); +const ait6 = toAsync(itn); +assertCoreJSAsyncIteratorLike(ait6); toAsync(is); @@ -76,8 +89,10 @@ take(ain); // @ts-expect-error toArray(ain, 1); -const s0: CoreJSPromiseAndPromiseLike = toArray(aiton); -const f0: CoreJSPromiseAndPromiseLike = find(aitos, (v: string, i: number) => v.length === 1); +const s0 = toArray(aiton); +assertCoreJSPromiseLike(s0); +const f0 = find(aitos, (v: string, i: number) => v.length === 1); +assertCoreJSPromiseLike(f0); // @ts-expect-error map(ais, (v: string, i: number) => v.length === 1, 'extra'); diff --git a/tests/type-definitions/pure/proposals/await-dictionary.test.ts b/tests/type-definitions/pure/proposals/await-dictionary.test.ts index 12dcd5e98409..2c13b652fb1f 100644 --- a/tests/type-definitions/pure/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/pure/proposals/await-dictionary.test.ts @@ -1,18 +1,20 @@ import promiseAllKeyed from '@core-js/pure/full/promise/all-keyed'; import promiseAllSettledKeyed from '@core-js/pure/full/promise/all-settled-keyed'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseAndPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers'; -const res: CoreJSPromiseAndPromiseLike<{ a: number, b: string, c: boolean }> = promiseAllKeyed({ +const res = promiseAllKeyed({ a: promiseResolve(1), b: promiseResolve('string'), c: promiseResolve(true), }); +assertCoreJSPromiseLike<{ a: number, b: string, c: boolean }>(res); declare const sym: unique symbol; -const res2: CoreJSPromiseAndPromiseLike<{ [sym]: number }> = promiseAllKeyed({ +const res2 = promiseAllKeyed({ [sym]: promiseResolve(1), }); +assertCoreJSPromiseLike<{ [sym]: number }>(res2); // @ts-expect-error promiseAllKeyed(); diff --git a/tests/type-definitions/pure/proposals/collection-of-from.test.ts b/tests/type-definitions/pure/proposals/collection-of-from.test.ts index 8fee96ad3a14..3866762cf02c 100644 --- a/tests/type-definitions/pure/proposals/collection-of-from.test.ts +++ b/tests/type-definitions/pure/proposals/collection-of-from.test.ts @@ -6,10 +6,12 @@ import weakMapFrom from '@core-js/pure/full/weak-map/from'; import weakMapOf from '@core-js/pure/full/weak-map/of'; import weakSetFrom from '@core-js/pure/full/weak-set/from'; import weakSetOf from '@core-js/pure/full/weak-set/of'; -import { CoreJSMapAndMapLike, CoreJSSetAndSetLike, CoreJSWeakMapAndWeakMapLike, CoreJSWeakSetAndWeakSetLike } from '../../helpers'; +import { assertCoreJSMapLike, assertCoreJSSetLike, assertCoreJSWeakMapLike, assertCoreJSWeakSetLike } from '../../helpers'; -const rm: CoreJSMapAndMapLike = mapFrom([[1, 'a'], [2, 'b']] as [number, string][]); -const rm2: CoreJSMapAndMapLike = mapFrom([[1, 10], [2, 20]] as [number, number][], (v: number, k: number) => v + k); +const rm = mapFrom([[1, 'a'], [2, 'b']] as [number, string][]); +assertCoreJSMapLike(rm); +const rm2 = mapFrom([[1, 10], [2, 20]] as [number, number][], (v: number, k: number) => v + k); +assertCoreJSMapLike(rm2); mapFrom([[1, 10], [2, 20]] as [number, number][], function (this: { n: number }, v: number) { return v + this.n; }, { n: 2 }); // @ts-expect-error mapFrom([['a', 1], ['b', 2]], (v: string, k: number) => v); @@ -19,28 +21,36 @@ mapFrom([1, 2]); mapFrom(); mapOf(['a', 1], ['b', 2]); -const rm4: CoreJSMapAndMapLike = mapOf(['a', 1], ['b', 2]); +const rm4 = mapOf(['a', 1], ['b', 2]); +assertCoreJSMapLike(rm4); // @ts-expect-error mapOf([1, 2, 3]); // @ts-expect-error mapOf(1, 2); -const rs1: CoreJSSetAndSetLike = setFrom([1, 2, 3]); -const rs2: CoreJSSetAndSetLike = setFrom([1, 2, 3], x => x.toString()); -const rs3: CoreJSSetAndSetLike<[string, number]> = setFrom([['a', 1], ['b', 2]]); +const rs1 = setFrom([1, 2, 3]); +assertCoreJSSetLike(rs1); +const rs2 = setFrom([1, 2, 3], x => x.toString()); +assertCoreJSSetLike(rs2); +const rs3 = setFrom([['a', 1], ['b', 2]]); +assertCoreJSSetLike<(string | number)[]>(rs3); setFrom(['a', 'b'], function (this: { s: string }, value: string) { return value + this.s; }, { s: '-' }); // @ts-expect-error setFrom([1, 2, 3], (v: string) => v); // @ts-expect-error setFrom(); -const rso1: CoreJSSetAndSetLike = setOf(1, 2, 3); -const rso2: CoreJSSetAndSetLike = setOf('a', 'b', 'c'); +const rso1 = setOf(1, 2, 3); +assertCoreJSSetLike(rso1); +const rso2 = setOf('a', 'b', 'c'); +assertCoreJSSetLike(rso2); // @ts-expect-error setOf({ foo: 'bar' }, 2); -const rwm1: CoreJSWeakMapAndWeakMapLike<{ a: number }, string> = weakMapFrom([[{ a: 1 }, 'x']] as [{ a: number }, string][]); -const rwm2: CoreJSWeakMapAndWeakMapLike = weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], (v, k) => v.toString()); +const rwm1 = weakMapFrom([[{ a: 1 }, 'x']] as [{ a: number }, string][]); +assertCoreJSWeakMapLike<{ a: number }, string>(rwm1); +const rwm2 = weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], (v, k) => v.toString()); +assertCoreJSWeakMapLike(rwm2); weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], function (this: { s: string }, v: number) { return this.s + v; }, { s: '-' }); // @ts-expect-error weakMapFrom([[1, 2], [2, 3]]); @@ -51,14 +61,17 @@ weakMapFrom([1, 2]); // @ts-expect-error weakMapFrom(); -const rwmo1: CoreJSWeakMapAndWeakMapLike = weakMapOf([{}, 2]); +const rwmo1 = weakMapOf([{}, 2]); +assertCoreJSWeakMapLike(rwmo1); // @ts-expect-error weakMapOf([1, 2]); // @ts-expect-error weakMapOf({}); -const rws1: CoreJSWeakSetAndWeakSetLike = weakSetFrom([{}]); -const rws2: CoreJSWeakSetAndWeakSetLike = weakSetFrom([{}, {}], x => x); +const rws1 = weakSetFrom([{}]); +assertCoreJSWeakSetLike(rws1); +const rws2 = weakSetFrom([{}, {}], x => x); +assertCoreJSWeakSetLike(rws2); weakSetFrom([{}], function (this: { s: string }, obj: object) { return obj; }, { s: '-' }); // @ts-expect-error weakSetFrom([1, 2]); @@ -69,6 +82,7 @@ weakSetFrom(); // @ts-expect-error weakSetFrom([{}], x => 'not-an-object'); -const rwso1: CoreJSWeakSetAndWeakSetLike = weakSetOf({}); +const rwso1 = weakSetOf({}); +assertCoreJSWeakSetLike(rwso1); // @ts-expect-error weakSetOf(1); diff --git a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts index 75b2160c70d9..b411c217fa32 100644 --- a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts @@ -7,7 +7,7 @@ import asyncIteratorFrom from '@core-js/pure/full/async-iterator/from'; import $SuppressedError from '@core-js/pure/full/suppressed-error/constructor'; import $DisposableStack from '@core-js/pure/full/disposable-stack/constructor'; import $AsyncDisposableStack from '@core-js/pure/full/async-disposable-stack/constructor'; -import { CoreJSPromiseAndPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers'; const d: symbol = symbolDispose; const ad: symbol = symbolAsyncDispose; @@ -23,7 +23,8 @@ objD[symbolDispose](); const objAD = { [symbolAsyncDispose]() { return promiseResolve(); }, }; -const p1: CoreJSPromiseAndPromiseLike = objAD[symbolAsyncDispose](); +const p1 = objAD[symbolAsyncDispose](); +assertCoreJSPromiseLike(p1); const err1 = new $SuppressedError('err', 'suppressed', 'msg'); err1.error; @@ -65,7 +66,8 @@ objDS[symbolToStringTag] = 'foo'; $AsyncDisposableStack.prototype; const objADS = new $AsyncDisposableStack(); const disposedASD: boolean = objDS.disposed; -const rda: CoreJSPromiseAndPromiseLike = objADS.disposeAsync(); +const rda = objADS.disposeAsync(); +assertCoreJSPromiseLike(rda); objADS.use(objAD); objADS.use(objD); const ruseASD3: null = objADS.use(null); diff --git a/tests/type-definitions/pure/proposals/iterator-chunking.test.ts b/tests/type-definitions/pure/proposals/iterator-chunking.test.ts index 325d6b48b9d3..3bbb57c0e2fe 100644 --- a/tests/type-definitions/pure/proposals/iterator-chunking.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-chunking.test.ts @@ -1,13 +1,15 @@ import iteratorChunks from '@core-js/pure/full/iterator/chunks'; import iteratorWindows from '@core-js/pure/full/iterator/windows'; -import { CoreJSIteratorAndIteratorLike } from '../../helpers'; +import { assertCoreJSIteratorLike } from '../../helpers'; declare function getNumberIterator(): Iterator; const numbersIter = getNumberIterator(); -const chunksObj: CoreJSIteratorAndIteratorLike = iteratorChunks(numbersIter, 2); -const windowsObj: CoreJSIteratorAndIteratorLike = iteratorWindows(numbersIter, 4); +const chunksObj = iteratorChunks(numbersIter, 2); +assertCoreJSIteratorLike(chunksObj); +const windowsObj = iteratorWindows(numbersIter, 4); +assertCoreJSIteratorLike(windowsObj); const chunkNext = chunksObj.next(); const windowsNext = windowsObj.next(); diff --git a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts index 31fd8fac51d0..ef754d312eb7 100644 --- a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts @@ -9,46 +9,54 @@ import iteratorForEach from '@core-js/pure/full/iterator/for-each'; import iteratorSome from '@core-js/pure/full/iterator/some'; import iteratorEvery from '@core-js/pure/full/iterator/every'; import iteratorFind from '@core-js/pure/full/iterator/find'; -import { CoreJSIteratorAndIteratorLike } from '../../helpers'; +import { assertCoreJSIteratorLike } from '../../helpers'; declare const it: Iterator; declare const itStr: Iterator; declare const itNumStr: Iterator; -const res: CoreJSIteratorAndIteratorLike = iteratorMap(it, (v, i) => String(v)); -const mappedNum: CoreJSIteratorAndIteratorLike = iteratorMap(it, n => n + 1); +const res = iteratorMap(it, (v, i) => String(v)); +assertCoreJSIteratorLike(res); +const mappedNum = iteratorMap(it, n => n + 1); +assertCoreJSIteratorLike(mappedNum); // @ts-expect-error iteratorMap(); // @ts-expect-error iteratorMap((v, i, extra) => v + i + extra); -const onlyEven: CoreJSIteratorAndIteratorLike = iteratorFilter(it, v => v % 2 === 0); -const filtered: CoreJSIteratorAndIteratorLike = iteratorFilter(it, (v): v is number => typeof v === 'number'); +const onlyEven = iteratorFilter(it, v => v % 2 === 0); +assertCoreJSIteratorLike(onlyEven); +const filtered = iteratorFilter(it, (v): v is number => typeof v === 'number'); +assertCoreJSIteratorLike(filtered); // @ts-expect-error iteratorFilter(); // @ts-expect-error iteratorFilter((v, i, extra) => true); -const taken: CoreJSIteratorAndIteratorLike = iteratorTake(it, 5); +const taken = iteratorTake(it, 5); +assertCoreJSIteratorLike(taken); // @ts-expect-error iteratorTake(); // @ts-expect-error iteratorTake('5'); -const dropped: CoreJSIteratorAndIteratorLike = iteratorDrop(it, 3); +const dropped = iteratorDrop(it, 3); +assertCoreJSIteratorLike(dropped); // @ts-expect-error iteratorDrop('3'); -const flatMapped: CoreJSIteratorAndIteratorLike = iteratorFlatMap(it, (v, i) => itStr); -const flatMapped2: CoreJSIteratorAndIteratorLike = iteratorFlatMap(it, (v, i) => ({ +const flatMapped = iteratorFlatMap(it, (v, i) => itStr); +assertCoreJSIteratorLike(flatMapped); +const flatMapped2 = iteratorFlatMap(it, (v, i) => ({ [Symbol.iterator]: function * () { yield String(v); }, })); +assertCoreJSIteratorLike(flatMapped2); // @ts-expect-error iteratorFlatMap(); diff --git a/tests/type-definitions/pure/proposals/iterator-joint.test.ts b/tests/type-definitions/pure/proposals/iterator-joint.test.ts index ad856ff10a57..e1aa6318fae5 100644 --- a/tests/type-definitions/pure/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-joint.test.ts @@ -1,12 +1,17 @@ import iteratorZip from '@core-js/pure/full/iterator/zip'; import iteratorZipKeyed from '@core-js/pure/full/iterator/zip-keyed'; -import { CoreJSIteratorAndIteratorLike } from '../../helpers'; +import { assertCoreJSIteratorLike } from '../../helpers'; -const zipped1: CoreJSIteratorAndIteratorLike = iteratorZip([[1, 2, 3], [4, 5, 6]]); -const zipped2: CoreJSIteratorAndIteratorLike = iteratorZip([['a', 'b', 'c'], ['d', 'e', 'f']]); -const zipped3: CoreJSIteratorAndIteratorLike = iteratorZip([[1, 2, 3], [4, 5, 6]], { mode: 'shortest' }); -const zipped4: CoreJSIteratorAndIteratorLike> = iteratorZipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); -const zipped5: CoreJSIteratorAndIteratorLike> = iteratorZipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: 'shortest' }); +const zipped1 = iteratorZip([[1, 2, 3], [4, 5, 6]]); +assertCoreJSIteratorLike(zipped1); +const zipped2 = iteratorZip([['a', 'b', 'c'], ['d', 'e', 'f']]); +assertCoreJSIteratorLike(zipped2); +const zipped3 = iteratorZip([[1, 2, 3], [4, 5, 6]], { mode: 'shortest' }); +assertCoreJSIteratorLike(zipped3); +const zipped4 = iteratorZipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); +assertCoreJSIteratorLike>(zipped4); +const zipped5 = iteratorZipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: 'shortest' }); +assertCoreJSIteratorLike>(zipped5); // @ts-expect-error iteratorZip(true); diff --git a/tests/type-definitions/pure/proposals/iterator-range.test.ts b/tests/type-definitions/pure/proposals/iterator-range.test.ts index 418a6850eabc..bc78fe7232f7 100644 --- a/tests/type-definitions/pure/proposals/iterator-range.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-range.test.ts @@ -1,7 +1,8 @@ import iteratorRange from '@core-js/pure/full/iterator/range'; -import { CoreJSIteratorAndIteratorLike } from '../../helpers'; +import { assertCoreJSIteratorLike } from '../../helpers'; -const rir1: CoreJSIteratorAndIteratorLike = iteratorRange(1, 10); +const rir1 = iteratorRange(1, 10); +assertCoreJSIteratorLike(rir1); iteratorRange(1, 10, 1); iteratorRange(1, 10, { step: 1 }); iteratorRange(1, 10, { inclusive: true }); diff --git a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts index 1dc7b4d2c600..27cd7bee11a7 100644 --- a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts @@ -1,5 +1,5 @@ import iteratorConcat from '@core-js/pure/full/iterator/concat'; -import { CoreJSIteratorAndIteratorLike } from '../../helpers'; +import { assertCoreJSIteratorLike } from '../../helpers'; declare const its1: Iterable; declare const arrs: string[]; @@ -7,11 +7,16 @@ declare const arrn: number[]; declare const arrb: boolean[]; declare const itb1: Iterable; -const ri1: CoreJSIteratorAndIteratorLike = iteratorConcat(its1); -const ri2: CoreJSIteratorAndIteratorLike = iteratorConcat(arrs); -const ri3: CoreJSIteratorAndIteratorLike = iteratorConcat(arrn); -const ri4: CoreJSIteratorAndIteratorLike = iteratorConcat(arrb, itb1); -const ri5: CoreJSIteratorAndIteratorLike = iteratorConcat(); +const ri1 = iteratorConcat(its1); +assertCoreJSIteratorLike(ri1); +const ri2 = iteratorConcat(arrs); +assertCoreJSIteratorLike(ri2); +const ri3 = iteratorConcat(arrn); +assertCoreJSIteratorLike(ri3); +const ri4 = iteratorConcat(arrb, itb1); +assertCoreJSIteratorLike(ri4); +const ri5 = iteratorConcat(); +assertCoreJSIteratorLike(ri5); // @ts-expect-error iteratorConcat(1); diff --git a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts index 68259b568993..94a6e6d8ef34 100644 --- a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts @@ -1,6 +1,6 @@ import promiseAllSettled from '@core-js/pure/full/promise/all-settled'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseAndPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers'; interface CoreJSPromiseResult { status: string; @@ -10,20 +10,21 @@ interface CoreJSPromiseResult { const promiseLike = { then: (cb: (val: number) => void) => cb(42) }; -const p1: CoreJSPromiseAndPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = - promiseAllSettled([promiseResolve(10), promiseResolve(20), 30]); -const p2: CoreJSPromiseAndPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]> = - promiseAllSettled(['a', 'b', 'c']); -const p3: CoreJSPromiseAndPromiseLike[]> = - promiseAllSettled(new Set([1, 2, 3])); +const p1 = promiseAllSettled([promiseResolve(10), promiseResolve(20), 30]); +assertCoreJSPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]>(p1); +const p2 = promiseAllSettled(['a', 'b', 'c']); +assertCoreJSPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult]>(p2); +const p3 = promiseAllSettled(new Set([1, 2, 3])); +assertCoreJSPromiseLike[]>(p3); promiseAllSettled([promiseLike]); const emptyTuple: [] = []; -const settled6: CoreJSPromiseAndPromiseLike<[]> = promiseAllSettled(emptyTuple); +const settled6 = promiseAllSettled(emptyTuple); +assertCoreJSPromiseLike<[]>(settled6); const mixedTuple = [42, promiseResolve('bar')] as const; -const p4: CoreJSPromiseAndPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult]> = - promiseAllSettled(mixedTuple); +const p4 = promiseAllSettled(mixedTuple); +assertCoreJSPromiseLike<[CoreJSPromiseResult, CoreJSPromiseResult]>(p4); // @ts-expect-error promiseAllSettled(); diff --git a/tests/type-definitions/pure/proposals/promise-any.test.ts b/tests/type-definitions/pure/proposals/promise-any.test.ts index 115e2112f1cd..b7a78c9d4763 100644 --- a/tests/type-definitions/pure/proposals/promise-any.test.ts +++ b/tests/type-definitions/pure/proposals/promise-any.test.ts @@ -1,6 +1,6 @@ import promiseAny from '@core-js/pure/full/promise/any'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseAndPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers'; const arr = [promiseResolve(1), promiseResolve('foo'), 3] as const; const justNumbers = [1, 2, 3]; @@ -9,16 +9,25 @@ const promiseLike = { then: (cb: (val: number) => void) => cb(123) }; const emptyTuple: [] = []; const mixed = [true, promiseResolve('z')] as const; -const any1: CoreJSPromiseAndPromiseLike = promiseAny(arr); -const any2: CoreJSPromiseAndPromiseLike = promiseAny(['x', 'y', promiseResolve(5)]); -const any3: CoreJSPromiseAndPromiseLike = promiseAny(emptyTuple); -const any4: CoreJSPromiseAndPromiseLike = promiseAny(mixed); - -const any5: CoreJSPromiseAndPromiseLike = promiseAny(justNumbers); -const any6: CoreJSPromiseAndPromiseLike = promiseAny(setOfStrings); -const any7: CoreJSPromiseAndPromiseLike = promiseAny([promiseLike]); -const any8: CoreJSPromiseAndPromiseLike = promiseAny(new Set([1])); -const any9: CoreJSPromiseAndPromiseLike = promiseAny([promiseResolve()]); +const any1 = promiseAny(arr); +assertCoreJSPromiseLike(any1); +const any2 = promiseAny(['x', 'y', promiseResolve(5)]); +assertCoreJSPromiseLike(any2); +const any3 = promiseAny(emptyTuple); +assertCoreJSPromiseLike(any3); +const any4 = promiseAny(mixed); +assertCoreJSPromiseLike(any4); + +const any5 = promiseAny(justNumbers); +assertCoreJSPromiseLike(any5); +const any6 = promiseAny(setOfStrings); +assertCoreJSPromiseLike(any6); +const any7 = promiseAny([promiseLike]); +assertCoreJSPromiseLike(any7); +const any8 = promiseAny(new Set([1])); +assertCoreJSPromiseLike(any8); +const any9 = promiseAny([promiseResolve()]); +assertCoreJSPromiseLike(any9); // @ts-expect-error promiseAny(); diff --git a/tests/type-definitions/pure/proposals/promise-finally.test.ts b/tests/type-definitions/pure/proposals/promise-finally.test.ts index 5a05e4309143..4c29d7d86707 100644 --- a/tests/type-definitions/pure/proposals/promise-finally.test.ts +++ b/tests/type-definitions/pure/proposals/promise-finally.test.ts @@ -1,20 +1,29 @@ import promiseFinally from '@core-js/pure/full/promise/finally'; import promiseResolve from '@core-js/pure/full/promise/resolve'; import promiseReject from '@core-js/pure/full/promise/reject'; -import { CoreJSPromiseAndPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers'; -const pr1: CoreJSPromiseAndPromiseLike = promiseResolve(42); +const pr1 = promiseResolve(42); +assertCoreJSPromiseLike(pr1); declare const p1: Promise; -const pf1: CoreJSPromiseAndPromiseLike = promiseFinally(p1); -const pf2: CoreJSPromiseAndPromiseLike = promiseFinally(p1, undefined); -const pf3: CoreJSPromiseAndPromiseLike = promiseFinally(p1, null); -const pf4: CoreJSPromiseAndPromiseLike = promiseFinally(p1, () => {}); -const pf5: CoreJSPromiseAndPromiseLike = promiseFinally(p1, function () {}); - -const pr2: CoreJSPromiseAndPromiseLike = promiseReject('err'); +const pf1 = promiseFinally(p1); +assertCoreJSPromiseLike(pf1); +const pf2 = promiseFinally(p1, undefined); +assertCoreJSPromiseLike(pf2); +const pf3 = promiseFinally(p1, null); +assertCoreJSPromiseLike(pf3); +const pf4 = promiseFinally(p1, () => {}); +assertCoreJSPromiseLike(pf4); +const pf5 = promiseFinally(p1, function () {}); +assertCoreJSPromiseLike(pf5); + +const pr2 = promiseReject('err'); +assertCoreJSPromiseLike(pr2); declare const p2: Promise; -const pf6: CoreJSPromiseAndPromiseLike = promiseFinally(p2); -const pf7: CoreJSPromiseAndPromiseLike = promiseFinally(p2, () => {}); +const pf6 = promiseFinally(p2); +assertCoreJSPromiseLike(pf6); +const pf7 = promiseFinally(p2, () => {}); +assertCoreJSPromiseLike(pf7); // @ts-expect-error promiseFinally(p1, 123); diff --git a/tests/type-definitions/pure/proposals/promise-try.test.ts b/tests/type-definitions/pure/proposals/promise-try.test.ts index 8ea9b4416003..506c5996c2e6 100644 --- a/tests/type-definitions/pure/proposals/promise-try.test.ts +++ b/tests/type-definitions/pure/proposals/promise-try.test.ts @@ -1,19 +1,27 @@ import promiseTry from '@core-js/pure/full/promise/try'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseAndPromiseLike } from '../../helpers'; - -const pt1: CoreJSPromiseAndPromiseLike = promiseTry(() => 42); -const pt2: CoreJSPromiseAndPromiseLike = promiseTry(() => promiseResolve('hi')); -const pt3: CoreJSPromiseAndPromiseLike = promiseTry((a: number, b: number) => a + b, 1, 2); -const pt4: CoreJSPromiseAndPromiseLike = promiseTry((x: string) => x + '!!', 'test'); -const pt5: CoreJSPromiseAndPromiseLike = promiseTry(() => {}); -const pt6: CoreJSPromiseAndPromiseLike = promiseTry((b: boolean) => b, false); - -const pt7: CoreJSPromiseAndPromiseLike = promiseTry((a: number, b: string, c: boolean) => c ? a : Number(b), 10, '100', true); -const pt8: CoreJSPromiseAndPromiseLike = promiseTry((a: string) => promiseResolve(a), 'bar'); - -declare function returnsPromise(): CoreJSPromiseAndPromiseLike; -const pt9: CoreJSPromiseAndPromiseLike = promiseTry(() => returnsPromise()); +import { assertCoreJSPromiseLike } from '../../helpers'; + +const pt1 = promiseTry(() => 42); +assertCoreJSPromiseLike(pt1); +const pt2 = promiseTry(() => promiseResolve('hi')); +assertCoreJSPromiseLike(pt2); +const pt3 = promiseTry((a: number, b: number) => a + b, 1, 2); +assertCoreJSPromiseLike(pt3); +const pt4 = promiseTry((x: string) => x + '!!', 'test'); +assertCoreJSPromiseLike(pt4); +const pt5 = promiseTry(() => {}); +assertCoreJSPromiseLike(pt5); +const pt6 = promiseTry((b: boolean) => b, false); +assertCoreJSPromiseLike(pt6); + +const pt7 = promiseTry((a: number, b: string, c: boolean) => c ? a : Number(b), 10, '100', true); +assertCoreJSPromiseLike(pt7); +const pt8 = promiseTry((a: string) => promiseResolve(a), 'bar'); +assertCoreJSPromiseLike(pt8); + +const pt9 = promiseTry(() => pt1); +assertCoreJSPromiseLike(pt9); // @ts-expect-error promiseTry(); diff --git a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts index 197cf58cf3eb..23aa94e210f8 100644 --- a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts +++ b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts @@ -1,14 +1,17 @@ import promiseWithResolvers from '@core-js/pure/full/promise/with-resolvers'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { CoreJSPromiseAndPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers'; const pr = promiseWithResolvers(); const pr2 = promiseWithResolvers(); const pr3 = promiseWithResolvers(); -const p1: CoreJSPromiseAndPromiseLike = pr.promise; -const p2: CoreJSPromiseAndPromiseLike = pr2.promise; -const p3: CoreJSPromiseAndPromiseLike = pr3.promise; +const p1 = pr.promise; +assertCoreJSPromiseLike(p1); +const p2 = pr2.promise; +assertCoreJSPromiseLike(p2); +const p3 = pr3.promise; +assertCoreJSPromiseLike(p3); pr.resolve(42); pr.resolve(promiseResolve(43)); diff --git a/tests/type-definitions/pure/proposals/set-methods.test.ts b/tests/type-definitions/pure/proposals/set-methods.test.ts index 37dcd242bc3a..4f376230d0d0 100644 --- a/tests/type-definitions/pure/proposals/set-methods.test.ts +++ b/tests/type-definitions/pure/proposals/set-methods.test.ts @@ -6,7 +6,7 @@ import setSymmetricDifference from '@core-js/pure/full/set/symmetric-difference' import setIsSubsetOf from '@core-js/pure/full/set/is-subset-of'; import setIsSupersetOf from '@core-js/pure/full/set/is-superset-of'; import setIsDisjointFrom from '@core-js/pure/full/set/is-disjoint-from'; -import { CoreJSSetAndSetLike } from '../../helpers'; +import { assertCoreJSSetLike } from '../../helpers'; const setA = new $Set([1, 2, 3]); const setB = new $Set(['a', 'b', 'c']); @@ -23,20 +23,31 @@ const setLikeStr = { size: 2, }; -const unionAB: CoreJSSetAndSetLike = setUnion(setA, setB); -const unionAL: CoreJSSetAndSetLike = setUnion(setA, setLike); -const unionALS: CoreJSSetAndSetLike = setUnion(setA, setLikeStr); +const unionAB = setUnion(setA, setB); +assertCoreJSSetLike(unionAB); +const unionAL = setUnion(setA, setLike); +assertCoreJSSetLike(unionAL); +const unionALS = setUnion(setA, setLikeStr); +assertCoreJSSetLike(unionALS); -const interAB: CoreJSSetAndSetLike = setIntersection(setA, setB); -const interAN: CoreJSSetAndSetLike = setIntersection(setA, setLike); -const intersectionALS: CoreJSSetAndSetLike = setIntersection(setA, setLikeStr); +const interAB = setIntersection(setA, setB); +assertCoreJSSetLike(interAB); +const interAN = setIntersection(setA, setLike); +assertCoreJSSetLike(interAN); +const intersectionALS = setIntersection(setA, setLikeStr); +assertCoreJSSetLike(intersectionALS); -const diffAB: CoreJSSetAndSetLike = setDifference(setA, setB); -const diffAN: CoreJSSetAndSetLike = setDifference(setA, setLike); -const diffALS: CoreJSSetAndSetLike = setDifference(setA, setLikeStr); +const diffAB = setDifference(setA, setB); +assertCoreJSSetLike(diffAB); +const diffAN = setDifference(setA, setLike); +assertCoreJSSetLike(diffAN); +const diffALS = setDifference(setA, setLikeStr); +assertCoreJSSetLike(diffALS); -const symdiffAB: CoreJSSetAndSetLike = setSymmetricDifference(setA, setB); -const symdiffAL: CoreJSSetAndSetLike = setSymmetricDifference(setA, setLike); +const symdiffAB = setSymmetricDifference(setA, setB); +assertCoreJSSetLike(symdiffAB); +const symdiffAL = setSymmetricDifference(setA, setLike); +assertCoreJSSetLike(symdiffAL); const sub: boolean = setIsSubsetOf(setA, setLikeStr); const superSet: boolean = setIsSupersetOf(setA, setLikeStr); From 352982504a3f662d4d6d832e906918cf6cf5488f Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 27 Jan 2026 22:56:52 +0700 Subject: [PATCH 157/315] TS 5.5 stabilization --- .../ts5-2/core-js-types/iterator-object.d.ts | 5 + .../pure/core-js-types/iterator-object.d.ts | 7 ++ .../proposals/async-iterator-helpers.d.ts | 110 ++++++++++++++++++ .../src/ts5-2/pure/proposals/iterator.d.ts | 23 ++-- .../ts5-2/web/iterable-dom-collections.d.ts | 78 +++++++------ tests/type-definitions/helpers.ts | 3 +- 6 files changed, 172 insertions(+), 54 deletions(-) create mode 100644 packages/core-js-types/src/ts5-2/core-js-types/iterator-object.d.ts create mode 100644 packages/core-js-types/src/ts5-2/pure/core-js-types/iterator-object.d.ts create mode 100644 packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts diff --git a/packages/core-js-types/src/ts5-2/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/ts5-2/core-js-types/iterator-object.d.ts new file mode 100644 index 000000000000..03a97c763925 --- /dev/null +++ b/packages/core-js-types/src/ts5-2/core-js-types/iterator-object.d.ts @@ -0,0 +1,5 @@ +// Motivation: Iterator until TS 5.6 used undefined as TNext defaults + +declare namespace CoreJS { + export interface CoreJSIteratorObject extends Iterator {} +} diff --git a/packages/core-js-types/src/ts5-2/pure/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/ts5-2/pure/core-js-types/iterator-object.d.ts new file mode 100644 index 000000000000..85721af98d3c --- /dev/null +++ b/packages/core-js-types/src/ts5-2/pure/core-js-types/iterator-object.d.ts @@ -0,0 +1,7 @@ +/// + +// Motivation: Iterator until TS 5.6 used undefined as TNext defaults + +declare namespace CoreJS { + export interface CoreJSIteratorObject extends CoreJSIterator {} +} diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts new file mode 100644 index 000000000000..05019f8e4259 --- /dev/null +++ b/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts @@ -0,0 +1,110 @@ +/// +/// +/// + +// Motivation: Has dependencies on internal types, e.g. AsyncIterable, AsyncIteratorObject +// Motivation: Iterator until TS 5.6 used undefined as TNext defaults + +// proposal stage: 2 +// https://github.com/tc39/proposal-async-iterator-helpers + +declare namespace CoreJS { + export interface CoreJSAsyncIteratorConstructor { + /** + * Creates an `AsyncIterator` from an iterable object + * @param iterable - An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` + * @returns A new `AsyncIterator` instance + */ + from(iterable: CoreJSAsyncIterable | Iterable | CoreJSAsyncIteratorObject): CoreJSAsyncIteratorObject; + } + + export interface CoreJSAsyncIterator { + + /** + * Drops elements from the iterator until the limit is reached + * @param limit - The number of elements to drop + * @returns A new `AsyncIterator` + */ + drop(limit: number): CoreJSAsyncIteratorObject; + + /** + * Check if every value generated by the iterator passes the `predicate` function. + * @param predicate - A function that tests each element of the iterator + * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` + */ + every(predicate: (value: T, index: number) => boolean): CoreJSPromise; + + /** + * Creates a new `AsyncIterator` that contains only the elements that pass the `predicate` function. + * @param predicate - A function that tests each element of the iterator + * @returns A new `AsyncIterator` + */ + filter(predicate: (value: T, index: number) => boolean): CoreJSAsyncIteratorObject; + + /** + * Finds the first element in the iterator that satisfies the `predicate` function. + * @param predicate - A function that tests each element of the iterator + * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` + */ + find(predicate: (value: T, index: number) => boolean): CoreJSPromise; + + /** + * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. + * @param mapper - A function that transforms each element of the iterator + * @returns A new `AsyncIterator` + */ + flatMap(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorObject; + + /** + * Executes a provided function once for each element in the iterator. + * @param callbackFn - A function that is called for each element of the iterator + * @returns A `Promise` that resolves when all elements have been processed + */ + forEach(callbackFn: (value: T, index: number) => void): CoreJSPromise; + + /** + * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. + * @param mapper - A function that transforms each element of the iterator + * @returns A new `AsyncIterator` + */ + map(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorObject; + + /** + * Reduces the elements of the iterator to a single value using the `reducer` function. + * @param reducer - A function that combines two elements of the iterator + * @param initialValue - An optional initial value to start the reduction + * @returns A `Promise` that resolves to the reduced value + */ + reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): CoreJSPromise; + + /** + * Checks if any value in the iterator matches a given `predicate` + * @param predicate - A function that tests each element of the iterator + * @returns A `Promise` that resolves to `true` if any element passes the `predicate`, otherwise `false` + */ + some(predicate: (value: T, index: number) => boolean): CoreJSPromise; + + /** + * Creates a new `AsyncIterator` that yields only the first `limit` elements from the original iterator. + * @param limit - The maximum number of elements to take + * @returns A new `AsyncIterator` + */ + take(limit: number): CoreJSAsyncIteratorObject; + + /** + * Collects all elements from the iterator into an array. + * @returns A `Promise` that resolves to an array containing all elements from the iterator + */ + toArray(): CoreJSPromise; + } + + var CoreJSAsyncIterator: CoreJSAsyncIteratorConstructor; + + interface CoreJSIterator extends Iterator { + /** + * Creates an `AsyncIterator` from the current `Iterator` + * @returns A new `AsyncIterator` instance + */ + toAsync(): CoreJSAsyncIteratorObject; + } +} diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index 61b866a42141..9b0c60a2cb11 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -1,5 +1,6 @@ -/// -/// +/// +/// +/// // Motivation: Has dependencies on internal types // Motivation: Iterable until TS 5.6 used only one type parameter @@ -63,7 +64,7 @@ declare namespace CoreJS { export interface CoreJSIteratorObject extends CoreJSDisposable {} - export interface CoreJSIterator extends Iterator { + export interface CoreJSIterator extends Iterator { /** * Yields arrays containing up to the specified number of elements * chunked from the source iterator. @@ -190,18 +191,8 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. */ - zip(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[T, U]>; + zip(iterables: Iterable>, options?: ZipOptions): CoreJSIteratorObject; - /** - * takes an object whose values are iterables and produces an iterable of objects where keys. - * correspond to keys in the passed object. - * @param iterables - An Iterable of iterables. - * @param options - Optional object: - * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; - * - padding: an object specifying padding values for each key when mode is 'longest'. - * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. - */ - zipKeyed(iterables: Iterable, options?: ZipOptions): CoreJSIteratorObject<[number, T, U]>; /** * takes an object whose values are iterables and produces an iterable of objects where keys. * correspond to keys in the passed object. @@ -211,7 +202,7 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. */ - zipKeyed(record: Record>, options?: ZipOptions): CoreJSIteratorObject<[PropertyKey, T, U]>; + zipKeyed }>(record: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }>; /** * Returns an iterator that generates a sequence of numbers or bigints within a range. @@ -229,7 +220,7 @@ declare namespace CoreJS { * @param iterators - The iterables to concatenate. * @returns An iterator yielding values from each input iterable in sequence. */ - concat(...iterators: Iterable[]): CoreJSIteratorObject; + concat(...iterators: Iterable[]): CoreJSIteratorObject; } var CoreJSIterator: CoreJSIteratorConstructor; diff --git a/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts index 23ce781ca483..14b092474e55 100644 --- a/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts +++ b/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts @@ -1,4 +1,8 @@ -// use only with DOM lib +// Fallbacks for DOM types +interface Element {} // @type-options no-export +interface Node {} // @type-options no-export +interface HTMLOptionElement {} // @type-options no-export + interface ArrayIterator extends IteratorObject { // @type-options no-export [Symbol.iterator](): ArrayIterator; } @@ -18,19 +22,19 @@ interface DOMTokenList { // @type-options no-export /** * Returns an iterable of keys in the DOMTokenList. */ - keys(): Iterable; + keys(): IterableIterator; /** * Returns an iterable of values in the DOMTokenList. */ - values(): Iterable; + values(): IterableIterator; /** * Returns an iterable of key, value pairs in the DOMTokenList. */ - entries(): Iterable<[number, Element]>; + entries(): IterableIterator<[number, Element]>; - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface NodeList { // @type-options no-export @@ -48,85 +52,85 @@ interface NodeList { // @type-options no-export /** * Returns an iterable of keys in the NodeList. */ - keys(): Iterable; + keys(): IterableIterator; /** * Returns an iterable of values in the NodeList. */ - values(): Iterable; + values(): IterableIterator; /** * Returns an iterable of key, value pairs in the NodeList. */ - entries(): Iterable<[number, Node]>; + entries(): IterableIterator<[number, Node]>; /** * Returns an iterable of values in the NodeList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface CSSRuleList { // @type-options no-export /** * Returns an iterable of values in the CSSRuleList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface CSSStyleDeclaration { // @type-options no-export /** * Returns an iterable of values in the CSSStyleDeclaration. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface CSSValueList { // @type-options no-export /** * Returns an iterable of values in the CSSValueList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface ClientRectList { // @type-options no-export /** * Returns an iterable of values in the ClientRectList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface DOMRectList { // @type-options no-export /** * Returns an iterable of values in the DOMRectList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface DOMStringList { // @type-options no-export /** * Returns an iterable of values in the DOMStringList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface DataTransferItemList { // @type-options no-export /** * Returns an iterable of values in the DataTransferItemList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface FileList { // @type-options no-export /** * Returns an iterable of values in the FileList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface HTMLAllCollection { // @type-options no-export /** * Returns an iterable of values in the HTMLAllCollection. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface HTMLCollection { // @type-options no-export @@ -140,105 +144,105 @@ interface HTMLFormElement { // @type-options no-export /** * Returns an iterable of values in the HTMLFormElement. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface HTMLSelectElement { // @type-options no-export /** * Returns an iterable of values in the HTMLSelectElement. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface MediaList { // @type-options no-export /** * Returns an iterable of values in the MediaList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface MimeTypeArray { // @type-options no-export /** * Returns an iterable of values in the MimeTypeArray. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface NamedNodeMap { // @type-options no-export /** * Returns an iterable of values in the NamedNodeMap. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface PaintRequestList { // @type-options no-export /** * Returns an iterable of values in the PaintRequestList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface Plugin { // @type-options no-export /** * Returns an iterable of values in the Plugin. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface PluginArray { // @type-options no-export /** * Returns an iterable of values in the PluginArray. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SVGLengthList { // @type-options no-export /** * Returns an iterable of values in the SVGLengthList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SVGNumberList { // @type-options no-export /** * Returns an iterable of values in the SVGNumberList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SVGPathSegList { // @type-options no-export /** * Returns an iterable of values in the SVGPathSegList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SVGPointList { // @type-options no-export /** * Returns an iterable of values in the SVGPointList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SVGStringList { // @type-options no-export /** * Returns an iterable of values in the SVGStringList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SVGTransformList { // @type-options no-export /** * Returns an iterable of values in the SVGTransformList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface SourceBufferList { // @type-options no-export /** * Returns an iterable of values in the SourceBufferList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface StyleSheetList { // @type-options no-export @@ -246,26 +250,26 @@ interface StyleSheetList { // @type-options no-export * Returns an iterable of values in the StyleSheetList. * */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface TextTrackCueList { // @type-options no-export /** * Returns an iterable of values in the TextTrackCueList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface TextTrackList { // @type-options no-export /** * Returns an iterable of values in the TextTrackList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } interface TouchList { // @type-options no-export /** * Returns an iterable of values in the TouchList. */ - [Symbol.iterator](): Iterable; + [Symbol.iterator](): IterableIterator; } diff --git a/tests/type-definitions/helpers.ts b/tests/type-definitions/helpers.ts index 601c422f0597..1b089a55c45b 100644 --- a/tests/type-definitions/helpers.ts +++ b/tests/type-definitions/helpers.ts @@ -33,7 +33,8 @@ export function assertCoreJSSetLike(value: CoreJSSetLike): asserts value i export interface CoreJSWeakSetLike extends WeakSet {} export function assertCoreJSWeakSetLike(value: CoreJSWeakSetLike): asserts value is CoreJSWeakSetLike {} -export interface CoreJSIteratorLike extends Iterator { +// TNext undefined added because of until TS 5.6 Iterator used undefined as TNext defaults +export interface CoreJSIteratorLike extends Iterator { chunks(...args: any[]): CoreJSIteratorLike; windows(...args: any[]): CoreJSIteratorLike; map(...args: any[]): CoreJSIteratorLike; From 3fa0fb99334b4f3f8257dc1e63e396eec115d551 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 27 Jan 2026 23:39:14 +0700 Subject: [PATCH 158/315] use @ in @type-options directive --- .../src/base/core-js-modules/url.d.ts | 2 + .../src/base/proposals/array-filtering.d.ts | 26 +++---- .../base/proposals/array-find-from-last.d.ts | 26 +++---- .../src/base/proposals/array-flat-map.d.ts | 4 +- .../src/base/proposals/array-from-async.d.ts | 4 +- .../src/base/proposals/array-grouping.d.ts | 2 +- .../src/base/proposals/array-includes.d.ts | 26 +++---- .../proposals/array-is-template-object.d.ts | 2 +- .../src/base/proposals/array-unique.d.ts | 26 +++---- .../base/proposals/change-array-by-copy.d.ts | 26 +++---- .../data-view-get-set-uint8-clamped.d.ts | 2 +- .../src/base/proposals/error-cause.d.ts | 18 ++--- .../explicit-resource-management.d.ts | 10 +-- .../src/base/proposals/float16.d.ts | 4 +- .../base/proposals/function-demethodize.d.ts | 2 +- .../src/base/proposals/is-error.d.ts | 2 +- .../src/base/proposals/iterator-helpers.d.ts | 2 +- .../src/base/proposals/iterator-joint.d.ts | 6 +- .../src/base/proposals/iterator-range.d.ts | 4 +- .../base/proposals/iterator-sequencing.d.ts | 2 +- .../proposals/json-parse-with-source.d.ts | 6 +- .../src/base/proposals/map-upsert.d.ts | 4 +- .../src/base/proposals/math-sum.d.ts | 2 +- .../src/base/proposals/number-clamp.d.ts | 2 +- .../base/proposals/promise-all-settled.d.ts | 4 +- .../src/base/proposals/promise-any.d.ts | 8 +-- .../src/base/proposals/promise-finally.d.ts | 2 +- .../src/base/proposals/promise-try.d.ts | 2 +- .../proposals/promise-with-resolvers.d.ts | 4 +- .../src/base/proposals/set-methods.d.ts | 22 +++--- .../proposals/string-left-right-trim.d.ts | 2 +- .../src/base/proposals/string-padding.d.ts | 2 +- .../base/proposals/string-replace-all.d.ts | 2 +- .../well-formed-unicode-strings.d.ts | 2 +- .../base/web/iterable-dom-collections.d.ts | 70 +++++++++---------- .../src/base/web/structured-clone.d.ts | 2 +- .../explicit-resource-management.d.ts | 10 +-- .../src/ts5-2/proposals/iterator-helpers.d.ts | 2 +- .../ts5-2/web/iterable-dom-collections.d.ts | 70 +++++++++---------- scripts/build-types/pure.mjs | 2 +- 40 files changed, 209 insertions(+), 207 deletions(-) diff --git a/packages/core-js-types/src/base/core-js-modules/url.d.ts b/packages/core-js-types/src/base/core-js-modules/url.d.ts index 3a0f0ba2509c..646ac472ae9a 100644 --- a/packages/core-js-types/src/base/core-js-modules/url.d.ts +++ b/packages/core-js-types/src/base/core-js-modules/url.d.ts @@ -1,3 +1,5 @@ +// TODO remove if URL conflict cannot be resolved + declare module 'core-js/internals/web/url' { interface URL { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */ diff --git a/packages/core-js-types/src/base/proposals/array-filtering.d.ts b/packages/core-js-types/src/base/proposals/array-filtering.d.ts index 15a42b610b63..c63b0f32f4f2 100644 --- a/packages/core-js-types/src/base/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/base/proposals/array-filtering.d.ts @@ -1,6 +1,6 @@ // https://github.com/tc39/proposal-array-filtering -interface Array { // @type-options no-redefine +interface Array { // @type-options: no-redefine /** * Removes the items that return true * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the @@ -11,7 +11,7 @@ interface Array { // @type-options no-redefine filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; } -interface ReadonlyArray { // @type-options no-export +interface ReadonlyArray { // @type-options: no-export /** * Removes the items that return true * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the @@ -22,7 +22,7 @@ interface ReadonlyArray { // @type-options no-export filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; } -interface Int8Array { // @type-options no-export +interface Int8Array { // @type-options: no-export /** * Removes the items that return true * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the @@ -33,7 +33,7 @@ interface Int8Array { // @type-options no-export filterReject(callbackFn: (value: number, index: number, target: Int8Array) => boolean, thisArg?: any): Int8Array; } -interface Uint8Array { // @type-options no-export +interface Uint8Array { // @type-options: no-export /** * Removes the items that return true * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the @@ -44,7 +44,7 @@ interface Uint8Array { // @type-options no-export filterReject(callbackFn: (value: number, index: number, target: Uint8Array) => boolean, thisArg?: any): Uint8Array; } -interface Uint8ClampedArray { // @type-options no-export +interface Uint8ClampedArray { // @type-options: no-export /** * Removes the items that return true * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the @@ -55,7 +55,7 @@ interface Uint8ClampedArray { // @type-options no-export filterReject(callbackFn: (value: number, index: number, target: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; } -interface Int16Array { // @type-options no-export +interface Int16Array { // @type-options: no-export /** * Removes the items that return true * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the @@ -66,7 +66,7 @@ interface Int16Array { // @type-options no-export filterReject(callbackFn: (value: number, index: number, target: Int16Array) => boolean, thisArg?: any): Int16Array; } -interface Uint16Array { // @type-options no-export +interface Uint16Array { // @type-options: no-export /** * Removes the items that return true * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the @@ -77,7 +77,7 @@ interface Uint16Array { // @type-options no-export filterReject(callbackFn: (value: number, index: number, target: Uint16Array) => boolean, thisArg?: any): Uint16Array; } -interface Int32Array { // @type-options no-export +interface Int32Array { // @type-options: no-export /** * Removes the items that return true * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the @@ -88,7 +88,7 @@ interface Int32Array { // @type-options no-export filterReject(callbackFn: (value: number, index: number, target: Int32Array) => boolean, thisArg?: any): Int32Array; } -interface Uint32Array { // @type-options no-export +interface Uint32Array { // @type-options: no-export /** * Removes the items that return true * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the @@ -99,7 +99,7 @@ interface Uint32Array { // @type-options no-export filterReject(callbackFn: (value: number, index: number, target: Uint32Array) => boolean, thisArg?: any): Uint32Array; } -interface Float32Array { // @type-options no-export +interface Float32Array { // @type-options: no-export /** * Removes the items that return true * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the @@ -110,7 +110,7 @@ interface Float32Array { // @type-options no-export filterReject(callbackFn: (value: number, index: number, target: Float32Array) => boolean, thisArg?: any): Float32Array; } -interface Float64Array { // @type-options no-export +interface Float64Array { // @type-options: no-export /** * Removes the items that return true * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the @@ -121,7 +121,7 @@ interface Float64Array { // @type-options no-export filterReject(callbackFn: (value: number, index: number, target: Float64Array) => boolean, thisArg?: any): Float64Array; } -interface BigInt64Array { // @type-options no-export +interface BigInt64Array { // @type-options: no-export /** * Removes the items that return true * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the @@ -132,7 +132,7 @@ interface BigInt64Array { // @type-options no-export filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array; } -interface BigUint64Array { // @type-options no-export +interface BigUint64Array { // @type-options: no-export /** * Removes the items that return true * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the diff --git a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts index 168e5a5f8104..cb7f277b2a63 100644 --- a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts @@ -4,7 +4,7 @@ // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface Array { // @type-options no-redefine +interface Array { // @type-options: no-redefine /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -29,7 +29,7 @@ interface Array { // @type-options no-redefine findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; } -interface ReadonlyArray { // @type-options no-export +interface ReadonlyArray { // @type-options: no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -54,7 +54,7 @@ interface ReadonlyArray { // @type-options no-export findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; } -interface Int8Array { // @type-options no-export +interface Int8Array { // @type-options: no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -79,7 +79,7 @@ interface Int8Array { // @type-options no-export findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Uint8Array { // @type-options no-export +interface Uint8Array { // @type-options: no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -104,7 +104,7 @@ interface Uint8Array { // @type-options no-export findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Uint8ClampedArray { // @type-options no-export +interface Uint8ClampedArray { // @type-options: no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -129,7 +129,7 @@ interface Uint8ClampedArray { // @type-options no-export findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Int16Array { // @type-options no-export +interface Int16Array { // @type-options: no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -154,7 +154,7 @@ interface Int16Array { // @type-options no-export findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Uint16Array { // @type-options no-export +interface Uint16Array { // @type-options: no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -179,7 +179,7 @@ interface Uint16Array { // @type-options no-export findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Int32Array { // @type-options no-export +interface Int32Array { // @type-options: no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -204,7 +204,7 @@ interface Int32Array { // @type-options no-export findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Uint32Array { // @type-options no-export +interface Uint32Array { // @type-options: no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -229,7 +229,7 @@ interface Uint32Array { // @type-options no-export findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Float32Array { // @type-options no-export +interface Float32Array { // @type-options: no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -254,7 +254,7 @@ interface Float32Array { // @type-options no-export findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface Float64Array { // @type-options no-export +interface Float64Array { // @type-options: no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -270,7 +270,7 @@ interface Float64Array { // @type-options no-export findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } -interface BigInt64Array { // @type-options no-export +interface BigInt64Array { // @type-options: no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -295,7 +295,7 @@ interface BigInt64Array { // @type-options no-export findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number; } -interface BigUint64Array { // @type-options no-export +interface BigUint64Array { // @type-options: no-export /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. diff --git a/packages/core-js-types/src/base/proposals/array-flat-map.d.ts b/packages/core-js-types/src/base/proposals/array-flat-map.d.ts index d046a2d03f58..78fcf21c8f7d 100644 --- a/packages/core-js-types/src/base/proposals/array-flat-map.d.ts +++ b/packages/core-js-types/src/base/proposals/array-flat-map.d.ts @@ -6,7 +6,7 @@ // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46 // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface Array { // @type-options no-redefine +interface Array { // @type-options: no-redefine /** * Calls a defined callback function on each element of an array. Then, flattens the result into * a new array. @@ -26,7 +26,7 @@ interface Array { // @type-options no-redefine flat(this: A, depth?: D): CoreJS.CoreJSFlatArray[]; } -interface ReadonlyArray { // @type-options no-export +interface ReadonlyArray { // @type-options: no-export /** * Calls a defined callback function on each element of an array. Then, flattens the result into * a new array. diff --git a/packages/core-js-types/src/base/proposals/array-from-async.d.ts b/packages/core-js-types/src/base/proposals/array-from-async.d.ts index 5bd012b78002..206773a4c672 100644 --- a/packages/core-js-types/src/base/proposals/array-from-async.d.ts +++ b/packages/core-js-types/src/base/proposals/array-from-async.d.ts @@ -9,7 +9,7 @@ interface ArrayConstructor { * Creates an array from an async iterator or iterable object. * @param iterableOrArrayLike - An async iterator or array-like object to convert to an array. */ - fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; // @type-options prefix-return-type + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; // @type-options: prefix-return-type /** * Creates an array from an async iterator or iterable object. @@ -19,5 +19,5 @@ interface ArrayConstructor { * Each return value is awaited before being added to result array. * @param thisArg - Value of 'this' used when executing mapFn. */ - fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; // @type-options prefix-return-type + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; // @type-options: prefix-return-type } diff --git a/packages/core-js-types/src/base/proposals/array-grouping.d.ts b/packages/core-js-types/src/base/proposals/array-grouping.d.ts index c5f5def164e3..4fd8335c8894 100644 --- a/packages/core-js-types/src/base/proposals/array-grouping.d.ts +++ b/packages/core-js-types/src/base/proposals/array-grouping.d.ts @@ -20,5 +20,5 @@ interface MapConstructor { * @param items - An iterable. * @param keySelector - A callback which will be invoked for each item in items. */ - groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Map; // @type-options prefix-return-type + groupBy(items: Iterable, keySelector: (item: T, index: number) => K): Map; // @type-options: prefix-return-type } diff --git a/packages/core-js-types/src/base/proposals/array-includes.d.ts b/packages/core-js-types/src/base/proposals/array-includes.d.ts index a9cae03d56bf..60549d7221ca 100644 --- a/packages/core-js-types/src/base/proposals/array-includes.d.ts +++ b/packages/core-js-types/src/base/proposals/array-includes.d.ts @@ -4,7 +4,7 @@ // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2016.array.include.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface Array { // @type-options no-redefine +interface Array { // @type-options: no-redefine /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement - The element to search for. @@ -13,7 +13,7 @@ interface Array { // @type-options no-redefine includes(searchElement: T, fromIndex?: number): boolean; } -interface ReadonlyArray { // @type-options no-export +interface ReadonlyArray { // @type-options: no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement - The element to search for. @@ -22,7 +22,7 @@ interface ReadonlyArray { // @type-options no-export includes(searchElement: T, fromIndex?: number): boolean; } -interface Int8Array { // @type-options no-export +interface Int8Array { // @type-options: no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement - The element to search for. @@ -31,7 +31,7 @@ interface Int8Array { // @type-options no-export includes(searchElement: number, fromIndex?: number): boolean; } -interface Uint8Array { // @type-options no-export +interface Uint8Array { // @type-options: no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement - The element to search for. @@ -40,7 +40,7 @@ interface Uint8Array { // @type-options no-export includes(searchElement: number, fromIndex?: number): boolean; } -interface Uint8ClampedArray { // @type-options no-export +interface Uint8ClampedArray { // @type-options: no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement - The element to search for. @@ -49,7 +49,7 @@ interface Uint8ClampedArray { // @type-options no-export includes(searchElement: number, fromIndex?: number): boolean; } -interface Int16Array { // @type-options no-export +interface Int16Array { // @type-options: no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement - The element to search for. @@ -58,7 +58,7 @@ interface Int16Array { // @type-options no-export includes(searchElement: number, fromIndex?: number): boolean; } -interface Uint16Array { // @type-options no-export +interface Uint16Array { // @type-options: no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement - The element to search for. @@ -67,7 +67,7 @@ interface Uint16Array { // @type-options no-export includes(searchElement: number, fromIndex?: number): boolean; } -interface Int32Array { // @type-options no-export +interface Int32Array { // @type-options: no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement - The element to search for. @@ -76,7 +76,7 @@ interface Int32Array { // @type-options no-export includes(searchElement: number, fromIndex?: number): boolean; } -interface Uint32Array { // @type-options no-export +interface Uint32Array { // @type-options: no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement - The element to search for. @@ -85,7 +85,7 @@ interface Uint32Array { // @type-options no-export includes(searchElement: number, fromIndex?: number): boolean; } -interface Float32Array { // @type-options no-export +interface Float32Array { // @type-options: no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement - The element to search for. @@ -94,7 +94,7 @@ interface Float32Array { // @type-options no-export includes(searchElement: number, fromIndex?: number): boolean; } -interface Float64Array { // @type-options no-export +interface Float64Array { // @type-options: no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement - The element to search for. @@ -103,7 +103,7 @@ interface Float64Array { // @type-options no-export includes(searchElement: number, fromIndex?: number): boolean; } -interface BigInt64Array { // @type-options no-export +interface BigInt64Array { // @type-options: no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement - The element to search for. @@ -112,7 +112,7 @@ interface BigInt64Array { // @type-options no-export includes(searchElement: bigint, fromIndex?: number): boolean; } -interface BigUint64Array { // @type-options no-export +interface BigUint64Array { // @type-options: no-export /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement - The element to search for. diff --git a/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts b/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts index 736f9dbf2f1a..28e0ab1cf540 100644 --- a/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts +++ b/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts @@ -1,6 +1,6 @@ // https://github.com/tc39/proposal-array-is-template-object -interface ArrayConstructor { // @type-options no-export +interface ArrayConstructor { // @type-options: no-export /** * Determines whether an `value` is a `TemplateStringsArray` * @param value - The value to be checked diff --git a/packages/core-js-types/src/base/proposals/array-unique.d.ts b/packages/core-js-types/src/base/proposals/array-unique.d.ts index 6d8826bcec04..3c9e18fe9a53 100644 --- a/packages/core-js-types/src/base/proposals/array-unique.d.ts +++ b/packages/core-js-types/src/base/proposals/array-unique.d.ts @@ -1,6 +1,6 @@ // https://github.com/tc39/proposal-array-unique -interface Array { // @type-options no-redefine +interface Array { // @type-options: no-redefine /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, @@ -10,7 +10,7 @@ interface Array { // @type-options no-redefine uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; } -interface ReadonlyArray { // @type-options no-export +interface ReadonlyArray { // @type-options: no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, @@ -20,7 +20,7 @@ interface ReadonlyArray { // @type-options no-export uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; } -interface Int8Array { // @type-options no-export +interface Int8Array { // @type-options: no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, @@ -30,7 +30,7 @@ interface Int8Array { // @type-options no-export uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int8Array; } -interface Uint8Array { // @type-options no-export +interface Uint8Array { // @type-options: no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, @@ -40,7 +40,7 @@ interface Uint8Array { // @type-options no-export uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8Array; } -interface Uint8ClampedArray { // @type-options no-export +interface Uint8ClampedArray { // @type-options: no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, @@ -50,7 +50,7 @@ interface Uint8ClampedArray { // @type-options no-export uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8ClampedArray; } -interface Int16Array { // @type-options no-export +interface Int16Array { // @type-options: no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, @@ -60,7 +60,7 @@ interface Int16Array { // @type-options no-export uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int16Array; } -interface Uint16Array { // @type-options no-export +interface Uint16Array { // @type-options: no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, @@ -70,7 +70,7 @@ interface Uint16Array { // @type-options no-export uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint16Array; } -interface Int32Array { // @type-options no-export +interface Int32Array { // @type-options: no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, @@ -80,7 +80,7 @@ interface Int32Array { // @type-options no-export uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int32Array; } -interface Uint32Array { // @type-options no-export +interface Uint32Array { // @type-options: no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, @@ -90,7 +90,7 @@ interface Uint32Array { // @type-options no-export uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint32Array; } -interface Float32Array { // @type-options no-export +interface Float32Array { // @type-options: no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, @@ -100,7 +100,7 @@ interface Float32Array { // @type-options no-export uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float32Array; } -interface Float64Array { // @type-options no-export +interface Float64Array { // @type-options: no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, @@ -110,7 +110,7 @@ interface Float64Array { // @type-options no-export uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float64Array; } -interface BigInt64Array { // @type-options no-export +interface BigInt64Array { // @type-options: no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, @@ -120,7 +120,7 @@ interface BigInt64Array { // @type-options no-export uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigInt64Array; } -interface BigUint64Array { // @type-options no-export +interface BigUint64Array { // @type-options: no-export /** * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, diff --git a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts index 369d82ebded1..3ae8331c45e9 100644 --- a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts +++ b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts @@ -4,7 +4,7 @@ // https://github.com/microsoft/TypeScript/blob/6afd0fb73fa18a48021ed54f44a0c51794519bf6/src/lib/es2023.array.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface Array { // @type-options no-redefine +interface Array { // @type-options: no-redefine /** * @returns A copy of an array with its elements reversed. */ @@ -49,7 +49,7 @@ interface Array { // @type-options no-redefine with(index: number, value: T): T[]; } -interface ReadonlyArray { // @type-options no-export +interface ReadonlyArray { // @type-options: no-export /** * @returns A copy of an array with its elements reversed. */ @@ -94,7 +94,7 @@ interface ReadonlyArray { // @type-options no-export with(index: number, value: T): T[]; } -interface Int8Array { // @type-options no-export +interface Int8Array { // @type-options: no-export /** * @returns A copy of an array with its elements reversed. */ @@ -122,7 +122,7 @@ interface Int8Array { // @type-options no-export with(index: number, value: number): Int8Array; } -interface Uint8Array { // @type-options no-export +interface Uint8Array { // @type-options: no-export /** * @returns A copy of an array with its elements reversed. */ @@ -150,7 +150,7 @@ interface Uint8Array { // @type-options no-export with(index: number, value: number): Uint8Array; } -interface Uint8ClampedArray { // @type-options no-export +interface Uint8ClampedArray { // @type-options: no-export /** * @returns A copy of an array with its elements reversed. */ @@ -178,7 +178,7 @@ interface Uint8ClampedArray { // @type-options no-export with(index: number, value: number): Uint8ClampedArray; } -interface Int16Array { // @type-options no-export +interface Int16Array { // @type-options: no-export /** * @returns A copy of an array with its elements reversed. */ @@ -206,7 +206,7 @@ interface Int16Array { // @type-options no-export with(index: number, value: number): Int16Array; } -interface Uint16Array { // @type-options no-export +interface Uint16Array { // @type-options: no-export /** * @returns A copy of an array with its elements reversed. */ @@ -234,7 +234,7 @@ interface Uint16Array { // @type-options no-export with(index: number, value: number): Uint16Array; } -interface Int32Array { // @type-options no-export +interface Int32Array { // @type-options: no-export /** * @returns A copy of an array with its elements reversed. */ @@ -262,7 +262,7 @@ interface Int32Array { // @type-options no-export with(index: number, value: number): Int32Array; } -interface Uint32Array { // @type-options no-export +interface Uint32Array { // @type-options: no-export /** * @returns A copy of an array with its elements reversed. */ @@ -290,7 +290,7 @@ interface Uint32Array { // @type-options no-export with(index: number, value: number): Uint32Array; } -interface Float32Array { // @type-options no-export +interface Float32Array { // @type-options: no-export /** * @returns A copy of an array with its elements reversed. */ @@ -318,7 +318,7 @@ interface Float32Array { // @type-options no-export with(index: number, value: number): Float32Array; } -interface Float64Array { // @type-options no-export +interface Float64Array { // @type-options: no-export /** * @returns A copy of an array with its elements reversed. */ @@ -346,7 +346,7 @@ interface Float64Array { // @type-options no-export with(index: number, value: number): Float64Array; } -interface BigInt64Array { // @type-options no-export +interface BigInt64Array { // @type-options: no-export /** * @returns A copy of an array with its elements reversed. */ @@ -374,7 +374,7 @@ interface BigInt64Array { // @type-options no-export with(index: number, value: bigint): BigInt64Array; } -interface BigUint64Array { // @type-options no-export +interface BigUint64Array { // @type-options: no-export /** * @returns A copy of an array with its elements reversed. */ diff --git a/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts b/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts index e8e16f5841e3..6d4e0504a5af 100644 --- a/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts +++ b/packages/core-js-types/src/base/proposals/data-view-get-set-uint8-clamped.d.ts @@ -1,6 +1,6 @@ // https://github.com/tc39/proposal-dataview-get-set-uint8clamped -interface DataView { // @type-options no-constructor +interface DataView { // @type-options: no-constructor /** * Reads an unsigned 8-bit integer at the specified byte offset from the DataView, * interpreting the byte as a clamped 8-bit unsigned value (same as Uint8ClampedArray). diff --git a/packages/core-js-types/src/base/proposals/error-cause.d.ts b/packages/core-js-types/src/base/proposals/error-cause.d.ts index 072aaad33f46..b89ebbb8d7f0 100644 --- a/packages/core-js-types/src/base/proposals/error-cause.d.ts +++ b/packages/core-js-types/src/base/proposals/error-cause.d.ts @@ -4,7 +4,7 @@ // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/es2022.error.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface ErrorOptions { // @type-options no-extends no-prefix no-redefine +interface ErrorOptions { // @type-options: no-extends, no-prefix, no-redefine cause?: unknown; } @@ -12,49 +12,49 @@ interface Error { cause?: unknown; // ts <= 4.7 Error | undefined } -interface ErrorConstructor { // @type-options no-redefine +interface ErrorConstructor { // @type-options: no-redefine new(message?: string, options?: ErrorOptions): Error; (message?: string, options?: ErrorOptions): Error; } -interface EvalErrorConstructor { // @type-options no-export +interface EvalErrorConstructor { // @type-options: no-export new(message?: string, options?: ErrorOptions): EvalError; (message?: string, options?: ErrorOptions): EvalError; } -interface RangeErrorConstructor { // @type-options no-export +interface RangeErrorConstructor { // @type-options: no-export new(message?: string, options?: ErrorOptions): RangeError; (message?: string, options?: ErrorOptions): RangeError; } -interface ReferenceErrorConstructor { // @type-options no-export +interface ReferenceErrorConstructor { // @type-options: no-export new(message?: string, options?: ErrorOptions): ReferenceError; (message?: string, options?: ErrorOptions): ReferenceError; } -interface SyntaxErrorConstructor { // @type-options no-export +interface SyntaxErrorConstructor { // @type-options: no-export new(message?: string, options?: ErrorOptions): SyntaxError; (message?: string, options?: ErrorOptions): SyntaxError; } -interface TypeErrorConstructor { // @type-options no-export +interface TypeErrorConstructor { // @type-options: no-export new(message?: string, options?: ErrorOptions): TypeError; (message?: string, options?: ErrorOptions): TypeError; } -interface URIErrorConstructor { // @type-options no-export +interface URIErrorConstructor { // @type-options: no-export new(message?: string, options?: ErrorOptions): URIError; (message?: string, options?: ErrorOptions): URIError; } -interface AggregateError extends Error { // @type-options no-redefine +interface AggregateError extends Error { // @type-options: no-redefine errors: any[]; cause?: unknown; diff --git a/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts index 5c1ab0eb9888..dabbe5e280dc 100644 --- a/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts @@ -16,11 +16,11 @@ interface SymbolConstructor { readonly asyncDispose: unique symbol; } -interface Disposable { // @type-options no-constructor +interface Disposable { // @type-options: no-constructor [Symbol.dispose](): void; } -interface AsyncDisposable { // @type-options no-constructor +interface AsyncDisposable { // @type-options: no-constructor [Symbol.asyncDispose](): PromiseLike; } @@ -178,7 +178,7 @@ interface AsyncDisposableStack { */ move(): AsyncDisposableStack; - [Symbol.asyncDispose](): Promise; // @type-options prefix-return-type + [Symbol.asyncDispose](): Promise; // @type-options: prefix-return-type readonly [Symbol.toStringTag]: string; } @@ -191,9 +191,9 @@ interface AsyncDisposableStackConstructor { declare var AsyncDisposableStack: AsyncDisposableStackConstructor; -interface IteratorObject extends Disposable {} // @type-options no-extends +interface IteratorObject extends Disposable {} // @type-options: no-extends -interface AsyncIteratorObject extends AsyncDisposable {} // @type-options no-extends +interface AsyncIteratorObject extends AsyncDisposable {} // @type-options: no-extends interface AsyncIteratorConstructor {} diff --git a/packages/core-js-types/src/base/proposals/float16.d.ts b/packages/core-js-types/src/base/proposals/float16.d.ts index f99539b3de55..c431b98be387 100644 --- a/packages/core-js-types/src/base/proposals/float16.d.ts +++ b/packages/core-js-types/src/base/proposals/float16.d.ts @@ -4,7 +4,7 @@ // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.float16.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface Math { // @type-options no-constructor +interface Math { // @type-options: no-constructor /** * Returns the nearest half precision float representation of a number. * @param x - A numeric expression. @@ -12,7 +12,7 @@ interface Math { // @type-options no-constructor f16round(x: number): number; } -interface DataView { // @type-options no-constructor +interface DataView { // @type-options: no-constructor /** * Gets the Float16 value at the specified byte offset from the start of the view. There is * no alignment constraint; multibyte values may be fetched from any offset. diff --git a/packages/core-js-types/src/base/proposals/function-demethodize.d.ts b/packages/core-js-types/src/base/proposals/function-demethodize.d.ts index d50d1d6f4da2..e65831a86423 100644 --- a/packages/core-js-types/src/base/proposals/function-demethodize.d.ts +++ b/packages/core-js-types/src/base/proposals/function-demethodize.d.ts @@ -1,6 +1,6 @@ // https://github.com/js-choi/proposal-function-demethodize -interface Function { // @type-options no-constructor +interface Function { // @type-options: no-constructor /** * Creates a function that calls the original with its first argument as `this` and the rest as regular arguments. * @returns A new function that applies the original function with its `this` set to the first argument. diff --git a/packages/core-js-types/src/base/proposals/is-error.d.ts b/packages/core-js-types/src/base/proposals/is-error.d.ts index 60cba842ebe1..c69cee1fe3ab 100644 --- a/packages/core-js-types/src/base/proposals/is-error.d.ts +++ b/packages/core-js-types/src/base/proposals/is-error.d.ts @@ -4,7 +4,7 @@ // https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/esnext.error.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface ErrorConstructor { // @type-options no-redefine +interface ErrorConstructor { // @type-options: no-redefine /** * Indicates whether the argument provided is a built-in Error instance or not. */ diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts index 5300b83d9c25..d62c2b3e4bf6 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts @@ -99,7 +99,7 @@ declare global { find(predicate: (value: T, index: number) => unknown): T | undefined; } - interface IteratorConstructor { // @type-options no-extends + interface IteratorConstructor { // @type-options: no-extends /** * Creates a native iterator from an iterator or iterable object. * Returns its input if the input already inherits from the built-in Iterator class. diff --git a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts index 90d85a1fdada..84f829796c77 100644 --- a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts @@ -6,7 +6,7 @@ interface ZipOptions { padding?: object; } -interface IteratorConstructor { // @type-options no-extends +interface IteratorConstructor { // @type-options: no-extends /** * Takes an iterable of iterables and produces an iterable of arrays where position corresponds * to position in the passed iterable. @@ -16,7 +16,7 @@ interface IteratorConstructor { // @type-options no-extends * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. */ - zip(iterables: Iterable>, options?: ZipOptions): IteratorObject; // @type-options prefix-return-type + zip(iterables: Iterable>, options?: ZipOptions): IteratorObject; // @type-options: prefix-return-type /** * takes an object whose values are iterables and produces an iterable of objects where keys. @@ -27,7 +27,7 @@ interface IteratorConstructor { // @type-options no-extends * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. */ - zipKeyed }>(record: T, options?: ZipOptions): IteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }>; // @type-options prefix-return-type + zipKeyed }>(record: T, options?: ZipOptions): IteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }>; // @type-options: prefix-return-type } declare var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/base/proposals/iterator-range.d.ts b/packages/core-js-types/src/base/proposals/iterator-range.d.ts index d681df44e58a..9271a97a67ba 100644 --- a/packages/core-js-types/src/base/proposals/iterator-range.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-range.d.ts @@ -6,7 +6,7 @@ interface IteratorRangeOptions { inclusive?: boolean; } -interface IteratorConstructor { // @type-options no-extends +interface IteratorConstructor { // @type-options: no-extends /** * Returns an iterator that generates a sequence of numbers or bigints within a range. * @param start - The starting value of the sequence. @@ -16,7 +16,7 @@ interface IteratorConstructor { // @type-options no-extends * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of numbers or bigints. */ - range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): IteratorObject; // @type-options prefix-return-type + range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): IteratorObject; // @type-options: prefix-return-type } declare var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts index eb0b64da077f..87e76c25d731 100644 --- a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts @@ -2,7 +2,7 @@ // https://github.com/tc39/proposal-iterator-sequencing -interface IteratorConstructor { // @type-options no-extends +interface IteratorConstructor { // @type-options: no-extends /** * Creates an iterator that sequentially yields values from the provided iterables. * @param iterators - The iterables to concatenate. diff --git a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts index 15229bf407ce..354d0ed2cba6 100644 --- a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts +++ b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts @@ -1,18 +1,18 @@ // https://github.com/tc39/proposal-json-parse-with-source -interface CoreJSReviverContext { // @type-options no-extends,no-prefix +interface CoreJSReviverContext { // @type-options: no-extends, no-prefix readonly __brand: unique symbol; source: string; } -interface CoreJSRawJSON { // @type-options no-extends,no-prefix +interface CoreJSRawJSON { // @type-options: no-extends, no-prefix readonly __brand: unique symbol; rawJSON: string; } -interface JSON { // @type-options no-constructor +interface JSON { // @type-options: no-constructor /** * Determines whether a value is a RawJSON object. * @param value - The value to check. diff --git a/packages/core-js-types/src/base/proposals/map-upsert.d.ts b/packages/core-js-types/src/base/proposals/map-upsert.d.ts index 45fe878a391f..6ef9256711c0 100644 --- a/packages/core-js-types/src/base/proposals/map-upsert.d.ts +++ b/packages/core-js-types/src/base/proposals/map-upsert.d.ts @@ -1,6 +1,6 @@ // https://github.com/tc39/proposal-upsert -interface Map { // @type-options no-redefine +interface Map { // @type-options: no-redefine /** * Gets the value for the given key. If the key does not exist, inserts the provided value and returns it. * @param key - The key to look up. @@ -19,7 +19,7 @@ interface Map { // @type-options no-redefine getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; } -interface WeakMap { // @type-options no-redefine +interface WeakMap { // @type-options: no-redefine /** * Gets the value for the given key. If the key does not exist, inserts the provided value and returns it. * @param key - The key to look up. diff --git a/packages/core-js-types/src/base/proposals/math-sum.d.ts b/packages/core-js-types/src/base/proposals/math-sum.d.ts index 13d257a31748..61645f9d8a2b 100644 --- a/packages/core-js-types/src/base/proposals/math-sum.d.ts +++ b/packages/core-js-types/src/base/proposals/math-sum.d.ts @@ -1,5 +1,5 @@ // https://github.com/tc39/proposal-math-sum -interface Math { // @type-options no-constructor +interface Math { // @type-options: no-constructor /** * Returns the sum of all given values. * @param items - An iterable of numbers to sum. diff --git a/packages/core-js-types/src/base/proposals/number-clamp.d.ts b/packages/core-js-types/src/base/proposals/number-clamp.d.ts index f6c82c36adca..5531ce8facab 100644 --- a/packages/core-js-types/src/base/proposals/number-clamp.d.ts +++ b/packages/core-js-types/src/base/proposals/number-clamp.d.ts @@ -1,6 +1,6 @@ // https://github.com/tc39/proposal-math-clamp -interface Number { // @type-options export-base-constructor +interface Number { // @type-options: export-base-constructor /** * Clamps the number within the inclusive lower and upper bounds. * @param lower - The lower bound. diff --git a/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts index ab51fdf89fe9..2aa1900fd098 100644 --- a/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts @@ -13,7 +13,7 @@ interface PromiseConstructor { * @param values - An array of Promises. * @returns A new Promise. */ - allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJS.CoreJSPromiseSettledResult>; }>; // @type-options prefix-return-type + allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJS.CoreJSPromiseSettledResult>; }>; // @type-options: prefix-return-type /** * Creates a Promise that is resolved with an array of results when all @@ -21,5 +21,5 @@ interface PromiseConstructor { * @param values - An array of Promises. * @returns A new Promise. */ - allSettled(values: Iterable>): Promise>[]>; // @type-options prefix-return-type + allSettled(values: Iterable>): Promise>[]>; // @type-options: prefix-return-type } diff --git a/packages/core-js-types/src/base/proposals/promise-any.d.ts b/packages/core-js-types/src/base/proposals/promise-any.d.ts index 720b443ebfa8..df1d842b42a4 100644 --- a/packages/core-js-types/src/base/proposals/promise-any.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-any.d.ts @@ -10,21 +10,21 @@ interface PromiseConstructor { * @param values - An array or iterable of Promises. * @returns A new Promise. */ - any(values: T): Promise>; // @type-options prefix-return-type + any(values: T): Promise>; // @type-options: prefix-return-type /** * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. * @param values - An array or iterable of Promises. * @returns A new Promise. */ - any(values: Iterable>): Promise>; // @type-options prefix-return-type + any(values: Iterable>): Promise>; // @type-options: prefix-return-type } -interface AggregateError extends Error { // @type-options no-redefine +interface AggregateError extends Error { // @type-options: no-redefine errors: any[]; } -interface AggregateErrorConstructor { // @type-options no-extends no-redefine +interface AggregateErrorConstructor { // @type-options: no-extends, no-redefine new (errors: Iterable, message?: string): AggregateError; (errors: Iterable, message?: string): AggregateError; readonly prototype: AggregateError; diff --git a/packages/core-js-types/src/base/proposals/promise-finally.d.ts b/packages/core-js-types/src/base/proposals/promise-finally.d.ts index e7410569e361..301ae177a2c1 100644 --- a/packages/core-js-types/src/base/proposals/promise-finally.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-finally.d.ts @@ -11,5 +11,5 @@ interface Promise { * @param onfinally - The callback to execute when the Promise is settled (fulfilled or rejected). * @returns A Promise for the completion of the callback. */ - finally(onfinally?: (() => void) | undefined | null): Promise; // @type-options prefix-return-type + finally(onfinally?: (() => void) | undefined | null): Promise; // @type-options: prefix-return-type } diff --git a/packages/core-js-types/src/base/proposals/promise-try.d.ts b/packages/core-js-types/src/base/proposals/promise-try.d.ts index adda8b3f5269..9fd477c53e6e 100644 --- a/packages/core-js-types/src/base/proposals/promise-try.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-try.d.ts @@ -18,6 +18,6 @@ interface PromiseConstructor { * - Already rejected, if the callback synchronously throws an error. * - Asynchronously fulfilled or rejected, if the callback returns a promise. */ - try(callbackFn: (...args: U) => T | PromiseLike, ...args: U): Promise>; // @type-options prefix-return-type + try(callbackFn: (...args: U) => T | PromiseLike, ...args: U): Promise>; // @type-options: prefix-return-type } diff --git a/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts index fbb80469e1f5..e3fee749a5a9 100644 --- a/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts @@ -4,8 +4,8 @@ // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2024.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface PromiseWithResolvers { // @type-options no-extends, no-prefix - promise: Promise; // @type-options prefix-return-type +interface PromiseWithResolvers { // @type-options: no-extends, no-prefix + promise: Promise; // @type-options: prefix-return-type resolve: (value: T | PromiseLike) => void; diff --git a/packages/core-js-types/src/base/proposals/set-methods.d.ts b/packages/core-js-types/src/base/proposals/set-methods.d.ts index c0c8c90e62a6..658beb4addee 100644 --- a/packages/core-js-types/src/base/proposals/set-methods.d.ts +++ b/packages/core-js-types/src/base/proposals/set-methods.d.ts @@ -4,7 +4,7 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/esnext.collection.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface ReadonlySetLike { // @type-options no-extends, no-prefix +interface ReadonlySetLike { // @type-options: no-extends, no-prefix /** * Despite its name, returns an iterator of the values in the set-like. */ @@ -21,26 +21,26 @@ interface ReadonlySetLike { // @type-options no-extends, no-prefix readonly size: number; } -interface Set { // @type-options no-redefine +interface Set { // @type-options: no-redefine /** * @returns a new Set containing all the elements in this Set and also all the elements in the argument. */ - union(other: ReadonlySetLike): Set; // @type-options prefix-return-type + union(other: ReadonlySetLike): Set; // @type-options: prefix-return-type /** * @returns a new Set containing all the elements which are both in this Set and in the argument. */ - intersection(other: ReadonlySetLike): Set; // @type-options prefix-return-type + intersection(other: ReadonlySetLike): Set; // @type-options: prefix-return-type /** * @returns a new Set containing all the elements in this Set which are not also in the argument. */ - difference(other: ReadonlySetLike): Set; // @type-options prefix-return-type + difference(other: ReadonlySetLike): Set; // @type-options: prefix-return-type /** * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. */ - symmetricDifference(other: ReadonlySetLike): Set; // @type-options prefix-return-type + symmetricDifference(other: ReadonlySetLike): Set; // @type-options: prefix-return-type /** * @returns a boolean indicating whether all the elements in this Set are also in the argument. @@ -58,26 +58,26 @@ interface Set { // @type-options no-redefine isDisjointFrom(other: ReadonlySetLike): boolean; } -interface ReadonlySet { // @type-options no-redefine +interface ReadonlySet { // @type-options: no-redefine /** * @returns a new Set containing all the elements in this Set and also all the elements in the argument. */ - union(other: ReadonlySetLike): Set; // @type-options prefix-return-type + union(other: ReadonlySetLike): Set; // @type-options: prefix-return-type /** * @returns a new Set containing all the elements which are both in this Set and in the argument. */ - intersection(other: ReadonlySetLike): Set; // @type-options prefix-return-type + intersection(other: ReadonlySetLike): Set; // @type-options: prefix-return-type /** * @returns a new Set containing all the elements in this Set which are not also in the argument. */ - difference(other: ReadonlySetLike): Set; // @type-options prefix-return-type + difference(other: ReadonlySetLike): Set; // @type-options: prefix-return-type /** * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. */ - symmetricDifference(other: ReadonlySetLike): Set; // @type-options prefix-return-type + symmetricDifference(other: ReadonlySetLike): Set; // @type-options: prefix-return-type /** * @returns a boolean indicating whether all the elements in this Set are also in the argument. diff --git a/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts index 0054bd2ae39e..1a33d45774a0 100644 --- a/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts +++ b/packages/core-js-types/src/base/proposals/string-left-right-trim.d.ts @@ -4,7 +4,7 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2019.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface String { // @type-options no-redefine +interface String { // @type-options: no-redefine /** Removes the trailing white space and line terminator characters from a string. */ trimEnd(): string; diff --git a/packages/core-js-types/src/base/proposals/string-padding.d.ts b/packages/core-js-types/src/base/proposals/string-padding.d.ts index 5530217e16c1..55d1ef2de2b5 100644 --- a/packages/core-js-types/src/base/proposals/string-padding.d.ts +++ b/packages/core-js-types/src/base/proposals/string-padding.d.ts @@ -4,7 +4,7 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface String { // @type-options no-redefine +interface String { // @type-options: no-redefine /** * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. * The padding is applied from the start (left) of the current string. diff --git a/packages/core-js-types/src/base/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/proposals/string-replace-all.d.ts index afcf2458b660..0b881c20a654 100644 --- a/packages/core-js-types/src/base/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/base/proposals/string-replace-all.d.ts @@ -4,7 +4,7 @@ // https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/es2021.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface String { // @type-options no-redefine +interface String { // @type-options: no-redefine /** * Replace all instances of a substring in a string, using a regular expression or search string. * @param searchValue - A string to search for. diff --git a/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts index 86a94fc3944f..ea76cab32567 100644 --- a/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts +++ b/packages/core-js-types/src/base/proposals/well-formed-unicode-strings.d.ts @@ -4,7 +4,7 @@ // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2024.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface String { // @type-options no-redefine +interface String { // @type-options: no-redefine /** * Returns true if all leading surrogates and trailing surrogates appear paired and in order. */ diff --git a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts index 6fb8ad96aef2..acacdb43bc50 100644 --- a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts +++ b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts @@ -1,15 +1,15 @@ // use only with DOM lib // Fallbacks for DOM types -interface Element {} // @type-options no-export -interface Node {} // @type-options no-export -interface HTMLOptionElement {} // @type-options no-export +interface Element {} // @type-options: no-export +interface Node {} // @type-options: no-export +interface HTMLOptionElement {} // @type-options: no-export -interface ArrayIterator extends IteratorObject { // @type-options no-export +interface ArrayIterator extends IteratorObject { // @type-options: no-export [Symbol.iterator](): ArrayIterator; } -interface DOMTokenList { // @type-options no-export +interface DOMTokenList { // @type-options: no-export /** * Calls a defined callback function on each element of the DOMTokenList, * passing the element, its index, and the entire DOMTokenList as arguments. @@ -39,7 +39,7 @@ interface DOMTokenList { // @type-options no-export [Symbol.iterator](): IterableIterator; } -interface NodeList { // @type-options no-export +interface NodeList { // @type-options: no-export /** * Calls a defined callback function on each element of the NodeList, * passing the element, its index, and the entire NodeList as arguments. @@ -72,182 +72,182 @@ interface NodeList { // @type-options no-export [Symbol.iterator](): IterableIterator; } -interface CSSRuleList { // @type-options no-export +interface CSSRuleList { // @type-options: no-export /** * Returns an iterable of values in the CSSRuleList. */ [Symbol.iterator](): IterableIterator; } -interface CSSStyleDeclaration { // @type-options no-export +interface CSSStyleDeclaration { // @type-options: no-export /** * Returns an iterable of values in the CSSStyleDeclaration. */ [Symbol.iterator](): IterableIterator; } -interface CSSValueList { // @type-options no-export +interface CSSValueList { // @type-options: no-export /** * Returns an iterable of values in the CSSValueList. */ [Symbol.iterator](): IterableIterator; } -interface ClientRectList { // @type-options no-export +interface ClientRectList { // @type-options: no-export /** * Returns an iterable of values in the ClientRectList. */ [Symbol.iterator](): IterableIterator; } -interface DOMRectList { // @type-options no-export +interface DOMRectList { // @type-options: no-export /** * Returns an iterable of values in the DOMRectList. */ [Symbol.iterator](): IterableIterator; } -interface DOMStringList { // @type-options no-export +interface DOMStringList { // @type-options: no-export /** * Returns an iterable of values in the DOMStringList. */ [Symbol.iterator](): IterableIterator; } -interface DataTransferItemList { // @type-options no-export +interface DataTransferItemList { // @type-options: no-export /** * Returns an iterable of values in the DataTransferItemList. */ [Symbol.iterator](): IterableIterator; } -interface FileList { // @type-options no-export +interface FileList { // @type-options: no-export /** * Returns an iterable of values in the FileList. */ [Symbol.iterator](): IterableIterator; } -interface HTMLAllCollection { // @type-options no-export +interface HTMLAllCollection { // @type-options: no-export /** * Returns an iterable of values in the HTMLAllCollection. */ [Symbol.iterator](): IterableIterator; } -interface HTMLCollection { // @type-options no-export +interface HTMLCollection { // @type-options: no-export /** * Returns an iterable of values in the HTMLCollection. */ [Symbol.iterator](): ArrayIterator; } -interface HTMLFormElement { // @type-options no-export +interface HTMLFormElement { // @type-options: no-export /** * Returns an iterable of values in the HTMLFormElement. */ [Symbol.iterator](): IterableIterator; } -interface HTMLSelectElement { // @type-options no-export +interface HTMLSelectElement { // @type-options: no-export /** * Returns an iterable of values in the HTMLSelectElement. */ [Symbol.iterator](): IterableIterator; } -interface MediaList { // @type-options no-export +interface MediaList { // @type-options: no-export /** * Returns an iterable of values in the MediaList. */ [Symbol.iterator](): IterableIterator; } -interface MimeTypeArray { // @type-options no-export +interface MimeTypeArray { // @type-options: no-export /** * Returns an iterable of values in the MimeTypeArray. */ [Symbol.iterator](): IterableIterator; } -interface NamedNodeMap { // @type-options no-export +interface NamedNodeMap { // @type-options: no-export /** * Returns an iterable of values in the NamedNodeMap. */ [Symbol.iterator](): IterableIterator; } -interface PaintRequestList { // @type-options no-export +interface PaintRequestList { // @type-options: no-export /** * Returns an iterable of values in the PaintRequestList. */ [Symbol.iterator](): IterableIterator; } -interface Plugin { // @type-options no-export +interface Plugin { // @type-options: no-export /** * Returns an iterable of values in the Plugin. */ [Symbol.iterator](): IterableIterator; } -interface PluginArray { // @type-options no-export +interface PluginArray { // @type-options: no-export /** * Returns an iterable of values in the PluginArray. */ [Symbol.iterator](): IterableIterator; } -interface SVGLengthList { // @type-options no-export +interface SVGLengthList { // @type-options: no-export /** * Returns an iterable of values in the SVGLengthList. */ [Symbol.iterator](): IterableIterator; } -interface SVGNumberList { // @type-options no-export +interface SVGNumberList { // @type-options: no-export /** * Returns an iterable of values in the SVGNumberList. */ [Symbol.iterator](): IterableIterator; } -interface SVGPathSegList { // @type-options no-export +interface SVGPathSegList { // @type-options: no-export /** * Returns an iterable of values in the SVGPathSegList. */ [Symbol.iterator](): IterableIterator; } -interface SVGPointList { // @type-options no-export +interface SVGPointList { // @type-options: no-export /** * Returns an iterable of values in the SVGPointList. */ [Symbol.iterator](): IterableIterator; } -interface SVGStringList { // @type-options no-export +interface SVGStringList { // @type-options: no-export /** * Returns an iterable of values in the SVGStringList. */ [Symbol.iterator](): IterableIterator; } -interface SVGTransformList { // @type-options no-export +interface SVGTransformList { // @type-options: no-export /** * Returns an iterable of values in the SVGTransformList. */ [Symbol.iterator](): IterableIterator; } -interface SourceBufferList { // @type-options no-export +interface SourceBufferList { // @type-options: no-export /** * Returns an iterable of values in the SourceBufferList. */ [Symbol.iterator](): IterableIterator; } -interface StyleSheetList { // @type-options no-export +interface StyleSheetList { // @type-options: no-export /** * Returns an iterable of values in the StyleSheetList. * @@ -255,21 +255,21 @@ interface StyleSheetList { // @type-options no-export [Symbol.iterator](): IterableIterator; } -interface TextTrackCueList { // @type-options no-export +interface TextTrackCueList { // @type-options: no-export /** * Returns an iterable of values in the TextTrackCueList. */ [Symbol.iterator](): IterableIterator; } -interface TextTrackList { // @type-options no-export +interface TextTrackList { // @type-options: no-export /** * Returns an iterable of values in the TextTrackList. */ [Symbol.iterator](): IterableIterator; } -interface TouchList { // @type-options no-export +interface TouchList { // @type-options: no-export /** * Returns an iterable of values in the TouchList. */ diff --git a/packages/core-js-types/src/base/web/structured-clone.d.ts b/packages/core-js-types/src/base/web/structured-clone.d.ts index 8a521894949c..d750bd6bfc38 100644 --- a/packages/core-js-types/src/base/web/structured-clone.d.ts +++ b/packages/core-js-types/src/base/web/structured-clone.d.ts @@ -1,4 +1,4 @@ -interface CoreJSStructuredSerializeOptions { // @type-options no-extends, no-prefix +interface CoreJSStructuredSerializeOptions { // @type-options: no-extends, no-prefix readonly __brand?: unique symbol; transfer?: any[]; diff --git a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts index 68ded576f8b3..cd4ced374b72 100644 --- a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts @@ -18,11 +18,11 @@ interface SymbolConstructor { readonly asyncDispose: unique symbol; } -interface Disposable { // @type-options no-constructor +interface Disposable { // @type-options: no-constructor [Symbol.dispose](): void; } -interface AsyncDisposable { // @type-options no-constructor +interface AsyncDisposable { // @type-options: no-constructor [Symbol.asyncDispose](): PromiseLike; } @@ -126,7 +126,7 @@ interface AsyncDisposableStack { /** * Disposes each resource in the stack in the reverse order that they were added. */ - disposeAsync(): Promise; // @type-options prefix-return-type + disposeAsync(): Promise; // @type-options: prefix-return-type /** * Adds a disposable resource to the stack, returning the resource. @@ -193,9 +193,9 @@ interface AsyncDisposableStackConstructor { declare var AsyncDisposableStack: AsyncDisposableStackConstructor; -interface IteratorObject extends Disposable {} // @type-options no-extends +interface IteratorObject extends Disposable {} // @type-options: no-extends -interface AsyncIteratorObject extends AsyncDisposable {} // @type-options no-extends +interface AsyncIteratorObject extends AsyncDisposable {} // @type-options: no-extends interface AsyncIteratorConstructor {} diff --git a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts index 7681173eb43a..b182e53c03a6 100644 --- a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts @@ -101,7 +101,7 @@ declare global { find(predicate: (value: T, index: number) => unknown): T | undefined; } - interface IteratorConstructor { // @type-options no-extends + interface IteratorConstructor { // @type-options: no-extends /** * Creates a native iterator from an iterator or iterable object. * Returns its input if the input already inherits from the built-in Iterator class. diff --git a/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts index 14b092474e55..81477345722c 100644 --- a/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts +++ b/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts @@ -1,13 +1,13 @@ // Fallbacks for DOM types -interface Element {} // @type-options no-export -interface Node {} // @type-options no-export -interface HTMLOptionElement {} // @type-options no-export +interface Element {} // @type-options: no-export +interface Node {} // @type-options: no-export +interface HTMLOptionElement {} // @type-options: no-export -interface ArrayIterator extends IteratorObject { // @type-options no-export +interface ArrayIterator extends IteratorObject { // @type-options: no-export [Symbol.iterator](): ArrayIterator; } -interface DOMTokenList { // @type-options no-export +interface DOMTokenList { // @type-options: no-export /** * Calls a defined callback function on each element of the DOMTokenList, * passing the element, its index, and the entire DOMTokenList as arguments. @@ -37,7 +37,7 @@ interface DOMTokenList { // @type-options no-export [Symbol.iterator](): IterableIterator; } -interface NodeList { // @type-options no-export +interface NodeList { // @type-options: no-export /** * Calls a defined callback function on each element of the NodeList, * passing the element, its index, and the entire NodeList as arguments. @@ -70,182 +70,182 @@ interface NodeList { // @type-options no-export [Symbol.iterator](): IterableIterator; } -interface CSSRuleList { // @type-options no-export +interface CSSRuleList { // @type-options: no-export /** * Returns an iterable of values in the CSSRuleList. */ [Symbol.iterator](): IterableIterator; } -interface CSSStyleDeclaration { // @type-options no-export +interface CSSStyleDeclaration { // @type-options: no-export /** * Returns an iterable of values in the CSSStyleDeclaration. */ [Symbol.iterator](): IterableIterator; } -interface CSSValueList { // @type-options no-export +interface CSSValueList { // @type-options: no-export /** * Returns an iterable of values in the CSSValueList. */ [Symbol.iterator](): IterableIterator; } -interface ClientRectList { // @type-options no-export +interface ClientRectList { // @type-options: no-export /** * Returns an iterable of values in the ClientRectList. */ [Symbol.iterator](): IterableIterator; } -interface DOMRectList { // @type-options no-export +interface DOMRectList { // @type-options: no-export /** * Returns an iterable of values in the DOMRectList. */ [Symbol.iterator](): IterableIterator; } -interface DOMStringList { // @type-options no-export +interface DOMStringList { // @type-options: no-export /** * Returns an iterable of values in the DOMStringList. */ [Symbol.iterator](): IterableIterator; } -interface DataTransferItemList { // @type-options no-export +interface DataTransferItemList { // @type-options: no-export /** * Returns an iterable of values in the DataTransferItemList. */ [Symbol.iterator](): IterableIterator; } -interface FileList { // @type-options no-export +interface FileList { // @type-options: no-export /** * Returns an iterable of values in the FileList. */ [Symbol.iterator](): IterableIterator; } -interface HTMLAllCollection { // @type-options no-export +interface HTMLAllCollection { // @type-options: no-export /** * Returns an iterable of values in the HTMLAllCollection. */ [Symbol.iterator](): IterableIterator; } -interface HTMLCollection { // @type-options no-export +interface HTMLCollection { // @type-options: no-export /** * Returns an iterable of values in the HTMLCollection. */ [Symbol.iterator](): ArrayIterator; } -interface HTMLFormElement { // @type-options no-export +interface HTMLFormElement { // @type-options: no-export /** * Returns an iterable of values in the HTMLFormElement. */ [Symbol.iterator](): IterableIterator; } -interface HTMLSelectElement { // @type-options no-export +interface HTMLSelectElement { // @type-options: no-export /** * Returns an iterable of values in the HTMLSelectElement. */ [Symbol.iterator](): IterableIterator; } -interface MediaList { // @type-options no-export +interface MediaList { // @type-options: no-export /** * Returns an iterable of values in the MediaList. */ [Symbol.iterator](): IterableIterator; } -interface MimeTypeArray { // @type-options no-export +interface MimeTypeArray { // @type-options: no-export /** * Returns an iterable of values in the MimeTypeArray. */ [Symbol.iterator](): IterableIterator; } -interface NamedNodeMap { // @type-options no-export +interface NamedNodeMap { // @type-options: no-export /** * Returns an iterable of values in the NamedNodeMap. */ [Symbol.iterator](): IterableIterator; } -interface PaintRequestList { // @type-options no-export +interface PaintRequestList { // @type-options: no-export /** * Returns an iterable of values in the PaintRequestList. */ [Symbol.iterator](): IterableIterator; } -interface Plugin { // @type-options no-export +interface Plugin { // @type-options: no-export /** * Returns an iterable of values in the Plugin. */ [Symbol.iterator](): IterableIterator; } -interface PluginArray { // @type-options no-export +interface PluginArray { // @type-options: no-export /** * Returns an iterable of values in the PluginArray. */ [Symbol.iterator](): IterableIterator; } -interface SVGLengthList { // @type-options no-export +interface SVGLengthList { // @type-options: no-export /** * Returns an iterable of values in the SVGLengthList. */ [Symbol.iterator](): IterableIterator; } -interface SVGNumberList { // @type-options no-export +interface SVGNumberList { // @type-options: no-export /** * Returns an iterable of values in the SVGNumberList. */ [Symbol.iterator](): IterableIterator; } -interface SVGPathSegList { // @type-options no-export +interface SVGPathSegList { // @type-options: no-export /** * Returns an iterable of values in the SVGPathSegList. */ [Symbol.iterator](): IterableIterator; } -interface SVGPointList { // @type-options no-export +interface SVGPointList { // @type-options: no-export /** * Returns an iterable of values in the SVGPointList. */ [Symbol.iterator](): IterableIterator; } -interface SVGStringList { // @type-options no-export +interface SVGStringList { // @type-options: no-export /** * Returns an iterable of values in the SVGStringList. */ [Symbol.iterator](): IterableIterator; } -interface SVGTransformList { // @type-options no-export +interface SVGTransformList { // @type-options: no-export /** * Returns an iterable of values in the SVGTransformList. */ [Symbol.iterator](): IterableIterator; } -interface SourceBufferList { // @type-options no-export +interface SourceBufferList { // @type-options: no-export /** * Returns an iterable of values in the SourceBufferList. */ [Symbol.iterator](): IterableIterator; } -interface StyleSheetList { // @type-options no-export +interface StyleSheetList { // @type-options: no-export /** * Returns an iterable of values in the StyleSheetList. * @@ -253,21 +253,21 @@ interface StyleSheetList { // @type-options no-export [Symbol.iterator](): IterableIterator; } -interface TextTrackCueList { // @type-options no-export +interface TextTrackCueList { // @type-options: no-export /** * Returns an iterable of values in the TextTrackCueList. */ [Symbol.iterator](): IterableIterator; } -interface TextTrackList { // @type-options no-export +interface TextTrackList { // @type-options: no-export /** * Returns an iterable of values in the TextTrackList. */ [Symbol.iterator](): IterableIterator; } -interface TouchList { // @type-options no-export +interface TouchList { // @type-options: no-export /** * Returns an iterable of values in the TouchList. */ diff --git a/scripts/build-types/pure.mjs b/scripts/build-types/pure.mjs index 73ad52f100e2..8becc7c4eac3 100644 --- a/scripts/build-types/pure.mjs +++ b/scripts/build-types/pure.mjs @@ -26,7 +26,7 @@ function extractDeclareGlobalSections(lines) { function parseOptions(line) { const hasOptions = line.includes('@type-options'); - const optionsStr = hasOptions ? line.match(/@type-options\s+(?[A-Za-z][\s\w,-]+)$/)?.groups?.options : ''; + const optionsStr = hasOptions ? line.match(/@type-options:\s+(?[A-Za-z][\s\w,-]+)$/)?.groups?.options : ''; return { noExtends: hasOptions && optionsStr.includes('no-extends'), noPrefix: hasOptions && optionsStr.includes('no-prefix'), From 35c14b3acf07a8e65e7ba3f03da1be7d46900ac1 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 27 Jan 2026 23:55:57 +0700 Subject: [PATCH 159/315] use @ in @types and @no-types directive --- packages/core-js/modules/es.aggregate-error.cause.js | 2 +- packages/core-js/modules/es.aggregate-error.constructor.js | 2 +- .../modules/es.array-buffer.transfer-to-fixed-length.js | 2 +- packages/core-js/modules/es.array-buffer.transfer.js | 2 +- packages/core-js/modules/es.array.at.js | 2 +- packages/core-js/modules/es.array.find-last-index.js | 2 +- packages/core-js/modules/es.array.find-last.js | 2 +- packages/core-js/modules/es.array.flat-map.js | 2 +- packages/core-js/modules/es.array.flat.js | 2 +- packages/core-js/modules/es.array.from-async.js | 2 +- packages/core-js/modules/es.array.includes.js | 2 +- packages/core-js/modules/es.array.to-reversed.js | 2 +- packages/core-js/modules/es.array.to-sorted.js | 2 +- packages/core-js/modules/es.array.to-spliced.js | 2 +- packages/core-js/modules/es.array.with.js | 2 +- .../modules/es.async-disposable-stack.constructor.js | 2 +- packages/core-js/modules/es.async-iterator.async-dispose.js | 2 +- packages/core-js/modules/es.data-view.get-float16.js | 2 +- packages/core-js/modules/es.data-view.set-float16.js | 2 +- packages/core-js/modules/es.disposable-stack.constructor.js | 2 +- packages/core-js/modules/es.error.cause.js | 2 +- packages/core-js/modules/es.error.is-error.js | 2 +- packages/core-js/modules/es.iterator.concat.js | 2 +- packages/core-js/modules/es.iterator.constructor.js | 6 +++--- packages/core-js/modules/es.iterator.dispose.js | 2 +- packages/core-js/modules/es.iterator.drop.js | 2 +- packages/core-js/modules/es.iterator.every.js | 2 +- packages/core-js/modules/es.iterator.filter.js | 2 +- packages/core-js/modules/es.iterator.find.js | 2 +- packages/core-js/modules/es.iterator.flat-map.js | 2 +- packages/core-js/modules/es.iterator.for-each.js | 2 +- packages/core-js/modules/es.iterator.from.js | 2 +- packages/core-js/modules/es.iterator.map.js | 2 +- packages/core-js/modules/es.iterator.reduce.js | 2 +- packages/core-js/modules/es.iterator.some.js | 2 +- packages/core-js/modules/es.iterator.take.js | 2 +- packages/core-js/modules/es.iterator.to-array.js | 2 +- packages/core-js/modules/es.json.is-raw-json.js | 2 +- packages/core-js/modules/es.json.parse.js | 2 +- packages/core-js/modules/es.json.raw-json.js | 2 +- packages/core-js/modules/es.map.get-or-insert-computed.js | 2 +- packages/core-js/modules/es.map.get-or-insert.js | 2 +- packages/core-js/modules/es.map.group-by.js | 2 +- packages/core-js/modules/es.math.f16round.js | 2 +- packages/core-js/modules/es.math.sum-precise.js | 2 +- packages/core-js/modules/es.object.define-getter.js | 2 +- packages/core-js/modules/es.object.define-setter.js | 2 +- packages/core-js/modules/es.object.entries.js | 2 +- packages/core-js/modules/es.object.from-entries.js | 2 +- .../modules/es.object.get-own-property-descriptors.js | 2 +- packages/core-js/modules/es.object.group-by.js | 2 +- packages/core-js/modules/es.object.has-own.js | 2 +- packages/core-js/modules/es.object.lookup-getter.js | 2 +- packages/core-js/modules/es.object.lookup-setter.js | 2 +- packages/core-js/modules/es.object.proto.js | 2 +- packages/core-js/modules/es.object.values.js | 2 +- packages/core-js/modules/es.promise.all-settled.js | 2 +- packages/core-js/modules/es.promise.any.js | 2 +- packages/core-js/modules/es.promise.finally.js | 2 +- packages/core-js/modules/es.promise.try.js | 2 +- packages/core-js/modules/es.promise.with-resolvers.js | 2 +- packages/core-js/modules/es.regexp.constructor.js | 4 ++-- packages/core-js/modules/es.regexp.dot-all.js | 2 +- packages/core-js/modules/es.regexp.escape.js | 2 +- packages/core-js/modules/es.regexp.exec.js | 4 ++-- packages/core-js/modules/es.regexp.flags.js | 2 +- packages/core-js/modules/es.set.difference.js | 2 +- packages/core-js/modules/es.set.intersection.js | 2 +- packages/core-js/modules/es.set.is-disjoint-from.js | 2 +- packages/core-js/modules/es.set.is-subset-of.js | 2 +- packages/core-js/modules/es.set.is-superset-of.js | 2 +- packages/core-js/modules/es.set.symmetric-difference.js | 2 +- packages/core-js/modules/es.set.union.js | 2 +- packages/core-js/modules/es.string.at.js | 2 +- packages/core-js/modules/es.string.is-well-formed.js | 2 +- packages/core-js/modules/es.string.match-all.js | 2 +- packages/core-js/modules/es.string.pad-end.js | 2 +- packages/core-js/modules/es.string.pad-start.js | 2 +- packages/core-js/modules/es.string.replace-all.js | 2 +- packages/core-js/modules/es.string.to-well-formed.js | 2 +- packages/core-js/modules/es.string.trim-end.js | 2 +- packages/core-js/modules/es.string.trim-left.js | 2 +- packages/core-js/modules/es.string.trim-right.js | 2 +- packages/core-js/modules/es.string.trim-start.js | 2 +- packages/core-js/modules/es.suppressed-error.constructor.js | 2 +- packages/core-js/modules/es.symbol.async-dispose.js | 2 +- packages/core-js/modules/es.symbol.async-iterator.js | 2 +- packages/core-js/modules/es.symbol.constructor.js | 2 +- packages/core-js/modules/es.symbol.description.js | 2 +- packages/core-js/modules/es.symbol.dispose.js | 2 +- packages/core-js/modules/es.symbol.match-all.js | 2 +- packages/core-js/modules/es.typed-array.at.js | 2 +- packages/core-js/modules/es.typed-array.find-last-index.js | 2 +- packages/core-js/modules/es.typed-array.find-last.js | 2 +- packages/core-js/modules/es.typed-array.includes.js | 2 +- packages/core-js/modules/es.typed-array.to-reversed.js | 2 +- packages/core-js/modules/es.typed-array.to-sorted.js | 2 +- packages/core-js/modules/es.typed-array.with.js | 2 +- packages/core-js/modules/es.uint8-array.from-base64.js | 2 +- packages/core-js/modules/es.uint8-array.from-hex.js | 2 +- packages/core-js/modules/es.uint8-array.set-from-base64.js | 2 +- packages/core-js/modules/es.uint8-array.set-from-hex.js | 2 +- packages/core-js/modules/es.uint8-array.to-base64.js | 2 +- packages/core-js/modules/es.uint8-array.to-hex.js | 2 +- .../core-js/modules/es.weak-map.get-or-insert-computed.js | 2 +- packages/core-js/modules/es.weak-map.get-or-insert.js | 2 +- packages/core-js/modules/esnext.array.filter-reject.js | 2 +- packages/core-js/modules/esnext.array.is-template-object.js | 2 +- packages/core-js/modules/esnext.array.unique-by.js | 2 +- .../core-js/modules/esnext.async-iterator.constructor.js | 2 +- packages/core-js/modules/esnext.async-iterator.drop.js | 2 +- packages/core-js/modules/esnext.async-iterator.every.js | 2 +- packages/core-js/modules/esnext.async-iterator.filter.js | 2 +- packages/core-js/modules/esnext.async-iterator.find.js | 2 +- packages/core-js/modules/esnext.async-iterator.flat-map.js | 2 +- packages/core-js/modules/esnext.async-iterator.for-each.js | 2 +- packages/core-js/modules/esnext.async-iterator.from.js | 2 +- packages/core-js/modules/esnext.async-iterator.map.js | 2 +- packages/core-js/modules/esnext.async-iterator.reduce.js | 2 +- packages/core-js/modules/esnext.async-iterator.some.js | 2 +- packages/core-js/modules/esnext.async-iterator.take.js | 2 +- packages/core-js/modules/esnext.async-iterator.to-array.js | 2 +- .../core-js/modules/esnext.data-view.get-uint8-clamped.js | 2 +- .../core-js/modules/esnext.data-view.set-uint8-clamped.js | 2 +- packages/core-js/modules/esnext.function.demethodize.js | 2 +- packages/core-js/modules/esnext.function.metadata.js | 2 +- packages/core-js/modules/esnext.iterator.chunks.js | 2 +- packages/core-js/modules/esnext.iterator.join.js | 2 +- packages/core-js/modules/esnext.iterator.range.js | 2 +- packages/core-js/modules/esnext.iterator.to-async.js | 2 +- packages/core-js/modules/esnext.iterator.windows.js | 2 +- packages/core-js/modules/esnext.iterator.zip-keyed.js | 2 +- packages/core-js/modules/esnext.iterator.zip.js | 2 +- packages/core-js/modules/esnext.map.from.js | 2 +- packages/core-js/modules/esnext.map.of.js | 2 +- packages/core-js/modules/esnext.number.clamp.js | 2 +- packages/core-js/modules/esnext.promise.all-keyed.js | 2 +- .../core-js/modules/esnext.promise.all-settled-keyed.js | 2 +- packages/core-js/modules/esnext.set.from.js | 2 +- packages/core-js/modules/esnext.set.of.js | 2 +- packages/core-js/modules/esnext.string.cooked.js | 2 +- packages/core-js/modules/esnext.string.dedent.js | 2 +- packages/core-js/modules/esnext.symbol.custom-matcher.js | 2 +- .../core-js/modules/esnext.symbol.is-registered-symbol.js | 2 +- .../core-js/modules/esnext.symbol.is-well-known-symbol.js | 2 +- packages/core-js/modules/esnext.symbol.metadata.js | 2 +- .../core-js/modules/esnext.typed-array.filter-reject.js | 2 +- packages/core-js/modules/esnext.typed-array.unique-by.js | 2 +- packages/core-js/modules/esnext.weak-map.from.js | 2 +- packages/core-js/modules/esnext.weak-map.of.js | 2 +- packages/core-js/modules/esnext.weak-set.from.js | 2 +- packages/core-js/modules/esnext.weak-set.of.js | 2 +- packages/core-js/modules/web.atob.js | 2 +- packages/core-js/modules/web.btoa.js | 2 +- packages/core-js/modules/web.clear-immediate.js | 2 +- packages/core-js/modules/web.dom-collections.entries.js | 2 +- packages/core-js/modules/web.dom-collections.for-each.js | 2 +- packages/core-js/modules/web.dom-collections.iterator.js | 2 +- packages/core-js/modules/web.dom-collections.keys.js | 2 +- packages/core-js/modules/web.dom-collections.values.js | 2 +- packages/core-js/modules/web.dom-exception.constructor.js | 2 +- packages/core-js/modules/web.dom-exception.stack.js | 2 +- packages/core-js/modules/web.dom-exception.to-string-tag.js | 2 +- packages/core-js/modules/web.queue-microtask.js | 2 +- packages/core-js/modules/web.self.js | 2 +- packages/core-js/modules/web.set-immediate.js | 2 +- packages/core-js/modules/web.structured-clone.js | 2 +- .../core-js/modules/web.url-search-params.constructor.js | 2 +- packages/core-js/modules/web.url-search-params.delete.js | 2 +- packages/core-js/modules/web.url-search-params.has.js | 2 +- packages/core-js/modules/web.url-search-params.size.js | 2 +- packages/core-js/modules/web.url.can-parse.js | 2 +- packages/core-js/modules/web.url.constructor.js | 2 +- packages/core-js/modules/web.url.parse.js | 2 +- packages/core-js/modules/web.url.to-json.js | 2 +- scripts/build-entries/get-dependencies.mjs | 2 +- tests/type-definitions/coverage.mjs | 2 +- 177 files changed, 181 insertions(+), 181 deletions(-) diff --git a/packages/core-js/modules/es.aggregate-error.cause.js b/packages/core-js/modules/es.aggregate-error.cause.js index 2bb587f3bde2..c6d32919a052 100644 --- a/packages/core-js/modules/es.aggregate-error.cause.js +++ b/packages/core-js/modules/es.aggregate-error.cause.js @@ -1,4 +1,4 @@ -// types: proposals/error-cause +// @types: proposals/error-cause 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/es.aggregate-error.constructor.js b/packages/core-js/modules/es.aggregate-error.constructor.js index d393e968976a..a9fc392f2b96 100644 --- a/packages/core-js/modules/es.aggregate-error.constructor.js +++ b/packages/core-js/modules/es.aggregate-error.constructor.js @@ -1,4 +1,4 @@ -// types: proposals/error-cause +// @types: proposals/error-cause 'use strict'; var $ = require('../internals/export'); var isPrototypeOf = require('../internals/object-is-prototype-of'); diff --git a/packages/core-js/modules/es.array-buffer.transfer-to-fixed-length.js b/packages/core-js/modules/es.array-buffer.transfer-to-fixed-length.js index 1ab7bba7df76..23c684e8fc22 100644 --- a/packages/core-js/modules/es.array-buffer.transfer-to-fixed-length.js +++ b/packages/core-js/modules/es.array-buffer.transfer-to-fixed-length.js @@ -1,4 +1,4 @@ -// types: proposals/array-buffer-transfer +// @types: proposals/array-buffer-transfer 'use strict'; var $ = require('../internals/export'); var $transfer = require('../internals/array-buffer-transfer'); diff --git a/packages/core-js/modules/es.array-buffer.transfer.js b/packages/core-js/modules/es.array-buffer.transfer.js index 2c487426c2eb..1780a60f59f3 100644 --- a/packages/core-js/modules/es.array-buffer.transfer.js +++ b/packages/core-js/modules/es.array-buffer.transfer.js @@ -1,4 +1,4 @@ -// types: proposals/array-buffer-transfer +// @types: proposals/array-buffer-transfer 'use strict'; var $ = require('../internals/export'); var $transfer = require('../internals/array-buffer-transfer'); diff --git a/packages/core-js/modules/es.array.at.js b/packages/core-js/modules/es.array.at.js index bc47f078eb21..3c511184e338 100644 --- a/packages/core-js/modules/es.array.at.js +++ b/packages/core-js/modules/es.array.at.js @@ -1,4 +1,4 @@ -// types: proposals/relative-indexing-method +// @types: proposals/relative-indexing-method 'use strict'; var $ = require('../internals/export'); var toObject = require('../internals/to-object'); diff --git a/packages/core-js/modules/es.array.find-last-index.js b/packages/core-js/modules/es.array.find-last-index.js index 7adf109d6be5..5cecffac0ba0 100644 --- a/packages/core-js/modules/es.array.find-last-index.js +++ b/packages/core-js/modules/es.array.find-last-index.js @@ -1,4 +1,4 @@ -// types: proposals/array-find-from-last +// @types: proposals/array-find-from-last 'use strict'; var $ = require('../internals/export'); var $findLastIndex = require('../internals/array-iteration-from-last').findLastIndex; diff --git a/packages/core-js/modules/es.array.find-last.js b/packages/core-js/modules/es.array.find-last.js index 5cf9529c8aa4..0cea65f315a1 100644 --- a/packages/core-js/modules/es.array.find-last.js +++ b/packages/core-js/modules/es.array.find-last.js @@ -1,4 +1,4 @@ -// types: proposals/array-find-from-last +// @types: proposals/array-find-from-last 'use strict'; var $ = require('../internals/export'); var $findLast = require('../internals/array-iteration-from-last').findLast; diff --git a/packages/core-js/modules/es.array.flat-map.js b/packages/core-js/modules/es.array.flat-map.js index abaade46ac35..589a3f0e61eb 100644 --- a/packages/core-js/modules/es.array.flat-map.js +++ b/packages/core-js/modules/es.array.flat-map.js @@ -1,4 +1,4 @@ -// types: proposals/array-flat-map +// @types: proposals/array-flat-map 'use strict'; // @dependency: es.array.unscopables.flat-map var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.array.flat.js b/packages/core-js/modules/es.array.flat.js index 8c245665c395..6b072db29d81 100644 --- a/packages/core-js/modules/es.array.flat.js +++ b/packages/core-js/modules/es.array.flat.js @@ -1,4 +1,4 @@ -// types: proposals/array-flat-map +// @types: proposals/array-flat-map 'use strict'; // @dependency: es.array.unscopables.flat var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.array.from-async.js b/packages/core-js/modules/es.array.from-async.js index 4057d06bb7e1..e721bb51a17a 100644 --- a/packages/core-js/modules/es.array.from-async.js +++ b/packages/core-js/modules/es.array.from-async.js @@ -1,4 +1,4 @@ -// types: proposals/array-from-async +// @types: proposals/array-from-async 'use strict'; var $ = require('../internals/export'); var bind = require('../internals/function-bind-context'); diff --git a/packages/core-js/modules/es.array.includes.js b/packages/core-js/modules/es.array.includes.js index 14b1e9b9b296..f151a351e234 100644 --- a/packages/core-js/modules/es.array.includes.js +++ b/packages/core-js/modules/es.array.includes.js @@ -1,4 +1,4 @@ -// types: proposals/array-includes +// @types: proposals/array-includes 'use strict'; var $ = require('../internals/export'); var $includes = require('../internals/array-includes'); diff --git a/packages/core-js/modules/es.array.to-reversed.js b/packages/core-js/modules/es.array.to-reversed.js index 882a8f85351e..9ae38dbfe833 100644 --- a/packages/core-js/modules/es.array.to-reversed.js +++ b/packages/core-js/modules/es.array.to-reversed.js @@ -1,4 +1,4 @@ -// types: proposals/change-array-by-copy +// @types: proposals/change-array-by-copy 'use strict'; var $ = require('../internals/export'); var toObject = require('../internals/to-object'); diff --git a/packages/core-js/modules/es.array.to-sorted.js b/packages/core-js/modules/es.array.to-sorted.js index 1345019c756c..683ac42ea8c7 100644 --- a/packages/core-js/modules/es.array.to-sorted.js +++ b/packages/core-js/modules/es.array.to-sorted.js @@ -1,4 +1,4 @@ -// types: proposals/change-array-by-copy +// @types: proposals/change-array-by-copy 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/es.array.to-spliced.js b/packages/core-js/modules/es.array.to-spliced.js index b3ea82afd286..2c8ef541e218 100644 --- a/packages/core-js/modules/es.array.to-spliced.js +++ b/packages/core-js/modules/es.array.to-spliced.js @@ -1,4 +1,4 @@ -// types: proposals/change-array-by-copy +// @types: proposals/change-array-by-copy 'use strict'; var $ = require('../internals/export'); var addToUnscopables = require('../internals/add-to-unscopables'); diff --git a/packages/core-js/modules/es.array.with.js b/packages/core-js/modules/es.array.with.js index 3d3241632bf0..067e5baa1364 100644 --- a/packages/core-js/modules/es.array.with.js +++ b/packages/core-js/modules/es.array.with.js @@ -1,4 +1,4 @@ -// types: proposals/change-array-by-copy +// @types: proposals/change-array-by-copy 'use strict'; var $ = require('../internals/export'); var lengthOfArrayLike = require('../internals/length-of-array-like'); diff --git a/packages/core-js/modules/es.async-disposable-stack.constructor.js b/packages/core-js/modules/es.async-disposable-stack.constructor.js index 394e3228e3f6..cb388aea86d2 100644 --- a/packages/core-js/modules/es.async-disposable-stack.constructor.js +++ b/packages/core-js/modules/es.async-disposable-stack.constructor.js @@ -1,4 +1,4 @@ -// types: proposals/explicit-resource-management +// @types: proposals/explicit-resource-management 'use strict'; // https://github.com/tc39/proposal-async-explicit-resource-management var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.async-iterator.async-dispose.js b/packages/core-js/modules/es.async-iterator.async-dispose.js index c43ce1f0339c..8b8d51cd0f47 100644 --- a/packages/core-js/modules/es.async-iterator.async-dispose.js +++ b/packages/core-js/modules/es.async-iterator.async-dispose.js @@ -1,4 +1,4 @@ -// types: proposals/explicit-resource-management +// @types: proposals/explicit-resource-management 'use strict'; // https://github.com/tc39/proposal-async-explicit-resource-management var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.data-view.get-float16.js b/packages/core-js/modules/es.data-view.get-float16.js index 36ae951cc411..f53b106f0d4a 100644 --- a/packages/core-js/modules/es.data-view.get-float16.js +++ b/packages/core-js/modules/es.data-view.get-float16.js @@ -1,4 +1,4 @@ -// types: proposals/float16 +// @types: proposals/float16 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/es.data-view.set-float16.js b/packages/core-js/modules/es.data-view.set-float16.js index f73985758a57..900c6ebcc0fd 100644 --- a/packages/core-js/modules/es.data-view.set-float16.js +++ b/packages/core-js/modules/es.data-view.set-float16.js @@ -1,4 +1,4 @@ -// types: proposals/float16 +// @types: proposals/float16 'use strict'; var $ = require('../internals/export'); var getBuiltInStaticMethod = require('../internals/get-built-in-static-method'); diff --git a/packages/core-js/modules/es.disposable-stack.constructor.js b/packages/core-js/modules/es.disposable-stack.constructor.js index bd62fb8bc9c6..56e2e385f9c8 100644 --- a/packages/core-js/modules/es.disposable-stack.constructor.js +++ b/packages/core-js/modules/es.disposable-stack.constructor.js @@ -1,4 +1,4 @@ -// types: proposals/explicit-resource-management +// @types: proposals/explicit-resource-management 'use strict'; // https://github.com/tc39/proposal-explicit-resource-management var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.error.cause.js b/packages/core-js/modules/es.error.cause.js index 33a6ab2afcf8..7b74b15a87a9 100644 --- a/packages/core-js/modules/es.error.cause.js +++ b/packages/core-js/modules/es.error.cause.js @@ -1,4 +1,4 @@ -// types: proposals/error-cause +// @types: proposals/error-cause 'use strict'; /* eslint-disable no-unused-vars -- required for functions `.length` */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.error.is-error.js b/packages/core-js/modules/es.error.is-error.js index c3a6509beda4..e2de15772a57 100644 --- a/packages/core-js/modules/es.error.is-error.js +++ b/packages/core-js/modules/es.error.is-error.js @@ -1,4 +1,4 @@ -// types: proposals/is-error +// @types: proposals/is-error 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/es.iterator.concat.js b/packages/core-js/modules/es.iterator.concat.js index dc744cb12099..d3b43b7ff962 100644 --- a/packages/core-js/modules/es.iterator.concat.js +++ b/packages/core-js/modules/es.iterator.concat.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-sequencing +// @types: proposals/iterator-sequencing 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.constructor.js b/packages/core-js/modules/es.iterator.constructor.js index b473170da470..9728a3e516ae 100644 --- a/packages/core-js/modules/es.iterator.constructor.js +++ b/packages/core-js/modules/es.iterator.constructor.js @@ -1,6 +1,6 @@ -// types: proposals/iterator-helpers -// types: proposals/iterator-sequencing -// types: proposals/explicit-resource-management +// @types: proposals/iterator-helpers +// @types: proposals/iterator-sequencing +// @types: proposals/explicit-resource-management 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/es.iterator.dispose.js b/packages/core-js/modules/es.iterator.dispose.js index 0d4abefdd197..498d7b87c9bd 100644 --- a/packages/core-js/modules/es.iterator.dispose.js +++ b/packages/core-js/modules/es.iterator.dispose.js @@ -1,4 +1,4 @@ -// types: proposals/explicit-resource-management +// @types: proposals/explicit-resource-management 'use strict'; // https://github.com/tc39/proposal-explicit-resource-management var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.drop.js b/packages/core-js/modules/es.iterator.drop.js index 8b2e94e33820..db688af3037a 100644 --- a/packages/core-js/modules/es.iterator.drop.js +++ b/packages/core-js/modules/es.iterator.drop.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-helpers +// @types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.every.js b/packages/core-js/modules/es.iterator.every.js index af354d168ab9..c401c13ce343 100644 --- a/packages/core-js/modules/es.iterator.every.js +++ b/packages/core-js/modules/es.iterator.every.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-helpers +// @types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.filter.js b/packages/core-js/modules/es.iterator.filter.js index a5b6af0fdc6d..689f1a8cddbb 100644 --- a/packages/core-js/modules/es.iterator.filter.js +++ b/packages/core-js/modules/es.iterator.filter.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-helpers +// @types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.find.js b/packages/core-js/modules/es.iterator.find.js index 679cc78f231f..05e46bdff74a 100644 --- a/packages/core-js/modules/es.iterator.find.js +++ b/packages/core-js/modules/es.iterator.find.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-helpers +// @types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.flat-map.js b/packages/core-js/modules/es.iterator.flat-map.js index 991d4fa04c8d..ab543194148d 100644 --- a/packages/core-js/modules/es.iterator.flat-map.js +++ b/packages/core-js/modules/es.iterator.flat-map.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-helpers +// @types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.for-each.js b/packages/core-js/modules/es.iterator.for-each.js index ab2fd1d66697..08c0d7b4b005 100644 --- a/packages/core-js/modules/es.iterator.for-each.js +++ b/packages/core-js/modules/es.iterator.for-each.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-helpers +// @types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.from.js b/packages/core-js/modules/es.iterator.from.js index e174ce298643..8569c51ad794 100644 --- a/packages/core-js/modules/es.iterator.from.js +++ b/packages/core-js/modules/es.iterator.from.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-helpers +// @types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.map.js b/packages/core-js/modules/es.iterator.map.js index 09f8c00caf0c..396cc4f69e0d 100644 --- a/packages/core-js/modules/es.iterator.map.js +++ b/packages/core-js/modules/es.iterator.map.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-helpers +// @types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.reduce.js b/packages/core-js/modules/es.iterator.reduce.js index c406e405fff9..b4914ddcbad3 100644 --- a/packages/core-js/modules/es.iterator.reduce.js +++ b/packages/core-js/modules/es.iterator.reduce.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-helpers +// @types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var iterate = require('../internals/iterate'); diff --git a/packages/core-js/modules/es.iterator.some.js b/packages/core-js/modules/es.iterator.some.js index d9d2d9818c96..9e80e682a801 100644 --- a/packages/core-js/modules/es.iterator.some.js +++ b/packages/core-js/modules/es.iterator.some.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-helpers +// @types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.take.js b/packages/core-js/modules/es.iterator.take.js index d53804538bbf..89fde77ec89d 100644 --- a/packages/core-js/modules/es.iterator.take.js +++ b/packages/core-js/modules/es.iterator.take.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-helpers +// @types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.iterator.to-array.js b/packages/core-js/modules/es.iterator.to-array.js index 85900fe6b1c4..cafb70852c46 100644 --- a/packages/core-js/modules/es.iterator.to-array.js +++ b/packages/core-js/modules/es.iterator.to-array.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-helpers +// @types: proposals/iterator-helpers 'use strict'; var $ = require('../internals/export'); var anObject = require('../internals/an-object'); diff --git a/packages/core-js/modules/es.json.is-raw-json.js b/packages/core-js/modules/es.json.is-raw-json.js index 8f954c97db49..1f108e5bc593 100644 --- a/packages/core-js/modules/es.json.is-raw-json.js +++ b/packages/core-js/modules/es.json.is-raw-json.js @@ -1,4 +1,4 @@ -// types: proposals/json-parse-with-source +// @types: proposals/json-parse-with-source 'use strict'; var $ = require('../internals/export'); var NATIVE_RAW_JSON = require('../internals/native-raw-json'); diff --git a/packages/core-js/modules/es.json.parse.js b/packages/core-js/modules/es.json.parse.js index ebf72ce72ec4..e076db0044bb 100644 --- a/packages/core-js/modules/es.json.parse.js +++ b/packages/core-js/modules/es.json.parse.js @@ -1,4 +1,4 @@ -// types: proposals/json-parse-with-source +// @types: proposals/json-parse-with-source 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/es.json.raw-json.js b/packages/core-js/modules/es.json.raw-json.js index f9c1d249292c..5dadc9c47a92 100644 --- a/packages/core-js/modules/es.json.raw-json.js +++ b/packages/core-js/modules/es.json.raw-json.js @@ -1,4 +1,4 @@ -// types: proposals/json-parse-with-source +// @types: proposals/json-parse-with-source 'use strict'; var $ = require('../internals/export'); var NATIVE_RAW_JSON = require('../internals/native-raw-json'); diff --git a/packages/core-js/modules/es.map.get-or-insert-computed.js b/packages/core-js/modules/es.map.get-or-insert-computed.js index 31f7cc6c3924..84c48af2988c 100644 --- a/packages/core-js/modules/es.map.get-or-insert-computed.js +++ b/packages/core-js/modules/es.map.get-or-insert-computed.js @@ -1,4 +1,4 @@ -// types: proposals/map-upsert +// @types: proposals/map-upsert 'use strict'; var $ = require('../internals/export'); var aCallable = require('../internals/a-callable'); diff --git a/packages/core-js/modules/es.map.get-or-insert.js b/packages/core-js/modules/es.map.get-or-insert.js index 1a23b9c6bf77..4a3fd1279bcc 100644 --- a/packages/core-js/modules/es.map.get-or-insert.js +++ b/packages/core-js/modules/es.map.get-or-insert.js @@ -1,4 +1,4 @@ -// types: proposals/map-upsert +// @types: proposals/map-upsert 'use strict'; var $ = require('../internals/export'); var MapHelpers = require('../internals/map-helpers'); diff --git a/packages/core-js/modules/es.map.group-by.js b/packages/core-js/modules/es.map.group-by.js index a15049fe69a6..94a7d7aea6cf 100644 --- a/packages/core-js/modules/es.map.group-by.js +++ b/packages/core-js/modules/es.map.group-by.js @@ -1,4 +1,4 @@ -// types: proposals/array-grouping +// @types: proposals/array-grouping 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/es.math.f16round.js b/packages/core-js/modules/es.math.f16round.js index 81dd13a80c2c..7430ee248b4e 100644 --- a/packages/core-js/modules/es.math.f16round.js +++ b/packages/core-js/modules/es.math.f16round.js @@ -1,4 +1,4 @@ -// types: proposals/float16 +// @types: proposals/float16 'use strict'; var $ = require('../internals/export'); var sign = require('../internals/math-sign'); diff --git a/packages/core-js/modules/es.math.sum-precise.js b/packages/core-js/modules/es.math.sum-precise.js index 2f74b363c19f..c2c25e56c102 100644 --- a/packages/core-js/modules/es.math.sum-precise.js +++ b/packages/core-js/modules/es.math.sum-precise.js @@ -1,4 +1,4 @@ -// types: proposals/math-sum +// @types: proposals/math-sum 'use strict'; // based on Shewchuk's algorithm for exactly floating point addition // adapted from https://github.com/tc39/proposal-math-sum/blob/3513d58323a1ae25560e8700aa5294500c6c9287/polyfill/polyfill.mjs diff --git a/packages/core-js/modules/es.object.define-getter.js b/packages/core-js/modules/es.object.define-getter.js index 71e38ed70c0c..06b4b1e3e252 100644 --- a/packages/core-js/modules/es.object.define-getter.js +++ b/packages/core-js/modules/es.object.define-getter.js @@ -1,4 +1,4 @@ -// types: annex-b/object-prototype-accessor-methods +// @types: annex-b/object-prototype-accessor-methods 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/es.object.define-setter.js b/packages/core-js/modules/es.object.define-setter.js index b3c5a1057840..69e7cf2d7abf 100644 --- a/packages/core-js/modules/es.object.define-setter.js +++ b/packages/core-js/modules/es.object.define-setter.js @@ -1,4 +1,4 @@ -// types: annex-b/object-prototype-accessor-methods +// @types: annex-b/object-prototype-accessor-methods 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/es.object.entries.js b/packages/core-js/modules/es.object.entries.js index b0d3954e984c..a59793058a75 100644 --- a/packages/core-js/modules/es.object.entries.js +++ b/packages/core-js/modules/es.object.entries.js @@ -1,4 +1,4 @@ -// types: proposals/object-values-entries +// @types: proposals/object-values-entries 'use strict'; var $ = require('../internals/export'); var $entries = require('../internals/object-to-array').entries; diff --git a/packages/core-js/modules/es.object.from-entries.js b/packages/core-js/modules/es.object.from-entries.js index 8276f14dbed8..0bc14216c61a 100644 --- a/packages/core-js/modules/es.object.from-entries.js +++ b/packages/core-js/modules/es.object.from-entries.js @@ -1,4 +1,4 @@ -// types: proposals/object-from-entries +// @types: proposals/object-from-entries 'use strict'; var $ = require('../internals/export'); var iterate = require('../internals/iterate'); diff --git a/packages/core-js/modules/es.object.get-own-property-descriptors.js b/packages/core-js/modules/es.object.get-own-property-descriptors.js index 0b006a7eadb3..76974ac99491 100644 --- a/packages/core-js/modules/es.object.get-own-property-descriptors.js +++ b/packages/core-js/modules/es.object.get-own-property-descriptors.js @@ -1,4 +1,4 @@ -// types: proposals/object-get-own-property-descriptors +// @types: proposals/object-get-own-property-descriptors 'use strict'; var $ = require('../internals/export'); var ownKeys = require('../internals/own-keys'); diff --git a/packages/core-js/modules/es.object.group-by.js b/packages/core-js/modules/es.object.group-by.js index d17635abc873..b8aa00981728 100644 --- a/packages/core-js/modules/es.object.group-by.js +++ b/packages/core-js/modules/es.object.group-by.js @@ -1,4 +1,4 @@ -// types: proposals/array-grouping +// @types: proposals/array-grouping 'use strict'; var $ = require('../internals/export'); var createProperty = require('../internals/create-property'); diff --git a/packages/core-js/modules/es.object.has-own.js b/packages/core-js/modules/es.object.has-own.js index fd33a1889b95..650443a0d779 100644 --- a/packages/core-js/modules/es.object.has-own.js +++ b/packages/core-js/modules/es.object.has-own.js @@ -1,4 +1,4 @@ -// types: proposals/accessible-object-hasownproperty +// @types: proposals/accessible-object-hasownproperty 'use strict'; var $ = require('../internals/export'); var hasOwn = require('../internals/has-own-property'); diff --git a/packages/core-js/modules/es.object.lookup-getter.js b/packages/core-js/modules/es.object.lookup-getter.js index a24b5b7a508e..9ca3da686270 100644 --- a/packages/core-js/modules/es.object.lookup-getter.js +++ b/packages/core-js/modules/es.object.lookup-getter.js @@ -1,4 +1,4 @@ -// types: annex-b/object-prototype-accessor-methods +// @types: annex-b/object-prototype-accessor-methods 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/es.object.lookup-setter.js b/packages/core-js/modules/es.object.lookup-setter.js index 0abf45d84f02..e984c9bd2af2 100644 --- a/packages/core-js/modules/es.object.lookup-setter.js +++ b/packages/core-js/modules/es.object.lookup-setter.js @@ -1,4 +1,4 @@ -// types: annex-b/object-prototype-accessor-methods +// @types: annex-b/object-prototype-accessor-methods 'use strict'; var $ = require('../internals/export'); var FORCED = require('../internals/object-prototype-accessors-forced'); diff --git a/packages/core-js/modules/es.object.proto.js b/packages/core-js/modules/es.object.proto.js index 1300596cacbe..f4a9575f99cd 100644 --- a/packages/core-js/modules/es.object.proto.js +++ b/packages/core-js/modules/es.object.proto.js @@ -1,4 +1,4 @@ -// types: annex-b/object-proto +// @types: annex-b/object-proto 'use strict'; var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); var isObject = require('../internals/is-object'); diff --git a/packages/core-js/modules/es.object.values.js b/packages/core-js/modules/es.object.values.js index 948d4d504cb7..80a933ea2079 100644 --- a/packages/core-js/modules/es.object.values.js +++ b/packages/core-js/modules/es.object.values.js @@ -1,4 +1,4 @@ -// types: proposals/object-values-entries +// @types: proposals/object-values-entries 'use strict'; var $ = require('../internals/export'); var $values = require('../internals/object-to-array').values; diff --git a/packages/core-js/modules/es.promise.all-settled.js b/packages/core-js/modules/es.promise.all-settled.js index f467d0d45354..6701f10ced0e 100644 --- a/packages/core-js/modules/es.promise.all-settled.js +++ b/packages/core-js/modules/es.promise.all-settled.js @@ -1,4 +1,4 @@ -// types: proposals/promise-all-settled +// @types: proposals/promise-all-settled 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.promise.any.js b/packages/core-js/modules/es.promise.any.js index 12eff381134d..74c44b87ba1c 100644 --- a/packages/core-js/modules/es.promise.any.js +++ b/packages/core-js/modules/es.promise.any.js @@ -1,4 +1,4 @@ -// types: proposals/promise-any +// @types: proposals/promise-any 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.promise.finally.js b/packages/core-js/modules/es.promise.finally.js index 2d275545d0e7..d668fc91d4b5 100644 --- a/packages/core-js/modules/es.promise.finally.js +++ b/packages/core-js/modules/es.promise.finally.js @@ -1,4 +1,4 @@ -// types: proposals/promise-finally +// @types: proposals/promise-finally 'use strict'; var $ = require('../internals/export'); var IS_PURE = require('../internals/is-pure'); diff --git a/packages/core-js/modules/es.promise.try.js b/packages/core-js/modules/es.promise.try.js index db9734a391c9..b4098c3172cd 100644 --- a/packages/core-js/modules/es.promise.try.js +++ b/packages/core-js/modules/es.promise.try.js @@ -1,4 +1,4 @@ -// types: proposals/promise-try +// @types: proposals/promise-try 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/es.promise.with-resolvers.js b/packages/core-js/modules/es.promise.with-resolvers.js index da81a79bd8b9..ffd3bafa060e 100644 --- a/packages/core-js/modules/es.promise.with-resolvers.js +++ b/packages/core-js/modules/es.promise.with-resolvers.js @@ -1,4 +1,4 @@ -// types: proposals/promise-with-resolvers +// @types: proposals/promise-with-resolvers 'use strict'; var $ = require('../internals/export'); var newPromiseCapabilityModule = require('../internals/new-promise-capability'); diff --git a/packages/core-js/modules/es.regexp.constructor.js b/packages/core-js/modules/es.regexp.constructor.js index 467f3474cca1..c593e6bf91d7 100644 --- a/packages/core-js/modules/es.regexp.constructor.js +++ b/packages/core-js/modules/es.regexp.constructor.js @@ -1,5 +1,5 @@ -// types: proposals/regexp-dotall-flag -// types: proposals/regexp-named-groups +// @types: proposals/regexp-dotall-flag +// @types: proposals/regexp-named-groups 'use strict'; // @dependency: es.regexp.exec var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/es.regexp.dot-all.js b/packages/core-js/modules/es.regexp.dot-all.js index 979c6dc1a198..5bbb40ff355e 100644 --- a/packages/core-js/modules/es.regexp.dot-all.js +++ b/packages/core-js/modules/es.regexp.dot-all.js @@ -1,4 +1,4 @@ -// types: proposals/regexp-dotall-flag +// @types: proposals/regexp-dotall-flag 'use strict'; var UNSUPPORTED_DOT_ALL = require('../internals/regexp-unsupported-dot-all'); var classof = require('../internals/classof-raw'); diff --git a/packages/core-js/modules/es.regexp.escape.js b/packages/core-js/modules/es.regexp.escape.js index 094bb3f22065..8f6986d14de9 100644 --- a/packages/core-js/modules/es.regexp.escape.js +++ b/packages/core-js/modules/es.regexp.escape.js @@ -1,4 +1,4 @@ -// types: proposals/regexp-escaping +// @types: proposals/regexp-escaping 'use strict'; var $ = require('../internals/export'); var getBuiltInPrototypeMethod = require('../internals/get-built-in-prototype-method'); diff --git a/packages/core-js/modules/es.regexp.exec.js b/packages/core-js/modules/es.regexp.exec.js index b5830f45a4dc..8401b63d1f79 100644 --- a/packages/core-js/modules/es.regexp.exec.js +++ b/packages/core-js/modules/es.regexp.exec.js @@ -1,5 +1,5 @@ -// types: proposals/regexp-dotall-flag -// types: proposals/regexp-named-groups +// @types: proposals/regexp-dotall-flag +// @types: proposals/regexp-named-groups 'use strict'; var $ = require('../internals/export'); var exec = require('../internals/regexp-exec'); diff --git a/packages/core-js/modules/es.regexp.flags.js b/packages/core-js/modules/es.regexp.flags.js index 9ae8e303a5d8..cf5f4f0b0f74 100644 --- a/packages/core-js/modules/es.regexp.flags.js +++ b/packages/core-js/modules/es.regexp.flags.js @@ -1,4 +1,4 @@ -// types: proposals/regexp-dotall-flag +// @types: proposals/regexp-dotall-flag 'use strict'; var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); var regExpFlagsDetection = require('../internals/regexp-flags-detection'); diff --git a/packages/core-js/modules/es.set.difference.js b/packages/core-js/modules/es.set.difference.js index c605f3253755..a20ca00acfc4 100644 --- a/packages/core-js/modules/es.set.difference.js +++ b/packages/core-js/modules/es.set.difference.js @@ -1,4 +1,4 @@ -// types: proposals/set-methods +// @types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var aSet = require('../internals/a-set'); diff --git a/packages/core-js/modules/es.set.intersection.js b/packages/core-js/modules/es.set.intersection.js index aaf095dfd241..f7eaad490b55 100644 --- a/packages/core-js/modules/es.set.intersection.js +++ b/packages/core-js/modules/es.set.intersection.js @@ -1,4 +1,4 @@ -// types: proposals/set-methods +// @types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var fails = require('../internals/fails'); diff --git a/packages/core-js/modules/es.set.is-disjoint-from.js b/packages/core-js/modules/es.set.is-disjoint-from.js index f9b7c6476458..88c4ee8b481e 100644 --- a/packages/core-js/modules/es.set.is-disjoint-from.js +++ b/packages/core-js/modules/es.set.is-disjoint-from.js @@ -1,4 +1,4 @@ -// types: proposals/set-methods +// @types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var aSet = require('../internals/a-set'); diff --git a/packages/core-js/modules/es.set.is-subset-of.js b/packages/core-js/modules/es.set.is-subset-of.js index bf9b7bdfceec..9947f1a471a5 100644 --- a/packages/core-js/modules/es.set.is-subset-of.js +++ b/packages/core-js/modules/es.set.is-subset-of.js @@ -1,4 +1,4 @@ -// types: proposals/set-methods +// @types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var aSet = require('../internals/a-set'); diff --git a/packages/core-js/modules/es.set.is-superset-of.js b/packages/core-js/modules/es.set.is-superset-of.js index bd17a20a1455..bad7af8fd3fb 100644 --- a/packages/core-js/modules/es.set.is-superset-of.js +++ b/packages/core-js/modules/es.set.is-superset-of.js @@ -1,4 +1,4 @@ -// types: proposals/set-methods +// @types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var aSet = require('../internals/a-set'); diff --git a/packages/core-js/modules/es.set.symmetric-difference.js b/packages/core-js/modules/es.set.symmetric-difference.js index 8c624605f219..a264a53ed538 100644 --- a/packages/core-js/modules/es.set.symmetric-difference.js +++ b/packages/core-js/modules/es.set.symmetric-difference.js @@ -1,4 +1,4 @@ -// types: proposals/set-methods +// @types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var aSet = require('../internals/a-set'); diff --git a/packages/core-js/modules/es.set.union.js b/packages/core-js/modules/es.set.union.js index 3d82d836f7c0..6bb9d4cdacd8 100644 --- a/packages/core-js/modules/es.set.union.js +++ b/packages/core-js/modules/es.set.union.js @@ -1,4 +1,4 @@ -// types: proposals/set-methods +// @types: proposals/set-methods 'use strict'; var $ = require('../internals/export'); var aSet = require('../internals/a-set'); diff --git a/packages/core-js/modules/es.string.at.js b/packages/core-js/modules/es.string.at.js index 87fff75cb477..b5c4de109fa6 100644 --- a/packages/core-js/modules/es.string.at.js +++ b/packages/core-js/modules/es.string.at.js @@ -1,4 +1,4 @@ -// types: proposals/relative-indexing-method +// @types: proposals/relative-indexing-method 'use strict'; var $ = require('../internals/export'); var requireObjectCoercible = require('../internals/require-object-coercible'); diff --git a/packages/core-js/modules/es.string.is-well-formed.js b/packages/core-js/modules/es.string.is-well-formed.js index df6ca9bada04..69e090531737 100644 --- a/packages/core-js/modules/es.string.is-well-formed.js +++ b/packages/core-js/modules/es.string.is-well-formed.js @@ -1,4 +1,4 @@ -// types: proposals/well-formed-unicode-strings +// @types: proposals/well-formed-unicode-strings 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/es.string.match-all.js b/packages/core-js/modules/es.string.match-all.js index 85d063b05b90..6982adda3359 100644 --- a/packages/core-js/modules/es.string.match-all.js +++ b/packages/core-js/modules/es.string.match-all.js @@ -1,4 +1,4 @@ -// types: proposals/string-match-all +// @types: proposals/string-match-all 'use strict'; /* eslint-disable es/no-string-prototype-matchall -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.string.pad-end.js b/packages/core-js/modules/es.string.pad-end.js index b075527317c2..7395f8d90916 100644 --- a/packages/core-js/modules/es.string.pad-end.js +++ b/packages/core-js/modules/es.string.pad-end.js @@ -1,4 +1,4 @@ -// types: proposals/string-padding +// @types: proposals/string-padding 'use strict'; var $ = require('../internals/export'); var $padEnd = require('../internals/string-pad').end; diff --git a/packages/core-js/modules/es.string.pad-start.js b/packages/core-js/modules/es.string.pad-start.js index ad8903560889..54ba90a8fea7 100644 --- a/packages/core-js/modules/es.string.pad-start.js +++ b/packages/core-js/modules/es.string.pad-start.js @@ -1,4 +1,4 @@ -// types: proposals/string-padding +// @types: proposals/string-padding 'use strict'; var $ = require('../internals/export'); var $padStart = require('../internals/string-pad').start; diff --git a/packages/core-js/modules/es.string.replace-all.js b/packages/core-js/modules/es.string.replace-all.js index b31ef52f6807..8df12fae509e 100644 --- a/packages/core-js/modules/es.string.replace-all.js +++ b/packages/core-js/modules/es.string.replace-all.js @@ -1,4 +1,4 @@ -// types: proposals/string-replace-all +// @types: proposals/string-replace-all 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.string.to-well-formed.js b/packages/core-js/modules/es.string.to-well-formed.js index 142342ac85b0..ecb426dc086f 100644 --- a/packages/core-js/modules/es.string.to-well-formed.js +++ b/packages/core-js/modules/es.string.to-well-formed.js @@ -1,4 +1,4 @@ -// types: proposals/well-formed-unicode-strings +// @types: proposals/well-formed-unicode-strings 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/es.string.trim-end.js b/packages/core-js/modules/es.string.trim-end.js index f841cc6ad380..4b79fe528384 100644 --- a/packages/core-js/modules/es.string.trim-end.js +++ b/packages/core-js/modules/es.string.trim-end.js @@ -1,4 +1,4 @@ -// types: proposals/string-left-right-trim +// @types: proposals/string-left-right-trim 'use strict'; var $ = require('../internals/export'); var trimEnd = require('../internals/string-trim-end'); diff --git a/packages/core-js/modules/es.string.trim-left.js b/packages/core-js/modules/es.string.trim-left.js index eec34be6510f..258ee53ac30d 100644 --- a/packages/core-js/modules/es.string.trim-left.js +++ b/packages/core-js/modules/es.string.trim-left.js @@ -1,4 +1,4 @@ -// types: proposals/string-left-right-trim +// @types: proposals/string-left-right-trim 'use strict'; var $ = require('../internals/export'); var trimStart = require('../internals/string-trim-start'); diff --git a/packages/core-js/modules/es.string.trim-right.js b/packages/core-js/modules/es.string.trim-right.js index ef8ba1ddb7f5..5f3771059fc1 100644 --- a/packages/core-js/modules/es.string.trim-right.js +++ b/packages/core-js/modules/es.string.trim-right.js @@ -1,4 +1,4 @@ -// types: proposals/string-left-right-trim +// @types: proposals/string-left-right-trim 'use strict'; var $ = require('../internals/export'); var trimEnd = require('../internals/string-trim-end'); diff --git a/packages/core-js/modules/es.string.trim-start.js b/packages/core-js/modules/es.string.trim-start.js index 095b8a01062b..59153fbabae8 100644 --- a/packages/core-js/modules/es.string.trim-start.js +++ b/packages/core-js/modules/es.string.trim-start.js @@ -1,4 +1,4 @@ -// types: proposals/string-left-right-trim +// @types: proposals/string-left-right-trim 'use strict'; var $ = require('../internals/export'); var trimStart = require('../internals/string-trim-start'); diff --git a/packages/core-js/modules/es.suppressed-error.constructor.js b/packages/core-js/modules/es.suppressed-error.constructor.js index d5029621b1fa..fae65eaab6d6 100644 --- a/packages/core-js/modules/es.suppressed-error.constructor.js +++ b/packages/core-js/modules/es.suppressed-error.constructor.js @@ -1,4 +1,4 @@ -// types: proposals/explicit-resource-management +// @types: proposals/explicit-resource-management 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/es.symbol.async-dispose.js b/packages/core-js/modules/es.symbol.async-dispose.js index 05ca2d794b84..0ad0912c8af5 100644 --- a/packages/core-js/modules/es.symbol.async-dispose.js +++ b/packages/core-js/modules/es.symbol.async-dispose.js @@ -1,4 +1,4 @@ -// types: proposals/explicit-resource-management +// @types: proposals/explicit-resource-management 'use strict'; var globalThis = require('../internals/global-this'); var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/es.symbol.async-iterator.js b/packages/core-js/modules/es.symbol.async-iterator.js index d343c338e3e4..5c27469ba7a3 100644 --- a/packages/core-js/modules/es.symbol.async-iterator.js +++ b/packages/core-js/modules/es.symbol.async-iterator.js @@ -1,4 +1,4 @@ -// types: proposals/async-iteration +// @types: proposals/async-iteration 'use strict'; var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/es.symbol.constructor.js b/packages/core-js/modules/es.symbol.constructor.js index 486b754377c9..a2f6ca4f0244 100644 --- a/packages/core-js/modules/es.symbol.constructor.js +++ b/packages/core-js/modules/es.symbol.constructor.js @@ -1,4 +1,4 @@ -// types: proposals/symbol-description +// @types: proposals/symbol-description 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/es.symbol.description.js b/packages/core-js/modules/es.symbol.description.js index ae39801858b9..3352b3c9e502 100644 --- a/packages/core-js/modules/es.symbol.description.js +++ b/packages/core-js/modules/es.symbol.description.js @@ -1,4 +1,4 @@ -// types: proposals/symbol-description +// @types: proposals/symbol-description // `Symbol.prototype.description` getter // https://tc39.es/ecma262/#sec-symbol.prototype.description 'use strict'; diff --git a/packages/core-js/modules/es.symbol.dispose.js b/packages/core-js/modules/es.symbol.dispose.js index d0bd8d15cdab..737f9fd68672 100644 --- a/packages/core-js/modules/es.symbol.dispose.js +++ b/packages/core-js/modules/es.symbol.dispose.js @@ -1,4 +1,4 @@ -// types: proposals/explicit-resource-management +// @types: proposals/explicit-resource-management 'use strict'; var globalThis = require('../internals/global-this'); var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/es.symbol.match-all.js b/packages/core-js/modules/es.symbol.match-all.js index 46d21606f78a..0afdec7e071e 100644 --- a/packages/core-js/modules/es.symbol.match-all.js +++ b/packages/core-js/modules/es.symbol.match-all.js @@ -1,4 +1,4 @@ -// types: proposals/string-match-all +// @types: proposals/string-match-all 'use strict'; var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/es.typed-array.at.js b/packages/core-js/modules/es.typed-array.at.js index 27027944ad6f..2aa62db84a62 100644 --- a/packages/core-js/modules/es.typed-array.at.js +++ b/packages/core-js/modules/es.typed-array.at.js @@ -1,4 +1,4 @@ -// types: proposals/relative-indexing-method +// @types: proposals/relative-indexing-method 'use strict'; var exportTypedArrayMethod = require('../internals/export-typed-array-method'); var aTypedArray = require('../internals/a-typed-array'); diff --git a/packages/core-js/modules/es.typed-array.find-last-index.js b/packages/core-js/modules/es.typed-array.find-last-index.js index f56787e179cb..a6b6eac803c1 100644 --- a/packages/core-js/modules/es.typed-array.find-last-index.js +++ b/packages/core-js/modules/es.typed-array.find-last-index.js @@ -1,4 +1,4 @@ -// types: proposals/array-find-from-last +// @types: proposals/array-find-from-last 'use strict'; var exportTypedArrayMethod = require('../internals/export-typed-array-method'); var aTypedArray = require('../internals/a-typed-array'); diff --git a/packages/core-js/modules/es.typed-array.find-last.js b/packages/core-js/modules/es.typed-array.find-last.js index eaf006561e9e..b8f6d0bae8ef 100644 --- a/packages/core-js/modules/es.typed-array.find-last.js +++ b/packages/core-js/modules/es.typed-array.find-last.js @@ -1,4 +1,4 @@ -// types: proposals/array-find-from-last +// @types: proposals/array-find-from-last 'use strict'; var exportTypedArrayMethod = require('../internals/export-typed-array-method'); var aTypedArray = require('../internals/a-typed-array'); diff --git a/packages/core-js/modules/es.typed-array.includes.js b/packages/core-js/modules/es.typed-array.includes.js index d9ade2d53eb0..b87a3fbca055 100644 --- a/packages/core-js/modules/es.typed-array.includes.js +++ b/packages/core-js/modules/es.typed-array.includes.js @@ -1,4 +1,4 @@ -// types: proposals/array-includes +// @types: proposals/array-includes 'use strict'; var exportTypedArrayMethod = require('../internals/export-typed-array-method'); var aTypedArray = require('../internals/a-typed-array'); diff --git a/packages/core-js/modules/es.typed-array.to-reversed.js b/packages/core-js/modules/es.typed-array.to-reversed.js index 7ca0511586ef..bc009c7e3c98 100644 --- a/packages/core-js/modules/es.typed-array.to-reversed.js +++ b/packages/core-js/modules/es.typed-array.to-reversed.js @@ -1,4 +1,4 @@ -// types: proposals/change-array-by-copy +// @types: proposals/change-array-by-copy 'use strict'; var lengthOfArrayLike = require('../internals/length-of-array-like'); var exportTypedArrayMethod = require('../internals/export-typed-array-method'); diff --git a/packages/core-js/modules/es.typed-array.to-sorted.js b/packages/core-js/modules/es.typed-array.to-sorted.js index f29f61e797b8..3aa8114a5a04 100644 --- a/packages/core-js/modules/es.typed-array.to-sorted.js +++ b/packages/core-js/modules/es.typed-array.to-sorted.js @@ -1,4 +1,4 @@ -// types: proposals/change-array-by-copy +// @types: proposals/change-array-by-copy 'use strict'; var uncurryThis = require('../internals/function-uncurry-this'); var aCallable = require('../internals/a-callable'); diff --git a/packages/core-js/modules/es.typed-array.with.js b/packages/core-js/modules/es.typed-array.with.js index c978b22c9244..0c8a1f4c3e9a 100644 --- a/packages/core-js/modules/es.typed-array.with.js +++ b/packages/core-js/modules/es.typed-array.with.js @@ -1,4 +1,4 @@ -// types: proposals/change-array-by-copy +// @types: proposals/change-array-by-copy 'use strict'; var exportTypedArrayMethod = require('../internals/export-typed-array-method'); var aTypedArray = require('../internals/a-typed-array'); diff --git a/packages/core-js/modules/es.uint8-array.from-base64.js b/packages/core-js/modules/es.uint8-array.from-base64.js index 837782775e28..e617667aeeb5 100644 --- a/packages/core-js/modules/es.uint8-array.from-base64.js +++ b/packages/core-js/modules/es.uint8-array.from-base64.js @@ -1,4 +1,4 @@ -// types: proposals/array-buffer-base64 +// @types: proposals/array-buffer-base64 'use strict'; /* eslint-disable es/no-uint8array-frombase64 -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.uint8-array.from-hex.js b/packages/core-js/modules/es.uint8-array.from-hex.js index f9d7d9094032..e4549f1d403e 100644 --- a/packages/core-js/modules/es.uint8-array.from-hex.js +++ b/packages/core-js/modules/es.uint8-array.from-hex.js @@ -1,4 +1,4 @@ -// types: proposals/array-buffer-base64 +// @types: proposals/array-buffer-base64 'use strict'; var $ = require('../internals/export'); var aString = require('../internals/a-string'); diff --git a/packages/core-js/modules/es.uint8-array.set-from-base64.js b/packages/core-js/modules/es.uint8-array.set-from-base64.js index 449fa1eb853b..f6a6c0dba893 100644 --- a/packages/core-js/modules/es.uint8-array.set-from-base64.js +++ b/packages/core-js/modules/es.uint8-array.set-from-base64.js @@ -1,4 +1,4 @@ -// types: proposals/array-buffer-base64 +// @types: proposals/array-buffer-base64 'use strict'; /* eslint-disable es/no-uint8array-prototype-setfrombase64 -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.uint8-array.set-from-hex.js b/packages/core-js/modules/es.uint8-array.set-from-hex.js index a1468bf59284..4a81c942a2af 100644 --- a/packages/core-js/modules/es.uint8-array.set-from-hex.js +++ b/packages/core-js/modules/es.uint8-array.set-from-hex.js @@ -1,4 +1,4 @@ -// types: proposals/array-buffer-base64 +// @types: proposals/array-buffer-base64 'use strict'; var $ = require('../internals/export'); var aString = require('../internals/a-string'); diff --git a/packages/core-js/modules/es.uint8-array.to-base64.js b/packages/core-js/modules/es.uint8-array.to-base64.js index 18539763c492..e3c518e44a62 100644 --- a/packages/core-js/modules/es.uint8-array.to-base64.js +++ b/packages/core-js/modules/es.uint8-array.to-base64.js @@ -1,4 +1,4 @@ -// types: proposals/array-buffer-base64 +// @types: proposals/array-buffer-base64 'use strict'; /* eslint-disable es/no-uint8array-prototype-tobase64 -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.uint8-array.to-hex.js b/packages/core-js/modules/es.uint8-array.to-hex.js index 81fc9e7dad55..d17f4dfaa1fc 100644 --- a/packages/core-js/modules/es.uint8-array.to-hex.js +++ b/packages/core-js/modules/es.uint8-array.to-hex.js @@ -1,4 +1,4 @@ -// types: proposals/array-buffer-base64 +// @types: proposals/array-buffer-base64 'use strict'; /* eslint-disable es/no-uint8array-prototype-tohex -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.weak-map.get-or-insert-computed.js b/packages/core-js/modules/es.weak-map.get-or-insert-computed.js index 5bfe32dde90d..2f994de08431 100644 --- a/packages/core-js/modules/es.weak-map.get-or-insert-computed.js +++ b/packages/core-js/modules/es.weak-map.get-or-insert-computed.js @@ -1,4 +1,4 @@ -// types: proposals/map-upsert +// @types: proposals/map-upsert 'use strict'; var $ = require('../internals/export'); var aCallable = require('../internals/a-callable'); diff --git a/packages/core-js/modules/es.weak-map.get-or-insert.js b/packages/core-js/modules/es.weak-map.get-or-insert.js index 4abfb54840d3..1be8965f361f 100644 --- a/packages/core-js/modules/es.weak-map.get-or-insert.js +++ b/packages/core-js/modules/es.weak-map.get-or-insert.js @@ -1,4 +1,4 @@ -// types: proposals/map-upsert +// @types: proposals/map-upsert 'use strict'; var $ = require('../internals/export'); var WeakMapHelpers = require('../internals/weak-map-helpers'); diff --git a/packages/core-js/modules/esnext.array.filter-reject.js b/packages/core-js/modules/esnext.array.filter-reject.js index 740395a4e01d..ca2bda0c8043 100644 --- a/packages/core-js/modules/esnext.array.filter-reject.js +++ b/packages/core-js/modules/esnext.array.filter-reject.js @@ -1,4 +1,4 @@ -// types: proposals/array-filtering +// @types: proposals/array-filtering 'use strict'; var $ = require('../internals/export'); var $filterReject = require('../internals/array-iteration').filterReject; diff --git a/packages/core-js/modules/esnext.array.is-template-object.js b/packages/core-js/modules/esnext.array.is-template-object.js index 2c1f0ecc46fb..6940e7071efa 100644 --- a/packages/core-js/modules/esnext.array.is-template-object.js +++ b/packages/core-js/modules/esnext.array.is-template-object.js @@ -1,4 +1,4 @@ -// types: proposals/array-is-template-object +// @types: proposals/array-is-template-object 'use strict'; var $ = require('../internals/export'); diff --git a/packages/core-js/modules/esnext.array.unique-by.js b/packages/core-js/modules/esnext.array.unique-by.js index 3b680aa3ace2..311b85f53a2c 100644 --- a/packages/core-js/modules/esnext.array.unique-by.js +++ b/packages/core-js/modules/esnext.array.unique-by.js @@ -1,4 +1,4 @@ -// types: proposals/array-unique +// @types: proposals/array-unique 'use strict'; var $ = require('../internals/export'); var addToUnscopables = require('../internals/add-to-unscopables'); diff --git a/packages/core-js/modules/esnext.async-iterator.constructor.js b/packages/core-js/modules/esnext.async-iterator.constructor.js index 920ef2dc4765..19d0da9b17bd 100644 --- a/packages/core-js/modules/esnext.async-iterator.constructor.js +++ b/packages/core-js/modules/esnext.async-iterator.constructor.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var anInstance = require('../internals/an-instance'); diff --git a/packages/core-js/modules/esnext.async-iterator.drop.js b/packages/core-js/modules/esnext.async-iterator.drop.js index 1c052f8ee770..878e4f1fd4a1 100644 --- a/packages/core-js/modules/esnext.async-iterator.drop.js +++ b/packages/core-js/modules/esnext.async-iterator.drop.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.every.js b/packages/core-js/modules/esnext.async-iterator.every.js index 15c763082d90..a3bb3f5692b5 100644 --- a/packages/core-js/modules/esnext.async-iterator.every.js +++ b/packages/core-js/modules/esnext.async-iterator.every.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var $every = require('../internals/async-iterator-iteration').every; diff --git a/packages/core-js/modules/esnext.async-iterator.filter.js b/packages/core-js/modules/esnext.async-iterator.filter.js index a9f30c545946..a0f121386b11 100644 --- a/packages/core-js/modules/esnext.async-iterator.filter.js +++ b/packages/core-js/modules/esnext.async-iterator.filter.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.find.js b/packages/core-js/modules/esnext.async-iterator.find.js index fc8e196c001d..f905bf19d84b 100644 --- a/packages/core-js/modules/esnext.async-iterator.find.js +++ b/packages/core-js/modules/esnext.async-iterator.find.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var $find = require('../internals/async-iterator-iteration').find; diff --git a/packages/core-js/modules/esnext.async-iterator.flat-map.js b/packages/core-js/modules/esnext.async-iterator.flat-map.js index 8dec19e2743a..2d0403b3e095 100644 --- a/packages/core-js/modules/esnext.async-iterator.flat-map.js +++ b/packages/core-js/modules/esnext.async-iterator.flat-map.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.for-each.js b/packages/core-js/modules/esnext.async-iterator.for-each.js index 49bf32f48657..3608432d9b5a 100644 --- a/packages/core-js/modules/esnext.async-iterator.for-each.js +++ b/packages/core-js/modules/esnext.async-iterator.for-each.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var $forEach = require('../internals/async-iterator-iteration').forEach; diff --git a/packages/core-js/modules/esnext.async-iterator.from.js b/packages/core-js/modules/esnext.async-iterator.from.js index 872c1f53cad1..4772620626d2 100644 --- a/packages/core-js/modules/esnext.async-iterator.from.js +++ b/packages/core-js/modules/esnext.async-iterator.from.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var toObject = require('../internals/to-object'); diff --git a/packages/core-js/modules/esnext.async-iterator.map.js b/packages/core-js/modules/esnext.async-iterator.map.js index f6b8c112b924..ca5593c78ca5 100644 --- a/packages/core-js/modules/esnext.async-iterator.map.js +++ b/packages/core-js/modules/esnext.async-iterator.map.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.reduce.js b/packages/core-js/modules/esnext.async-iterator.reduce.js index a3b771b06eaa..3f502f59a470 100644 --- a/packages/core-js/modules/esnext.async-iterator.reduce.js +++ b/packages/core-js/modules/esnext.async-iterator.reduce.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.some.js b/packages/core-js/modules/esnext.async-iterator.some.js index e93052381c67..751a90fc38c3 100644 --- a/packages/core-js/modules/esnext.async-iterator.some.js +++ b/packages/core-js/modules/esnext.async-iterator.some.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var $some = require('../internals/async-iterator-iteration').some; diff --git a/packages/core-js/modules/esnext.async-iterator.take.js b/packages/core-js/modules/esnext.async-iterator.take.js index 55685f746895..7a75bd083801 100644 --- a/packages/core-js/modules/esnext.async-iterator.take.js +++ b/packages/core-js/modules/esnext.async-iterator.take.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var call = require('../internals/function-call'); diff --git a/packages/core-js/modules/esnext.async-iterator.to-array.js b/packages/core-js/modules/esnext.async-iterator.to-array.js index a85a0cd50ba7..8d3f9d8be321 100644 --- a/packages/core-js/modules/esnext.async-iterator.to-array.js +++ b/packages/core-js/modules/esnext.async-iterator.to-array.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var $toArray = require('../internals/async-iterator-iteration').toArray; diff --git a/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js b/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js index d7d608d14997..a6715023b2d5 100644 --- a/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js +++ b/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js @@ -1,4 +1,4 @@ -// types: proposals/data-view-get-set-uint8-clamped +// @types: proposals/data-view-get-set-uint8-clamped 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js b/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js index 2794124f9d35..5d906fba56a1 100644 --- a/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js +++ b/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js @@ -1,4 +1,4 @@ -// types: proposals/data-view-get-set-uint8-clamped +// @types: proposals/data-view-get-set-uint8-clamped 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/esnext.function.demethodize.js b/packages/core-js/modules/esnext.function.demethodize.js index a9392fd48d4a..1899734ebf86 100644 --- a/packages/core-js/modules/esnext.function.demethodize.js +++ b/packages/core-js/modules/esnext.function.demethodize.js @@ -1,4 +1,4 @@ -// types: proposals/function-demethodize +// @types: proposals/function-demethodize 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/esnext.function.metadata.js b/packages/core-js/modules/esnext.function.metadata.js index 1f9d6a1036fe..df25e0e936af 100644 --- a/packages/core-js/modules/esnext.function.metadata.js +++ b/packages/core-js/modules/esnext.function.metadata.js @@ -1,4 +1,4 @@ -// types: proposals/decorator-metadata +// @types: proposals/decorator-metadata 'use strict'; var wellKnownSymbol = require('../internals/well-known-symbol'); diff --git a/packages/core-js/modules/esnext.iterator.chunks.js b/packages/core-js/modules/esnext.iterator.chunks.js index 77eb9ee0beb9..8e6bafe2fdc5 100644 --- a/packages/core-js/modules/esnext.iterator.chunks.js +++ b/packages/core-js/modules/esnext.iterator.chunks.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-chunking +// @types: proposals/iterator-chunking 'use strict'; var $ = require('../internals/export'); var anObject = require('../internals/an-object'); diff --git a/packages/core-js/modules/esnext.iterator.join.js b/packages/core-js/modules/esnext.iterator.join.js index 685944885fe0..ff2fc67f862c 100644 --- a/packages/core-js/modules/esnext.iterator.join.js +++ b/packages/core-js/modules/esnext.iterator.join.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-join +// @types: proposals/iterator-join 'use strict'; var $ = require('../internals/export'); var $toString = require('../internals/to-string'); diff --git a/packages/core-js/modules/esnext.iterator.range.js b/packages/core-js/modules/esnext.iterator.range.js index 14cd0141c72c..a3b9d0597157 100644 --- a/packages/core-js/modules/esnext.iterator.range.js +++ b/packages/core-js/modules/esnext.iterator.range.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-range +// @types: proposals/iterator-range 'use strict'; /* eslint-disable es/no-bigint -- safe */ var $ = require('../internals/export'); diff --git a/packages/core-js/modules/esnext.iterator.to-async.js b/packages/core-js/modules/esnext.iterator.to-async.js index 8ae383c18971..0f657b17541e 100644 --- a/packages/core-js/modules/esnext.iterator.to-async.js +++ b/packages/core-js/modules/esnext.iterator.to-async.js @@ -1,4 +1,4 @@ -// types: proposals/async-iterator-helpers +// @types: proposals/async-iterator-helpers 'use strict'; var $ = require('../internals/export'); var anObject = require('../internals/an-object'); diff --git a/packages/core-js/modules/esnext.iterator.windows.js b/packages/core-js/modules/esnext.iterator.windows.js index 22ebc0845d20..20a708542a01 100644 --- a/packages/core-js/modules/esnext.iterator.windows.js +++ b/packages/core-js/modules/esnext.iterator.windows.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-chunking +// @types: proposals/iterator-chunking 'use strict'; var $ = require('../internals/export'); var anObject = require('../internals/an-object'); diff --git a/packages/core-js/modules/esnext.iterator.zip-keyed.js b/packages/core-js/modules/esnext.iterator.zip-keyed.js index 0e8fba2f1338..60dd90490612 100644 --- a/packages/core-js/modules/esnext.iterator.zip-keyed.js +++ b/packages/core-js/modules/esnext.iterator.zip-keyed.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-joint +// @types: proposals/iterator-joint 'use strict'; var $ = require('../internals/export'); var anObject = require('../internals/an-object'); diff --git a/packages/core-js/modules/esnext.iterator.zip.js b/packages/core-js/modules/esnext.iterator.zip.js index a79b28afbcfb..60017608d40b 100644 --- a/packages/core-js/modules/esnext.iterator.zip.js +++ b/packages/core-js/modules/esnext.iterator.zip.js @@ -1,4 +1,4 @@ -// types: proposals/iterator-joint +// @types: proposals/iterator-joint 'use strict'; var $ = require('../internals/export'); var anObject = require('../internals/an-object'); diff --git a/packages/core-js/modules/esnext.map.from.js b/packages/core-js/modules/esnext.map.from.js index 7d6e6e7fe26a..b86335d20454 100644 --- a/packages/core-js/modules/esnext.map.from.js +++ b/packages/core-js/modules/esnext.map.from.js @@ -1,4 +1,4 @@ -// types: proposals/collection-of-from +// @types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var MapHelpers = require('../internals/map-helpers'); diff --git a/packages/core-js/modules/esnext.map.of.js b/packages/core-js/modules/esnext.map.of.js index 6f21c8112d3d..dc8865331eb2 100644 --- a/packages/core-js/modules/esnext.map.of.js +++ b/packages/core-js/modules/esnext.map.of.js @@ -1,4 +1,4 @@ -// types: proposals/collection-of-from +// @types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var MapHelpers = require('../internals/map-helpers'); diff --git a/packages/core-js/modules/esnext.number.clamp.js b/packages/core-js/modules/esnext.number.clamp.js index d052b01ae2f3..5347af458310 100644 --- a/packages/core-js/modules/esnext.number.clamp.js +++ b/packages/core-js/modules/esnext.number.clamp.js @@ -1,4 +1,4 @@ -// types: proposals/number-clamp +// @types: proposals/number-clamp 'use strict'; var $ = require('../internals/export'); var aNumber = require('../internals/a-number'); diff --git a/packages/core-js/modules/esnext.promise.all-keyed.js b/packages/core-js/modules/esnext.promise.all-keyed.js index ae942742a3a0..8e3a6ced3682 100644 --- a/packages/core-js/modules/esnext.promise.all-keyed.js +++ b/packages/core-js/modules/esnext.promise.all-keyed.js @@ -1,4 +1,4 @@ -// types: proposals/await-dictionary +// @types: proposals/await-dictionary 'use strict'; var $ = require('../internals/export'); var aCallable = require('../internals/a-callable'); diff --git a/packages/core-js/modules/esnext.promise.all-settled-keyed.js b/packages/core-js/modules/esnext.promise.all-settled-keyed.js index 10cc239348c5..b5275abfba47 100644 --- a/packages/core-js/modules/esnext.promise.all-settled-keyed.js +++ b/packages/core-js/modules/esnext.promise.all-settled-keyed.js @@ -1,4 +1,4 @@ -// types: proposals/await-dictionary +// @types: proposals/await-dictionary 'use strict'; var $ = require('../internals/export'); var aCallable = require('../internals/a-callable'); diff --git a/packages/core-js/modules/esnext.set.from.js b/packages/core-js/modules/esnext.set.from.js index e1428f8c845e..5bf3cc3b47e7 100644 --- a/packages/core-js/modules/esnext.set.from.js +++ b/packages/core-js/modules/esnext.set.from.js @@ -1,4 +1,4 @@ -// types: proposals/collection-of-from +// @types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var SetHelpers = require('../internals/set-helpers'); diff --git a/packages/core-js/modules/esnext.set.of.js b/packages/core-js/modules/esnext.set.of.js index 861fadc26518..ae7d1aad9bf7 100644 --- a/packages/core-js/modules/esnext.set.of.js +++ b/packages/core-js/modules/esnext.set.of.js @@ -1,4 +1,4 @@ -// types: proposals/collection-of-from +// @types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var SetHelpers = require('../internals/set-helpers'); diff --git a/packages/core-js/modules/esnext.string.cooked.js b/packages/core-js/modules/esnext.string.cooked.js index 9a96a7539ad9..d4ca65e7c5e2 100644 --- a/packages/core-js/modules/esnext.string.cooked.js +++ b/packages/core-js/modules/esnext.string.cooked.js @@ -1,4 +1,4 @@ -// types: proposals/string-cooked +// @types: proposals/string-cooked 'use strict'; var $ = require('../internals/export'); var cooked = require('../internals/string-cooked'); diff --git a/packages/core-js/modules/esnext.string.dedent.js b/packages/core-js/modules/esnext.string.dedent.js index e4cdeee965f2..f81c53e532e1 100644 --- a/packages/core-js/modules/esnext.string.dedent.js +++ b/packages/core-js/modules/esnext.string.dedent.js @@ -1,4 +1,4 @@ -// types: proposals/string-dedent +// @types: proposals/string-dedent 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/esnext.symbol.custom-matcher.js b/packages/core-js/modules/esnext.symbol.custom-matcher.js index 7c4b9da8e8df..2ddc3a914fd4 100644 --- a/packages/core-js/modules/esnext.symbol.custom-matcher.js +++ b/packages/core-js/modules/esnext.symbol.custom-matcher.js @@ -1,4 +1,4 @@ -// types: proposals/pattern-matching +// @types: proposals/pattern-matching 'use strict'; var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/esnext.symbol.is-registered-symbol.js b/packages/core-js/modules/esnext.symbol.is-registered-symbol.js index 1d5e6e3d19d5..ca91b552cd47 100644 --- a/packages/core-js/modules/esnext.symbol.is-registered-symbol.js +++ b/packages/core-js/modules/esnext.symbol.is-registered-symbol.js @@ -1,4 +1,4 @@ -// types: proposals/symbol-predicates +// @types: proposals/symbol-predicates 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js b/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js index ceabd077c2b5..bb1058ba5d4c 100644 --- a/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js +++ b/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js @@ -1,4 +1,4 @@ -// types: proposals/symbol-predicates +// @types: proposals/symbol-predicates 'use strict'; var $ = require('../internals/export'); var shared = require('../internals/shared'); diff --git a/packages/core-js/modules/esnext.symbol.metadata.js b/packages/core-js/modules/esnext.symbol.metadata.js index ed4d4448b4f3..ff23a5ff083c 100644 --- a/packages/core-js/modules/esnext.symbol.metadata.js +++ b/packages/core-js/modules/esnext.symbol.metadata.js @@ -1,4 +1,4 @@ -// types: proposals/decorator-metadata +// @types: proposals/decorator-metadata 'use strict'; var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); diff --git a/packages/core-js/modules/esnext.typed-array.filter-reject.js b/packages/core-js/modules/esnext.typed-array.filter-reject.js index 898891ee744c..9b66ff4eaf28 100644 --- a/packages/core-js/modules/esnext.typed-array.filter-reject.js +++ b/packages/core-js/modules/esnext.typed-array.filter-reject.js @@ -1,4 +1,4 @@ -// types: proposals/array-filtering +// @types: proposals/array-filtering 'use strict'; var exportTypedArrayMethod = require('../internals/export-typed-array-method'); var aTypedArray = require('../internals/a-typed-array'); diff --git a/packages/core-js/modules/esnext.typed-array.unique-by.js b/packages/core-js/modules/esnext.typed-array.unique-by.js index e1427b8dfa1c..c80233f779c8 100644 --- a/packages/core-js/modules/esnext.typed-array.unique-by.js +++ b/packages/core-js/modules/esnext.typed-array.unique-by.js @@ -1,4 +1,4 @@ -// types: proposals/array-unique +// @types: proposals/array-unique 'use strict'; var uncurryThis = require('../internals/function-uncurry-this'); var exportTypedArrayMethod = require('../internals/export-typed-array-method'); diff --git a/packages/core-js/modules/esnext.weak-map.from.js b/packages/core-js/modules/esnext.weak-map.from.js index dc8277045834..a6321f5c6e46 100644 --- a/packages/core-js/modules/esnext.weak-map.from.js +++ b/packages/core-js/modules/esnext.weak-map.from.js @@ -1,4 +1,4 @@ -// types: proposals/collection-of-from +// @types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var WeakMapHelpers = require('../internals/weak-map-helpers'); diff --git a/packages/core-js/modules/esnext.weak-map.of.js b/packages/core-js/modules/esnext.weak-map.of.js index dfc6ea2f20cb..94404e093c62 100644 --- a/packages/core-js/modules/esnext.weak-map.of.js +++ b/packages/core-js/modules/esnext.weak-map.of.js @@ -1,4 +1,4 @@ -// types: proposals/collection-of-from +// @types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var WeakMapHelpers = require('../internals/weak-map-helpers'); diff --git a/packages/core-js/modules/esnext.weak-set.from.js b/packages/core-js/modules/esnext.weak-set.from.js index c7b32e8a41b0..7b11a80dedf3 100644 --- a/packages/core-js/modules/esnext.weak-set.from.js +++ b/packages/core-js/modules/esnext.weak-set.from.js @@ -1,4 +1,4 @@ -// types: proposals/collection-of-from +// @types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var WeakSetHelpers = require('../internals/weak-set-helpers'); diff --git a/packages/core-js/modules/esnext.weak-set.of.js b/packages/core-js/modules/esnext.weak-set.of.js index 26f97989747c..4712a392f73e 100644 --- a/packages/core-js/modules/esnext.weak-set.of.js +++ b/packages/core-js/modules/esnext.weak-set.of.js @@ -1,4 +1,4 @@ -// types: proposals/collection-of-from +// @types: proposals/collection-of-from 'use strict'; var $ = require('../internals/export'); var WeakSetHelpers = require('../internals/weak-set-helpers'); diff --git a/packages/core-js/modules/web.atob.js b/packages/core-js/modules/web.atob.js index b8954e7464ed..58dcc4e23695 100644 --- a/packages/core-js/modules/web.atob.js +++ b/packages/core-js/modules/web.atob.js @@ -1,4 +1,4 @@ -// types: web/atob-btoa +// @types: web/atob-btoa 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.btoa.js b/packages/core-js/modules/web.btoa.js index 4989240f341c..fe6ad99830d1 100644 --- a/packages/core-js/modules/web.btoa.js +++ b/packages/core-js/modules/web.btoa.js @@ -1,4 +1,4 @@ -// types: web/atob-btoa +// @types: web/atob-btoa 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.clear-immediate.js b/packages/core-js/modules/web.clear-immediate.js index 652cb967faca..49a95fabe36e 100644 --- a/packages/core-js/modules/web.clear-immediate.js +++ b/packages/core-js/modules/web.clear-immediate.js @@ -1,4 +1,4 @@ -// types: web/efficient-script-yielding +// @types: web/efficient-script-yielding 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.dom-collections.entries.js b/packages/core-js/modules/web.dom-collections.entries.js index 8e63b117c90a..1b8212f558ae 100644 --- a/packages/core-js/modules/web.dom-collections.entries.js +++ b/packages/core-js/modules/web.dom-collections.entries.js @@ -1,4 +1,4 @@ -// types: web/iterable-dom-collections +// @types: web/iterable-dom-collections 'use strict'; var domIterablesDefineMethod = require('../internals/dom-iterables-define-method'); diff --git a/packages/core-js/modules/web.dom-collections.for-each.js b/packages/core-js/modules/web.dom-collections.for-each.js index cd51d8a6d3d0..69c6dc716a62 100644 --- a/packages/core-js/modules/web.dom-collections.for-each.js +++ b/packages/core-js/modules/web.dom-collections.for-each.js @@ -1,4 +1,4 @@ -// types: web/iterable-dom-collections +// @types: web/iterable-dom-collections 'use strict'; var domIterablesDefineMethod = require('../internals/dom-iterables-define-method'); diff --git a/packages/core-js/modules/web.dom-collections.iterator.js b/packages/core-js/modules/web.dom-collections.iterator.js index 1d5998c1f8ce..4d69270abc6d 100644 --- a/packages/core-js/modules/web.dom-collections.iterator.js +++ b/packages/core-js/modules/web.dom-collections.iterator.js @@ -1,4 +1,4 @@ -// types: web/iterable-dom-collections +// @types: web/iterable-dom-collections 'use strict'; var domIterablesDefineMethod = require('../internals/dom-iterables-define-method'); var wellKnownSymbol = require('../internals/well-known-symbol'); diff --git a/packages/core-js/modules/web.dom-collections.keys.js b/packages/core-js/modules/web.dom-collections.keys.js index 06e64d5ab0f2..e1dd198f2f5d 100644 --- a/packages/core-js/modules/web.dom-collections.keys.js +++ b/packages/core-js/modules/web.dom-collections.keys.js @@ -1,4 +1,4 @@ -// types: web/iterable-dom-collections +// @types: web/iterable-dom-collections 'use strict'; var domIterablesDefineMethod = require('../internals/dom-iterables-define-method'); diff --git a/packages/core-js/modules/web.dom-collections.values.js b/packages/core-js/modules/web.dom-collections.values.js index c1353f4f1001..b5ba531ea1a6 100644 --- a/packages/core-js/modules/web.dom-collections.values.js +++ b/packages/core-js/modules/web.dom-collections.values.js @@ -1,4 +1,4 @@ -// types: web/iterable-dom-collections +// @types: web/iterable-dom-collections 'use strict'; var domIterablesDefineMethod = require('../internals/dom-iterables-define-method'); var wellKnownSymbol = require('../internals/well-known-symbol'); diff --git a/packages/core-js/modules/web.dom-exception.constructor.js b/packages/core-js/modules/web.dom-exception.constructor.js index e791505c67e3..13ae452df48e 100644 --- a/packages/core-js/modules/web.dom-exception.constructor.js +++ b/packages/core-js/modules/web.dom-exception.constructor.js @@ -1,4 +1,4 @@ -// types: web/dom-exception +// @types: web/dom-exception 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/web.dom-exception.stack.js b/packages/core-js/modules/web.dom-exception.stack.js index cc83550c8f0b..e0dfb69e0ae3 100644 --- a/packages/core-js/modules/web.dom-exception.stack.js +++ b/packages/core-js/modules/web.dom-exception.stack.js @@ -1,4 +1,4 @@ -// types: web/dom-exception +// @types: web/dom-exception 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.dom-exception.to-string-tag.js b/packages/core-js/modules/web.dom-exception.to-string-tag.js index 3f3bd1df5ba5..b5a73a3b85a8 100644 --- a/packages/core-js/modules/web.dom-exception.to-string-tag.js +++ b/packages/core-js/modules/web.dom-exception.to-string-tag.js @@ -1,4 +1,4 @@ -// types: web/dom-exception +// @types: web/dom-exception 'use strict'; var getBuiltIn = require('../internals/get-built-in'); var setToStringTag = require('../internals/set-to-string-tag'); diff --git a/packages/core-js/modules/web.queue-microtask.js b/packages/core-js/modules/web.queue-microtask.js index 25b9c191b72f..cca90ee7bd14 100644 --- a/packages/core-js/modules/web.queue-microtask.js +++ b/packages/core-js/modules/web.queue-microtask.js @@ -1,4 +1,4 @@ -// types: web/queue-microtask +// @types: web/queue-microtask 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.self.js b/packages/core-js/modules/web.self.js index 795dfb0a9fe0..04905346b0f0 100644 --- a/packages/core-js/modules/web.self.js +++ b/packages/core-js/modules/web.self.js @@ -1,4 +1,4 @@ -// types: web/self +// @types: web/self 'use strict'; var globalThis = require('../internals/global-this'); var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); diff --git a/packages/core-js/modules/web.set-immediate.js b/packages/core-js/modules/web.set-immediate.js index 68ab987df0b5..62eb5eee48a9 100644 --- a/packages/core-js/modules/web.set-immediate.js +++ b/packages/core-js/modules/web.set-immediate.js @@ -1,4 +1,4 @@ -// types: web/efficient-script-yielding +// @types: web/efficient-script-yielding 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/packages/core-js/modules/web.structured-clone.js b/packages/core-js/modules/web.structured-clone.js index 06acce0dd7d1..cc1dc578821e 100644 --- a/packages/core-js/modules/web.structured-clone.js +++ b/packages/core-js/modules/web.structured-clone.js @@ -1,4 +1,4 @@ -// types: web/structured-clone +// @types: web/structured-clone 'use strict'; var IS_PURE = require('../internals/is-pure'); var $ = require('../internals/export'); diff --git a/packages/core-js/modules/web.url-search-params.constructor.js b/packages/core-js/modules/web.url-search-params.constructor.js index ac904e93d430..aa3ce401cf55 100644 --- a/packages/core-js/modules/web.url-search-params.constructor.js +++ b/packages/core-js/modules/web.url-search-params.constructor.js @@ -1,4 +1,4 @@ -// no types: because of a conflict with lib.dom.d.ts +// @no-types: because of a conflict with lib.dom.d.ts 'use strict'; var $ = require('../internals/export'); var safeGetBuiltIn = require('../internals/safe-get-built-in'); diff --git a/packages/core-js/modules/web.url-search-params.delete.js b/packages/core-js/modules/web.url-search-params.delete.js index 26d2b0ba2fc0..2b68bcebb2d5 100644 --- a/packages/core-js/modules/web.url-search-params.delete.js +++ b/packages/core-js/modules/web.url-search-params.delete.js @@ -1,4 +1,4 @@ -// no types: because of a conflict with lib.dom.d.ts +// @no-types: because of a conflict with lib.dom.d.ts 'use strict'; var defineBuiltIn = require('../internals/define-built-in'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/web.url-search-params.has.js b/packages/core-js/modules/web.url-search-params.has.js index 3fcadb2d9a6e..8cb81fe1a98b 100644 --- a/packages/core-js/modules/web.url-search-params.has.js +++ b/packages/core-js/modules/web.url-search-params.has.js @@ -1,4 +1,4 @@ -// no types: because of a conflict with lib.dom.d.ts +// @no-types: because of a conflict with lib.dom.d.ts 'use strict'; var defineBuiltIn = require('../internals/define-built-in'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/packages/core-js/modules/web.url-search-params.size.js b/packages/core-js/modules/web.url-search-params.size.js index 5ce3f7ae8993..c675109c64cd 100644 --- a/packages/core-js/modules/web.url-search-params.size.js +++ b/packages/core-js/modules/web.url-search-params.size.js @@ -1,4 +1,4 @@ -// no types: because of a conflict with lib.dom.d.ts +// @no-types: because of a conflict with lib.dom.d.ts 'use strict'; var uncurryThis = require('../internals/function-uncurry-this'); var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); diff --git a/packages/core-js/modules/web.url.can-parse.js b/packages/core-js/modules/web.url.can-parse.js index 0ea7235f71ea..6e396076ad92 100644 --- a/packages/core-js/modules/web.url.can-parse.js +++ b/packages/core-js/modules/web.url.can-parse.js @@ -1,4 +1,4 @@ -// no types: because of a conflict with lib.dom.d.ts +// @no-types: because of a conflict with lib.dom.d.ts 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/web.url.constructor.js b/packages/core-js/modules/web.url.constructor.js index 0021e54ee9a3..27d80bba514c 100644 --- a/packages/core-js/modules/web.url.constructor.js +++ b/packages/core-js/modules/web.url.constructor.js @@ -1,4 +1,4 @@ -// no types: because of a conflict with @types/node +// @no-types: because of a conflict with @types/node 'use strict'; var $ = require('../internals/export'); var USE_NATIVE_URL = require('../internals/url-constructor-detection'); diff --git a/packages/core-js/modules/web.url.parse.js b/packages/core-js/modules/web.url.parse.js index cfe56bbee6d6..25b3f5e1419c 100644 --- a/packages/core-js/modules/web.url.parse.js +++ b/packages/core-js/modules/web.url.parse.js @@ -1,4 +1,4 @@ -// no types: because of a conflict with lib.dom.d.ts +// @no-types: because of a conflict with lib.dom.d.ts 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/web.url.to-json.js b/packages/core-js/modules/web.url.to-json.js index 27c1b608f5bf..8a769188a61f 100644 --- a/packages/core-js/modules/web.url.to-json.js +++ b/packages/core-js/modules/web.url.to-json.js @@ -1,4 +1,4 @@ -// types: web/url-to-json +// @types: web/url-to-json 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); diff --git a/scripts/build-entries/get-dependencies.mjs b/scripts/build-entries/get-dependencies.mjs index 3459c7e391f5..c336fc4a906f 100644 --- a/scripts/build-entries/get-dependencies.mjs +++ b/scripts/build-entries/get-dependencies.mjs @@ -7,7 +7,7 @@ const allModulesSet = new Set(modules); const MODULE_PATH = /\/(?(?:internals|modules)\/[\d\-.a-z]+)$/; const DEPENDENCY_DIRECTIVE = /^ *\/\/ @dependency: (?(?:es|esnext|web)\.[\d\-.a-z]+)$/gm; -const TYPES_DIRECTIVE = /^ *\/\/ types: (?[\d\-./a-z]+)$/gm; +const TYPES_DIRECTIVE = /^ *\/\/ @types: (?[\d\-./a-z]+)$/gm; const cache = new Map(); diff --git a/tests/type-definitions/coverage.mjs b/tests/type-definitions/coverage.mjs index f14794133bce..7861b973d27e 100644 --- a/tests/type-definitions/coverage.mjs +++ b/tests/type-definitions/coverage.mjs @@ -8,7 +8,7 @@ const Modules = AllModules.filter(it => it.match(/^(?:esnext|web)\./)); for (const moduleName of Modules) { const modulePath = path.join(MODULES_PATH, `${ moduleName }.js`); const content = await readFile(modulePath, 'utf8'); - if (!/\/\/ (?:types:|no\stypes)/.test(content)) { + if (!/\/\/ (?:@types:|@no-types)/.test(content)) { echo(red('No types for module:'), path.resolve(modulePath)); } } From 3c82b624b28ac7673a38c564d2bf5aeabb5b1870 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 28 Jan 2026 00:59:55 +0700 Subject: [PATCH 160/315] Build pure types script refactoring --- scripts/build-types/pure.mjs | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/scripts/build-types/pure.mjs b/scripts/build-types/pure.mjs index 8becc7c4eac3..fa5bc920cf2b 100644 --- a/scripts/build-types/pure.mjs +++ b/scripts/build-types/pure.mjs @@ -1,28 +1,6 @@ const { outputFile, pathExists, readdir } = fs; -function extractDeclareGlobalSections(lines) { - const sections = []; - const outside = []; - - for (let i = 0; i < lines.length; i++) { - if (/^\s*declare\s+global\s*\{/.test(lines[i])) { - let depth = 1; - const section = []; - - for (++i; i < lines.length && depth > 0; ++i) { - depth += lines[i].match(/\{/g)?.length ?? 0; - depth -= lines[i].match(/\}/g)?.length ?? 0; - - if (depth === 0 && /^\s*\}\s*$/.test(lines[i])) break; - if (depth > 0) section.push(lines[i]); - } - sections.push(section); - } else { - outside.push(lines[i]); - } - } - return { sections, outside }; -} +const NAMESPACE = 'CoreJS'; function parseOptions(line) { const hasOptions = line.includes('@type-options'); @@ -157,9 +135,6 @@ function wrapInNamespace(content, namespace = 'CoreJS') { break; } - const bodyLines = lines.slice(i); - const { sections, outside } = extractDeclareGlobalSections(bodyLines); - const namespaceBody = [...processLines(outside, namespace), ...sections.flatMap(s => processLines(s, namespace))] .reduce((res, line) => { if (line?.trim() !== '' || (res.at(-1) && res.at(-1).trim() !== '')) res.push(line); @@ -168,7 +143,7 @@ function wrapInNamespace(content, namespace = 'CoreJS') { .map(line => line ? ` ${ line }` : '') .join('\n'); - return `${ headerLines.length ? `${ headerLines.join('\n') }\n` : '' }declare namespace ${ namespace } {\n${ namespaceBody }\n}\n`; + return `${ headerLines.length ? `${ headerLines.join('\n') }\n` : '' }declare namespace ${ NAMESPACE } {\n${ namespaceBody }\n}\n`; } export async function preparePureTypes(typesPath, initialPath) { From 3ba11d2c64c81444ae191bcd3a3ad97a89d1459a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 28 Jan 2026 01:00:31 +0700 Subject: [PATCH 161/315] Update Types title in CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6cc765d7be1e..44a473bd7b0b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,7 +65,7 @@ engine | how to run tests | base data inherits from | mandatory ch If you have no access to all required browsers / versions of browsers, use [Sauce Labs](https://saucelabs.com/), [BrowserStack](https://www.browserstack.com/) or [Cloud Browser](https://ieonchrome.com/). -## How to add new TypeScript definitions +## TypeScript type definitions - TypeScript definitions should be added to the [`packages/core-js-types/src/base`](./packages/core-js-types/src/base) directory. - Our type definitions are built on top of ES6. If any related type is missing in ES6, it must be added to the [`packages/core-js-types/src/base/core-js-types`](./packages/core-js-types/src/base/core-js-types) directory and imported via triple-slash directives in your type definition file. From e812c3d90063a7fd7dd6ed318aee353f29df963b Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 28 Jan 2026 01:25:57 +0700 Subject: [PATCH 162/315] Build pure types script refactoring --- scripts/build-types/pure.mjs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/build-types/pure.mjs b/scripts/build-types/pure.mjs index fa5bc920cf2b..05b3e751a2cd 100644 --- a/scripts/build-types/pure.mjs +++ b/scripts/build-types/pure.mjs @@ -103,7 +103,7 @@ function processLines(lines, prefix) { .filter(line => line !== null); } -function wrapInNamespace(content, namespace = 'CoreJS') { +function wrapInNamespace(content) { const lines = content.split('\n'); const headerLines = []; @@ -115,7 +115,7 @@ function wrapInNamespace(content, namespace = 'CoreJS') { // Update reference paths and add to header if (/\/\/\/\s* processLines(s, namespace))] + const namespaceBody = processLines(lines.slice(i), NAMESPACE) .reduce((res, line) => { - if (line?.trim() !== '' || (res.at(-1) && res.at(-1).trim() !== '')) res.push(line); + if (line.trim() || res.at(-1)?.trim()) res.push(line); return res; }, []) .map(line => line ? ` ${ line }` : '') @@ -154,14 +154,14 @@ export async function preparePureTypes(typesPath, initialPath) { if (entry.isDirectory()) { await preparePureTypes(path.join(typesPath, entry.name), initialPath); } else { - if (entry.name.includes('core-js-types.d.ts')) continue; + if (entry.name === 'core-js-types.d.ts') continue; const typePath = path.join(typesPath, entry.name); const resultFilePath = typePath.replace(initialPath, `${ initialPath }/pure/`); if (await pathExists(resultFilePath)) continue; - const content = await fs.readFile(typePath, 'utf8'); + const content = await fs.readFile(typePath, 'utf8'); // move to spread on top const result = content.includes('declare namespace') ? content : wrapInNamespace(content); From 164309a7775bcdb00317809e19edbfadeaa9c766 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 29 Jan 2026 04:46:30 +0700 Subject: [PATCH 163/315] Iterator & AsyncIterator types refactoring --- .../src/base/core-js-types/core-js-types.d.ts | 2 +- .../src/base/proposals/array-from-async.d.ts | 2 + .../proposals/async-iterator-helpers.d.ts | 2 + .../src/base/proposals/iterator-helpers.d.ts | 18 ++++----- .../ts5-2/core-js-types/core-js-types.d.ts | 40 ------------------- .../src/ts5-2/proposals/iterator-helpers.d.ts | 18 ++++----- 6 files changed, 23 insertions(+), 59 deletions(-) delete mode 100644 packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts diff --git a/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts index 3e2a3975c411..03c4cc2c2fa0 100644 --- a/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts +++ b/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts @@ -29,4 +29,4 @@ declare global { } } -export type CoreJSIteratorObject = IteratorObject; +export {}; diff --git a/packages/core-js-types/src/base/proposals/array-from-async.d.ts b/packages/core-js-types/src/base/proposals/array-from-async.d.ts index 206773a4c672..7b8c0d1b99b9 100644 --- a/packages/core-js-types/src/base/proposals/array-from-async.d.ts +++ b/packages/core-js-types/src/base/proposals/array-from-async.d.ts @@ -1,3 +1,5 @@ +/// + // https://github.com/tc39/proposal-array-from-async // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index ae81238635fc..3a07db4a77cd 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -1,3 +1,5 @@ +/// + // https://github.com/tc39/proposal-async-iterator-helpers interface AsyncIteratorConstructor { diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts index d62c2b3e4bf6..9c6458fa0f82 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts @@ -1,47 +1,47 @@ +/// + // https://github.com/tc39/proposal-iterator-helpers // For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; - declare global { interface Iterator { /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator. * @param callbackfn - A function that accepts up to two arguments to be used to transform values from the underlying iterator. */ - map(callbackfn: (value: T, index: number) => U): CoreJSIteratorObject; + map(callbackfn: (value: T, index: number) => U): IteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. */ - filter(predicate: (value: T, index: number) => value is S): CoreJSIteratorObject; + filter(predicate: (value: T, index: number) => value is S): IteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. */ - filter(predicate: (value: T, index: number) => unknown): CoreJSIteratorObject; + filter(predicate: (value: T, index: number) => unknown): IteratorObject; /** * Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached. * @param limit - The maximum number of values to yield. */ - take(limit: number): CoreJSIteratorObject; + take(limit: number): IteratorObject; /** * Creates an iterator whose values are the values from this iterator after skipping the provided count. * @param count - The number of values to drop. */ - drop(count: number): CoreJSIteratorObject; + drop(count: number): IteratorObject; /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. * @param callback - A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. */ - flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; // ts < 5.6 Iterable + flatMap(callback: (value: T, index: number) => Iterator | Iterable): IteratorObject; // ts < 5.6 Iterable /** * Calls the specified callback function for all the elements in this iterator. 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. @@ -105,7 +105,7 @@ declare global { * Returns its input if the input already inherits from the built-in Iterator class. * @param value - An iterator or iterable object to convert a native iterator. */ - from(value: Iterator | Iterable): CoreJSIteratorObject; + from(value: Iterator | Iterable): IteratorObject; } var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts deleted file mode 100644 index 8dbb224d9084..000000000000 --- a/packages/core-js-types/src/ts5-2/core-js-types/core-js-types.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2019.array.d.ts -// https://github.com/microsoft/TypeScript/blob/6f4fb0145845db22791188c4d38e3a1a0edfd449/src/lib/es2018.asyncgenerator.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare global { - interface IteratorObject extends Iterator {} - - interface AsyncIteratorObject extends AsyncIterator { - [Symbol.asyncIterator](): AsyncIteratorObject; - } - - interface AsyncIterableIterator extends AsyncIterator { - [Symbol.asyncIterator](): AsyncIterableIterator; - } - - interface AsyncGenerator extends AsyncIteratorObject { - next(...[value]: [] | [undefined]): Promise>; - return(value: TReturn | PromiseLike): Promise>; - throw(e: any): Promise>; - [Symbol.asyncIterator](): AsyncGenerator; - } - - interface AsyncIterator { - // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. - next(...[value]: [] | [TNext]): Promise>; - return?(value?: TReturn | PromiseLike): Promise>; - throw?(e?: any): Promise>; - } - - interface AsyncIteratorConstructor {} - - var AsyncIterator: AsyncIteratorConstructor; - - interface AsyncIterable { - [Symbol.asyncIterator](): AsyncIterator; - } -} - -export type CoreJSIteratorObject = IteratorObject; diff --git a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts index b182e53c03a6..ff4fcebec530 100644 --- a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts @@ -1,3 +1,5 @@ +/// + // Motivation: Iterable until TS 5.6 used only one type parameter // https://github.com/tc39/proposal-iterator-helpers @@ -6,44 +8,42 @@ // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -import { CoreJSIteratorObject } from '../core-js-types/core-js-types'; - declare global { interface Iterator { /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator. * @param callbackfn - A function that accepts up to two arguments to be used to transform values from the underlying iterator. */ - map(callbackfn: (value: T, index: number) => U): CoreJSIteratorObject; + map(callbackfn: (value: T, index: number) => U): CoreJS.CoreJSIteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. */ - filter(predicate: (value: T, index: number) => value is S): CoreJSIteratorObject; + filter(predicate: (value: T, index: number) => value is S): CoreJS.CoreJSIteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. */ - filter(predicate: (value: T, index: number) => unknown): CoreJSIteratorObject; + filter(predicate: (value: T, index: number) => unknown): CoreJS.CoreJSIteratorObject; /** * Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached. * @param limit - The maximum number of values to yield. */ - take(limit: number): CoreJSIteratorObject; + take(limit: number): CoreJS.CoreJSIteratorObject; /** * Creates an iterator whose values are the values from this iterator after skipping the provided count. * @param count - The number of values to drop. */ - drop(count: number): CoreJSIteratorObject; + drop(count: number): CoreJS.CoreJSIteratorObject; /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. * @param callback - A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. */ - flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; + flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJS.CoreJSIteratorObject; /** * Calls the specified callback function for all the elements in this iterator. 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. @@ -107,7 +107,7 @@ declare global { * Returns its input if the input already inherits from the built-in Iterator class. * @param value - An iterator or iterable object to convert a native iterator. */ - from(value: Iterator | Iterable): CoreJSIteratorObject; + from(value: Iterator | Iterable): CoreJS.CoreJSIteratorObject; } var Iterator: IteratorConstructor; From 2cb3b51769615e3de46823268f5fcefc8b57ae2d Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 29 Jan 2026 04:46:55 +0700 Subject: [PATCH 164/315] Build pure types script refactoring --- scripts/build-types/pure.mjs | 54 +++++++++++++++--------------------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/scripts/build-types/pure.mjs b/scripts/build-types/pure.mjs index 05b3e751a2cd..12161868f384 100644 --- a/scripts/build-types/pure.mjs +++ b/scripts/build-types/pure.mjs @@ -1,4 +1,4 @@ -const { outputFile, pathExists, readdir } = fs; +const { outputFile, pathExists, readdir, readFile } = fs; const NAMESPACE = 'CoreJS'; @@ -16,37 +16,37 @@ function parseOptions(line) { }; } -function processLines(lines, prefix) { +function processLines(lines) { const prefixed = []; let noExport = false; return lines - .map(line => { + .flatMap(line => { const options = parseOptions(line); if (noExport && /^[^{]*\}/.test(line)) { noExport = false; - return null; + return []; } - if (noExport) return null; + if (noExport) return []; if (options.noExport) { - if (/^[^{]*$/.test(line) || /\{[^}]?\}/.test(line)) return null; + if (/^[^{]*$/.test(line) || /\{[^}]?\}/.test(line)) return []; noExport = true; - return null; + return []; } - if (line.includes('export {')) return null; + if (line.includes('export {')) return []; // Process interfaces that either don’t need to extend other interfaces or have already been extended if (/^\s*(?:declare\s+)?interface\s+\w+\s*extends/.test(line) || options.noExtends && /^\s*(?:declare\s+)?interface\s+\w+(?:<[^>]+>)?\s*\{/.test(line)) { if (!options.noPrefix) { const m = line.match(/interface\s+(?\w+)/); - if (m && m.groups) { + if (m?.groups) { prefixed.push(m.groups.name); } } return line.replace(/^(?\s*)(?:declare\s+)?interface\s+(?[\s\w,<=>]+)/, - `$export interface ${ !options.noPrefix ? prefix : '' }$`); + `$export interface ${ !options.noPrefix ? NAMESPACE : '' }$`); } // Process interfaces: prefix name, emit backing var (constructor) and make it extend original @@ -59,7 +59,7 @@ function processLines(lines, prefix) { prefixed.push(iName); } const genericsForExtends = iExtend.replace(/\sextends\s[^,>]+/g, '').replace(/\s?=\s?\w+/g, ''); - const entityName = `${ !options.noPrefix ? prefix : '' }${ iName }`; + const entityName = `${ !options.noPrefix ? NAMESPACE : '' }${ iName }`; const isConstructor = iName.includes('Constructor'); let constructorDeclaration; if (isConstructor) { @@ -76,31 +76,30 @@ function processLines(lines, prefix) { // Process function if (/^\s*(?:declare\s+)?function/.test(line)) { return line.replace(/^(?\s*)(?:declare\s+)?function\s+(?\w+)/, - `$export function ${ !options.noPrefix ? prefix : '' }$`); + `$export function ${ !options.noPrefix ? NAMESPACE : '' }$`); } if (options.prefixReturnType) { return line.replace(/^(?.*):\s(?[a-z_]\w*)(?<[^;]+);/i, - `$: ${ prefix }.${ prefix }$$;`); + `$: ${ NAMESPACE }.${ NAMESPACE }$$;`); } // Replace prefixed types in the entire file if (/(?::|\|)\s*\w/.test(line)) { - const sortedPrefixed = prefixed.sort((a, b) => b.length - a.length); - sortedPrefixed.forEach(item => { + prefixed.sort((a, b) => b.length - a.length); + prefixed.forEach(item => { const reg = new RegExp(`(?:||) ${ item }(?[,;<)])`, 'g'); - line = line.replace(reg, `$ ${ prefix }${ item }$`); + line = line.replace(reg, `$ ${ NAMESPACE }${ item }$`); }); } // Handle vars: prefix variable name, keep original type if (/^\s*(?:declare)?\svar/.test(line)) { const m = line.match(/^(?\s*)(?:declare\s+)?var\s+(?\w+):\s+(?\w+)/); - return `${ m?.groups?.indent ?? '' }var ${ !options.noPrefix ? prefix : '' }${ m?.groups?.name ?? '' }: ${ m?.groups?.type };\n`; + return `${ m?.groups?.indent ?? '' }var ${ !options.noPrefix ? NAMESPACE : '' }${ m?.groups?.name ?? '' }: ${ m?.groups?.type };\n`; } return line; - }) - .filter(line => line !== null); + }); } function wrapInNamespace(content) { @@ -120,22 +119,15 @@ function wrapInNamespace(content) { continue; } - // Update import paths and add to header - if (/^\s*import /.test(line)) { - headerLines.push(line.replace(/^\s*import\s.*from\s+["'].+["']/, - (_, start, importPath, end) => `${ start }../${ importPath }${ end }`)); - continue; - } - // Comments & new lines add to header as is - if (/^\s*\/\//.test(line) || /^\s*$/.test(line)) { + if (/^\s*(?:\/\/|$)/.test(line)) { headerLines.push(line); continue; } break; } - const namespaceBody = processLines(lines.slice(i), NAMESPACE) + const namespaceBody = processLines(lines.slice(i)) .reduce((res, line) => { if (line.trim() || res.at(-1)?.trim()) res.push(line); return res; @@ -149,19 +141,17 @@ function wrapInNamespace(content) { export async function preparePureTypes(typesPath, initialPath) { const entries = await readdir(typesPath, { withFileTypes: true }); for (const entry of entries) { - if (entry.name === 'pure') continue; + if (['pure', 'core-js-types.d.ts'].includes(entry.name)) continue; if (entry.isDirectory()) { await preparePureTypes(path.join(typesPath, entry.name), initialPath); } else { - if (entry.name === 'core-js-types.d.ts') continue; - const typePath = path.join(typesPath, entry.name); const resultFilePath = typePath.replace(initialPath, `${ initialPath }/pure/`); if (await pathExists(resultFilePath)) continue; - const content = await fs.readFile(typePath, 'utf8'); // move to spread on top + const content = await readFile(typePath, 'utf8'); const result = content.includes('declare namespace') ? content : wrapInNamespace(content); From 80f93c348e12e003bcf20631973cf1053e7649f8 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 30 Jan 2026 17:59:58 +0700 Subject: [PATCH 165/315] Disable types for TS 5.5- --- scripts/build-types/index.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-types/index.mjs b/scripts/build-types/index.mjs index 95b481dd0b4b..c117c13e696c 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-types/index.mjs @@ -15,7 +15,7 @@ const PACKAGE_NAME_PURE = '@core-js/pure/'; const PACKAGE_TEMPLATE = 'packages/core-js-types/package.tpl.json'; const SRC_DIR = 'packages/core-js-types/src/'; const SRC_BASE = 'base'; -const TS_VERSION_BREAKPOINTS = [5.2, 5.6]; +const TS_VERSION_BREAKPOINTS = [5.6]; const TYPE_PREFIX = 'CoreJS.CoreJS'; const imports = { From 52bc70267d48718a098031d7709e408093c99cc3 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 31 Jan 2026 01:36:45 +0700 Subject: [PATCH 166/315] Build entries and types scripts refactoring --- CONTRIBUTING.md | 2 +- package.json | 4 ++-- .../build-entries.mjs} | 0 .../build-types-pure.mjs} | 0 .../build-types.mjs} | 10 +++++----- .../entries-definitions.mjs | 0 .../get-dependencies.mjs | 0 .../helpers.mjs | 0 .../package-lock.json | 4 ++-- .../package.json | 2 +- .../templates.mjs | 0 scripts/build-types/package-lock.json | 10 ---------- scripts/build-types/package.json | 3 --- .../debug-get-dependencies/debug-get-dependencies.mjs | 2 +- tests/templates/templates.mjs | 2 +- 15 files changed, 13 insertions(+), 26 deletions(-) rename scripts/{build-entries/index.mjs => build-entries-and-types/build-entries.mjs} (100%) rename scripts/{build-types/pure.mjs => build-entries-and-types/build-types-pure.mjs} (100%) rename scripts/{build-types/index.mjs => build-entries-and-types/build-types.mjs} (96%) rename scripts/{build-entries => build-entries-and-types}/entries-definitions.mjs (100%) rename scripts/{build-entries => build-entries-and-types}/get-dependencies.mjs (100%) rename scripts/{build-entries => build-entries-and-types}/helpers.mjs (100%) rename scripts/{build-entries => build-entries-and-types}/package-lock.json (87%) rename scripts/{build-entries => build-entries-and-types}/package.json (54%) rename scripts/{build-entries => build-entries-and-types}/templates.mjs (100%) delete mode 100644 scripts/build-types/package-lock.json delete mode 100644 scripts/build-types/package.json diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 44a473bd7b0b..a3871b29948a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ There is always some ["help wanted" issues](https://github.com/zloirock/core-js/ - For export the polyfill, in all common cases use [`internals/export`](./packages/core-js/modules/export.js) helper. Use something else only if this helper is not applicable - for example, if you want to polyfill accessors. - If the code of the pure version implementation should significantly differ from the global version (*that's not a frequent situation, in most cases [`internals/is-pure`](./packages/core-js/modules/is-pure.js) constant is enough*), you can add it to [`packages/core-js-pure/override`](./packages/core-js-pure/override) directory. The rest parts of `@core-js/pure` will be copied from `core-js` package. - Add the feature detection of the polyfill to [`tests/compat/tests.js`](./tests/compat/tests.js), add the compatibility data to [`packages/core-js-compat/src/data.mjs`](./packages/core-js-compat/src/data.mjs), how to do it [see below](#how-to-update-core-js-compat-data). -- Add it to entries definitions, see [`scripts/build-entries/entries-definitions.mjs`](./scripts/build-entries/entries-definitions.mjs). +- Add it to entries definitions, see [`scripts/build-entries-and-types/entries-definitions.mjs`](scripts/build-entries-and-types/entries-definitions.mjs). - Add unit tests to [`tests/unit-global`](./tests/unit-global) and [`tests/unit-pure`](./tests/unit-pure). - Add tests of entry points to [`tests/entries/unit.mjs`](./tests/entries/unit.mjs). - Make sure that you are following [our coding style](#style-and-standards) and [all tests](#testing) are passed. diff --git a/package.json b/package.json index de87aab9b70d..9d74512068ae 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,9 @@ "zxi": "zx scripts/zxi.mjs", "prepare": "npm run zxi scripts/prepare.mjs", "prepare-monorepo": "node scripts/prepare-monorepo.mjs", - "build-entries": "npm run zxi time scripts/build-entries/index.mjs", + "build-entries": "npm run zxi time scripts/build-entries-and-types/build-entries.mjs", "build-compat": "npm run zxi scripts/build-compat/index.mjs", - "build-types": "npm run zxi time scripts/build-types/index.mjs", + "build-types": "npm run zxi time scripts/build-entries-and-types/build-types.mjs", "build-website": "npm run zxi time website/index.mjs", "build-website-local": "npm run zxi time website/build-local.mjs", "bundle": "run-s bundle-package bundle-tests", diff --git a/scripts/build-entries/index.mjs b/scripts/build-entries-and-types/build-entries.mjs similarity index 100% rename from scripts/build-entries/index.mjs rename to scripts/build-entries-and-types/build-entries.mjs diff --git a/scripts/build-types/pure.mjs b/scripts/build-entries-and-types/build-types-pure.mjs similarity index 100% rename from scripts/build-types/pure.mjs rename to scripts/build-entries-and-types/build-types-pure.mjs diff --git a/scripts/build-types/index.mjs b/scripts/build-entries-and-types/build-types.mjs similarity index 96% rename from scripts/build-types/index.mjs rename to scripts/build-entries-and-types/build-types.mjs index c117c13e696c..2c8913934df5 100644 --- a/scripts/build-types/index.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -1,9 +1,9 @@ -import { features, proposals } from '../build-entries/entries-definitions.mjs'; -import { $path, $proposal } from '../build-entries/templates.mjs'; +import { features, proposals } from './entries-definitions.mjs'; +import { $path, $proposal } from './templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; -import { getModulesMetadata } from '../build-entries/get-dependencies.mjs'; -import { expandModules, modulesToStage } from '../build-entries/helpers.mjs'; -import { preparePureTypes } from './pure.mjs'; +import { getModulesMetadata } from './get-dependencies.mjs'; +import { expandModules, modulesToStage } from './helpers.mjs'; +import { preparePureTypes } from './build-types-pure.mjs'; const { copy, outputFile, pathExists, readdir, readFile, readJson, remove, writeJson } = fs; const { green } = chalk; diff --git a/scripts/build-entries/entries-definitions.mjs b/scripts/build-entries-and-types/entries-definitions.mjs similarity index 100% rename from scripts/build-entries/entries-definitions.mjs rename to scripts/build-entries-and-types/entries-definitions.mjs diff --git a/scripts/build-entries/get-dependencies.mjs b/scripts/build-entries-and-types/get-dependencies.mjs similarity index 100% rename from scripts/build-entries/get-dependencies.mjs rename to scripts/build-entries-and-types/get-dependencies.mjs diff --git a/scripts/build-entries/helpers.mjs b/scripts/build-entries-and-types/helpers.mjs similarity index 100% rename from scripts/build-entries/helpers.mjs rename to scripts/build-entries-and-types/helpers.mjs diff --git a/scripts/build-entries/package-lock.json b/scripts/build-entries-and-types/package-lock.json similarity index 87% rename from scripts/build-entries/package-lock.json rename to scripts/build-entries-and-types/package-lock.json index 91087c985c8a..7cfa1505454c 100644 --- a/scripts/build-entries/package-lock.json +++ b/scripts/build-entries-and-types/package-lock.json @@ -1,10 +1,10 @@ { - "name": "scripts/build-entries", + "name": "scripts/build-entries-and-types", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "scripts/build-entries", + "name": "scripts/build-entries-and-types", "devDependencies": { "dedent": "^1.7.1" } diff --git a/scripts/build-entries/package.json b/scripts/build-entries-and-types/package.json similarity index 54% rename from scripts/build-entries/package.json rename to scripts/build-entries-and-types/package.json index 41aedd403575..6bea28f423c2 100644 --- a/scripts/build-entries/package.json +++ b/scripts/build-entries-and-types/package.json @@ -1,5 +1,5 @@ { - "name": "scripts/build-entries", + "name": "scripts/build-entries-and-types", "devDependencies": { "dedent": "^1.7.1" } diff --git a/scripts/build-entries/templates.mjs b/scripts/build-entries-and-types/templates.mjs similarity index 100% rename from scripts/build-entries/templates.mjs rename to scripts/build-entries-and-types/templates.mjs diff --git a/scripts/build-types/package-lock.json b/scripts/build-types/package-lock.json deleted file mode 100644 index 24bea456d15f..000000000000 --- a/scripts/build-types/package-lock.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "scripts/build-types", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "scripts/build-types" - } - } -} diff --git a/scripts/build-types/package.json b/scripts/build-types/package.json deleted file mode 100644 index 6e42c9e1600e..000000000000 --- a/scripts/build-types/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "scripts/build-types" -} diff --git a/tests/debug-get-dependencies/debug-get-dependencies.mjs b/tests/debug-get-dependencies/debug-get-dependencies.mjs index 4c049aca0a1a..c278eba21150 100644 --- a/tests/debug-get-dependencies/debug-get-dependencies.mjs +++ b/tests/debug-get-dependencies/debug-get-dependencies.mjs @@ -1,4 +1,4 @@ import { modules } from '@core-js/compat/src/data.mjs'; -import { getModulesMetadata } from '../../scripts/build-entries/get-dependencies.mjs'; +import { getModulesMetadata } from '../../scripts/build-entries-and-types/get-dependencies.mjs'; for (const module of modules) console.log(module, await getModulesMetadata([module])); diff --git a/tests/templates/templates.mjs b/tests/templates/templates.mjs index fba935c8e2df..48c6a56a490a 100644 --- a/tests/templates/templates.mjs +++ b/tests/templates/templates.mjs @@ -4,7 +4,7 @@ import { $uncurriedIterator, $static, $staticWithContext, $prototype, $prototypeIterator, -} from '../../scripts/build-entries/templates.mjs'; +} from '../../scripts/build-entries-and-types/templates.mjs'; import { deepEqual } from 'node:assert/strict'; const props = { From 530974a35bef4a6885b71dfcccd9998239da51ba Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 31 Jan 2026 02:12:19 +0700 Subject: [PATCH 167/315] Remove redundant entries definition & type dependencies --- packages/core-js/modules/es.iterator.constructor.js | 2 -- scripts/build-entries-and-types/entries-definitions.mjs | 4 ---- scripts/build-entries-and-types/templates.mjs | 4 ++-- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/core-js/modules/es.iterator.constructor.js b/packages/core-js/modules/es.iterator.constructor.js index 9728a3e516ae..4478b408b7b6 100644 --- a/packages/core-js/modules/es.iterator.constructor.js +++ b/packages/core-js/modules/es.iterator.constructor.js @@ -1,6 +1,4 @@ // @types: proposals/iterator-helpers -// @types: proposals/iterator-sequencing -// @types: proposals/explicit-resource-management 'use strict'; var $ = require('../internals/export'); var globalThis = require('../internals/global-this'); diff --git a/scripts/build-entries-and-types/entries-definitions.mjs b/scripts/build-entries-and-types/entries-definitions.mjs index b39c9c6e29a0..4a7b657e3d43 100644 --- a/scripts/build-entries-and-types/entries-definitions.mjs +++ b/scripts/build-entries-and-types/entries-definitions.mjs @@ -377,13 +377,11 @@ export const features = { 'array/iterator': { modules: ['es.array.iterator'], template: $uncurriedIterator, - source: '[]', namespace: 'Array', }, 'array/prototype/iterator': { modules: ['es.array.iterator'], template: $prototypeIterator, - source: '[]', namespace: 'Array', }, 'array/join': { @@ -2462,13 +2460,11 @@ export const features = { 'string/iterator': { modules: ['es.string.iterator'], template: $uncurriedIterator, - source: "''", namespace: 'String', }, 'string/prototype/iterator': { modules: ['es.string.iterator'], template: $prototypeIterator, - source: "''", namespace: 'String', }, 'string/link': { diff --git a/scripts/build-entries-and-types/templates.mjs b/scripts/build-entries-and-types/templates.mjs index db3dd23ad83f..2ff94b1945e5 100644 --- a/scripts/build-entries-and-types/templates.mjs +++ b/scripts/build-entries-and-types/templates.mjs @@ -112,7 +112,7 @@ export const $prototypeIterator = p => ({ var getIteratorMethod = ${ importInternal('get-iterator-method', p.level) } - module.exports = getIteratorMethod(${ p.source }); + module.exports = getIteratorMethod(${ p.namespace }()); `, types: dedent` declare module '${ buildModulePath(p) }' { @@ -162,7 +162,7 @@ export const $uncurriedIterator = p => ({ var uncurryThis = ${ importInternal('function-uncurry-this', p.level) } var getIteratorMethod = ${ importInternal('get-iterator-method', p.level) } - module.exports = uncurryThis(getIteratorMethod(${ p.source })); + module.exports = uncurryThis(getIteratorMethod(${ p.namespace }())); `, types: dedent` declare module '${ buildModulePath(p) }' { From 0f8665b156635f949de9373a4f2e0fbad5811f6a Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sat, 31 Jan 2026 15:58:44 +0200 Subject: [PATCH 168/315] `.sort` -> `.toSorted` --- scripts/build-entries-and-types/build-types-pure.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/build-entries-and-types/build-types-pure.mjs b/scripts/build-entries-and-types/build-types-pure.mjs index 12161868f384..79f697c86734 100644 --- a/scripts/build-entries-and-types/build-types-pure.mjs +++ b/scripts/build-entries-and-types/build-types-pure.mjs @@ -86,8 +86,7 @@ function processLines(lines) { // Replace prefixed types in the entire file if (/(?::|\|)\s*\w/.test(line)) { - prefixed.sort((a, b) => b.length - a.length); - prefixed.forEach(item => { + prefixed.toSorted((a, b) => b.length - a.length).forEach(item => { const reg = new RegExp(`(?:||) ${ item }(?[,;<)])`, 'g'); line = line.replace(reg, `$ ${ NAMESPACE }${ item }$`); }); From 1c4d4652f764997ef19ec173dade4a5a6b038a75 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sat, 31 Jan 2026 20:12:10 +0200 Subject: [PATCH 169/315] add `WeakSet` to `getGenericsForNamespace` for consistency with `WeakMap` --- scripts/build-entries-and-types/templates.mjs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/build-entries-and-types/templates.mjs b/scripts/build-entries-and-types/templates.mjs index 2ff94b1945e5..5f13c5ca5e53 100644 --- a/scripts/build-entries-and-types/templates.mjs +++ b/scripts/build-entries-and-types/templates.mjs @@ -46,6 +46,9 @@ function getGenericsForNamespace(namespace) { if (namespace === 'WeakMap') { return ''; } + if (namespace === 'WeakSet') { + return ''; + } if (namespacesWithTwoGeneric.includes(namespace)) { return ''; } From d50f6476f5a95014c004b261901aa637617c05e0 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 2 Feb 2026 21:35:01 +0700 Subject: [PATCH 170/315] URL types refactoring --- packages/core-js-types/src/base/pure/web/url-parse.d.ts | 5 ----- packages/core-js-types/src/base/web/url-parse.d.ts | 2 -- packages/core-js-types/src/base/web/url-to-json.d.ts | 2 -- packages/core-js/modules/web.url.can-parse.js | 2 +- packages/core-js/modules/web.url.constructor.js | 2 +- packages/core-js/modules/web.url.parse.js | 2 +- packages/core-js/modules/web.url.to-json.js | 2 +- 7 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 packages/core-js-types/src/base/pure/web/url-parse.d.ts delete mode 100644 packages/core-js-types/src/base/web/url-parse.d.ts delete mode 100644 packages/core-js-types/src/base/web/url-to-json.d.ts diff --git a/packages/core-js-types/src/base/pure/web/url-parse.d.ts b/packages/core-js-types/src/base/pure/web/url-parse.d.ts deleted file mode 100644 index 52c2a94052c3..000000000000 --- a/packages/core-js-types/src/base/pure/web/url-parse.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// - -declare namespace CoreJS { - export type URLParse = (url: string | CoreJSURL, base?: string | CoreJSURL) => CoreJSURL | null; -} diff --git a/packages/core-js-types/src/base/web/url-parse.d.ts b/packages/core-js-types/src/base/web/url-parse.d.ts deleted file mode 100644 index 2ec27ec39d3c..000000000000 --- a/packages/core-js-types/src/base/web/url-parse.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -// empty -// Moved to ../core-js-modules/url.d.ts diff --git a/packages/core-js-types/src/base/web/url-to-json.d.ts b/packages/core-js-types/src/base/web/url-to-json.d.ts deleted file mode 100644 index 2ec27ec39d3c..000000000000 --- a/packages/core-js-types/src/base/web/url-to-json.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -// empty -// Moved to ../core-js-modules/url.d.ts diff --git a/packages/core-js/modules/web.url.can-parse.js b/packages/core-js/modules/web.url.can-parse.js index 6e396076ad92..ac25797b3bad 100644 --- a/packages/core-js/modules/web.url.can-parse.js +++ b/packages/core-js/modules/web.url.can-parse.js @@ -1,4 +1,4 @@ -// @no-types: because of a conflict with lib.dom.d.ts +// @types: web/url 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/web.url.constructor.js b/packages/core-js/modules/web.url.constructor.js index 27d80bba514c..ca3402ec528a 100644 --- a/packages/core-js/modules/web.url.constructor.js +++ b/packages/core-js/modules/web.url.constructor.js @@ -1,4 +1,4 @@ -// @no-types: because of a conflict with @types/node +// @types: web/url 'use strict'; var $ = require('../internals/export'); var USE_NATIVE_URL = require('../internals/url-constructor-detection'); diff --git a/packages/core-js/modules/web.url.parse.js b/packages/core-js/modules/web.url.parse.js index 25b3f5e1419c..63509951beab 100644 --- a/packages/core-js/modules/web.url.parse.js +++ b/packages/core-js/modules/web.url.parse.js @@ -1,4 +1,4 @@ -// @no-types: because of a conflict with lib.dom.d.ts +// @types: web/url 'use strict'; var $ = require('../internals/export'); var getBuiltIn = require('../internals/get-built-in'); diff --git a/packages/core-js/modules/web.url.to-json.js b/packages/core-js/modules/web.url.to-json.js index 8a769188a61f..5ab149725431 100644 --- a/packages/core-js/modules/web.url.to-json.js +++ b/packages/core-js/modules/web.url.to-json.js @@ -1,4 +1,4 @@ -// @types: web/url-to-json +// @types: web/url 'use strict'; var $ = require('../internals/export'); var uncurryThis = require('../internals/function-uncurry-this'); From a1a6448c56baa6a6c8f7162c4045011b5349486a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 2 Feb 2026 23:49:08 +0700 Subject: [PATCH 171/315] Add recursive type collection --- scripts/build-entries-and-types/get-dependencies.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build-entries-and-types/get-dependencies.mjs b/scripts/build-entries-and-types/get-dependencies.mjs index c336fc4a906f..f330774a259b 100644 --- a/scripts/build-entries-and-types/get-dependencies.mjs +++ b/scripts/build-entries-and-types/get-dependencies.mjs @@ -45,6 +45,7 @@ async function getModuleMetadata(path, stack = new Set()) { for (const dependency of dependencies) { const moduleMetadata = await getModuleMetadata(dependency, new Set(stack)); moduleMetadata.dependencies.forEach(it => paths.add(it)); + moduleMetadata.types.forEach(it => types.add(it)); } const result = { dependencies: paths, From 6808ab737f9dd1f006c967a038d3a4c27e2b478e Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 3 Feb 2026 01:45:49 +0700 Subject: [PATCH 172/315] Type dummy --- scripts/build-entries-and-types/build-types.mjs | 7 ++++++- scripts/build-entries-and-types/templates.mjs | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/build-entries-and-types/build-types.mjs b/scripts/build-entries-and-types/build-types.mjs index 2c8913934df5..923b4fbf8d62 100644 --- a/scripts/build-entries-and-types/build-types.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -1,5 +1,5 @@ import { features, proposals } from './entries-definitions.mjs'; -import { $path, $proposal } from './templates.mjs'; +import { $path, $proposal, $typeDummy } from './templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; import { getModulesMetadata } from './get-dependencies.mjs'; import { expandModules, modulesToStage } from './helpers.mjs'; @@ -48,6 +48,8 @@ async function buildType(entry, options) { let { entryFromNamespace, subset = entryFromNamespace ?? 'full', + typeDummy, + isTypeDummy = typeDummy ?? false, globalType, exportGlobalType = globalType ?? true, template, templateStable, templateActual, templateFull, filter, modules, enforceEntryCreation, @@ -71,6 +73,9 @@ async function buildType(entry, options) { break; } + if (isTypeDummy) { + template = $typeDummy; + } const level = entry.split('/').length - 1; if (!types) { diff --git a/scripts/build-entries-and-types/templates.mjs b/scripts/build-entries-and-types/templates.mjs index 5f13c5ca5e53..37d2e137fd40 100644 --- a/scripts/build-entries-and-types/templates.mjs +++ b/scripts/build-entries-and-types/templates.mjs @@ -482,3 +482,13 @@ export const $proposal = p => ({ `, types: '', }); + +export const $typeDummy = p => ({ + entry: '', + types: dedent` + declare module '${ buildModulePath(p) }' { + const method: any; + export = method; + } + `, +}); From 6b06f4dc92551dc40e977a901c327be1d77dc995 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 3 Feb 2026 16:46:35 +0700 Subject: [PATCH 173/315] Fix options decomposition --- scripts/build-entries-and-types/build-types.mjs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/build-entries-and-types/build-types.mjs b/scripts/build-entries-and-types/build-types.mjs index 923b4fbf8d62..3eed163c04bd 100644 --- a/scripts/build-entries-and-types/build-types.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -48,10 +48,8 @@ async function buildType(entry, options) { let { entryFromNamespace, subset = entryFromNamespace ?? 'full', - typeDummy, - isTypeDummy = typeDummy ?? false, - globalType, - exportGlobalType = globalType ?? true, + typeDummy = false, + globalType = true, template, templateStable, templateActual, templateFull, filter, modules, enforceEntryCreation, customType, tsVersion, proposal, types, ownEntryPoint, } = options; @@ -73,7 +71,7 @@ async function buildType(entry, options) { break; } - if (isTypeDummy) { + if (typeDummy) { template = $typeDummy; } const level = entry.split('/').length - 1; @@ -88,7 +86,7 @@ async function buildType(entry, options) { } types.forEach(type => { - if (exportGlobalType) { + if (globalType) { imports.index.add(type); imports[subset].add(type); } @@ -96,7 +94,7 @@ async function buildType(entry, options) { }); if (customType) { - if (exportGlobalType) { + if (globalType) { imports.index.add(customType); imports[subset].add(customType); } From 3a510f204a5c7ceee433d16a9801c9cdce946cb3 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Tue, 3 Feb 2026 16:06:02 +0200 Subject: [PATCH 174/315] declare some types dependencies --- packages/core-js/modules/es.aggregate-error.cause.js | 1 + packages/core-js/modules/es.aggregate-error.constructor.js | 1 + packages/core-js/modules/es.array-buffer.detached.js | 1 + 3 files changed, 3 insertions(+) diff --git a/packages/core-js/modules/es.aggregate-error.cause.js b/packages/core-js/modules/es.aggregate-error.cause.js index c6d32919a052..dd9d892a01c2 100644 --- a/packages/core-js/modules/es.aggregate-error.cause.js +++ b/packages/core-js/modules/es.aggregate-error.cause.js @@ -1,3 +1,4 @@ +// @types: proposals/promise-any // @types: proposals/error-cause 'use strict'; var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.aggregate-error.constructor.js b/packages/core-js/modules/es.aggregate-error.constructor.js index a9fc392f2b96..4d3ae77624f7 100644 --- a/packages/core-js/modules/es.aggregate-error.constructor.js +++ b/packages/core-js/modules/es.aggregate-error.constructor.js @@ -1,3 +1,4 @@ +// @types: proposals/promise-any // @types: proposals/error-cause 'use strict'; var $ = require('../internals/export'); diff --git a/packages/core-js/modules/es.array-buffer.detached.js b/packages/core-js/modules/es.array-buffer.detached.js index 7431a99048dc..724f4066f98a 100644 --- a/packages/core-js/modules/es.array-buffer.detached.js +++ b/packages/core-js/modules/es.array-buffer.detached.js @@ -1,3 +1,4 @@ +// @types: proposals/array-buffer-transfer 'use strict'; var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); var isDetached = require('../internals/array-buffer-is-detached'); From f4d0bf472aa4e941e9d60fba75f51b392e92a391 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 4 Feb 2026 01:48:13 +0700 Subject: [PATCH 175/315] Entries namespaces tests & build-types script improvements --- .../build-entries-and-types/build-types.mjs | 11 +++++--- .../entries/entries.actual.ts | 18 +++++++++++++ tests/type-definitions/entries/entries.es.ts | 20 +++++++++++++++ .../type-definitions/entries/entries.full.ts | 15 +++++++++++ .../entries/entries.proposals.ts | 5 ++++ .../entries/entries.stable.ts | 25 +++++++++++++++++++ .../entries/tsconfig.actual.json | 4 +++ .../type-definitions/entries/tsconfig.es.json | 4 +++ .../entries/tsconfig.full.json | 4 +++ .../entries/tsconfig.proposals.json | 4 +++ .../entries/tsconfig.stable.json | 4 +++ tests/type-definitions/global/entries.ts | 7 ------ tests/type-definitions/runner.mjs | 5 ++++ 13 files changed, 116 insertions(+), 10 deletions(-) create mode 100644 tests/type-definitions/entries/entries.actual.ts create mode 100644 tests/type-definitions/entries/entries.es.ts create mode 100644 tests/type-definitions/entries/entries.full.ts create mode 100644 tests/type-definitions/entries/entries.proposals.ts create mode 100644 tests/type-definitions/entries/entries.stable.ts create mode 100644 tests/type-definitions/entries/tsconfig.actual.json create mode 100644 tests/type-definitions/entries/tsconfig.es.json create mode 100644 tests/type-definitions/entries/tsconfig.full.json create mode 100644 tests/type-definitions/entries/tsconfig.proposals.json create mode 100644 tests/type-definitions/entries/tsconfig.stable.json delete mode 100644 tests/type-definitions/global/entries.ts diff --git a/scripts/build-entries-and-types/build-types.mjs b/scripts/build-entries-and-types/build-types.mjs index 3eed163c04bd..bec40ee5f97a 100644 --- a/scripts/build-entries-and-types/build-types.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -54,9 +54,11 @@ async function buildType(entry, options) { customType, tsVersion, proposal, types, ownEntryPoint, } = options; + let typesFilter = null; switch (subset) { case 'es': filter ??= ESSet; + typesFilter = '/web/'; break; case 'stable': filter ??= StableSet; @@ -74,17 +76,20 @@ async function buildType(entry, options) { if (typeDummy) { template = $typeDummy; } + const level = entry.split('/').length - 1; if (!types) { if (!enforceEntryCreation && !expandModules(modules[0], filter, AllModules).length) return; modules = expandModules(modules, filter, AllModules); - const { dependencies, types: typePaths } = await getModulesMetadata(modules); - modules = dependencies; - if (filter) modules = modules.filter(it => filter.has(it)); + const { types: typePaths } = await getModulesMetadata(modules); types = typePaths; } + if (typesFilter) { + types = types.filter(it => !it.includes(typesFilter)); + } + types.forEach(type => { if (globalType) { imports.index.add(type); diff --git a/tests/type-definitions/entries/entries.actual.ts b/tests/type-definitions/entries/entries.actual.ts new file mode 100644 index 000000000000..274fa3d7e1ba --- /dev/null +++ b/tests/type-definitions/entries/entries.actual.ts @@ -0,0 +1,18 @@ +import '@core-js/types/actual'; + +const concat = Iterator.concat([1, 2, 3]); + +Iterator.zipKeyed({ a: [1, 2], b: [3, 4] }); +Iterator.zip([[1, 2, 3], [4, 5, 6]]); + +// @ts-expect-error +concat.chunks(2); +// @ts-expect-error +concat.windows(3); + +Promise.all([1, 2, 3]); +// @ts-expect-error +Promise.allKeyed({ + a: Promise.resolve(1), + b: Promise.resolve('string'), +}); diff --git a/tests/type-definitions/entries/entries.es.ts b/tests/type-definitions/entries/entries.es.ts new file mode 100644 index 000000000000..78b6d2577891 --- /dev/null +++ b/tests/type-definitions/entries/entries.es.ts @@ -0,0 +1,20 @@ +import '@core-js/types/es'; + +const concat = Iterator.concat([1, 2, 3]); + +// @ts-expect-error +Iterator.zipKeyed({ a: [1, 2], b: [3, 4] }); +// @ts-expect-error +Iterator.zip([[1, 2, 3], [4, 5, 6]]); + +// @ts-expect-error +concat.chunks(2); +// @ts-expect-error +concat.windows(3); + +Promise.all([1, 2, 3]); +// @ts-expect-error +Promise.allKeyed({ + a: Promise.resolve(1), + b: Promise.resolve('string'), +}); diff --git a/tests/type-definitions/entries/entries.full.ts b/tests/type-definitions/entries/entries.full.ts new file mode 100644 index 000000000000..d238d7116134 --- /dev/null +++ b/tests/type-definitions/entries/entries.full.ts @@ -0,0 +1,15 @@ +import '@core-js/types/full'; + +const concat = Iterator.concat([1, 2, 3]); + +Iterator.zipKeyed({ a: [1, 2], b: [3, 4] }); +Iterator.zip([[1, 2, 3], [4, 5, 6]]); + +concat.chunks(2); +concat.windows(3); + +Promise.all([1, 2, 3]); +Promise.allKeyed({ + a: Promise.resolve(1), + b: Promise.resolve('string'), +}); diff --git a/tests/type-definitions/entries/entries.proposals.ts b/tests/type-definitions/entries/entries.proposals.ts new file mode 100644 index 000000000000..118f55d7f99a --- /dev/null +++ b/tests/type-definitions/entries/entries.proposals.ts @@ -0,0 +1,5 @@ +import '@core-js/types/proposals/array-unique'; +const uniqueArr: number[] = [1, 2, 2, 3, 3, 3].uniqueBy(); + +import '@core-js/types/proposals/array-flat-map'; +const flatMappedArr: number[] = [1, 2, 3].flatMap(x => [x, x * 2]); diff --git a/tests/type-definitions/entries/entries.stable.ts b/tests/type-definitions/entries/entries.stable.ts new file mode 100644 index 000000000000..9d0c1a174550 --- /dev/null +++ b/tests/type-definitions/entries/entries.stable.ts @@ -0,0 +1,25 @@ +import '@core-js/types/stable'; + +const concat = Iterator.concat([1, 2, 3]); + +// @ts-expect-error +Iterator.zipKeyed({ a: [1, 2], b: [3, 4] }); +// @ts-expect-error +Iterator.zip([[1, 2, 3], [4, 5, 6]]); + +// @ts-expect-error +concat.chunks(2); +// @ts-expect-error +concat.windows(3); + +// @ts-expect-error +concat.chunks(2); +// @ts-expect-error +concat.windows(3); + +Promise.all([1, 2, 3]); +// @ts-expect-error +Promise.allKeyed({ + a: Promise.resolve(1), + b: Promise.resolve('string'), +}); diff --git a/tests/type-definitions/entries/tsconfig.actual.json b/tests/type-definitions/entries/tsconfig.actual.json new file mode 100644 index 000000000000..7307d61c3fa4 --- /dev/null +++ b/tests/type-definitions/entries/tsconfig.actual.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.json", + "include": ["./entries.actual.ts"] +} diff --git a/tests/type-definitions/entries/tsconfig.es.json b/tests/type-definitions/entries/tsconfig.es.json new file mode 100644 index 000000000000..3b79650f8066 --- /dev/null +++ b/tests/type-definitions/entries/tsconfig.es.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.json", + "include": ["./entries.es.ts"] +} diff --git a/tests/type-definitions/entries/tsconfig.full.json b/tests/type-definitions/entries/tsconfig.full.json new file mode 100644 index 000000000000..4015819d0939 --- /dev/null +++ b/tests/type-definitions/entries/tsconfig.full.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.json", + "include": ["./entries.full.ts"] +} diff --git a/tests/type-definitions/entries/tsconfig.proposals.json b/tests/type-definitions/entries/tsconfig.proposals.json new file mode 100644 index 000000000000..b90cb77f4bae --- /dev/null +++ b/tests/type-definitions/entries/tsconfig.proposals.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.json", + "include": ["./entries.proposals.ts"] +} diff --git a/tests/type-definitions/entries/tsconfig.stable.json b/tests/type-definitions/entries/tsconfig.stable.json new file mode 100644 index 000000000000..645690137e02 --- /dev/null +++ b/tests/type-definitions/entries/tsconfig.stable.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.json", + "include": ["./entries.stable.ts"] +} diff --git a/tests/type-definitions/global/entries.ts b/tests/type-definitions/global/entries.ts deleted file mode 100644 index e144532cd934..000000000000 --- a/tests/type-definitions/global/entries.ts +++ /dev/null @@ -1,7 +0,0 @@ -import '@core-js/types/stable'; -Iterator.concat([]); -// @ts-expect-error -Iterator.zipKeyed([]); - -import '@core-js/types/proposals/array-unique'; -const uniqueArr: number[] = [1, 2, 2, 3, 3, 3].uniqueBy(); diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 77615c4832e4..fddce561fe04 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -159,6 +159,11 @@ tasks.push( { args: ['-p', 'typescript@5.9', 'tsc'] }, { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'templates/tsconfig.json'] }, { args: ['-p', 'typescript@5.9', '-p', '@types/node@24', 'tsc', '-p', 'templates/tsconfig.require.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/tsconfig.full.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/tsconfig.actual.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/tsconfig.stable.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/tsconfig.es.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/tsconfig.proposals.json'] }, ); let envs; From 51ebec837338fdab62c3acfef8554139b84a8040 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 4 Feb 2026 23:04:48 +0700 Subject: [PATCH 176/315] Add tests for imported global types & some tests improvements --- .../accessible-object-hasownproperty.test.ts | 10 +++ .../proposals/array-buffer-base64.test.ts | 3 + .../proposals/array-buffer-transfer.test.ts | 6 +- .../global/proposals/array-filtering.test.ts | 19 ++++- .../proposals/array-find-from-last.test.ts | 21 +++++- .../global/proposals/array-flat-map.test.ts | 17 ++++- .../global/proposals/array-from-async.test.ts | 22 ++++++ .../global/proposals/array-grouping.test.ts | 11 +++ .../global/proposals/array-includes.test.ts | 62 +++++++++------- .../array-is-template-object.test.ts | 12 ++- .../global/proposals/array-unique.test.ts | 11 ++- .../proposals/async-iterator-helper.test.ts | 27 ++++++- .../global/proposals/await-dictionary.test.ts | 36 +++++++-- .../proposals/change-array-by-copy.test.ts | 42 ++++++++--- .../proposals/collection-of-from.test.ts | 51 +++++++++---- .../global/proposals/float16.test.ts | 11 ++- .../proposals/function-demethodize.test.ts | 2 + .../global/proposals/is-error.test.ts | 8 +- .../proposals/iterator-chunking.test.ts | 18 ++++- .../global/proposals/iterator-helpers.test.ts | 46 ++++++++++-- .../global/proposals/iterator-join.test.ts | 19 +++-- .../global/proposals/iterator-joint.test.ts | 8 ++ .../global/proposals/iterator-range.test.ts | 8 +- .../proposals/iterator-sequencing.test.ts | 6 ++ .../proposals/json-parse-with-source.test.ts | 19 ++++- .../global/proposals/map-upsert.test.ts | 23 +++++- .../global/proposals/math-sum.test.ts | 14 +++- .../global/proposals/number-clamp.test.ts | 8 +- .../proposals/object-from-entries.test.ts | 10 ++- ...bject-get-own-property-descriptors.test.ts | 10 ++- .../proposals/object-values-entries.test.ts | 23 ++++-- .../proposals/promise-all-settled.test.ts | 15 ++-- .../global/proposals/promise-any.test.ts | 10 ++- .../global/proposals/promise-finally.test.ts | 15 ++-- .../global/proposals/promise-try.test.ts | 12 +-- .../proposals/promise-with-resolvers.test.ts | 8 +- .../global/proposals/regexp-escaping.test.ts | 12 ++- .../relative-indexing-method.test.ts | 16 +++- .../global/proposals/set-methods.test.ts | 20 +++++ .../global/proposals/string-cooked.test.ts | 13 +++- .../global/proposals/string-dedent.test.ts | 12 ++- .../proposals/string-left-right-trim.test.ts | 19 ++++- .../global/proposals/string-match-all.test.ts | 10 +-- .../global/proposals/string-padding.test.ts | 19 ++++- .../proposals/string-replace-all.test.ts | 13 ++-- .../proposals/symbol-predicates.test.ts | 29 ++++++-- .../well-formed-unicode-strings.test.ts | 16 +++- .../type-definitions/global/web/atob.test.ts | 8 +- .../type-definitions/global/web/btoa.test.ts | 14 +++- .../web/efficient-script-yielding.test.ts | 10 +++ .../global/web/queue-microtask.test.ts | 6 ++ .../global/web/structured-clone.test.ts | 11 ++- tests/type-definitions/helpers.pure.ts | 71 ++++++++++++++++++ tests/type-definitions/helpers.ts | 74 ++----------------- .../pure/proposals/array-from-async.test.ts | 2 +- .../pure/proposals/array-grouping.test.ts | 2 +- .../proposals/async-iterator-helper.test.ts | 2 +- .../pure/proposals/await-dictionary.test.ts | 2 +- .../pure/proposals/collection-of-from.test.ts | 2 +- .../pure/proposals/error-cause.test.ts | 2 +- .../explicit-resource-management.test.ts | 2 +- .../pure/proposals/iterator-chunking.test.ts | 2 +- .../pure/proposals/iterator-helpers.test.ts | 2 +- .../pure/proposals/iterator-joint.test.ts | 2 +- .../pure/proposals/iterator-range.test.ts | 2 +- .../proposals/iterator-sequencing.test.ts | 2 +- .../proposals/promise-all-settled.test.ts | 2 +- .../pure/proposals/promise-any.test.ts | 2 +- .../pure/proposals/promise-finally.test.ts | 2 +- .../pure/proposals/promise-try.test.ts | 2 +- .../proposals/promise-with-resolvers.test.ts | 2 +- .../pure/proposals/set-methods.test.ts | 2 +- 72 files changed, 783 insertions(+), 269 deletions(-) create mode 100644 tests/type-definitions/helpers.pure.ts diff --git a/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts b/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts index 99db1af9b4a2..07b7b821d714 100644 --- a/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts +++ b/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts @@ -1,4 +1,14 @@ import 'core-js/full'; +import hasOwn from 'core-js/full/object/has-own'; +import $Object from 'core-js/full/object'; + +$Object.hasOwn({ a: 1 }, 'a'); +hasOwn({ a: 1 }, 'a'); + +// @ts-expect-error +hasOwn(1, 'a'); +// @ts-expect-error +$Object.hasOwn(1, 'a'); Object.hasOwn({ a: 1 }, 'a'); Object.hasOwn([], 0); diff --git a/tests/type-definitions/global/proposals/array-buffer-base64.test.ts b/tests/type-definitions/global/proposals/array-buffer-base64.test.ts index 22d0162d6899..d938f11da1bc 100644 --- a/tests/type-definitions/global/proposals/array-buffer-base64.test.ts +++ b/tests/type-definitions/global/proposals/array-buffer-base64.test.ts @@ -1,4 +1,7 @@ import 'core-js/full'; +import $Uint8Array from 'core-js/full/typed-array/uint8-array'; + +$Uint8Array.fromBase64('SGVsbG8gd29ybGQ=', { alphabet: 'base64', lastChunkHandling: 'loose' }); function acceptUint8Array(v: Uint8Array) {} function acceptProcessMetadata(v: { read: number; written: number }) {} diff --git a/tests/type-definitions/global/proposals/array-buffer-transfer.test.ts b/tests/type-definitions/global/proposals/array-buffer-transfer.test.ts index 7e4acf0eae5f..3e35c6ea079e 100644 --- a/tests/type-definitions/global/proposals/array-buffer-transfer.test.ts +++ b/tests/type-definitions/global/proposals/array-buffer-transfer.test.ts @@ -1,7 +1,11 @@ import 'core-js/full'; +import $ArrayBuffer from 'core-js/full/array-buffer'; + +const abFromNamespace = new $ArrayBuffer(16); +const abFNSTransfer: ArrayBuffer = abFromNamespace.transfer(); const ab = new ArrayBuffer(16); -// todo uncomment when fixed +// TODO uncomment when fixed // const abDetached: boolean = ab.detached; const abTransfer: ArrayBuffer = ab.transfer(); const abTransfer2: ArrayBuffer = ab.transfer(32); diff --git a/tests/type-definitions/global/proposals/array-filtering.test.ts b/tests/type-definitions/global/proposals/array-filtering.test.ts index 85eaa9495fea..da4103bb2b3d 100644 --- a/tests/type-definitions/global/proposals/array-filtering.test.ts +++ b/tests/type-definitions/global/proposals/array-filtering.test.ts @@ -1,9 +1,20 @@ import 'core-js/full'; +import filterReject from 'core-js/full/array/filter-reject'; +import filterRejectJS from 'core-js/full/array/filter-reject.js'; +import { assertNumberArray } from '../../helpers'; + +filterReject([1, 2, 3], (v, i, arr) => v > 1); +filterRejectJS([1, 2, 3], (v, i, arr) => v > 1); + +// @ts-expect-error +filterReject([1, 2, 3], (x: string) => false); +// @ts-expect-error +filterRejectJS([1, 2, 3], (x: string) => false); [1, 2, 3].filterReject((v, i, arr) => v > 1); ['a', 'b'].filterReject((v, i, arr) => v === 'a'); -const arr: number[] = [1, 2, 3]; -const res: number[] = arr.filterReject(function (v) { return v < 2; }, { foo: true }); +const arr = [1, 2, 3]; +assertNumberArray(arr.filterReject(function (v) { return v < 2; }, { foo: true })); new Int8Array([1, 2, 3]).filterReject((v, i, arr) => v > 1); new Uint8Array([1, 2, 3]).filterReject((v, i, arr) => v > 1); @@ -15,7 +26,7 @@ new Uint32Array([1, 2, 3]).filterReject((v, i, arr) => v > 1); new Float32Array([1, 2, 3]).filterReject((v, i, arr) => v > 1); new Float64Array([1, 2, 3]).filterReject((v, i, arr) => v > 1); -// todo for es6 +// TODO for es6 // declare var BigInt: (value: number | string | bigint) => bigint; // (new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((v, i, arr) => v > BigInt(1)); // (new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((v, i, arr) => v > BigInt(1)); @@ -50,7 +61,7 @@ new Float32Array([1, 2, 3]).filterReject((x: string) => false); // @ts-expect-error new Float64Array([1, 2, 3]).filterReject((x: string) => false); -// todo +// TODO for es6 // // @ts-expect-error // (new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).filterReject((x: number) => false); // diff --git a/tests/type-definitions/global/proposals/array-find-from-last.test.ts b/tests/type-definitions/global/proposals/array-find-from-last.test.ts index 20cf56e4d599..089053d57ed1 100644 --- a/tests/type-definitions/global/proposals/array-find-from-last.test.ts +++ b/tests/type-definitions/global/proposals/array-find-from-last.test.ts @@ -1,4 +1,23 @@ import 'core-js/full'; +import findLast from 'core-js/full/array/find-last'; +import findLastJS from 'core-js/full/array/find-last.js'; +import findLastIndex from 'core-js/full/array/find-last-index'; +import findLastIndexJS from 'core-js/full/array/find-last-index.js'; +import { assertNumber } from '../../helpers'; + +const resNS1: number | undefined = findLast([1, 2, 3], v => v > 1); +const resNS2: number | undefined = findLastJS([1, 2, 3], v => v > 1); +assertNumber(findLastIndex([1, 2, 3], v => v > 1, {})); +assertNumber(findLastIndexJS([1, 2, 3], v => v > 1, {})); + +// @ts-expect-error +findLast([1, 2, 3]); +// @ts-expect-error +findLastJS([1, 2, 3]); +// @ts-expect-error +findLastIndex([1, 2, 3]); +// @ts-expect-error +findLastIndexJS([1, 2, 3]); const res: number | undefined = [1, 2, 3].findLast(v => v > 1); [1, 2, 3].findLast((v): v is 2 => v === 2); @@ -18,7 +37,7 @@ new Uint8Array([1, 2, 3]).findLast(v => v > 0); new Uint8Array([1, 2, 3]).findLastIndex(v => v < 0); new Float64Array([1, 2, 3]).findLast(v => v > 1.1); new Float64Array([1, 2, 3]).findLastIndex(v => v > 100); -// todo for es6 +// TODO for es6 // (new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLast(v => v > BigInt(1)); // (new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLast((v): v is bigint => v === BigInt(2)); // (new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)])).findLastIndex(v => v > BigInt(0)); diff --git a/tests/type-definitions/global/proposals/array-flat-map.test.ts b/tests/type-definitions/global/proposals/array-flat-map.test.ts index 8ae7007f3a6d..021b67d6a78d 100644 --- a/tests/type-definitions/global/proposals/array-flat-map.test.ts +++ b/tests/type-definitions/global/proposals/array-flat-map.test.ts @@ -1,12 +1,23 @@ import 'core-js/full'; +import flatMap from 'core-js/full/array/flat-map'; +import flatMapJS from 'core-js/full/array/flat-map.js'; +import { assertNumberArray, assertStringArray } from '../../helpers'; -const flatMapped: number[] = [1, 2, 3].flatMap(x => [x, x * 2]); -const flatMapped2: string[] = ['a', 'b', 'c'].flatMap(x => [x, x.toUpperCase()]); +assertNumberArray(flatMap([1, 2, 3], x => [x, x * 2])); +assertNumberArray(flatMapJS([1, 2, 3], x => [x, x * 2])); + +// @ts-expect-error +flatMap([1, 2, 3]); +// @ts-expect-error +flatMapJS([1, 2, 3]); + +assertNumberArray([1, 2, 3].flatMap(x => [x, x * 2])); +assertStringArray(['a', 'b', 'c'].flatMap(x => [x, x.toUpperCase()])); [1, 2, 3].flatMap(x => x > 1 ? [x, x] : []); [1, 2, 3].flatMap(function (x) { return [this, x]; }, 123); [1, 2, 3].flatMap((x, i, arr) => arr); -const flatted: number[] = [[1], [2], [3]].flat(); +assertNumberArray([[1], [2], [3]].flat()); const flatted2: (string[] | string)[] = ['a', ['b', ['c']]].flat(); [[1], [2], [3]].flat(2); [1, [2, [3, [4]]]].flat(2); diff --git a/tests/type-definitions/global/proposals/array-from-async.test.ts b/tests/type-definitions/global/proposals/array-from-async.test.ts index 61f7e9154802..7379bf533850 100644 --- a/tests/type-definitions/global/proposals/array-from-async.test.ts +++ b/tests/type-definitions/global/proposals/array-from-async.test.ts @@ -1,4 +1,26 @@ import 'core-js/full'; +import fromAsync from 'core-js/full/array/from-async'; +import fromAsyncJS from 'core-js/full/array/from-async.js'; +import $Array from 'core-js/full/array'; +import $ArrayIndex from 'core-js/full/array/index'; +import $ArrayIndexJS from 'core-js/full/array/index.js'; + +const pNS: Promise = fromAsync([1, 2, 3]); +const pNS2: Promise = fromAsyncJS([1, 2, 3]); +const pNS3: Promise = $Array.fromAsync([1, 2, 3]); +const pNS4: Promise = $ArrayIndex.fromAsync([1, 2, 3]); +const pNS5: Promise = $ArrayIndexJS.fromAsync([1, 2, 3]); + +// @ts-expect-error +fromAsync([1, 2, 3], 'not a function'); +// @ts-expect-error +fromAsyncJS([1, 2, 3], 'not a function'); +// @ts-expect-error +$Array.fromAsync([1, 2, 3], 'not a function'); +// @ts-expect-error +$ArrayIndex.fromAsync([1, 2, 3], 'not a function'); +// @ts-expect-error +$ArrayIndexJS.fromAsync([1, 2, 3], 'not a function'); const p1: Promise = Array.fromAsync([1, 2, 3]); const p2: Promise = Array.fromAsync([Promise.resolve(1), 2, 3]); diff --git a/tests/type-definitions/global/proposals/array-grouping.test.ts b/tests/type-definitions/global/proposals/array-grouping.test.ts index e5504ce274b7..7098b15092a2 100644 --- a/tests/type-definitions/global/proposals/array-grouping.test.ts +++ b/tests/type-definitions/global/proposals/array-grouping.test.ts @@ -1,6 +1,17 @@ import 'core-js/full'; +import objectGroupBy from 'core-js/full/object/group-by'; +import mapGroupBy from 'core-js/full/map/group-by'; const arr = [1, 2, 3, 4, 5]; + +const objGroupNS: Partial> = objectGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); +const mapGroupNS2: Map<'even' | 'odd', number[]> = mapGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); + +// @ts-expect-error +objectGroupBy(); +// @ts-expect-error +mapGroupBy(); + const objGroup: Partial> = Object.groupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); const mapGroup: Map<'even' | 'odd', number[]> = Map.groupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); const objGroup2: Partial> = Object.groupBy(['foo', 'bar', 'baz'], (s, i) => i > 1 ? s[0] : 'x'); diff --git a/tests/type-definitions/global/proposals/array-includes.test.ts b/tests/type-definitions/global/proposals/array-includes.test.ts index 5d8745599020..b7875e8d6064 100644 --- a/tests/type-definitions/global/proposals/array-includes.test.ts +++ b/tests/type-definitions/global/proposals/array-includes.test.ts @@ -1,57 +1,65 @@ import 'core-js/full'; +import includes from 'core-js/full/array/includes'; +import { assertBool } from '../../helpers'; -const arr: number[] = [1, 2, 3]; -const arrRes: boolean = arr.includes(2); -const arrRes2: boolean = arr.includes(2, 1); +const arr = [1, 2, 3]; + +assertBool(includes(arr, 2)); + +// @ts-expect-error +includes(arr); + +assertBool(arr.includes(2)); +assertBool(arr.includes(2, 1)); const strArr: string[] = ['a', 'b', 'c']; -const strArrRes: boolean = strArr.includes('b'); -const strArrRes2: boolean = strArr.includes('b', 1); +assertBool(strArr.includes('b')); +assertBool(strArr.includes('b', 1)); const i8 = new Int8Array([1, 2, 3]); -const i8Res: boolean = i8.includes(2); -const i8Res2: boolean = i8.includes(2, 1); +assertBool(i8.includes(2)); +assertBool(i8.includes(2, 1)); const u8 = new Uint8Array([1, 2, 3]); -const u8Res: boolean = u8.includes(2); -const u8Res2: boolean = u8.includes(2, 1); +assertBool(u8.includes(2)); +assertBool(u8.includes(2, 1)); const u8c = new Uint8ClampedArray([1, 2, 3]); -const u8cRes: boolean = u8c.includes(2); -const u8cRes2: boolean = u8c.includes(2, 1); +assertBool(u8c.includes(2)); +assertBool(u8c.includes(2, 1)); const i16 = new Int16Array([1, 2, 3]); -const i16Res: boolean = i16.includes(2); -const i16Res2: boolean = i16.includes(2, 1); +assertBool(i16.includes(2)); +assertBool(i16.includes(2, 1)); const u16 = new Uint16Array([1, 2, 3]); -const u16Res: boolean = u16.includes(2); -const u16Res2: boolean = u16.includes(2, 1); +assertBool(u16.includes(2)); +assertBool(u16.includes(2, 1)); const i32 = new Int32Array([1, 2, 3]); -const i32Res: boolean = i32.includes(2); -const i32Res2: boolean = i32.includes(2, 1); +assertBool(i32.includes(2)); +assertBool(i32.includes(2, 1)); const u32 = new Uint32Array([1, 2, 3]); -const u32Res: boolean = u32.includes(2); -const u32Res2: boolean = u32.includes(2, 1); +assertBool(u32.includes(2)); +assertBool(u32.includes(2, 1)); const f32 = new Float32Array([1.5, 2.5, 3.5]); -const f32Res: boolean = f32.includes(2.5); -const f32Res2: boolean = f32.includes(2.5, 1); +assertBool(f32.includes(2.5)); +assertBool(f32.includes(2.5, 1)); const f64 = new Float64Array([1.5, 2.5, 3.5]); -const f64Res: boolean = f64.includes(2.5); -const f64Res2: boolean = f64.includes(2.5, 1); +assertBool(f64.includes(2.5)); +assertBool(f64.includes(2.5, 1)); // todo for es6 // const bi64 = new BigInt64Array([BigInt(1), BigInt(2), BigInt(3)]); -// const bi64Res: boolean = bi64.includes(BigInt(2)); -// const bi64Res2: boolean = bi64.includes(BigInt(2), 1); +// assertBool(bi64.includes(BigInt(2)); +// assertBool(bi64.includes(BigInt(2), 1); // // const bu64 = new BigUint64Array([BigInt(1), BigInt(2), BigInt(3)]); -// const bu64Res: boolean = bu64.includes(BigInt(2)); -// const bu64Res2: boolean = bu64.includes(BigInt(2), 1); +// assertBool(bu64.includes(BigInt(2)); +// assertBool(bu64.includes(BigInt(2), 1); // @ts-expect-error arr.includes(); diff --git a/tests/type-definitions/global/proposals/array-is-template-object.test.ts b/tests/type-definitions/global/proposals/array-is-template-object.test.ts index bc54ef0bd82d..f7b2f2c396e1 100644 --- a/tests/type-definitions/global/proposals/array-is-template-object.test.ts +++ b/tests/type-definitions/global/proposals/array-is-template-object.test.ts @@ -1,6 +1,13 @@ import 'core-js/full'; +import isTemplateObject from 'core-js/full/array/is-template-object'; +import { assertBool } from '../../helpers'; -const t: boolean = Array.isTemplateObject([]); +const res: boolean = isTemplateObject([]); + +// @ts-expect-error +isTemplateObject(); + +assertBool(Array.isTemplateObject([])); Array.isTemplateObject({}); Array.isTemplateObject(['a', 'b']); Array.isTemplateObject(Object.freeze(['foo', 'bar'])); @@ -13,3 +20,6 @@ if (Array.isTemplateObject(x)) { x.raw; const _: readonly string[] = x.raw; } + +// @ts-expect-error +Array.isTemplateObject(); diff --git a/tests/type-definitions/global/proposals/array-unique.test.ts b/tests/type-definitions/global/proposals/array-unique.test.ts index 45b560ed927d..d94c0d2bcc1a 100644 --- a/tests/type-definitions/global/proposals/array-unique.test.ts +++ b/tests/type-definitions/global/proposals/array-unique.test.ts @@ -1,4 +1,11 @@ import 'core-js/full'; +import uniqueBy from 'core-js/full/array/unique-by'; +import { assertNumberArray } from '../../helpers'; + +const uniqueByNS: number[] = uniqueBy([1, 2, 1, 3]); + +// @ts-expect-error +uniqueBy([1, 2, 3], 123); interface Obj { a: number; @@ -10,8 +17,8 @@ const arrRes2: Obj[] = arr.uniqueBy('a'); const arrRes3: Obj[] = arr.uniqueBy(obj => obj.b); const numArr: number[] = [1, 2, 1, 3]; -const numArrRes: number[] = numArr.uniqueBy(); -const numArrRes2: number[] = numArr.uniqueBy(x => x % 2); +assertNumberArray(numArr.uniqueBy()); +assertNumberArray(numArr.uniqueBy(x => x % 2)); const i8 = new Int8Array([1, 2, 2, 3]); const i8Res: Int8Array = i8.uniqueBy(); diff --git a/tests/type-definitions/global/proposals/async-iterator-helper.test.ts b/tests/type-definitions/global/proposals/async-iterator-helper.test.ts index e61c6d5de90a..a9c128e64c4f 100644 --- a/tests/type-definitions/global/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/global/proposals/async-iterator-helper.test.ts @@ -1,4 +1,29 @@ import 'core-js/full'; +import from from 'core-js/full/async-iterator/from'; +import drop from 'core-js/full/async-iterator/drop'; +import every from 'core-js/full/async-iterator/every'; +import filter from 'core-js/full/async-iterator/filter'; +import find from 'core-js/full/async-iterator/find'; +import flatMap from 'core-js/full/async-iterator/flat-map'; +import forEach from 'core-js/full/async-iterator/for-each'; +import map from 'core-js/full/async-iterator/map'; +import reduce from 'core-js/full/async-iterator/reduce'; +import some from 'core-js/full/async-iterator/some'; +import take from 'core-js/full/async-iterator/take'; +import toArray from 'core-js/full/async-iterator/to-array'; + +const ait: AsyncIterator = from([1, 2]); +drop(ait, 1); +every(ait, (v: number, i: number) => v > 0); +filter(ait, (v: number, i: number) => v > 0); +find(ait, (v: number, i: number) => v > 0); +flatMap(ait, (v: number, i: number) => v); +forEach(ait, (v: number, i: number) => { }); +map(ait, (v: number, i: number) => v * 2); +reduce(ait, (acc: number, v: number, i: number) => acc + v, 0); +some(ait, (v: number, i: number) => v > 0); +take(ait, 1); +toArray(ait); const res: AsyncIterator = AsyncIterator.from([1, 2, 3]); const res2: AsyncIterator = AsyncIterator.from(new Set([1, 2, 3])); @@ -42,7 +67,7 @@ const r1: AsyncIterator = ain.drop(3); const r2: Promise = ain.every((v: number, i: number) => v > 0); const r3: AsyncIterator = ain.filter((v: number, i: number) => v > 0); const r4: Promise = ain.find((v: number, i: number) => v > 0); -const r5: AsyncIterator = ain.flatMap((v: number, i: number) => `${ v }`); +const r5: AsyncIterator = ain.flatMap((v: number, i: number) => v); const r6: Promise = ain.forEach((v: number, i: number) => { }); const r7: AsyncIterator = ain.map((v: number, i: number) => v * 2); const r8: Promise = ain.reduce((acc: number, v: number, i: number) => acc + v, 0); diff --git a/tests/type-definitions/global/proposals/await-dictionary.test.ts b/tests/type-definitions/global/proposals/await-dictionary.test.ts index d1aeb17a9f15..a094efd2db94 100644 --- a/tests/type-definitions/global/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/global/proposals/await-dictionary.test.ts @@ -1,4 +1,33 @@ import 'core-js/full'; +import allKeyed from 'core-js/full/promise/all-keyed'; +import allSettledKeyed from 'core-js/full/promise/all-settled-keyed'; +import $Promise from 'core-js/full/promise'; + +const sym = Symbol('sym'); +interface CoreJSPromiseResult { + status: string; + value?: T; + reason?: any; +} + +const resNS: Promise<{ a: number, b: string, c: boolean }> = allKeyed({ + a: Promise.resolve(1), + b: Promise.resolve('string'), + c: Promise.resolve(true), +}); +const resNS2: Promise<{ a: number, b: string, c: boolean }> = $Promise.allKeyed({ + a: Promise.resolve(1), + b: Promise.resolve('string'), + c: Promise.resolve(true), +}); +const resNS3: Promise<{ [sym]: CoreJSPromiseResult }> = allSettledKeyed({ + [sym]: Promise.resolve(1), +}); + +// @ts-expect-error +allKeyed(); +// @ts-expect-error +allSettledKeyed(); const res: Promise<{ a: number, b: string, c: boolean }> = Promise.allKeyed({ a: Promise.resolve(1), @@ -6,7 +35,6 @@ const res: Promise<{ a: number, b: string, c: boolean }> = Promise.allKeyed({ c: Promise.resolve(true), }); -const sym = Symbol('sym'); const res2: Promise<{ [sym]: number }> = Promise.allKeyed({ [sym]: Promise.resolve(1), }); @@ -18,12 +46,6 @@ Promise.allKeyed({ a: 1, b: Promise.resolve(2) }); // @ts-expect-error Promise.allKeyed([Promise.resolve(1), Promise.resolve(2)]); -interface CoreJSPromiseResult { - status: string; - value?: T; - reason?: any; -} - const resASK: Promise<{ a: CoreJSPromiseResult, b: CoreJSPromiseResult, c: CoreJSPromiseResult }> = Promise.allSettledKeyed({ a: Promise.resolve(1), b: Promise.resolve('string'), diff --git a/tests/type-definitions/global/proposals/change-array-by-copy.test.ts b/tests/type-definitions/global/proposals/change-array-by-copy.test.ts index 75947ca90b54..ef4c07c80269 100644 --- a/tests/type-definitions/global/proposals/change-array-by-copy.test.ts +++ b/tests/type-definitions/global/proposals/change-array-by-copy.test.ts @@ -1,19 +1,39 @@ import 'core-js/full'; +import toSorted from 'core-js/full/array/to-sorted'; +import toSpliced from 'core-js/full/array/to-spliced'; +import toReversed from 'core-js/full/array/to-reversed'; +import withArray from 'core-js/full/array/with'; +import { assertNumberArray, assertStringArray } from '../../helpers'; const arr: number[] = [1, 2, 3]; -const arrRev: number[] = arr.toReversed(); -const arrSorted: number[] = arr.toSorted(); -const arrSorted2: number[] = arr.toSorted((a, b) => b - a); -const arrSpliced: number[] = arr.toSpliced(1, 1, 4, 5); -const arrSpliced2: number[] = arr.toSpliced(1); -const arrSpliced3: number[] = arr.toSpliced(1, 2); -const arrWith: number[] = arr.with(1, 42); + +assertNumberArray(toSorted(arr)); +assertNumberArray(toSpliced(arr, 1, 1, 4, 5)); +assertNumberArray(toReversed(arr)); +assertNumberArray(withArray(arr, 1, 42)); + +// @ts-expect-error +toSorted(arr, 'not a function'); +// @ts-expect-error +toSpliced(arr, '1', 1); +// @ts-expect-error +toReversed(arr, 1); +// @ts-expect-error +withArray(arr); + +assertNumberArray(arr.toReversed()); +assertNumberArray(arr.toSorted()); +assertNumberArray(arr.toSorted((a, b) => b - a)); +assertNumberArray(arr.toSpliced(1, 1, 4, 5)); +assertNumberArray(arr.toSpliced(1)); +assertNumberArray(arr.toSpliced(1, 2)); +assertNumberArray(arr.with(1, 42)); const sarr: string[] = ['a', 'b', 'c']; -const sarrRev: string[] = sarr.toReversed(); -const sarrSorted: string[] = sarr.toSorted(); -const sarrWith: string[] = sarr.with(0, 'z'); -const sarrSpliced: string[] = sarr.toSpliced(0, 1, 'x'); +assertStringArray(sarr.toReversed()); +assertStringArray(sarr.toSorted()); +assertStringArray(sarr.with(0, 'z')); +assertStringArray(sarr.toSpliced(0, 1, 'x')); const i8 = new Int8Array([1, 2, 3]); const i8Rev: Int8Array = i8.toReversed(); diff --git a/tests/type-definitions/global/proposals/collection-of-from.test.ts b/tests/type-definitions/global/proposals/collection-of-from.test.ts index 0b94e79d150c..7d2b0a317e55 100644 --- a/tests/type-definitions/global/proposals/collection-of-from.test.ts +++ b/tests/type-definitions/global/proposals/collection-of-from.test.ts @@ -1,27 +1,50 @@ import 'core-js/full'; +import mapFrom from 'core-js/full/map/from'; +import mapOf from 'core-js/full/map/of'; +import setFrom from 'core-js/full/set/from'; +import setOf from 'core-js/full/set/of'; +import weakSetFrom from 'core-js/full/weak-set/from'; +import weakSetOf from 'core-js/full/weak-set/of'; +import weakMapFrom from 'core-js/full/weak-map/from'; +import weakMapOf from 'core-js/full/weak-map/of'; const arrEntries: Array<[string, number]> = [['a', 1], ['b', 2]]; -const mapFrom: Map = Map.from(arrEntries, v => String(v)); -const mapFrom2: Map = Map.from(arrEntries, v => v > 1); -const mapFrom3: Map = Map.from(arrEntries); -const mapOf: Map = Map.of(['a', 1], ['b', 2]); -const setFrom: Set = Set.from(['a', 'b', 'c']); -const setFrom2: Set = Set.from([1, 2, 3], v => v * 2); -const setFrom3: Set = Set.from(['a', 'b', 'c'], String); -const setOf: Set = Set.of(1, 2, 3); +const resNS: Map = mapFrom(arrEntries, v => String(v)); +const resNS2: Map = mapOf(['a', 1], ['b', 2]); + +const res: Map = Map.from(arrEntries, v => String(v)); +const res2: Map = Map.from(arrEntries, v => v > 1); +const res3: Map = Map.from(arrEntries); +const res4: Map = Map.of(['a', 1], ['b', 2]); + +const resNS3: Set = setFrom([1, 2, 3], v => v * 2); +const resNS4: Set = setOf('a', 'b', 'c'); + +const res5: Set = Set.from(['a', 'b', 'c']); +const res6: Set = Set.from([1, 2, 3], v => v * 2); +const res7: Set = Set.from(['a', 'b', 'c'], String); +const res8: Set = Set.of(1, 2, 3); const ws1 = {}; const ws2 = {}; const wsArr = [ws1, ws2]; -const weakSetFrom: WeakSet<{ a?: number }> = WeakSet.from(wsArr); -const weakSetFrom2: WeakSet = WeakSet.from(wsArr, x => x); -const weakSetOf: WeakSet = WeakSet.of(ws1, ws2); + +const resNS5: WeakSet = weakSetFrom(wsArr); +const resNS6: WeakSet = weakSetOf(ws1, ws2); + +const res9: WeakSet<{ a?: number }> = WeakSet.from(wsArr); +const res10: WeakSet = WeakSet.from(wsArr, x => x); +const res11: WeakSet = WeakSet.of(ws1, ws2); const wmArr: Array<[object, string]> = [[ws1, 'a'], [ws2, 'b']]; -const weakMapFrom: WeakMap = WeakMap.from(wmArr); -const weakMapFrom2: WeakMap = WeakMap.from(wmArr, v => Number(v.length)); -const weakMapOf: WeakMap = WeakMap.of([ws1, 'a'], [ws2, 'b']); + +const resNS7: WeakMap = weakMapFrom(wmArr); +const resNS8: WeakMap = weakMapOf([ws1, 1], [ws2, 2]); + +const res12: WeakMap = WeakMap.from(wmArr); +const res13: WeakMap = WeakMap.from(wmArr, v => Number(v.length)); +const res14: WeakMap = WeakMap.of([ws1, 'a'], [ws2, 'b']); // @ts-expect-error Map.from(); diff --git a/tests/type-definitions/global/proposals/float16.test.ts b/tests/type-definitions/global/proposals/float16.test.ts index 810fc9e2c788..058af923d5d3 100644 --- a/tests/type-definitions/global/proposals/float16.test.ts +++ b/tests/type-definitions/global/proposals/float16.test.ts @@ -1,13 +1,20 @@ import 'core-js/full'; +import f16round from 'core-js/full/math/f16round'; +import { assertNumber } from '../../helpers'; -const res: number = Math.f16round(1); +assertNumber(f16round(1)); +// @ts-expect-error +f16round('123'); + +assertNumber(Math.f16round(1)); // @ts-expect-error Math.f16round('123'); const view = new DataView(new ArrayBuffer(4)); view.setFloat16(0, 1.5); -const res2: number = view.getFloat16(0); +assertNumber(view.getFloat16(0)); + // @ts-expect-error view.setFloat16(0, '123'); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/function-demethodize.test.ts b/tests/type-definitions/global/proposals/function-demethodize.test.ts index be44d65caf70..cd4b6f3edac5 100644 --- a/tests/type-definitions/global/proposals/function-demethodize.test.ts +++ b/tests/type-definitions/global/proposals/function-demethodize.test.ts @@ -1,9 +1,11 @@ import 'core-js/full'; +import demethodize from 'core-js/full/function/demethodize'; function sumTo(this: { base: number }, a: number, b: number): number { return this.base + a + b; } const sumToD = sumTo.demethodize(); +const sumToDNS = demethodize(sumTo); const rsumd: number = sumToD({ base: 1 }, 2, 3); // @ts-expect-error sumToD(2, 3); diff --git a/tests/type-definitions/global/proposals/is-error.test.ts b/tests/type-definitions/global/proposals/is-error.test.ts index fde89158e17f..1ca4a8c52c08 100644 --- a/tests/type-definitions/global/proposals/is-error.test.ts +++ b/tests/type-definitions/global/proposals/is-error.test.ts @@ -1,9 +1,15 @@ import 'core-js/full'; +import isError from 'core-js/full/error/is-error'; +import { assertBool } from '../../helpers'; const e = new Error(); const ne = { foo: 1 }; -const re1: boolean = Error.isError(e); +assertBool(isError(e)); +// @ts-expect-error +isError(); + +assertBool(Error.isError(e)); Error.isError(ne); Error.isError(undefined); Error.isError('str'); diff --git a/tests/type-definitions/global/proposals/iterator-chunking.test.ts b/tests/type-definitions/global/proposals/iterator-chunking.test.ts index 593ac5f267de..773f357233fe 100644 --- a/tests/type-definitions/global/proposals/iterator-chunking.test.ts +++ b/tests/type-definitions/global/proposals/iterator-chunking.test.ts @@ -1,14 +1,24 @@ import 'core-js/full'; +import chunks from 'core-js/full/iterator/chunks'; +import windows from 'core-js/full/iterator/windows'; declare function getNumberIterator(): Iterator; const numbersIter = getNumberIterator(); -const chunks: Iterator = numbersIter.chunks(2); -const windows: Iterator = numbersIter.windows(4); +const res1: Iterator = chunks(numbersIter, 2); +const res2: Iterator = windows(numbersIter, 4); -const chunkNext = chunks.next(); -const windowsNext = windows.next(); +// @ts-expect-error +chunks(); +// @ts-expect-error +windows(); + +const res3: Iterator = numbersIter.chunks(2); +const res4: Iterator = numbersIter.windows(4); + +const chunkNext = res1.next(); +const windowsNext = res2.next(); // @ts-expect-error numbersIter.chunks(); diff --git a/tests/type-definitions/global/proposals/iterator-helpers.test.ts b/tests/type-definitions/global/proposals/iterator-helpers.test.ts index 7f70d365e58d..a1c8ea3b5171 100644 --- a/tests/type-definitions/global/proposals/iterator-helpers.test.ts +++ b/tests/type-definitions/global/proposals/iterator-helpers.test.ts @@ -1,9 +1,22 @@ import 'core-js/full'; +import map from 'core-js/full/iterator/map'; +import filter from 'core-js/full/iterator/filter'; +import take from 'core-js/full/iterator/take'; +import drop from 'core-js/full/iterator/drop'; +import flatMap from 'core-js/full/iterator/flat-map'; +import reduce from 'core-js/full/iterator/reduce'; +import forEach from 'core-js/full/iterator/for-each'; +import some from 'core-js/full/iterator/some'; +import every from 'core-js/full/iterator/every'; +import find from 'core-js/full/iterator/find'; +import { assertBool, assertNumber, assertNumberArray, assertString } from '../../helpers'; declare const it: Iterator; declare const itStr: Iterator; declare const itNumStr: Iterator; +const mappedNumNS: Iterator = map(it, n => n + 1); + const mappedStr: Iterator = it.map((v, i) => String(v)); const mappedNum: Iterator = it.map(n => n + 1); @@ -12,6 +25,8 @@ it.map(); // @ts-expect-error it.map((v, i, extra) => v + i + extra); +const onlyEvenNS: Iterator = filter(it, v => v % 2 === 0); + const onlyEven: Iterator = it.filter(v => v % 2 === 0); const filtered: Iterator = it.filter((v): v is number => typeof v === 'number'); @@ -20,6 +35,8 @@ it.filter(); // @ts-expect-error it.filter((v, i, extra) => true); +const takenNS: Iterator = take(it, 5); + const taken: Iterator = it.take(5); // @ts-expect-error @@ -27,11 +44,15 @@ it.take(); // @ts-expect-error it.take('5'); +const droppedNS: Iterator = drop(it, 3); + const dropped: Iterator = it.drop(3); // @ts-expect-error it.drop('3'); +const flatMappedNS: Iterator = flatMap(it, (v, i) => itStr); + const flatMapped: Iterator = it.flatMap((v, i) => itStr); const flatMapped2: Iterator = it.flatMap((v, i) => ({ [Symbol.iterator]: function * () { @@ -42,19 +63,26 @@ const flatMapped2: Iterator = it.flatMap((v, i) => ({ // @ts-expect-error it.flatMap(); -const sum1: number = it.reduce((a, b, c) => a + b + c); -const sum2: number = it.reduce((a, b, c) => a + b + c, 0); -const strReduce: string = it.reduce( +assertNumber(reduce(it, (a, b, c) => a + b + c)); + +assertNumber(it.reduce((a, b, c) => a + b + c)); +assertNumber(it.reduce((a, b, c) => a + b + c, 0)); +assertString(it.reduce( (acc: string, val) => acc + val, '', -); +)); // @ts-expect-error it.reduce(); // @ts-expect-error it.reduce((a, b, c, d) => a); -const arr: number[] = it.toArray(); +assertNumberArray(it.toArray()); + +forEach(it, (value, idx) => { + const x: number = value; + const y: number = idx; +}); it.forEach((value, idx) => { const x: number = value; @@ -64,20 +92,24 @@ it.forEach((value, idx) => { // @ts-expect-error it.forEach(); -const hasPositive: boolean = it.some((v, i) => v > 0); +assertBool(some(it, (v, i) => v > 0)); +assertBool(it.some((v, i) => v > 0)); // @ts-expect-error it.some(); // @ts-expect-error it.some((v, i, extra) => true); -const allPositive: boolean = it.every((v, i) => v > 0); +assertBool(every(it, (v, i) => v > 0)); +assertBool(it.every((v, i) => v > 0)); // @ts-expect-error it.every(); // @ts-expect-error it.every((v, i, extra) => true); +const found1NS: number | undefined = find(it, (v, i) => v > 5); + const found1: number | undefined = it.find((v, i) => v > 5); const findString: string | number | undefined = itNumStr.find((v): v is string => typeof v === 'string'); diff --git a/tests/type-definitions/global/proposals/iterator-join.test.ts b/tests/type-definitions/global/proposals/iterator-join.test.ts index 9c21fbe3eaaf..499d98fcb635 100644 --- a/tests/type-definitions/global/proposals/iterator-join.test.ts +++ b/tests/type-definitions/global/proposals/iterator-join.test.ts @@ -1,13 +1,20 @@ import 'core-js/full'; +import join from 'core-js/full/iterator/join'; +import { assertString } from '../../helpers'; declare const it: Iterator; -const res1: string = it.join(); -const res2: string = it.join(' '); -const res3: string = it.join(5); -const res4: string = it.join(Symbol('x')); -const res5: string = it.join(undefined); -const res6: string = it.join(null); +assertString(join(it, ' ')); + +// @ts-expect-error +join(it, '+', '_'); + +assertString(it.join()); +assertString(it.join(' ')); +assertString(it.join(5)); +assertString(it.join(Symbol('x'))); +assertString(it.join(undefined)); +assertString(it.join(null)); // @ts-expect-error it.join('+', '_'); diff --git a/tests/type-definitions/global/proposals/iterator-joint.test.ts b/tests/type-definitions/global/proposals/iterator-joint.test.ts index 48a53cef92a1..2454eedbac02 100644 --- a/tests/type-definitions/global/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/global/proposals/iterator-joint.test.ts @@ -1,4 +1,12 @@ import 'core-js/full'; +import zip from 'core-js/full/iterator/zip'; +import zipKeyed from 'core-js/full/iterator/zip-keyed'; +import $Iterator from 'core-js/full/iterator'; + +zip([[1, 2, 3], [4, 5, 6]]); +$Iterator.zip([[1, 2, 3], [4, 5, 6]]); +zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); +$Iterator.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); Iterator.zip([[1, 2, 3], [4, 5, 6]]); Iterator.zip([['a', 'b', 'c'], ['d', 'e', 'f']]); diff --git a/tests/type-definitions/global/proposals/iterator-range.test.ts b/tests/type-definitions/global/proposals/iterator-range.test.ts index 599bde908a47..03ae49f0962a 100644 --- a/tests/type-definitions/global/proposals/iterator-range.test.ts +++ b/tests/type-definitions/global/proposals/iterator-range.test.ts @@ -1,10 +1,16 @@ import 'core-js/full'; +import range from 'core-js/full/iterator/range'; + +const res: Iterator = range(1, 10); + +// @ts-expect-error +Iterator.range(0, 'not-a-number'); const rir1: Iterator = Iterator.range(1, 10); Iterator.range(1, 10, 1); Iterator.range(1, 10, { step: 1 }); Iterator.range(1, 10, { inclusive: true }); -// todo for es6 +// TODO for es6 // const rir2: Iterator< bigint> = Iterator.range(BigInt(0), BigInt(10), { step: BigInt(2), inclusive: true }); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/iterator-sequencing.test.ts b/tests/type-definitions/global/proposals/iterator-sequencing.test.ts index 21a342cca779..285cd05f2aec 100644 --- a/tests/type-definitions/global/proposals/iterator-sequencing.test.ts +++ b/tests/type-definitions/global/proposals/iterator-sequencing.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import concat from 'core-js/full/iterator/concat'; declare const its1: Iterable; declare const arrs: string[]; @@ -6,6 +7,11 @@ declare const arrn: number[]; declare const arrb: boolean[]; declare const itb1: Iterable; +const resNS: Iterator = concat(arrn); + +// @ts-expect-error +concat(1); + const ri1: Iterator = Iterator.concat(its1); const ri2: Iterator = Iterator.concat(arrs); const ri3: Iterator = Iterator.concat(arrn); diff --git a/tests/type-definitions/global/proposals/json-parse-with-source.test.ts b/tests/type-definitions/global/proposals/json-parse-with-source.test.ts index d8c9a4944fd8..c712c0a00a7a 100644 --- a/tests/type-definitions/global/proposals/json-parse-with-source.test.ts +++ b/tests/type-definitions/global/proposals/json-parse-with-source.test.ts @@ -1,11 +1,22 @@ import 'core-js/full'; +import rawJSON from 'core-js/full/json/raw-json'; +import isRawJSON from 'core-js/full/json/is-raw-json'; +import { assertBool } from '../../helpers'; + +const resNS: CoreJSRawJSON = rawJSON('{"a":123}'); +assertBool(isRawJSON(resNS)); + +// @ts-expect-error +rawJSON(); +// @ts-expect-error +isRawJSON(); const r: CoreJSRawJSON = JSON.rawJSON('{"a":123}'); -const isr1: boolean = JSON.isRawJSON(r); -const isr2: boolean = JSON.isRawJSON({}); -const isr3: boolean = JSON.isRawJSON('abc'); -const isr4: boolean = JSON.isRawJSON(undefined); +assertBool(JSON.isRawJSON(r)); +assertBool(JSON.isRawJSON({})); +assertBool(JSON.isRawJSON('abc')); +assertBool(JSON.isRawJSON(undefined)); declare const smth: unknown; diff --git a/tests/type-definitions/global/proposals/map-upsert.test.ts b/tests/type-definitions/global/proposals/map-upsert.test.ts index 67e80f422712..8ca97b36ed91 100644 --- a/tests/type-definitions/global/proposals/map-upsert.test.ts +++ b/tests/type-definitions/global/proposals/map-upsert.test.ts @@ -1,9 +1,22 @@ import 'core-js/full'; +import mapGetOrInsert from 'core-js/full/map/get-or-insert'; +import mapGetOrInsertComputed from 'core-js/full/map/get-or-insert-computed'; +import wMapGetOrInsert from 'core-js/full/weak-map/get-or-insert'; +import wMapGetOrInsertComputed from 'core-js/full/weak-map/get-or-insert-computed'; +import { assertBool, assertNumber } from '../../helpers'; declare const map: Map; -const a: number = map.getOrInsert('x', 42); -const b: number = map.getOrInsertComputed('y', k => k.length); +assertNumber(mapGetOrInsert(map, 'a', 10)); +assertNumber(mapGetOrInsertComputed(map, 'b', k => k.length)); + +assertNumber(map.getOrInsert('x', 42)); +assertNumber(map.getOrInsertComputed('y', k => k.length)); + +// @ts-expect-error +mapGetOrInsert(map, 1, 2); +// @ts-expect-error +mapGetOrInsertComputed(map, 'x', (k: number) => k + 1); // @ts-expect-error map.getOrInsert(1, 2); @@ -14,8 +27,12 @@ map.getOrInsertComputed('x', (k: number) => k + 1); declare const wmap: WeakMap<{ id: number }, boolean>; -const wb: boolean = wmap.getOrInsert({ id: 1 }, true); +assertBool(wMapGetOrInsert(wmap, { id: 1 }, true)); +wMapGetOrInsertComputed(wmap, { id: 2 }, obj => obj.id === 2); + +assertBool(wmap.getOrInsert({ id: 1 }, true)); wmap.getOrInsertComputed({ id: 2 }, obj => obj.id === 2); + // @ts-expect-error wmap.getOrInsert(123, true); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/math-sum.test.ts b/tests/type-definitions/global/proposals/math-sum.test.ts index 0ba98a2f3222..224285f31594 100644 --- a/tests/type-definitions/global/proposals/math-sum.test.ts +++ b/tests/type-definitions/global/proposals/math-sum.test.ts @@ -1,13 +1,19 @@ import 'core-js/full'; +import sumPrecise from 'core-js/full/math/sum-precise'; +import { assertNumber } from '../../helpers'; -function acceptsNumber(x: number) {} declare const it: Iterable; -acceptsNumber(Math.sumPrecise(it)); -acceptsNumber(Math.sumPrecise([1, 2])); +assertNumber(sumPrecise(it)); + +assertNumber(Math.sumPrecise(it)); +assertNumber(Math.sumPrecise([1, 2])); // @ts-expect-error -Math.sumPrecise('10'); +sumPrecise('10'); +// @ts-expect-error +Math.sumPrecise('10'); // @ts-expect-error Math.sumPrecise(1, 2); + diff --git a/tests/type-definitions/global/proposals/number-clamp.test.ts b/tests/type-definitions/global/proposals/number-clamp.test.ts index 44617c511b3f..6b18a92329f7 100644 --- a/tests/type-definitions/global/proposals/number-clamp.test.ts +++ b/tests/type-definitions/global/proposals/number-clamp.test.ts @@ -1,8 +1,14 @@ import 'core-js/full'; +import clamp from 'core-js/full/number/clamp'; +import { assertNumber } from '../../helpers'; declare const num: number; -const clamped: number = num.clamp(0, 100); +assertNumber(num.clamp(0, 100)); +assertNumber(clamp(num, 0, 100)); + +// @ts-expect-error +clamp(num); // @ts-expect-error num.clamp(); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/object-from-entries.test.ts b/tests/type-definitions/global/proposals/object-from-entries.test.ts index b94077437001..56465b24e873 100644 --- a/tests/type-definitions/global/proposals/object-from-entries.test.ts +++ b/tests/type-definitions/global/proposals/object-from-entries.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import fromEntries from 'core-js/full/object/from-entries'; declare const objEntries: Iterable; declare const mixedEntries: Iterable; @@ -6,22 +7,23 @@ declare const wrongEntries1: Iterable; declare const wrongEntries2: number; declare const notIterable: {}; +const rNS1: { [k: string]: number } = fromEntries(objEntries); + const r1: { [k: string]: number } = Object.fromEntries(objEntries); const r2: any = Object.fromEntries(mixedEntries); const r3: any = Object.fromEntries([['a', 1], ['b', 2]]); const r4: object = Object.fromEntries(new Map([['x', 1], ['y', 2]])); // @ts-expect-error -Object.fromEntries(); +fromEntries(); +// @ts-expect-error +Object.fromEntries(); // @ts-expect-error Object.fromEntries(123); - // @ts-expect-error Object.fromEntries(wrongEntries1); - // @ts-expect-error Object.fromEntries(wrongEntries2); - // @ts-expect-error Object.fromEntries(notIterable); diff --git a/tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts b/tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts index b938ffbdf181..474f860bf96d 100644 --- a/tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts +++ b/tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts @@ -1,6 +1,11 @@ import 'core-js/full'; +import getOwnPropertyDescriptors from 'core-js/full/object/get-own-property-descriptors'; const obj = { a: 1, b: 'x', c: true }; + +const objDescsNS: { a: TypedPropertyDescriptor; b: TypedPropertyDescriptor; c: TypedPropertyDescriptor } & + { [x: string]: PropertyDescriptor } = getOwnPropertyDescriptors(obj); + const objDescs: { a: TypedPropertyDescriptor; b: TypedPropertyDescriptor; c: TypedPropertyDescriptor } & { [x: string]: PropertyDescriptor } = Object.getOwnPropertyDescriptors(obj); @@ -9,10 +14,13 @@ class Foo { baz() {} } const foo = new Foo(); + const fooDescs: { bar: TypedPropertyDescriptor; baz: TypedPropertyDescriptor<() => void> } & { [x: string]: PropertyDescriptor } = Object.getOwnPropertyDescriptors(foo); - const descsAny = Object.getOwnPropertyDescriptors({ x: 1, y: 2 }); +// @ts-expect-error +getOwnPropertyDescriptors(); + // @ts-expect-error Object.getOwnPropertyDescriptors(); diff --git a/tests/type-definitions/global/proposals/object-values-entries.test.ts b/tests/type-definitions/global/proposals/object-values-entries.test.ts index 618f329bc151..dd9df923ce14 100644 --- a/tests/type-definitions/global/proposals/object-values-entries.test.ts +++ b/tests/type-definitions/global/proposals/object-values-entries.test.ts @@ -1,4 +1,7 @@ import 'core-js/full'; +import values from 'core-js/full/object/values'; +import entries from 'core-js/full/object/entries'; +import { assertNumberArray, assertStringArray } from '../../helpers'; const obj = { a: 1, b: 2 }; const arr = [1, 2, 3]; @@ -6,11 +9,15 @@ const strArr = ['a', 'b', 'c']; const arrLike: ArrayLike = { 0: 10, 1: 20, length: 2 }; const emptyObj = {}; -const values1: number[] = Object.values(obj); -const values2: number[] = Object.values(arr); -const values3: string[] = Object.values(strArr); -const values4: number[] = Object.values(arrLike); -const values5: any[] = Object.values(emptyObj); +assertNumberArray(values(obj)); + +assertNumberArray(Object.values(obj)); +assertNumberArray(Object.values(arr)); +assertStringArray(Object.values(strArr)); +assertNumberArray(Object.values(arrLike)); +const res: any[] = Object.values(emptyObj); + +const entriesNS: [string, number][] = entries(obj); const entries1: [string, number][] = Object.entries(obj); const entries2: [string, number][] = Object.entries(arr); @@ -22,7 +29,11 @@ const valuesAnyArr: any[] = Object.values({ foo: 123, bar: 'baz' }); const entriesAnyArr: [string, any][] = Object.entries({ foo: 123, bar: 'baz' }); // @ts-expect-error -Object.values(); +values(); +// @ts-expect-error +entries(); +// @ts-expect-error +Object.values(); // @ts-expect-error Object.entries(); diff --git a/tests/type-definitions/global/proposals/promise-all-settled.test.ts b/tests/type-definitions/global/proposals/promise-all-settled.test.ts index 786f9f1f294d..d64bdf4045ba 100644 --- a/tests/type-definitions/global/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/global/proposals/promise-all-settled.test.ts @@ -1,4 +1,6 @@ import 'core-js/full'; +import allSettled from 'core-js/full/promise/all-settled'; +import $Promise from 'core-js/full/promise'; const promises = [Promise.resolve(1), Promise.resolve('foo'), 3] as const; const arr = [Promise.resolve(1), Promise.resolve(2)]; @@ -11,12 +13,14 @@ interface CoreJSPromiseResult { reason?: any; } +const settledNS: Promise[]> = allSettled(strArr); +const settledNS2: Promise[]> = $Promise.allSettled(strArr); + const settled1: Promise<[ CoreJSPromiseResult, CoreJSPromiseResult, CoreJSPromiseResult, ]> = Promise.allSettled(promises); - const settled2: Promise[]> = Promise.allSettled([Promise.resolve(10), Promise.resolve(20), 30]); const settled3: Promise[]> = Promise.allSettled(strArr); const settled4: Promise[]> = Promise.allSettled(new Set([1, 2, 3])); @@ -32,16 +36,17 @@ const settled7: Promise<[ ]> = Promise.allSettled(mixedTuple); // @ts-expect-error -Promise.allSettled(); +allSettled(); +// @ts-expect-error +$Promise.allSettled(); +// @ts-expect-error +Promise.allSettled(); // @ts-expect-error Promise.allSettled(5); - // @ts-expect-error Promise.allSettled({ foo: 123 }); - // @ts-expect-error Promise.allSettled([1, 2], 123); - // @ts-expect-error Promise.allSettled([Promise.resolve(1)], 'extra'); diff --git a/tests/type-definitions/global/proposals/promise-any.test.ts b/tests/type-definitions/global/proposals/promise-any.test.ts index 03c910826bce..638d7bca2e3b 100644 --- a/tests/type-definitions/global/proposals/promise-any.test.ts +++ b/tests/type-definitions/global/proposals/promise-any.test.ts @@ -1,4 +1,5 @@ import 'core-js/full'; +import promiseAny from 'core-js/full/promise/any'; const arr = [Promise.resolve(1), Promise.resolve('foo'), 3] as const; const justNumbers = [1, 2, 3]; @@ -7,6 +8,8 @@ const promiseLike = { then: (cb: (val: number) => void) => cb(123) }; const emptyTuple: [] = []; const mixed = [true, Promise.resolve('z')] as const; +const anyNS: Promise = promiseAny(arr); + const any1: Promise = Promise.any(arr); const any2: Promise = Promise.any(['x', 'y', Promise.resolve(5)]); const any3: Promise = Promise.any(emptyTuple); @@ -19,16 +22,15 @@ const any8: Promise = Promise.any(new Set([1])); const any9: Promise = Promise.any([Promise.resolve()]); // @ts-expect-error -Promise.any(); +promiseAny(); +// @ts-expect-error +Promise.any(); // @ts-expect-error Promise.any(123); - // @ts-expect-error Promise.any({ foo: 42 }); - // @ts-expect-error Promise.any([1, 2], 3); - // @ts-expect-error Promise.any(justNumbers, 'extra'); diff --git a/tests/type-definitions/global/proposals/promise-finally.test.ts b/tests/type-definitions/global/proposals/promise-finally.test.ts index b1de2f6c35d0..bc495e09448a 100644 --- a/tests/type-definitions/global/proposals/promise-finally.test.ts +++ b/tests/type-definitions/global/proposals/promise-finally.test.ts @@ -1,6 +1,10 @@ import 'core-js/full'; +import promiseFinally from 'core-js/full/promise/finally'; const p1 = Promise.resolve(42); + +const pfNS: Promise = promiseFinally(p1); + const pf1: Promise = p1.finally(); const pf2: Promise = p1.finally(undefined); const pf3: Promise = p1.finally(null); @@ -8,29 +12,28 @@ const pf4: Promise = p1.finally(() => {}); const pf5: Promise = p1.finally(function () {}); const p2 = Promise.reject('err'); + const pf6: Promise = p2.finally(); const pf7: Promise = p2.finally(() => {}); declare function returnsPromise(): Promise; + const genericF: Promise = returnsPromise().finally(() => {}); // @ts-expect-error -p1.finally(123); +promiseFinally(p1, 123); +// @ts-expect-error +p1.finally(123); // @ts-expect-error p1.finally('foo'); - // @ts-expect-error p1.finally({}); - // @ts-expect-error p1.finally([]); - // @ts-expect-error p1.finally(() => {}, 'extra'); - // @ts-expect-error p1.finally(true); - // @ts-expect-error p1.finally(Symbol('x')); diff --git a/tests/type-definitions/global/proposals/promise-try.test.ts b/tests/type-definitions/global/proposals/promise-try.test.ts index 19e1b0f31adb..21ee9b1f7dbf 100644 --- a/tests/type-definitions/global/proposals/promise-try.test.ts +++ b/tests/type-definitions/global/proposals/promise-try.test.ts @@ -1,4 +1,7 @@ import 'core-js/full'; +import promiseTry from 'core-js/full/promise/try'; + +const ptNS: Promise = promiseTry(() => 42); const pt1: Promise = Promise.try(() => 42); const pt2: Promise = Promise.try(() => Promise.resolve('hi')); @@ -14,22 +17,19 @@ declare function returnsPromise(): Promise; const pt9: Promise = Promise.try(() => returnsPromise()); // @ts-expect-error -Promise.try(); +promiseTry(); +// @ts-expect-error +Promise.try(); // @ts-expect-error Promise.try(42); - // @ts-expect-error Promise.try('callback'); - // @ts-expect-error Promise.try({}); - // @ts-expect-error Promise.try([]); - // @ts-expect-error Promise.try(() => 1, 2, 'a', Symbol('x')); - // @ts-expect-error Promise.try((a: boolean) => a, 123); diff --git a/tests/type-definitions/global/proposals/promise-with-resolvers.test.ts b/tests/type-definitions/global/proposals/promise-with-resolvers.test.ts index a22face5a074..320280681bb4 100644 --- a/tests/type-definitions/global/proposals/promise-with-resolvers.test.ts +++ b/tests/type-definitions/global/proposals/promise-with-resolvers.test.ts @@ -1,4 +1,8 @@ import 'core-js/full'; +import promiseWithResolvers from 'core-js/full/promise/with-resolvers'; + +const prNS = promiseWithResolvers(); +const pNS1: Promise = prNS.promise; const pr = Promise.withResolvers(); const pr2 = Promise.withResolvers(); @@ -28,7 +32,9 @@ gr.resolve(true); gr.reject(); // @ts-expect-error -Promise.withResolvers(123); +promiseWithResolvers(123); +// @ts-expect-error +Promise.withResolvers(123); // @ts-expect-error Promise.withResolvers(123); diff --git a/tests/type-definitions/global/proposals/regexp-escaping.test.ts b/tests/type-definitions/global/proposals/regexp-escaping.test.ts index 03fa454ee4c9..deb5fc6042c2 100644 --- a/tests/type-definitions/global/proposals/regexp-escaping.test.ts +++ b/tests/type-definitions/global/proposals/regexp-escaping.test.ts @@ -1,9 +1,13 @@ import 'core-js/full'; +import escape from 'core-js/full/regexp/escape'; +import { assertString } from '../../helpers'; -const escaped1: string = RegExp.escape('foo.*+?^${}()|[]\\'); -const escaped2: string = RegExp.escape(''); -const s = 'abc'; -const escaped3: string = RegExp.escape(s); +assertString(escape('foo.*+?^${}()|[]\\')); +assertString(RegExp.escape('foo.*+?^${}()|[]\\')); +assertString(RegExp.escape('')); + +// @ts-expect-error +escape(); // @ts-expect-error RegExp.escape(); diff --git a/tests/type-definitions/global/proposals/relative-indexing-method.test.ts b/tests/type-definitions/global/proposals/relative-indexing-method.test.ts index 1b7107a542d6..b17ebdb9f71a 100644 --- a/tests/type-definitions/global/proposals/relative-indexing-method.test.ts +++ b/tests/type-definitions/global/proposals/relative-indexing-method.test.ts @@ -1,10 +1,18 @@ import 'core-js/full'; +import stringAt from 'core-js/full/string/at'; +import arrayAt from 'core-js/full/array/at'; const str = 'hello'; + +const res: string | undefined = stringAt(str, 0); + const s1: string | undefined = str.at(0); const s2: string | undefined = str.at(-1); const arr: number[] = [10, 20, 30]; + +const res2: number | undefined = arrayAt(arr, 1); + const a1: number | undefined = arr.at(1); const a2: number | undefined = arr.at(-2); @@ -40,13 +48,16 @@ const f32$1: number | undefined = f32.at(-1); const f64 = new Float64Array([11.1, 22.2, 33.3]); const f64$1: number | undefined = f64.at(0); -// todo for es6 +// TODO for es6 // const bi64 = new (BigInt64Array as { new(arr: ArrayLike): BigInt64Array })([BigInt(1), BigInt(2), BigInt(3)]); // const bi64_1: bigint | undefined = bi64.at(2); // // const bu64 = new (BigUint64Array as { new(arr: ArrayLike): BigUint64Array })([BigInt(10), BigInt(20)]); // const bu64_1: bigint | undefined = bu64.at(-1); +// @ts-expect-error +stringAt(str); + // @ts-expect-error str.at(); // @ts-expect-error @@ -54,6 +65,9 @@ str.at('1'); // @ts-expect-error str.at(1, 2); +// @ts-expect-error +arrayAt(); + // @ts-expect-error arr.at(); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/set-methods.test.ts b/tests/type-definitions/global/proposals/set-methods.test.ts index 8e2b654c3975..7a5018ed02fe 100644 --- a/tests/type-definitions/global/proposals/set-methods.test.ts +++ b/tests/type-definitions/global/proposals/set-methods.test.ts @@ -1,4 +1,11 @@ import 'core-js/full'; +import setUnion from 'core-js/full/set/union'; +import setIntersection from 'core-js/full/set/intersection'; +import setDifference from 'core-js/full/set/difference'; +import setSymmetricDifference from 'core-js/full/set/symmetric-difference'; +import setIsSubsetOf from 'core-js/full/set/is-subset-of'; +import setIsSupersetOf from 'core-js/full/set/is-superset-of'; +import setIsDisjointFrom from 'core-js/full/set/is-disjoint-from'; const setA = new Set([1, 2, 3]); const setB = new Set(['a', 'b', 'c']); @@ -17,20 +24,33 @@ const setLikeStr: ReadonlySetLike = { const arrSet: ReadonlySet = new Set([4, 5, 6]); +const unionABNS: Set = setUnion(setA, setB); + const unionAB: Set = setA.union(setB); const unionAN: Set = setA.union(setLike); +const interABNS: Set = setIntersection(setA, setLike); + const interAB: Set = setA.intersection(setB); const interAN: Set = setA.intersection(setLike); +const diffABNS: Set = setDifference(setA, setB); + const diffAB: Set = setA.difference(setB); const diffAN: Set = setA.difference(setLike); +const symdiffALNS: Set = setSymmetricDifference(setA, setLike); + const symdiffAB: Set = setA.symmetricDifference(setB); const symdiffAL: Set = setA.symmetricDifference(setLike); +const subNS: boolean = setIsSubsetOf(setA, setLikeStr); const sub: boolean = setA.isSubsetOf(setLikeStr); + +const superSetNS: boolean = setIsSupersetOf(setA, setLikeStr); const superSet: boolean = setA.isSupersetOf(setLikeStr); + +const isDisjointNS: boolean = setIsDisjointFrom(setA, setLike); const isDisjoint: boolean = setA.isDisjointFrom(setLike); const unionR: Set = arrSet.union(setLike); diff --git a/tests/type-definitions/global/proposals/string-cooked.test.ts b/tests/type-definitions/global/proposals/string-cooked.test.ts index fcd8e13bd27e..164a93e42da8 100644 --- a/tests/type-definitions/global/proposals/string-cooked.test.ts +++ b/tests/type-definitions/global/proposals/string-cooked.test.ts @@ -1,8 +1,19 @@ import 'core-js/full'; +import cooked from 'core-js/full/string/cooked'; +import $String from 'core-js/full/string'; +import { assertString } from '../../helpers'; -const rcooked1: string = String.cooked(['foo', 'bar'], 1, 2); +assertString(cooked([])); +$String.cooked([]); + +assertString(String.cooked(['foo', 'bar'], 1, 2)); String.cooked([]); +// @ts-expect-error +$String.cooked(1); +// @ts-expect-error +cooked(1); + // @ts-expect-error String.cooked(1); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/string-dedent.test.ts b/tests/type-definitions/global/proposals/string-dedent.test.ts index 5d8f2b92484b..3bfcfd12ff14 100644 --- a/tests/type-definitions/global/proposals/string-dedent.test.ts +++ b/tests/type-definitions/global/proposals/string-dedent.test.ts @@ -1,9 +1,13 @@ import 'core-js/full'; +import dedent from 'core-js/full/string/dedent'; +import { assertString } from '../../helpers'; -const rdedent1: string = String.dedent`foo\nbar`; -const rdedent2: string = String.dedent`line1 +assertString(dedent`foo\nbar`); + +assertString(String.dedent`foo\nbar`); +assertString(String.dedent`line1 line2 - line3`; + line3`); const tpl = Object.assign(['foo', 'bar'], { raw: ['foo', 'bar'] }); String.dedent(tpl, 1, 2); @@ -21,5 +25,7 @@ myAndDedent`line1 // @ts-expect-error 'string\ndedent'.dedent(); +// @ts-expect-error +dedent(); // @ts-expect-error String.dedent(); diff --git a/tests/type-definitions/global/proposals/string-left-right-trim.test.ts b/tests/type-definitions/global/proposals/string-left-right-trim.test.ts index 0da6d7ed51a7..cce63802d0c6 100644 --- a/tests/type-definitions/global/proposals/string-left-right-trim.test.ts +++ b/tests/type-definitions/global/proposals/string-left-right-trim.test.ts @@ -1,10 +1,21 @@ import 'core-js/full'; +import trimEnd from 'core-js/full/string/trim-end'; +import trimStart from 'core-js/full/string/trim-start'; +import trimLeft from 'core-js/full/string/trim-left'; +import trimRight from 'core-js/full/string/trim-right'; +import { assertString } from '../../helpers'; const s = 'abc'; -const t1: string = s.trimEnd(); -const t2: string = s.trimStart(); -const t3: string = s.trimLeft(); -const t4: string = s.trimRight(); + +assertString(trimEnd(s)); +assertString(trimStart(s)); +assertString(trimLeft(s)); +assertString(trimRight(s)); + +assertString(s.trimEnd()); +assertString(s.trimStart()); +assertString(s.trimLeft()); +assertString(s.trimRight()); // @ts-expect-error s.trimEnd(123); diff --git a/tests/type-definitions/global/proposals/string-match-all.test.ts b/tests/type-definitions/global/proposals/string-match-all.test.ts index c7031ada18a1..204e77a1a01c 100644 --- a/tests/type-definitions/global/proposals/string-match-all.test.ts +++ b/tests/type-definitions/global/proposals/string-match-all.test.ts @@ -1,23 +1,23 @@ import 'core-js/full'; +import matchAll from 'core-js/full/string/match-all'; const s = 'abcabc'; const re = /abc/g; + +const matchIterNS: RegExpStringIterator = matchAll(s, re); const matchIter: RegExpStringIterator = s.matchAll(re); +// @ts-expect-error +matchAll(s); // @ts-expect-error s.matchAll(); - // @ts-expect-error s.matchAll('abc'); - // @ts-expect-error const n: number = s.matchAll(re); - // @ts-expect-error s.matchAll({}); - // @ts-expect-error s.matchAll(123); - // @ts-expect-error s.matchAll(/abc/g, /def/g); diff --git a/tests/type-definitions/global/proposals/string-padding.test.ts b/tests/type-definitions/global/proposals/string-padding.test.ts index 42e5c44aeea5..69ea24447eba 100644 --- a/tests/type-definitions/global/proposals/string-padding.test.ts +++ b/tests/type-definitions/global/proposals/string-padding.test.ts @@ -1,11 +1,22 @@ import 'core-js/full'; +import padStart from 'core-js/full/string/pad-start'; +import padEnd from 'core-js/full/string/pad-end'; +import { assertString } from '../../helpers'; const s = 'foo'; -const p1: string = s.padStart(5); -const p2: string = s.padStart(10, '0'); -const p3: string = s.padEnd(8); -const p4: string = s.padEnd(4, '-'); +assertString(padStart(s, 5)); +assertString(padEnd(s, 8)); + +assertString(s.padStart(5)); +assertString(s.padStart(10, '0')); +assertString(s.padEnd(8)); +assertString(s.padEnd(4, '-')); + +// @ts-expect-error +padStart(s); +// @ts-expect-error +padEnd(s); // @ts-expect-error s.padStart(); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/string-replace-all.test.ts b/tests/type-definitions/global/proposals/string-replace-all.test.ts index ac6e7ad6b449..a195c6e7d56b 100644 --- a/tests/type-definitions/global/proposals/string-replace-all.test.ts +++ b/tests/type-definitions/global/proposals/string-replace-all.test.ts @@ -1,7 +1,11 @@ import 'core-js/full'; +import replaceAll from 'core-js/full/string/replace-all'; +import { assertString } from '../../helpers'; const s = 'foo bar foo'; +assertString(replaceAll(s, 'foo', 'baz')); + const r1: string = s.replaceAll('foo', 'baz'); const r2: string = s.replaceAll(/foo/g, 'baz'); const r3: string = s.replaceAll('bar', (substr: string) => substr); @@ -9,26 +13,21 @@ const r4: string = s.replaceAll(/bar/g, (substr: string) => substr + 'Test'); const r5: string = s.replaceAll('foo', function (substring: string): string { return substring + '!'; }); const r6: string = s.replaceAll(/foo/g, (match: string, ...args: any[]) => match + args.length); +// @ts-expect-error +replaceAll(s); // @ts-expect-error s.replaceAll(); - // @ts-expect-error s.replaceAll('foo'); - // @ts-expect-error s.replaceAll('foo', 1); - // @ts-expect-error s.replaceAll('foo', {}); - // @ts-expect-error s.replaceAll(/foo/, 'bar', 'extra'); - // @ts-expect-error s.replaceAll(/foo/g, (match: string) => 123); - // @ts-expect-error s.replaceAll(/foo/g, 5); - // @ts-expect-error const n: number = s.replaceAll('foo', 'baz'); diff --git a/tests/type-definitions/global/proposals/symbol-predicates.test.ts b/tests/type-definitions/global/proposals/symbol-predicates.test.ts index 5cad02b9fd39..84a3bd542878 100644 --- a/tests/type-definitions/global/proposals/symbol-predicates.test.ts +++ b/tests/type-definitions/global/proposals/symbol-predicates.test.ts @@ -1,17 +1,34 @@ import 'core-js/full'; +import isRegisteredSymbol from 'core-js/full/symbol/is-registered-symbol'; +import isWellKnownSymbol from 'core-js/full/symbol/is-well-known-symbol'; +import $Symbol from 'core-js/full/symbol'; +import { assertBool } from '../../helpers'; -const rsymbol1: boolean = Symbol.isRegisteredSymbol(Symbol.for('foo')); -const rsymbol2: boolean = Symbol.isRegisteredSymbol(undefined); -const rsymbol3: boolean = Symbol.isRegisteredSymbol(Symbol('bar')); +assertBool(isRegisteredSymbol($Symbol.for('foo'))); +assertBool(isWellKnownSymbol($Symbol.iterator)); +assertBool($Symbol.isRegisteredSymbol($Symbol.for('foo'))); +assertBool($Symbol.isWellKnownSymbol($Symbol.iterator)); -const rsymbol4: boolean = Symbol.isWellKnownSymbol(Symbol.iterator); -const rsymbol5: boolean = Symbol.isWellKnownSymbol({}); -const rsymbol6: boolean = Symbol.isWellKnownSymbol(Symbol('baz')); +assertBool(Symbol.isRegisteredSymbol(Symbol.for('foo'))); +assertBool(Symbol.isRegisteredSymbol(undefined)); +assertBool(Symbol.isRegisteredSymbol(Symbol('bar'))); + +assertBool(Symbol.isWellKnownSymbol(Symbol.iterator)); +assertBool(Symbol.isWellKnownSymbol({})); +assertBool(Symbol.isWellKnownSymbol(Symbol('baz'))); declare const u: unknown; Symbol.isRegisteredSymbol(u); Symbol.isWellKnownSymbol(u); +// @ts-expect-error +isRegisteredSymbol(); +// @ts-expect-error +$Symbol.isRegisteredSymbol(); +// @ts-expect-error +isWellKnownSymbol(); +// @ts-expect-error +$Symbol.isWellKnownSymbol(); // @ts-expect-error Symbol.isRegisteredSymbol(); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts b/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts index e089e4857fa2..985a1306d2ff 100644 --- a/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts +++ b/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts @@ -1,8 +1,20 @@ import 'core-js/full'; +import isWellFormed from 'core-js/full/string/is-well-formed'; +import toWellFormed from 'core-js/full/string/to-well-formed'; +import { assertBool, assertString } from '../../helpers'; const s = 'test'; -const b: boolean = s.isWellFormed(); -const str: string = s.toWellFormed(); + +assertBool(isWellFormed(s)); +assertString(toWellFormed(s)); + +assertBool(s.isWellFormed()); +assertString(s.toWellFormed()); + +// @ts-expect-error +isWellFormed(123); +// @ts-expect-error +toWellFormed([]); // @ts-expect-error s.isWellFormed(123); diff --git a/tests/type-definitions/global/web/atob.test.ts b/tests/type-definitions/global/web/atob.test.ts index 64e5b59f7194..47fedcc86aed 100644 --- a/tests/type-definitions/global/web/atob.test.ts +++ b/tests/type-definitions/global/web/atob.test.ts @@ -1,7 +1,13 @@ import 'core-js/full'; +import $atob from 'core-js/full/atob'; +import { assertString } from '../../helpers'; -const s: string = atob('SGVsbG8gd29ybGQ='); +assertString($atob('SGVsbG8gd29ybGQ=')); +assertString(atob('SGVsbG8gd29ybGQ=')); + +// @ts-expect-error +$atob(); // @ts-expect-error atob(); // @ts-expect-error diff --git a/tests/type-definitions/global/web/btoa.test.ts b/tests/type-definitions/global/web/btoa.test.ts index 23fd5a256318..dedb30acd0b0 100644 --- a/tests/type-definitions/global/web/btoa.test.ts +++ b/tests/type-definitions/global/web/btoa.test.ts @@ -1,10 +1,16 @@ import 'core-js/full'; +import $btoa from 'core-js/full/btoa'; +import { assertString } from '../../helpers'; -const s: string = btoa('SGVsbG8gd29ybGQ='); +assertString($btoa('SGVsbG8gd29ybGQ=')); +assertString(btoa('SGVsbG8gd29ybGQ=')); + +// @ts-expect-error +$btoa(); // @ts-expect-error -atob(); +btoa(); // @ts-expect-error -atob(123); +btoa(123); // @ts-expect-error -atob({}); +btoa({}); diff --git a/tests/type-definitions/global/web/efficient-script-yielding.test.ts b/tests/type-definitions/global/web/efficient-script-yielding.test.ts index ba0e97df8056..761b66379a2f 100644 --- a/tests/type-definitions/global/web/efficient-script-yielding.test.ts +++ b/tests/type-definitions/global/web/efficient-script-yielding.test.ts @@ -1,8 +1,18 @@ import 'core-js/full'; +import $setImmediate from 'core-js/full/set-immediate'; +import $clearImmediate from 'core-js/full/clear-immediate'; + +const resNS: number | object = $setImmediate(() => 42); +$clearImmediate(resNS); const res: number | object = setImmediate(() => 42); clearImmediate(res); +// @ts-expect-error +$setImmediate(); +// @ts-expect-error +$clearImmediate('str'); + // @ts-expect-error setImmediate(); // @ts-expect-error diff --git a/tests/type-definitions/global/web/queue-microtask.test.ts b/tests/type-definitions/global/web/queue-microtask.test.ts index 0ce0553e994f..c146e1e94b6d 100644 --- a/tests/type-definitions/global/web/queue-microtask.test.ts +++ b/tests/type-definitions/global/web/queue-microtask.test.ts @@ -1,8 +1,14 @@ import 'core-js/full'; +import $queueMicrotask from 'core-js/full/queue-microtask'; + +$queueMicrotask((): void => {}); queueMicrotask((): void => {}); queueMicrotask(function (): void {}); +// @ts-expect-error +$queueMicrotask(); + // @ts-expect-error queueMicrotask(); // @ts-expect-error diff --git a/tests/type-definitions/global/web/structured-clone.test.ts b/tests/type-definitions/global/web/structured-clone.test.ts index 45225ae242cb..fccbda04298f 100644 --- a/tests/type-definitions/global/web/structured-clone.test.ts +++ b/tests/type-definitions/global/web/structured-clone.test.ts @@ -1,12 +1,19 @@ import 'core-js/full'; +import $structuredClone from 'core-js/full/structured-clone'; +import { assertNumber, assertString } from '../../helpers'; -const n: number = structuredClone(5); -const s: string = structuredClone('text'); +assertNumber($structuredClone(5)); + +assertNumber(structuredClone(5)); +assertString(structuredClone('text')); declare const buffer: ArrayBuffer; const obj = { buffer }; const cloned: typeof obj = structuredClone(obj, { transfer: [buffer] }); +// @ts-expect-error +$structuredClone(); + // @ts-expect-error structuredClone(); // @ts-expect-error diff --git a/tests/type-definitions/helpers.pure.ts b/tests/type-definitions/helpers.pure.ts new file mode 100644 index 000000000000..1b089a55c45b --- /dev/null +++ b/tests/type-definitions/helpers.pure.ts @@ -0,0 +1,71 @@ +interface CoreJSPromiseLike { + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; + + finally(onfinally?: (() => void) | undefined | null): PromiseLike; +} +export function assertCoreJSPromiseLike(value: CoreJSPromiseLike): asserts value is CoreJSPromiseLike {} + +export interface CoreJSMapLike extends Map { + getOrInsert(key: K, value: V): V; + + getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; +} +export function assertCoreJSMapLike(value: CoreJSMapLike): asserts value is CoreJSMapLike {} + +export interface CoreJSWeakMapLike extends WeakMap { + getOrInsert(key: K, value: V): V; + + getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; +} +export function assertCoreJSWeakMapLike(value: CoreJSWeakMapLike): asserts value is CoreJSWeakMapLike {} + +export interface CoreJSSetLike extends Set { + union(...args: any[]): CoreJSSetLike; + intersection(...args: any[]): CoreJSSetLike; + difference(...args: any[]): CoreJSSetLike; + symmetricDifference(...args: any[]): CoreJSSetLike; + isSubsetOf(...args: any[]): boolean; + isSupersetOf(...args: any[]): boolean; + isDisjointFrom(...args: any[]): boolean; +} +export function assertCoreJSSetLike(value: CoreJSSetLike): asserts value is CoreJSSetLike {} + +export interface CoreJSWeakSetLike extends WeakSet {} +export function assertCoreJSWeakSetLike(value: CoreJSWeakSetLike): asserts value is CoreJSWeakSetLike {} + +// TNext undefined added because of until TS 5.6 Iterator used undefined as TNext defaults +export interface CoreJSIteratorLike extends Iterator { + chunks(...args: any[]): CoreJSIteratorLike; + windows(...args: any[]): CoreJSIteratorLike; + map(...args: any[]): CoreJSIteratorLike; + filter(...args: any[]): CoreJSIteratorLike; + take(...args: any[]): CoreJSIteratorLike; + drop(...args: any[]): CoreJSIteratorLike; + flatMap(...args: any[]): CoreJSIteratorLike; + reduce(...args: any[]): CoreJSIteratorLike; + toArray(): T[]; + forEach(...args: any[]): void; + some(...args: any[]): boolean; + every(...args: any[]): boolean; + find(...args: any[]): T | undefined; + join(...args: any[]): string; +} +export function assertCoreJSIteratorLike(value: CoreJSIteratorLike): asserts value is CoreJSIteratorLike {} + +interface CoreJSAsyncIteratorLike { + drop(...args: any[]): any; + every(...args: any[]): any; + filter(predicate: (value: T, index: number) => boolean): CoreJSAsyncIteratorLike; + find(...args: any[]): any; + flatMap(...args: any[]): any; + forEach(...args: any[]): any; + map(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorLike; + reduce(...args: any[]): any; + some(...args: any[]): any; + take(limit: number): CoreJSAsyncIteratorLike; + toArray(...args: any[]): any; +} +export function assertCoreJSAsyncIteratorLike(value: CoreJSAsyncIteratorLike): asserts value is CoreJSAsyncIteratorLike {} + +type HasCause = 'cause' extends keyof T ? T : never; +export function assertHasCause(value: T): asserts value is HasCause & { cause: unknown } {} diff --git a/tests/type-definitions/helpers.ts b/tests/type-definitions/helpers.ts index 1b089a55c45b..90d997bcaa0c 100644 --- a/tests/type-definitions/helpers.ts +++ b/tests/type-definitions/helpers.ts @@ -1,71 +1,7 @@ -interface CoreJSPromiseLike { - then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; +export function assertNumber(x: number) {} - finally(onfinally?: (() => void) | undefined | null): PromiseLike; -} -export function assertCoreJSPromiseLike(value: CoreJSPromiseLike): asserts value is CoreJSPromiseLike {} +export function assertNumberArray(x: number[]) {} -export interface CoreJSMapLike extends Map { - getOrInsert(key: K, value: V): V; - - getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; -} -export function assertCoreJSMapLike(value: CoreJSMapLike): asserts value is CoreJSMapLike {} - -export interface CoreJSWeakMapLike extends WeakMap { - getOrInsert(key: K, value: V): V; - - getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; -} -export function assertCoreJSWeakMapLike(value: CoreJSWeakMapLike): asserts value is CoreJSWeakMapLike {} - -export interface CoreJSSetLike extends Set { - union(...args: any[]): CoreJSSetLike; - intersection(...args: any[]): CoreJSSetLike; - difference(...args: any[]): CoreJSSetLike; - symmetricDifference(...args: any[]): CoreJSSetLike; - isSubsetOf(...args: any[]): boolean; - isSupersetOf(...args: any[]): boolean; - isDisjointFrom(...args: any[]): boolean; -} -export function assertCoreJSSetLike(value: CoreJSSetLike): asserts value is CoreJSSetLike {} - -export interface CoreJSWeakSetLike extends WeakSet {} -export function assertCoreJSWeakSetLike(value: CoreJSWeakSetLike): asserts value is CoreJSWeakSetLike {} - -// TNext undefined added because of until TS 5.6 Iterator used undefined as TNext defaults -export interface CoreJSIteratorLike extends Iterator { - chunks(...args: any[]): CoreJSIteratorLike; - windows(...args: any[]): CoreJSIteratorLike; - map(...args: any[]): CoreJSIteratorLike; - filter(...args: any[]): CoreJSIteratorLike; - take(...args: any[]): CoreJSIteratorLike; - drop(...args: any[]): CoreJSIteratorLike; - flatMap(...args: any[]): CoreJSIteratorLike; - reduce(...args: any[]): CoreJSIteratorLike; - toArray(): T[]; - forEach(...args: any[]): void; - some(...args: any[]): boolean; - every(...args: any[]): boolean; - find(...args: any[]): T | undefined; - join(...args: any[]): string; -} -export function assertCoreJSIteratorLike(value: CoreJSIteratorLike): asserts value is CoreJSIteratorLike {} - -interface CoreJSAsyncIteratorLike { - drop(...args: any[]): any; - every(...args: any[]): any; - filter(predicate: (value: T, index: number) => boolean): CoreJSAsyncIteratorLike; - find(...args: any[]): any; - flatMap(...args: any[]): any; - forEach(...args: any[]): any; - map(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorLike; - reduce(...args: any[]): any; - some(...args: any[]): any; - take(limit: number): CoreJSAsyncIteratorLike; - toArray(...args: any[]): any; -} -export function assertCoreJSAsyncIteratorLike(value: CoreJSAsyncIteratorLike): asserts value is CoreJSAsyncIteratorLike {} - -type HasCause = 'cause' extends keyof T ? T : never; -export function assertHasCause(value: T): asserts value is HasCause & { cause: unknown } {} +export function assertString(x: string) {} +export function assertStringArray(x: string[]) {} +export function assertBool(x: boolean) {} diff --git a/tests/type-definitions/pure/proposals/array-from-async.test.ts b/tests/type-definitions/pure/proposals/array-from-async.test.ts index bed6815b8dd9..3ede7dbf32a5 100644 --- a/tests/type-definitions/pure/proposals/array-from-async.test.ts +++ b/tests/type-definitions/pure/proposals/array-from-async.test.ts @@ -1,6 +1,6 @@ import arrayFromAsync from '@core-js/pure/full/array/from-async'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers.pure'; const p1 = arrayFromAsync([1, 2, 3]); assertCoreJSPromiseLike(p1); diff --git a/tests/type-definitions/pure/proposals/array-grouping.test.ts b/tests/type-definitions/pure/proposals/array-grouping.test.ts index dc9ad1d3b48e..774520160b58 100644 --- a/tests/type-definitions/pure/proposals/array-grouping.test.ts +++ b/tests/type-definitions/pure/proposals/array-grouping.test.ts @@ -1,6 +1,6 @@ import objectGroupBy from '@core-js/pure/full/object/group-by'; import mapGroupBy from '@core-js/pure/full/map/group-by'; -import { assertCoreJSMapLike } from '../../helpers'; +import { assertCoreJSMapLike } from '../../helpers.pure'; const arr = [1, 2, 3, 4, 5]; const objGroup: Partial> = objectGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index c621397cbb9b..5a3a2f15a938 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -11,7 +11,7 @@ import some from '@core-js/pure/full/async-iterator/some'; import take from '@core-js/pure/full/async-iterator/take'; import toArray from '@core-js/pure/full/async-iterator/to-array'; import toAsync from '@core-js/pure/full/iterator/to-async'; -import { assertCoreJSAsyncIteratorLike, assertCoreJSPromiseLike } from '../../helpers'; +import { assertCoreJSAsyncIteratorLike, assertCoreJSPromiseLike } from '../../helpers.pure'; const aitn = from([1]); assertCoreJSAsyncIteratorLike(aitn); diff --git a/tests/type-definitions/pure/proposals/await-dictionary.test.ts b/tests/type-definitions/pure/proposals/await-dictionary.test.ts index 2c13b652fb1f..1e4c61ee078d 100644 --- a/tests/type-definitions/pure/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/pure/proposals/await-dictionary.test.ts @@ -1,7 +1,7 @@ import promiseAllKeyed from '@core-js/pure/full/promise/all-keyed'; import promiseAllSettledKeyed from '@core-js/pure/full/promise/all-settled-keyed'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers.pure'; const res = promiseAllKeyed({ a: promiseResolve(1), diff --git a/tests/type-definitions/pure/proposals/collection-of-from.test.ts b/tests/type-definitions/pure/proposals/collection-of-from.test.ts index 3866762cf02c..31dad6e3a457 100644 --- a/tests/type-definitions/pure/proposals/collection-of-from.test.ts +++ b/tests/type-definitions/pure/proposals/collection-of-from.test.ts @@ -6,7 +6,7 @@ import weakMapFrom from '@core-js/pure/full/weak-map/from'; import weakMapOf from '@core-js/pure/full/weak-map/of'; import weakSetFrom from '@core-js/pure/full/weak-set/from'; import weakSetOf from '@core-js/pure/full/weak-set/of'; -import { assertCoreJSMapLike, assertCoreJSSetLike, assertCoreJSWeakMapLike, assertCoreJSWeakSetLike } from '../../helpers'; +import { assertCoreJSMapLike, assertCoreJSSetLike, assertCoreJSWeakMapLike, assertCoreJSWeakSetLike } from '../../helpers.pure'; const rm = mapFrom([[1, 'a'], [2, 'b']] as [number, string][]); assertCoreJSMapLike(rm); diff --git a/tests/type-definitions/pure/proposals/error-cause.test.ts b/tests/type-definitions/pure/proposals/error-cause.test.ts index 9dfc20693a1f..df58bfd33352 100644 --- a/tests/type-definitions/pure/proposals/error-cause.test.ts +++ b/tests/type-definitions/pure/proposals/error-cause.test.ts @@ -1,6 +1,6 @@ import $AggregateError from '@core-js/pure/full/aggregate-error'; // import $Error from '@core-js/pure/full/error'; TODO separated entry points -import { assertHasCause } from '../../helpers'; +import { assertHasCause } from '../../helpers.pure'; const prevError = new Error('Prev error'); const someError = new Error('Some error'); diff --git a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts index b411c217fa32..4dff03fc1ed4 100644 --- a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts @@ -7,7 +7,7 @@ import asyncIteratorFrom from '@core-js/pure/full/async-iterator/from'; import $SuppressedError from '@core-js/pure/full/suppressed-error/constructor'; import $DisposableStack from '@core-js/pure/full/disposable-stack/constructor'; import $AsyncDisposableStack from '@core-js/pure/full/async-disposable-stack/constructor'; -import { assertCoreJSPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers.pure'; const d: symbol = symbolDispose; const ad: symbol = symbolAsyncDispose; diff --git a/tests/type-definitions/pure/proposals/iterator-chunking.test.ts b/tests/type-definitions/pure/proposals/iterator-chunking.test.ts index 3bbb57c0e2fe..3114612aa2db 100644 --- a/tests/type-definitions/pure/proposals/iterator-chunking.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-chunking.test.ts @@ -1,6 +1,6 @@ import iteratorChunks from '@core-js/pure/full/iterator/chunks'; import iteratorWindows from '@core-js/pure/full/iterator/windows'; -import { assertCoreJSIteratorLike } from '../../helpers'; +import { assertCoreJSIteratorLike } from '../../helpers.pure'; declare function getNumberIterator(): Iterator; diff --git a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts index ef754d312eb7..b51136a7cfab 100644 --- a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts @@ -9,7 +9,7 @@ import iteratorForEach from '@core-js/pure/full/iterator/for-each'; import iteratorSome from '@core-js/pure/full/iterator/some'; import iteratorEvery from '@core-js/pure/full/iterator/every'; import iteratorFind from '@core-js/pure/full/iterator/find'; -import { assertCoreJSIteratorLike } from '../../helpers'; +import { assertCoreJSIteratorLike } from '../../helpers.pure'; declare const it: Iterator; declare const itStr: Iterator; diff --git a/tests/type-definitions/pure/proposals/iterator-joint.test.ts b/tests/type-definitions/pure/proposals/iterator-joint.test.ts index e1aa6318fae5..3a952a217ea7 100644 --- a/tests/type-definitions/pure/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-joint.test.ts @@ -1,6 +1,6 @@ import iteratorZip from '@core-js/pure/full/iterator/zip'; import iteratorZipKeyed from '@core-js/pure/full/iterator/zip-keyed'; -import { assertCoreJSIteratorLike } from '../../helpers'; +import { assertCoreJSIteratorLike } from '../../helpers.pure'; const zipped1 = iteratorZip([[1, 2, 3], [4, 5, 6]]); assertCoreJSIteratorLike(zipped1); diff --git a/tests/type-definitions/pure/proposals/iterator-range.test.ts b/tests/type-definitions/pure/proposals/iterator-range.test.ts index bc78fe7232f7..458c2c5c6fb7 100644 --- a/tests/type-definitions/pure/proposals/iterator-range.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-range.test.ts @@ -1,5 +1,5 @@ import iteratorRange from '@core-js/pure/full/iterator/range'; -import { assertCoreJSIteratorLike } from '../../helpers'; +import { assertCoreJSIteratorLike } from '../../helpers.pure'; const rir1 = iteratorRange(1, 10); assertCoreJSIteratorLike(rir1); diff --git a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts index 27cd7bee11a7..8b74cbbcf7c3 100644 --- a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts @@ -1,5 +1,5 @@ import iteratorConcat from '@core-js/pure/full/iterator/concat'; -import { assertCoreJSIteratorLike } from '../../helpers'; +import { assertCoreJSIteratorLike } from '../../helpers.pure'; declare const its1: Iterable; declare const arrs: string[]; diff --git a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts index 94a6e6d8ef34..43e3eab0c0e3 100644 --- a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts @@ -1,6 +1,6 @@ import promiseAllSettled from '@core-js/pure/full/promise/all-settled'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers.pure'; interface CoreJSPromiseResult { status: string; diff --git a/tests/type-definitions/pure/proposals/promise-any.test.ts b/tests/type-definitions/pure/proposals/promise-any.test.ts index b7a78c9d4763..b75277ff5fef 100644 --- a/tests/type-definitions/pure/proposals/promise-any.test.ts +++ b/tests/type-definitions/pure/proposals/promise-any.test.ts @@ -1,6 +1,6 @@ import promiseAny from '@core-js/pure/full/promise/any'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers.pure'; const arr = [promiseResolve(1), promiseResolve('foo'), 3] as const; const justNumbers = [1, 2, 3]; diff --git a/tests/type-definitions/pure/proposals/promise-finally.test.ts b/tests/type-definitions/pure/proposals/promise-finally.test.ts index 4c29d7d86707..8d4b8edb87dc 100644 --- a/tests/type-definitions/pure/proposals/promise-finally.test.ts +++ b/tests/type-definitions/pure/proposals/promise-finally.test.ts @@ -1,7 +1,7 @@ import promiseFinally from '@core-js/pure/full/promise/finally'; import promiseResolve from '@core-js/pure/full/promise/resolve'; import promiseReject from '@core-js/pure/full/promise/reject'; -import { assertCoreJSPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers.pure'; const pr1 = promiseResolve(42); assertCoreJSPromiseLike(pr1); diff --git a/tests/type-definitions/pure/proposals/promise-try.test.ts b/tests/type-definitions/pure/proposals/promise-try.test.ts index 506c5996c2e6..6c75e85cac19 100644 --- a/tests/type-definitions/pure/proposals/promise-try.test.ts +++ b/tests/type-definitions/pure/proposals/promise-try.test.ts @@ -1,6 +1,6 @@ import promiseTry from '@core-js/pure/full/promise/try'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers.pure'; const pt1 = promiseTry(() => 42); assertCoreJSPromiseLike(pt1); diff --git a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts index 23aa94e210f8..a215cf0ce93e 100644 --- a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts +++ b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts @@ -1,6 +1,6 @@ import promiseWithResolvers from '@core-js/pure/full/promise/with-resolvers'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers'; +import { assertCoreJSPromiseLike } from '../../helpers.pure'; const pr = promiseWithResolvers(); const pr2 = promiseWithResolvers(); diff --git a/tests/type-definitions/pure/proposals/set-methods.test.ts b/tests/type-definitions/pure/proposals/set-methods.test.ts index 4f376230d0d0..f7e02a909629 100644 --- a/tests/type-definitions/pure/proposals/set-methods.test.ts +++ b/tests/type-definitions/pure/proposals/set-methods.test.ts @@ -6,7 +6,7 @@ import setSymmetricDifference from '@core-js/pure/full/set/symmetric-difference' import setIsSubsetOf from '@core-js/pure/full/set/is-subset-of'; import setIsSupersetOf from '@core-js/pure/full/set/is-superset-of'; import setIsDisjointFrom from '@core-js/pure/full/set/is-disjoint-from'; -import { assertCoreJSSetLike } from '../../helpers'; +import { assertCoreJSSetLike } from '../../helpers.pure'; const setA = new $Set([1, 2, 3]); const setB = new $Set(['a', 'b', 'c']); From 0afd60d7545b90ed63bd188815f318564e548336 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 5 Feb 2026 19:37:15 +0700 Subject: [PATCH 177/315] Update feature namespaces in type tests according to support --- .../accessible-object-hasownproperty.test.ts | 6 ++--- .../proposals/array-buffer-base64.test.ts | 4 ++-- .../proposals/array-buffer-transfer.test.ts | 4 ++-- .../proposals/array-find-from-last.test.ts | 10 ++++----- .../global/proposals/array-flat-map.test.ts | 6 ++--- .../global/proposals/array-from-async.test.ts | 12 +++++----- .../global/proposals/array-grouping.test.ts | 6 ++--- .../global/proposals/array-includes.test.ts | 4 ++-- .../proposals/change-array-by-copy.test.ts | 10 ++++----- .../global/proposals/float16.test.ts | 4 ++-- .../global/proposals/is-error.test.ts | 4 ++-- .../global/proposals/iterator-helpers.test.ts | 22 +++++++++---------- .../global/proposals/iterator-joint.test.ts | 8 +++---- .../proposals/iterator-sequencing.test.ts | 4 ++-- .../proposals/json-parse-with-source.test.ts | 6 ++--- .../global/proposals/map-upsert.test.ts | 10 ++++----- .../global/proposals/math-sum.test.ts | 4 ++-- .../proposals/object-from-entries.test.ts | 4 ++-- ...bject-get-own-property-descriptors.test.ts | 4 ++-- .../proposals/object-values-entries.test.ts | 6 ++--- .../proposals/promise-all-settled.test.ts | 6 ++--- .../global/proposals/promise-any.test.ts | 4 ++-- .../global/proposals/promise-finally.test.ts | 4 ++-- .../global/proposals/promise-try.test.ts | 4 ++-- .../proposals/promise-with-resolvers.test.ts | 4 ++-- .../global/proposals/regexp-escaping.test.ts | 4 ++-- .../relative-indexing-method.test.ts | 6 ++--- .../global/proposals/set-methods.test.ts | 16 +++++++------- .../proposals/string-left-right-trim.test.ts | 10 ++++----- .../global/proposals/string-match-all.test.ts | 4 ++-- .../global/proposals/string-padding.test.ts | 6 ++--- .../proposals/string-replace-all.test.ts | 4 ++-- .../well-formed-unicode-strings.test.ts | 6 ++--- .../type-definitions/global/web/atob.test.ts | 4 ++-- .../type-definitions/global/web/btoa.test.ts | 4 ++-- .../web/efficient-script-yielding.test.ts | 6 ++--- .../global/web/queue-microtask.test.ts | 4 ++-- .../global/web/structured-clone.test.ts | 4 ++-- 38 files changed, 119 insertions(+), 119 deletions(-) diff --git a/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts b/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts index 07b7b821d714..c20ffe587e0c 100644 --- a/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts +++ b/tests/type-definitions/global/proposals/accessible-object-hasownproperty.test.ts @@ -1,6 +1,6 @@ -import 'core-js/full'; -import hasOwn from 'core-js/full/object/has-own'; -import $Object from 'core-js/full/object'; +import 'core-js/es'; +import hasOwn from 'core-js/es/object/has-own'; +import $Object from 'core-js/es/object'; $Object.hasOwn({ a: 1 }, 'a'); hasOwn({ a: 1 }, 'a'); diff --git a/tests/type-definitions/global/proposals/array-buffer-base64.test.ts b/tests/type-definitions/global/proposals/array-buffer-base64.test.ts index d938f11da1bc..1d0a06e42faa 100644 --- a/tests/type-definitions/global/proposals/array-buffer-base64.test.ts +++ b/tests/type-definitions/global/proposals/array-buffer-base64.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import $Uint8Array from 'core-js/full/typed-array/uint8-array'; +import 'core-js/es'; +import $Uint8Array from 'core-js/es/typed-array/uint8-array'; $Uint8Array.fromBase64('SGVsbG8gd29ybGQ=', { alphabet: 'base64', lastChunkHandling: 'loose' }); diff --git a/tests/type-definitions/global/proposals/array-buffer-transfer.test.ts b/tests/type-definitions/global/proposals/array-buffer-transfer.test.ts index 3e35c6ea079e..753572fb1b69 100644 --- a/tests/type-definitions/global/proposals/array-buffer-transfer.test.ts +++ b/tests/type-definitions/global/proposals/array-buffer-transfer.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import $ArrayBuffer from 'core-js/full/array-buffer'; +import 'core-js/es'; +import $ArrayBuffer from 'core-js/es/array-buffer'; const abFromNamespace = new $ArrayBuffer(16); const abFNSTransfer: ArrayBuffer = abFromNamespace.transfer(); diff --git a/tests/type-definitions/global/proposals/array-find-from-last.test.ts b/tests/type-definitions/global/proposals/array-find-from-last.test.ts index 089053d57ed1..9ea98f535a1e 100644 --- a/tests/type-definitions/global/proposals/array-find-from-last.test.ts +++ b/tests/type-definitions/global/proposals/array-find-from-last.test.ts @@ -1,8 +1,8 @@ -import 'core-js/full'; -import findLast from 'core-js/full/array/find-last'; -import findLastJS from 'core-js/full/array/find-last.js'; -import findLastIndex from 'core-js/full/array/find-last-index'; -import findLastIndexJS from 'core-js/full/array/find-last-index.js'; +import 'core-js/es'; +import findLast from 'core-js/es/array/find-last'; +import findLastJS from 'core-js/es/array/find-last.js'; +import findLastIndex from 'core-js/es/array/find-last-index'; +import findLastIndexJS from 'core-js/es/array/find-last-index.js'; import { assertNumber } from '../../helpers'; const resNS1: number | undefined = findLast([1, 2, 3], v => v > 1); diff --git a/tests/type-definitions/global/proposals/array-flat-map.test.ts b/tests/type-definitions/global/proposals/array-flat-map.test.ts index 021b67d6a78d..6aba1574bb4c 100644 --- a/tests/type-definitions/global/proposals/array-flat-map.test.ts +++ b/tests/type-definitions/global/proposals/array-flat-map.test.ts @@ -1,6 +1,6 @@ -import 'core-js/full'; -import flatMap from 'core-js/full/array/flat-map'; -import flatMapJS from 'core-js/full/array/flat-map.js'; +import 'core-js/es'; +import flatMap from 'core-js/es/array/flat-map'; +import flatMapJS from 'core-js/es/array/flat-map.js'; import { assertNumberArray, assertStringArray } from '../../helpers'; assertNumberArray(flatMap([1, 2, 3], x => [x, x * 2])); diff --git a/tests/type-definitions/global/proposals/array-from-async.test.ts b/tests/type-definitions/global/proposals/array-from-async.test.ts index 7379bf533850..8083394cd413 100644 --- a/tests/type-definitions/global/proposals/array-from-async.test.ts +++ b/tests/type-definitions/global/proposals/array-from-async.test.ts @@ -1,9 +1,9 @@ -import 'core-js/full'; -import fromAsync from 'core-js/full/array/from-async'; -import fromAsyncJS from 'core-js/full/array/from-async.js'; -import $Array from 'core-js/full/array'; -import $ArrayIndex from 'core-js/full/array/index'; -import $ArrayIndexJS from 'core-js/full/array/index.js'; +import 'core-js/es'; +import fromAsync from 'core-js/es/array/from-async'; +import fromAsyncJS from 'core-js/es/array/from-async.js'; +import $Array from 'core-js/es/array'; +import $ArrayIndex from 'core-js/es/array/index'; +import $ArrayIndexJS from 'core-js/es/array/index.js'; const pNS: Promise = fromAsync([1, 2, 3]); const pNS2: Promise = fromAsyncJS([1, 2, 3]); diff --git a/tests/type-definitions/global/proposals/array-grouping.test.ts b/tests/type-definitions/global/proposals/array-grouping.test.ts index 7098b15092a2..206451b662c9 100644 --- a/tests/type-definitions/global/proposals/array-grouping.test.ts +++ b/tests/type-definitions/global/proposals/array-grouping.test.ts @@ -1,6 +1,6 @@ -import 'core-js/full'; -import objectGroupBy from 'core-js/full/object/group-by'; -import mapGroupBy from 'core-js/full/map/group-by'; +import 'core-js/es'; +import objectGroupBy from 'core-js/es/object/group-by'; +import mapGroupBy from 'core-js/es/map/group-by'; const arr = [1, 2, 3, 4, 5]; diff --git a/tests/type-definitions/global/proposals/array-includes.test.ts b/tests/type-definitions/global/proposals/array-includes.test.ts index b7875e8d6064..cfd29c326bcc 100644 --- a/tests/type-definitions/global/proposals/array-includes.test.ts +++ b/tests/type-definitions/global/proposals/array-includes.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import includes from 'core-js/full/array/includes'; +import 'core-js/es'; +import includes from 'core-js/es/array/includes'; import { assertBool } from '../../helpers'; const arr = [1, 2, 3]; diff --git a/tests/type-definitions/global/proposals/change-array-by-copy.test.ts b/tests/type-definitions/global/proposals/change-array-by-copy.test.ts index ef4c07c80269..c09b9918348f 100644 --- a/tests/type-definitions/global/proposals/change-array-by-copy.test.ts +++ b/tests/type-definitions/global/proposals/change-array-by-copy.test.ts @@ -1,8 +1,8 @@ -import 'core-js/full'; -import toSorted from 'core-js/full/array/to-sorted'; -import toSpliced from 'core-js/full/array/to-spliced'; -import toReversed from 'core-js/full/array/to-reversed'; -import withArray from 'core-js/full/array/with'; +import 'core-js/es'; +import toSorted from 'core-js/es/array/to-sorted'; +import toSpliced from 'core-js/es/array/to-spliced'; +import toReversed from 'core-js/es/array/to-reversed'; +import withArray from 'core-js/es/array/with'; import { assertNumberArray, assertStringArray } from '../../helpers'; const arr: number[] = [1, 2, 3]; diff --git a/tests/type-definitions/global/proposals/float16.test.ts b/tests/type-definitions/global/proposals/float16.test.ts index 058af923d5d3..ac3bbdaa80b2 100644 --- a/tests/type-definitions/global/proposals/float16.test.ts +++ b/tests/type-definitions/global/proposals/float16.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import f16round from 'core-js/full/math/f16round'; +import 'core-js/es'; +import f16round from 'core-js/es/math/f16round'; import { assertNumber } from '../../helpers'; assertNumber(f16round(1)); diff --git a/tests/type-definitions/global/proposals/is-error.test.ts b/tests/type-definitions/global/proposals/is-error.test.ts index 1ca4a8c52c08..3abba25aa53f 100644 --- a/tests/type-definitions/global/proposals/is-error.test.ts +++ b/tests/type-definitions/global/proposals/is-error.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import isError from 'core-js/full/error/is-error'; +import 'core-js/es'; +import isError from 'core-js/es/error/is-error'; import { assertBool } from '../../helpers'; const e = new Error(); diff --git a/tests/type-definitions/global/proposals/iterator-helpers.test.ts b/tests/type-definitions/global/proposals/iterator-helpers.test.ts index a1c8ea3b5171..578b49f45fd7 100644 --- a/tests/type-definitions/global/proposals/iterator-helpers.test.ts +++ b/tests/type-definitions/global/proposals/iterator-helpers.test.ts @@ -1,14 +1,14 @@ -import 'core-js/full'; -import map from 'core-js/full/iterator/map'; -import filter from 'core-js/full/iterator/filter'; -import take from 'core-js/full/iterator/take'; -import drop from 'core-js/full/iterator/drop'; -import flatMap from 'core-js/full/iterator/flat-map'; -import reduce from 'core-js/full/iterator/reduce'; -import forEach from 'core-js/full/iterator/for-each'; -import some from 'core-js/full/iterator/some'; -import every from 'core-js/full/iterator/every'; -import find from 'core-js/full/iterator/find'; +import 'core-js/es'; +import map from 'core-js/es/iterator/map'; +import filter from 'core-js/es/iterator/filter'; +import take from 'core-js/es/iterator/take'; +import drop from 'core-js/es/iterator/drop'; +import flatMap from 'core-js/es/iterator/flat-map'; +import reduce from 'core-js/es/iterator/reduce'; +import forEach from 'core-js/es/iterator/for-each'; +import some from 'core-js/es/iterator/some'; +import every from 'core-js/es/iterator/every'; +import find from 'core-js/es/iterator/find'; import { assertBool, assertNumber, assertNumberArray, assertString } from '../../helpers'; declare const it: Iterator; diff --git a/tests/type-definitions/global/proposals/iterator-joint.test.ts b/tests/type-definitions/global/proposals/iterator-joint.test.ts index 2454eedbac02..a058b6870d63 100644 --- a/tests/type-definitions/global/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/global/proposals/iterator-joint.test.ts @@ -1,7 +1,7 @@ -import 'core-js/full'; -import zip from 'core-js/full/iterator/zip'; -import zipKeyed from 'core-js/full/iterator/zip-keyed'; -import $Iterator from 'core-js/full/iterator'; +import 'core-js/actual'; +import zip from 'core-js/actual/iterator/zip'; +import zipKeyed from 'core-js/actual/iterator/zip-keyed'; +import $Iterator from 'core-js/actual/iterator'; zip([[1, 2, 3], [4, 5, 6]]); $Iterator.zip([[1, 2, 3], [4, 5, 6]]); diff --git a/tests/type-definitions/global/proposals/iterator-sequencing.test.ts b/tests/type-definitions/global/proposals/iterator-sequencing.test.ts index 285cd05f2aec..16da5ada0513 100644 --- a/tests/type-definitions/global/proposals/iterator-sequencing.test.ts +++ b/tests/type-definitions/global/proposals/iterator-sequencing.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import concat from 'core-js/full/iterator/concat'; +import 'core-js/es'; +import concat from 'core-js/es/iterator/concat'; declare const its1: Iterable; declare const arrs: string[]; diff --git a/tests/type-definitions/global/proposals/json-parse-with-source.test.ts b/tests/type-definitions/global/proposals/json-parse-with-source.test.ts index c712c0a00a7a..619214349875 100644 --- a/tests/type-definitions/global/proposals/json-parse-with-source.test.ts +++ b/tests/type-definitions/global/proposals/json-parse-with-source.test.ts @@ -1,6 +1,6 @@ -import 'core-js/full'; -import rawJSON from 'core-js/full/json/raw-json'; -import isRawJSON from 'core-js/full/json/is-raw-json'; +import 'core-js/es'; +import rawJSON from 'core-js/es/json/raw-json'; +import isRawJSON from 'core-js/es/json/is-raw-json'; import { assertBool } from '../../helpers'; const resNS: CoreJSRawJSON = rawJSON('{"a":123}'); diff --git a/tests/type-definitions/global/proposals/map-upsert.test.ts b/tests/type-definitions/global/proposals/map-upsert.test.ts index 8ca97b36ed91..93467f45133e 100644 --- a/tests/type-definitions/global/proposals/map-upsert.test.ts +++ b/tests/type-definitions/global/proposals/map-upsert.test.ts @@ -1,8 +1,8 @@ -import 'core-js/full'; -import mapGetOrInsert from 'core-js/full/map/get-or-insert'; -import mapGetOrInsertComputed from 'core-js/full/map/get-or-insert-computed'; -import wMapGetOrInsert from 'core-js/full/weak-map/get-or-insert'; -import wMapGetOrInsertComputed from 'core-js/full/weak-map/get-or-insert-computed'; +import 'core-js/es'; +import mapGetOrInsert from 'core-js/es/map/get-or-insert'; +import mapGetOrInsertComputed from 'core-js/es/map/get-or-insert-computed'; +import wMapGetOrInsert from 'core-js/es/weak-map/get-or-insert'; +import wMapGetOrInsertComputed from 'core-js/es/weak-map/get-or-insert-computed'; import { assertBool, assertNumber } from '../../helpers'; declare const map: Map; diff --git a/tests/type-definitions/global/proposals/math-sum.test.ts b/tests/type-definitions/global/proposals/math-sum.test.ts index 224285f31594..e490c77e489f 100644 --- a/tests/type-definitions/global/proposals/math-sum.test.ts +++ b/tests/type-definitions/global/proposals/math-sum.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import sumPrecise from 'core-js/full/math/sum-precise'; +import 'core-js/es'; +import sumPrecise from 'core-js/es/math/sum-precise'; import { assertNumber } from '../../helpers'; declare const it: Iterable; diff --git a/tests/type-definitions/global/proposals/object-from-entries.test.ts b/tests/type-definitions/global/proposals/object-from-entries.test.ts index 56465b24e873..6c6fd0dec0c6 100644 --- a/tests/type-definitions/global/proposals/object-from-entries.test.ts +++ b/tests/type-definitions/global/proposals/object-from-entries.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import fromEntries from 'core-js/full/object/from-entries'; +import 'core-js/es'; +import fromEntries from 'core-js/es/object/from-entries'; declare const objEntries: Iterable; declare const mixedEntries: Iterable; diff --git a/tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts b/tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts index 474f860bf96d..ed3a30e7b200 100644 --- a/tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts +++ b/tests/type-definitions/global/proposals/object-get-own-property-descriptors.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import getOwnPropertyDescriptors from 'core-js/full/object/get-own-property-descriptors'; +import 'core-js/es'; +import getOwnPropertyDescriptors from 'core-js/es/object/get-own-property-descriptors'; const obj = { a: 1, b: 'x', c: true }; diff --git a/tests/type-definitions/global/proposals/object-values-entries.test.ts b/tests/type-definitions/global/proposals/object-values-entries.test.ts index dd9df923ce14..c16c0ee2d557 100644 --- a/tests/type-definitions/global/proposals/object-values-entries.test.ts +++ b/tests/type-definitions/global/proposals/object-values-entries.test.ts @@ -1,6 +1,6 @@ -import 'core-js/full'; -import values from 'core-js/full/object/values'; -import entries from 'core-js/full/object/entries'; +import 'core-js/es'; +import values from 'core-js/es/object/values'; +import entries from 'core-js/es/object/entries'; import { assertNumberArray, assertStringArray } from '../../helpers'; const obj = { a: 1, b: 2 }; diff --git a/tests/type-definitions/global/proposals/promise-all-settled.test.ts b/tests/type-definitions/global/proposals/promise-all-settled.test.ts index d64bdf4045ba..98561fd6dd94 100644 --- a/tests/type-definitions/global/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/global/proposals/promise-all-settled.test.ts @@ -1,6 +1,6 @@ -import 'core-js/full'; -import allSettled from 'core-js/full/promise/all-settled'; -import $Promise from 'core-js/full/promise'; +import 'core-js/es'; +import allSettled from 'core-js/es/promise/all-settled'; +import $Promise from 'core-js/es/promise'; const promises = [Promise.resolve(1), Promise.resolve('foo'), 3] as const; const arr = [Promise.resolve(1), Promise.resolve(2)]; diff --git a/tests/type-definitions/global/proposals/promise-any.test.ts b/tests/type-definitions/global/proposals/promise-any.test.ts index 638d7bca2e3b..44b7509fdb45 100644 --- a/tests/type-definitions/global/proposals/promise-any.test.ts +++ b/tests/type-definitions/global/proposals/promise-any.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import promiseAny from 'core-js/full/promise/any'; +import 'core-js/es'; +import promiseAny from 'core-js/es/promise/any'; const arr = [Promise.resolve(1), Promise.resolve('foo'), 3] as const; const justNumbers = [1, 2, 3]; diff --git a/tests/type-definitions/global/proposals/promise-finally.test.ts b/tests/type-definitions/global/proposals/promise-finally.test.ts index bc495e09448a..82a34b36340c 100644 --- a/tests/type-definitions/global/proposals/promise-finally.test.ts +++ b/tests/type-definitions/global/proposals/promise-finally.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import promiseFinally from 'core-js/full/promise/finally'; +import 'core-js/es'; +import promiseFinally from 'core-js/es/promise/finally'; const p1 = Promise.resolve(42); diff --git a/tests/type-definitions/global/proposals/promise-try.test.ts b/tests/type-definitions/global/proposals/promise-try.test.ts index 21ee9b1f7dbf..43826a7ac536 100644 --- a/tests/type-definitions/global/proposals/promise-try.test.ts +++ b/tests/type-definitions/global/proposals/promise-try.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import promiseTry from 'core-js/full/promise/try'; +import 'core-js/es'; +import promiseTry from 'core-js/es/promise/try'; const ptNS: Promise = promiseTry(() => 42); diff --git a/tests/type-definitions/global/proposals/promise-with-resolvers.test.ts b/tests/type-definitions/global/proposals/promise-with-resolvers.test.ts index 320280681bb4..8b0d38d6550a 100644 --- a/tests/type-definitions/global/proposals/promise-with-resolvers.test.ts +++ b/tests/type-definitions/global/proposals/promise-with-resolvers.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import promiseWithResolvers from 'core-js/full/promise/with-resolvers'; +import 'core-js/es'; +import promiseWithResolvers from 'core-js/es/promise/with-resolvers'; const prNS = promiseWithResolvers(); const pNS1: Promise = prNS.promise; diff --git a/tests/type-definitions/global/proposals/regexp-escaping.test.ts b/tests/type-definitions/global/proposals/regexp-escaping.test.ts index deb5fc6042c2..7fe3d7757e95 100644 --- a/tests/type-definitions/global/proposals/regexp-escaping.test.ts +++ b/tests/type-definitions/global/proposals/regexp-escaping.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import escape from 'core-js/full/regexp/escape'; +import 'core-js/es'; +import escape from 'core-js/es/regexp/escape'; import { assertString } from '../../helpers'; assertString(escape('foo.*+?^${}()|[]\\')); diff --git a/tests/type-definitions/global/proposals/relative-indexing-method.test.ts b/tests/type-definitions/global/proposals/relative-indexing-method.test.ts index b17ebdb9f71a..6ff2e8eafd74 100644 --- a/tests/type-definitions/global/proposals/relative-indexing-method.test.ts +++ b/tests/type-definitions/global/proposals/relative-indexing-method.test.ts @@ -1,6 +1,6 @@ -import 'core-js/full'; -import stringAt from 'core-js/full/string/at'; -import arrayAt from 'core-js/full/array/at'; +import 'core-js/es'; +import stringAt from 'core-js/es/string/at'; +import arrayAt from 'core-js/es/array/at'; const str = 'hello'; diff --git a/tests/type-definitions/global/proposals/set-methods.test.ts b/tests/type-definitions/global/proposals/set-methods.test.ts index 7a5018ed02fe..6883d3a7b9f8 100644 --- a/tests/type-definitions/global/proposals/set-methods.test.ts +++ b/tests/type-definitions/global/proposals/set-methods.test.ts @@ -1,11 +1,11 @@ -import 'core-js/full'; -import setUnion from 'core-js/full/set/union'; -import setIntersection from 'core-js/full/set/intersection'; -import setDifference from 'core-js/full/set/difference'; -import setSymmetricDifference from 'core-js/full/set/symmetric-difference'; -import setIsSubsetOf from 'core-js/full/set/is-subset-of'; -import setIsSupersetOf from 'core-js/full/set/is-superset-of'; -import setIsDisjointFrom from 'core-js/full/set/is-disjoint-from'; +import 'core-js/es'; +import setUnion from 'core-js/es/set/union'; +import setIntersection from 'core-js/es/set/intersection'; +import setDifference from 'core-js/es/set/difference'; +import setSymmetricDifference from 'core-js/es/set/symmetric-difference'; +import setIsSubsetOf from 'core-js/es/set/is-subset-of'; +import setIsSupersetOf from 'core-js/es/set/is-superset-of'; +import setIsDisjointFrom from 'core-js/es/set/is-disjoint-from'; const setA = new Set([1, 2, 3]); const setB = new Set(['a', 'b', 'c']); diff --git a/tests/type-definitions/global/proposals/string-left-right-trim.test.ts b/tests/type-definitions/global/proposals/string-left-right-trim.test.ts index cce63802d0c6..30dda7feab60 100644 --- a/tests/type-definitions/global/proposals/string-left-right-trim.test.ts +++ b/tests/type-definitions/global/proposals/string-left-right-trim.test.ts @@ -1,8 +1,8 @@ -import 'core-js/full'; -import trimEnd from 'core-js/full/string/trim-end'; -import trimStart from 'core-js/full/string/trim-start'; -import trimLeft from 'core-js/full/string/trim-left'; -import trimRight from 'core-js/full/string/trim-right'; +import 'core-js/es'; +import trimEnd from 'core-js/es/string/trim-end'; +import trimStart from 'core-js/es/string/trim-start'; +import trimLeft from 'core-js/es/string/trim-left'; +import trimRight from 'core-js/es/string/trim-right'; import { assertString } from '../../helpers'; const s = 'abc'; diff --git a/tests/type-definitions/global/proposals/string-match-all.test.ts b/tests/type-definitions/global/proposals/string-match-all.test.ts index 204e77a1a01c..dcd89d1634ae 100644 --- a/tests/type-definitions/global/proposals/string-match-all.test.ts +++ b/tests/type-definitions/global/proposals/string-match-all.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import matchAll from 'core-js/full/string/match-all'; +import 'core-js/es'; +import matchAll from 'core-js/es/string/match-all'; const s = 'abcabc'; const re = /abc/g; diff --git a/tests/type-definitions/global/proposals/string-padding.test.ts b/tests/type-definitions/global/proposals/string-padding.test.ts index 69ea24447eba..1247fc2d806f 100644 --- a/tests/type-definitions/global/proposals/string-padding.test.ts +++ b/tests/type-definitions/global/proposals/string-padding.test.ts @@ -1,6 +1,6 @@ -import 'core-js/full'; -import padStart from 'core-js/full/string/pad-start'; -import padEnd from 'core-js/full/string/pad-end'; +import 'core-js/es'; +import padStart from 'core-js/es/string/pad-start'; +import padEnd from 'core-js/es/string/pad-end'; import { assertString } from '../../helpers'; const s = 'foo'; diff --git a/tests/type-definitions/global/proposals/string-replace-all.test.ts b/tests/type-definitions/global/proposals/string-replace-all.test.ts index a195c6e7d56b..0d550475cad5 100644 --- a/tests/type-definitions/global/proposals/string-replace-all.test.ts +++ b/tests/type-definitions/global/proposals/string-replace-all.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import replaceAll from 'core-js/full/string/replace-all'; +import 'core-js/es'; +import replaceAll from 'core-js/es/string/replace-all'; import { assertString } from '../../helpers'; const s = 'foo bar foo'; diff --git a/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts b/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts index 985a1306d2ff..f4ea33a34548 100644 --- a/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts +++ b/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts @@ -1,6 +1,6 @@ -import 'core-js/full'; -import isWellFormed from 'core-js/full/string/is-well-formed'; -import toWellFormed from 'core-js/full/string/to-well-formed'; +import 'core-js/es'; +import isWellFormed from 'core-js/es/string/is-well-formed'; +import toWellFormed from 'core-js/es/string/to-well-formed'; import { assertBool, assertString } from '../../helpers'; const s = 'test'; diff --git a/tests/type-definitions/global/web/atob.test.ts b/tests/type-definitions/global/web/atob.test.ts index 47fedcc86aed..724da5b9b376 100644 --- a/tests/type-definitions/global/web/atob.test.ts +++ b/tests/type-definitions/global/web/atob.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import $atob from 'core-js/full/atob'; +import 'core-js/stable'; +import $atob from 'core-js/stable/atob'; import { assertString } from '../../helpers'; assertString($atob('SGVsbG8gd29ybGQ=')); diff --git a/tests/type-definitions/global/web/btoa.test.ts b/tests/type-definitions/global/web/btoa.test.ts index dedb30acd0b0..ed018354cbc1 100644 --- a/tests/type-definitions/global/web/btoa.test.ts +++ b/tests/type-definitions/global/web/btoa.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import $btoa from 'core-js/full/btoa'; +import 'core-js/stable'; +import $btoa from 'core-js/stable/btoa'; import { assertString } from '../../helpers'; assertString($btoa('SGVsbG8gd29ybGQ=')); diff --git a/tests/type-definitions/global/web/efficient-script-yielding.test.ts b/tests/type-definitions/global/web/efficient-script-yielding.test.ts index 761b66379a2f..cc2dfb5906e4 100644 --- a/tests/type-definitions/global/web/efficient-script-yielding.test.ts +++ b/tests/type-definitions/global/web/efficient-script-yielding.test.ts @@ -1,6 +1,6 @@ -import 'core-js/full'; -import $setImmediate from 'core-js/full/set-immediate'; -import $clearImmediate from 'core-js/full/clear-immediate'; +import 'core-js/stable'; +import $setImmediate from 'core-js/stable/set-immediate'; +import $clearImmediate from 'core-js/stable/clear-immediate'; const resNS: number | object = $setImmediate(() => 42); $clearImmediate(resNS); diff --git a/tests/type-definitions/global/web/queue-microtask.test.ts b/tests/type-definitions/global/web/queue-microtask.test.ts index c146e1e94b6d..1dfaf94520cb 100644 --- a/tests/type-definitions/global/web/queue-microtask.test.ts +++ b/tests/type-definitions/global/web/queue-microtask.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import $queueMicrotask from 'core-js/full/queue-microtask'; +import 'core-js/stable'; +import $queueMicrotask from 'core-js/stable/queue-microtask'; $queueMicrotask((): void => {}); diff --git a/tests/type-definitions/global/web/structured-clone.test.ts b/tests/type-definitions/global/web/structured-clone.test.ts index fccbda04298f..231ce3cbf910 100644 --- a/tests/type-definitions/global/web/structured-clone.test.ts +++ b/tests/type-definitions/global/web/structured-clone.test.ts @@ -1,5 +1,5 @@ -import 'core-js/full'; -import $structuredClone from 'core-js/full/structured-clone'; +import 'core-js/stable'; +import $structuredClone from 'core-js/stable/structured-clone'; import { assertNumber, assertString } from '../../helpers'; assertNumber($structuredClone(5)); From d34692684b207292dfc20415e650b53137ffd739 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 5 Feb 2026 19:51:01 +0700 Subject: [PATCH 178/315] Separate entries types tests --- .../entries/{entries.actual.ts => actual/entries.ts} | 0 tests/type-definitions/entries/actual/tsconfig.json | 4 ++++ .../entries/{entries.es.ts => es/entries.ts} | 0 tests/type-definitions/entries/es/tsconfig.json | 4 ++++ .../entries/{entries.full.ts => full/entries.ts} | 0 tests/type-definitions/entries/full/tsconfig.json | 4 ++++ .../{entries.proposals.ts => proposals/entries.ts} | 0 tests/type-definitions/entries/proposals/tsconfig.json | 4 ++++ .../entries/{entries.stable.ts => stable/entries.ts} | 0 tests/type-definitions/entries/stable/tsconfig.json | 4 ++++ tests/type-definitions/entries/tsconfig.actual.json | 4 ---- tests/type-definitions/entries/tsconfig.es.json | 4 ---- tests/type-definitions/entries/tsconfig.full.json | 4 ---- tests/type-definitions/entries/tsconfig.proposals.json | 4 ---- tests/type-definitions/entries/tsconfig.stable.json | 4 ---- tests/type-definitions/runner.mjs | 10 +++++----- 16 files changed, 25 insertions(+), 25 deletions(-) rename tests/type-definitions/entries/{entries.actual.ts => actual/entries.ts} (100%) create mode 100644 tests/type-definitions/entries/actual/tsconfig.json rename tests/type-definitions/entries/{entries.es.ts => es/entries.ts} (100%) create mode 100644 tests/type-definitions/entries/es/tsconfig.json rename tests/type-definitions/entries/{entries.full.ts => full/entries.ts} (100%) create mode 100644 tests/type-definitions/entries/full/tsconfig.json rename tests/type-definitions/entries/{entries.proposals.ts => proposals/entries.ts} (100%) create mode 100644 tests/type-definitions/entries/proposals/tsconfig.json rename tests/type-definitions/entries/{entries.stable.ts => stable/entries.ts} (100%) create mode 100644 tests/type-definitions/entries/stable/tsconfig.json delete mode 100644 tests/type-definitions/entries/tsconfig.actual.json delete mode 100644 tests/type-definitions/entries/tsconfig.es.json delete mode 100644 tests/type-definitions/entries/tsconfig.full.json delete mode 100644 tests/type-definitions/entries/tsconfig.proposals.json delete mode 100644 tests/type-definitions/entries/tsconfig.stable.json diff --git a/tests/type-definitions/entries/entries.actual.ts b/tests/type-definitions/entries/actual/entries.ts similarity index 100% rename from tests/type-definitions/entries/entries.actual.ts rename to tests/type-definitions/entries/actual/entries.ts diff --git a/tests/type-definitions/entries/actual/tsconfig.json b/tests/type-definitions/entries/actual/tsconfig.json new file mode 100644 index 000000000000..6a33da986402 --- /dev/null +++ b/tests/type-definitions/entries/actual/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./entries.ts"] +} diff --git a/tests/type-definitions/entries/entries.es.ts b/tests/type-definitions/entries/es/entries.ts similarity index 100% rename from tests/type-definitions/entries/entries.es.ts rename to tests/type-definitions/entries/es/entries.ts diff --git a/tests/type-definitions/entries/es/tsconfig.json b/tests/type-definitions/entries/es/tsconfig.json new file mode 100644 index 000000000000..6a33da986402 --- /dev/null +++ b/tests/type-definitions/entries/es/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./entries.ts"] +} diff --git a/tests/type-definitions/entries/entries.full.ts b/tests/type-definitions/entries/full/entries.ts similarity index 100% rename from tests/type-definitions/entries/entries.full.ts rename to tests/type-definitions/entries/full/entries.ts diff --git a/tests/type-definitions/entries/full/tsconfig.json b/tests/type-definitions/entries/full/tsconfig.json new file mode 100644 index 000000000000..6a33da986402 --- /dev/null +++ b/tests/type-definitions/entries/full/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./entries.ts"] +} diff --git a/tests/type-definitions/entries/entries.proposals.ts b/tests/type-definitions/entries/proposals/entries.ts similarity index 100% rename from tests/type-definitions/entries/entries.proposals.ts rename to tests/type-definitions/entries/proposals/entries.ts diff --git a/tests/type-definitions/entries/proposals/tsconfig.json b/tests/type-definitions/entries/proposals/tsconfig.json new file mode 100644 index 000000000000..6a33da986402 --- /dev/null +++ b/tests/type-definitions/entries/proposals/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./entries.ts"] +} diff --git a/tests/type-definitions/entries/entries.stable.ts b/tests/type-definitions/entries/stable/entries.ts similarity index 100% rename from tests/type-definitions/entries/entries.stable.ts rename to tests/type-definitions/entries/stable/entries.ts diff --git a/tests/type-definitions/entries/stable/tsconfig.json b/tests/type-definitions/entries/stable/tsconfig.json new file mode 100644 index 000000000000..6a33da986402 --- /dev/null +++ b/tests/type-definitions/entries/stable/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./entries.ts"] +} diff --git a/tests/type-definitions/entries/tsconfig.actual.json b/tests/type-definitions/entries/tsconfig.actual.json deleted file mode 100644 index 7307d61c3fa4..000000000000 --- a/tests/type-definitions/entries/tsconfig.actual.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": ["./entries.actual.ts"] -} diff --git a/tests/type-definitions/entries/tsconfig.es.json b/tests/type-definitions/entries/tsconfig.es.json deleted file mode 100644 index 3b79650f8066..000000000000 --- a/tests/type-definitions/entries/tsconfig.es.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": ["./entries.es.ts"] -} diff --git a/tests/type-definitions/entries/tsconfig.full.json b/tests/type-definitions/entries/tsconfig.full.json deleted file mode 100644 index 4015819d0939..000000000000 --- a/tests/type-definitions/entries/tsconfig.full.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": ["./entries.full.ts"] -} diff --git a/tests/type-definitions/entries/tsconfig.proposals.json b/tests/type-definitions/entries/tsconfig.proposals.json deleted file mode 100644 index b90cb77f4bae..000000000000 --- a/tests/type-definitions/entries/tsconfig.proposals.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": ["./entries.proposals.ts"] -} diff --git a/tests/type-definitions/entries/tsconfig.stable.json b/tests/type-definitions/entries/tsconfig.stable.json deleted file mode 100644 index 645690137e02..000000000000 --- a/tests/type-definitions/entries/tsconfig.stable.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": ["./entries.stable.ts"] -} diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index fddce561fe04..d8e861612c65 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -159,11 +159,11 @@ tasks.push( { args: ['-p', 'typescript@5.9', 'tsc'] }, { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'templates/tsconfig.json'] }, { args: ['-p', 'typescript@5.9', '-p', '@types/node@24', 'tsc', '-p', 'templates/tsconfig.require.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/tsconfig.full.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/tsconfig.actual.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/tsconfig.stable.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/tsconfig.es.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/tsconfig.proposals.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/full/tsconfig.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/actual/tsconfig.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/stable/tsconfig.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/es/tsconfig.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/proposals/tsconfig.json'] }, ); let envs; From ecee37beedd773ace9de2f12fa14d449b8ca4919 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 5 Feb 2026 20:14:23 +0700 Subject: [PATCH 179/315] Add import variations tests --- .../entries/global/imports.ts | 20 +++++++++++++++++++ .../entries/global/tsconfig.json | 7 +++++++ .../type-definitions/entries/pure/imports.ts | 20 +++++++++++++++++++ .../entries/pure/tsconfig.json | 7 +++++++ tests/type-definitions/runner.mjs | 2 ++ 5 files changed, 56 insertions(+) create mode 100644 tests/type-definitions/entries/global/imports.ts create mode 100644 tests/type-definitions/entries/global/tsconfig.json create mode 100644 tests/type-definitions/entries/pure/imports.ts create mode 100644 tests/type-definitions/entries/pure/tsconfig.json diff --git a/tests/type-definitions/entries/global/imports.ts b/tests/type-definitions/entries/global/imports.ts new file mode 100644 index 000000000000..672f41d761ce --- /dev/null +++ b/tests/type-definitions/entries/global/imports.ts @@ -0,0 +1,20 @@ +import $Math from 'core-js/full/math'; +import $MathIndex from 'core-js/full/math/index'; +import $MathIndexJS from 'core-js/full/math/index.js'; +import $Array from 'core-js/full/array'; +import $ArrayIndex from 'core-js/full/array/index'; +import $ArrayIndexJS from 'core-js/full/array/index.js'; +import chunks from 'core-js/full/iterator/chunks'; +import chunksJS from 'core-js/full/iterator/chunks.js'; + +$Math.f16round(7.9999999); +$MathIndex.f16round(7.9999999); +$MathIndexJS.f16round(7.9999999); + +$Array.from([1, 2, 3]); +$ArrayIndex.from([1, 2, 3]); +$ArrayIndexJS.from([1, 2, 3]); + +declare const num: Iterator; +chunks(num, 2); +chunksJS(num, 2); diff --git a/tests/type-definitions/entries/global/tsconfig.json b/tests/type-definitions/entries/global/tsconfig.json new file mode 100644 index 000000000000..3a2fb2f85d59 --- /dev/null +++ b/tests/type-definitions/entries/global/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./imports.ts"], + "compilerOptions": { + "types": ["@core-js/types"] + } +} diff --git a/tests/type-definitions/entries/pure/imports.ts b/tests/type-definitions/entries/pure/imports.ts new file mode 100644 index 000000000000..aec4ea087bc4 --- /dev/null +++ b/tests/type-definitions/entries/pure/imports.ts @@ -0,0 +1,20 @@ +import $Math from '@core-js/pure/full/math'; +import $MathIndex from '@core-js/pure/full/math/index'; +import $MathIndexJS from '@core-js/pure/full/math/index.js'; +import $Array from '@core-js/pure/full/array'; +import $ArrayIndex from '@core-js/pure/full/array/index'; +import $ArrayIndexJS from '@core-js/pure/full/array/index.js'; +import chunks from '@core-js/pure/full/iterator/chunks'; +import chunksJS from '@core-js/pure/full/iterator/chunks.js'; + +$Math.f16round(7.9999999); +$MathIndex.f16round(7.9999999); +$MathIndexJS.f16round(7.9999999); + +$Array.from([1, 2, 3]); +$ArrayIndex.from([1, 2, 3]); +$ArrayIndexJS.from([1, 2, 3]); + +declare const num: Iterator; +chunks(num, 2); +chunksJS(num, 2); diff --git a/tests/type-definitions/entries/pure/tsconfig.json b/tests/type-definitions/entries/pure/tsconfig.json new file mode 100644 index 000000000000..87b6595a8b0c --- /dev/null +++ b/tests/type-definitions/entries/pure/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./imports.ts"], + "compilerOptions": { + "types": ["@core-js/types/pure"] + } +} diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index d8e861612c65..2ef47bfeef0c 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -164,6 +164,8 @@ tasks.push( { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/stable/tsconfig.json'] }, { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/es/tsconfig.json'] }, { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/proposals/tsconfig.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/global/tsconfig.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/pure/tsconfig.json'] }, ); let envs; From 8590e58c60f11abe2f02aef238e0a622138270f7 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 6 Feb 2026 00:48:01 +0700 Subject: [PATCH 180/315] Types for configurator --- .../core-js-types/src/base/configurator.d.ts | 1 + .../build-entries-and-types/build-types.mjs | 19 +++++++++++++++++-- .../configurator/global/configurator.ts | 1 + .../entries/configurator/global/tsconfig.json | 9 +++++++++ .../configurator/import/configurator.ts | 3 +++ .../entries/configurator/import/tsconfig.json | 4 ++++ tests/type-definitions/runner.mjs | 2 ++ 7 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 packages/core-js-types/src/base/configurator.d.ts create mode 100644 tests/type-definitions/entries/configurator/global/configurator.ts create mode 100644 tests/type-definitions/entries/configurator/global/tsconfig.json create mode 100644 tests/type-definitions/entries/configurator/import/configurator.ts create mode 100644 tests/type-definitions/entries/configurator/import/tsconfig.json diff --git a/packages/core-js-types/src/base/configurator.d.ts b/packages/core-js-types/src/base/configurator.d.ts new file mode 100644 index 000000000000..dd4932f53bfc --- /dev/null +++ b/packages/core-js-types/src/base/configurator.d.ts @@ -0,0 +1 @@ +declare function configurator(options: Record): void; diff --git a/scripts/build-entries-and-types/build-types.mjs b/scripts/build-entries-and-types/build-types.mjs index bec40ee5f97a..571fc1842d9f 100644 --- a/scripts/build-entries-and-types/build-types.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -1,5 +1,5 @@ import { features, proposals } from './entries-definitions.mjs'; -import { $path, $proposal, $typeDummy } from './templates.mjs'; +import { $namespace, $path, $proposal, $typeDummy } from './templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; import { getModulesMetadata } from './get-dependencies.mjs'; import { expandModules, modulesToStage } from './helpers.mjs'; @@ -25,6 +25,7 @@ const imports = { full: new Set(), pure: new Set(), index: new Set(), + configurator: new Set(), }; let outputFiles = {}; @@ -42,6 +43,9 @@ function addType(tsVersion, subset, template, options) { function addEntryTypes(tsVersion, template, options) { addType(tsVersion, 'index', template, { ...options, packageName: PACKAGE_NAME }); addType(tsVersion, 'pure', template, { ...options, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); + if (options.exportForSubset) { + addType(tsVersion, options.subset, template, { ...options, packageName: PACKAGE_NAME }); + } } async function buildType(entry, options) { @@ -105,7 +109,7 @@ async function buildType(entry, options) { } imports.pure.add(path.join('pure', customType)); } - options = { ...options, modules, level, entry, types }; + options = { ...options, modules, level, entry, types, subset }; addEntryTypes(tsVersion, template, options); if (!entry.endsWith('/')) { // add alias with .js ending @@ -226,6 +230,16 @@ async function buildTypesForTSVersion(tsVersion) { await buildType('full/index', { template: $path, modules: AllModules, tsVersion }); await buildType('index', { template: $path, modules: ActualModules, tsVersion }); + await buildType('configurator', { + entryFromNamespace: 'configurator', + template: $namespace, + modules: ['configurator'], + name: 'configurator', + tsVersion, + types: ['configurator'], + exportForSubset: true, + }); + await prependImports(tsVersion); await saveOutputFiles(); } @@ -293,6 +307,7 @@ const namespaces = { pure: { isDir: false }, proposals: { isDir: true }, index: { isDir: false }, + configurator: { isDir: false }, }; await buildPackageJson(TS_VERSION_BREAKPOINTS, namespaces); diff --git a/tests/type-definitions/entries/configurator/global/configurator.ts b/tests/type-definitions/entries/configurator/global/configurator.ts new file mode 100644 index 000000000000..f7cfbbfd3953 --- /dev/null +++ b/tests/type-definitions/entries/configurator/global/configurator.ts @@ -0,0 +1 @@ +configurator({ something: 'value' }); diff --git a/tests/type-definitions/entries/configurator/global/tsconfig.json b/tests/type-definitions/entries/configurator/global/tsconfig.json new file mode 100644 index 000000000000..9212a1b7b314 --- /dev/null +++ b/tests/type-definitions/entries/configurator/global/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../../tsconfig.json", + "include": ["./configurator.ts"], + "compilerOptions": { + "types": [ + "@core-js/types" + ] + } +} diff --git a/tests/type-definitions/entries/configurator/import/configurator.ts b/tests/type-definitions/entries/configurator/import/configurator.ts new file mode 100644 index 000000000000..24728bd991a7 --- /dev/null +++ b/tests/type-definitions/entries/configurator/import/configurator.ts @@ -0,0 +1,3 @@ +import '@core-js/types/configurator'; + +configurator({ something: 'value' }); diff --git a/tests/type-definitions/entries/configurator/import/tsconfig.json b/tests/type-definitions/entries/configurator/import/tsconfig.json new file mode 100644 index 000000000000..49cb748ee483 --- /dev/null +++ b/tests/type-definitions/entries/configurator/import/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../../tsconfig.json", + "include": ["./configurator.ts"] +} diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 2ef47bfeef0c..abb9b18703b8 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -166,6 +166,8 @@ tasks.push( { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/proposals/tsconfig.json'] }, { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/global/tsconfig.json'] }, { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/pure/tsconfig.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/configurator/global/tsconfig.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/configurator/import/tsconfig.json'] }, ); let envs; From 3390b5361f8a2cef4c5cde6353589cecef84bd64 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 6 Feb 2026 01:05:34 +0700 Subject: [PATCH 181/315] Rename new tests --- .../entries/actual/{entries.ts => entries.actual.test.ts} | 0 tests/type-definitions/entries/actual/tsconfig.json | 4 +++- .../global/{configurator.ts => configurator.global.test.ts} | 0 .../entries/configurator/global/tsconfig.json | 4 +++- .../import/{configurator.ts => configurator.import.test.ts} | 0 .../entries/configurator/import/tsconfig.json | 4 +++- .../entries/es/{entries.ts => entries.es.test.ts} | 0 tests/type-definitions/entries/es/tsconfig.json | 4 +++- .../entries/full/{entries.ts => entries.full.test.ts} | 0 tests/type-definitions/entries/full/tsconfig.json | 4 +++- .../entries/global/{imports.ts => imports.global.test.ts} | 0 tests/type-definitions/entries/global/tsconfig.json | 4 +++- .../proposals/{entries.ts => entries.proposals.test.ts} | 0 tests/type-definitions/entries/proposals/tsconfig.json | 4 +++- .../entries/pure/{imports.ts => imports.pure.test.ts} | 0 tests/type-definitions/entries/pure/tsconfig.json | 4 +++- .../entries/stable/{entries.ts => entries.stable.test.ts} | 0 tests/type-definitions/entries/stable/tsconfig.json | 4 +++- 18 files changed, 27 insertions(+), 9 deletions(-) rename tests/type-definitions/entries/actual/{entries.ts => entries.actual.test.ts} (100%) rename tests/type-definitions/entries/configurator/global/{configurator.ts => configurator.global.test.ts} (100%) rename tests/type-definitions/entries/configurator/import/{configurator.ts => configurator.import.test.ts} (100%) rename tests/type-definitions/entries/es/{entries.ts => entries.es.test.ts} (100%) rename tests/type-definitions/entries/full/{entries.ts => entries.full.test.ts} (100%) rename tests/type-definitions/entries/global/{imports.ts => imports.global.test.ts} (100%) rename tests/type-definitions/entries/proposals/{entries.ts => entries.proposals.test.ts} (100%) rename tests/type-definitions/entries/pure/{imports.ts => imports.pure.test.ts} (100%) rename tests/type-definitions/entries/stable/{entries.ts => entries.stable.test.ts} (100%) diff --git a/tests/type-definitions/entries/actual/entries.ts b/tests/type-definitions/entries/actual/entries.actual.test.ts similarity index 100% rename from tests/type-definitions/entries/actual/entries.ts rename to tests/type-definitions/entries/actual/entries.actual.test.ts diff --git a/tests/type-definitions/entries/actual/tsconfig.json b/tests/type-definitions/entries/actual/tsconfig.json index 6a33da986402..0c077220aa24 100644 --- a/tests/type-definitions/entries/actual/tsconfig.json +++ b/tests/type-definitions/entries/actual/tsconfig.json @@ -1,4 +1,6 @@ { "extends": "../../tsconfig.json", - "include": ["./entries.ts"] + "include": [ + "./entries.actual.test.ts" + ] } diff --git a/tests/type-definitions/entries/configurator/global/configurator.ts b/tests/type-definitions/entries/configurator/global/configurator.global.test.ts similarity index 100% rename from tests/type-definitions/entries/configurator/global/configurator.ts rename to tests/type-definitions/entries/configurator/global/configurator.global.test.ts diff --git a/tests/type-definitions/entries/configurator/global/tsconfig.json b/tests/type-definitions/entries/configurator/global/tsconfig.json index 9212a1b7b314..b267339aac62 100644 --- a/tests/type-definitions/entries/configurator/global/tsconfig.json +++ b/tests/type-definitions/entries/configurator/global/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../../tsconfig.json", - "include": ["./configurator.ts"], + "include": [ + "./configurator.global.test.ts" + ], "compilerOptions": { "types": [ "@core-js/types" diff --git a/tests/type-definitions/entries/configurator/import/configurator.ts b/tests/type-definitions/entries/configurator/import/configurator.import.test.ts similarity index 100% rename from tests/type-definitions/entries/configurator/import/configurator.ts rename to tests/type-definitions/entries/configurator/import/configurator.import.test.ts diff --git a/tests/type-definitions/entries/configurator/import/tsconfig.json b/tests/type-definitions/entries/configurator/import/tsconfig.json index 49cb748ee483..f68c1d31a954 100644 --- a/tests/type-definitions/entries/configurator/import/tsconfig.json +++ b/tests/type-definitions/entries/configurator/import/tsconfig.json @@ -1,4 +1,6 @@ { "extends": "../../../tsconfig.json", - "include": ["./configurator.ts"] + "include": [ + "./configurator.import.test.ts" + ] } diff --git a/tests/type-definitions/entries/es/entries.ts b/tests/type-definitions/entries/es/entries.es.test.ts similarity index 100% rename from tests/type-definitions/entries/es/entries.ts rename to tests/type-definitions/entries/es/entries.es.test.ts diff --git a/tests/type-definitions/entries/es/tsconfig.json b/tests/type-definitions/entries/es/tsconfig.json index 6a33da986402..a9c9c798139b 100644 --- a/tests/type-definitions/entries/es/tsconfig.json +++ b/tests/type-definitions/entries/es/tsconfig.json @@ -1,4 +1,6 @@ { "extends": "../../tsconfig.json", - "include": ["./entries.ts"] + "include": [ + "./entries.es.test.ts" + ] } diff --git a/tests/type-definitions/entries/full/entries.ts b/tests/type-definitions/entries/full/entries.full.test.ts similarity index 100% rename from tests/type-definitions/entries/full/entries.ts rename to tests/type-definitions/entries/full/entries.full.test.ts diff --git a/tests/type-definitions/entries/full/tsconfig.json b/tests/type-definitions/entries/full/tsconfig.json index 6a33da986402..c96132e9d3f0 100644 --- a/tests/type-definitions/entries/full/tsconfig.json +++ b/tests/type-definitions/entries/full/tsconfig.json @@ -1,4 +1,6 @@ { "extends": "../../tsconfig.json", - "include": ["./entries.ts"] + "include": [ + "./entries.full.test.ts" + ] } diff --git a/tests/type-definitions/entries/global/imports.ts b/tests/type-definitions/entries/global/imports.global.test.ts similarity index 100% rename from tests/type-definitions/entries/global/imports.ts rename to tests/type-definitions/entries/global/imports.global.test.ts diff --git a/tests/type-definitions/entries/global/tsconfig.json b/tests/type-definitions/entries/global/tsconfig.json index 3a2fb2f85d59..8d3adea9ba57 100644 --- a/tests/type-definitions/entries/global/tsconfig.json +++ b/tests/type-definitions/entries/global/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.json", - "include": ["./imports.ts"], + "include": [ + "./imports.global.test.ts" + ], "compilerOptions": { "types": ["@core-js/types"] } diff --git a/tests/type-definitions/entries/proposals/entries.ts b/tests/type-definitions/entries/proposals/entries.proposals.test.ts similarity index 100% rename from tests/type-definitions/entries/proposals/entries.ts rename to tests/type-definitions/entries/proposals/entries.proposals.test.ts diff --git a/tests/type-definitions/entries/proposals/tsconfig.json b/tests/type-definitions/entries/proposals/tsconfig.json index 6a33da986402..94fae1f45eb1 100644 --- a/tests/type-definitions/entries/proposals/tsconfig.json +++ b/tests/type-definitions/entries/proposals/tsconfig.json @@ -1,4 +1,6 @@ { "extends": "../../tsconfig.json", - "include": ["./entries.ts"] + "include": [ + "./entries.proposals.test.ts" + ] } diff --git a/tests/type-definitions/entries/pure/imports.ts b/tests/type-definitions/entries/pure/imports.pure.test.ts similarity index 100% rename from tests/type-definitions/entries/pure/imports.ts rename to tests/type-definitions/entries/pure/imports.pure.test.ts diff --git a/tests/type-definitions/entries/pure/tsconfig.json b/tests/type-definitions/entries/pure/tsconfig.json index 87b6595a8b0c..473bd4e3233e 100644 --- a/tests/type-definitions/entries/pure/tsconfig.json +++ b/tests/type-definitions/entries/pure/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.json", - "include": ["./imports.ts"], + "include": [ + "./imports.pure.test.ts" + ], "compilerOptions": { "types": ["@core-js/types/pure"] } diff --git a/tests/type-definitions/entries/stable/entries.ts b/tests/type-definitions/entries/stable/entries.stable.test.ts similarity index 100% rename from tests/type-definitions/entries/stable/entries.ts rename to tests/type-definitions/entries/stable/entries.stable.test.ts diff --git a/tests/type-definitions/entries/stable/tsconfig.json b/tests/type-definitions/entries/stable/tsconfig.json index 6a33da986402..4697660823b7 100644 --- a/tests/type-definitions/entries/stable/tsconfig.json +++ b/tests/type-definitions/entries/stable/tsconfig.json @@ -1,4 +1,6 @@ { "extends": "../../tsconfig.json", - "include": ["./entries.ts"] + "include": [ + "./entries.stable.test.ts" + ] } From 7616ade942f65ad98a7654b672b75c56867ca414 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 6 Feb 2026 01:28:48 +0700 Subject: [PATCH 182/315] Revert "Rename new tests" This reverts commit 3f74e41795e9a871f2cef9f16f1356f6741e76a7. --- .../entries/actual/{entries.actual.test.ts => entries.ts} | 0 tests/type-definitions/entries/actual/tsconfig.json | 4 +--- .../global/{configurator.global.test.ts => configurator.ts} | 0 .../entries/configurator/global/tsconfig.json | 4 +--- .../import/{configurator.import.test.ts => configurator.ts} | 0 .../entries/configurator/import/tsconfig.json | 4 +--- .../entries/es/{entries.es.test.ts => entries.ts} | 0 tests/type-definitions/entries/es/tsconfig.json | 4 +--- .../entries/full/{entries.full.test.ts => entries.ts} | 0 tests/type-definitions/entries/full/tsconfig.json | 4 +--- .../entries/global/{imports.global.test.ts => imports.ts} | 0 tests/type-definitions/entries/global/tsconfig.json | 4 +--- .../proposals/{entries.proposals.test.ts => entries.ts} | 0 tests/type-definitions/entries/proposals/tsconfig.json | 4 +--- .../entries/pure/{imports.pure.test.ts => imports.ts} | 0 tests/type-definitions/entries/pure/tsconfig.json | 4 +--- .../entries/stable/{entries.stable.test.ts => entries.ts} | 0 tests/type-definitions/entries/stable/tsconfig.json | 4 +--- 18 files changed, 9 insertions(+), 27 deletions(-) rename tests/type-definitions/entries/actual/{entries.actual.test.ts => entries.ts} (100%) rename tests/type-definitions/entries/configurator/global/{configurator.global.test.ts => configurator.ts} (100%) rename tests/type-definitions/entries/configurator/import/{configurator.import.test.ts => configurator.ts} (100%) rename tests/type-definitions/entries/es/{entries.es.test.ts => entries.ts} (100%) rename tests/type-definitions/entries/full/{entries.full.test.ts => entries.ts} (100%) rename tests/type-definitions/entries/global/{imports.global.test.ts => imports.ts} (100%) rename tests/type-definitions/entries/proposals/{entries.proposals.test.ts => entries.ts} (100%) rename tests/type-definitions/entries/pure/{imports.pure.test.ts => imports.ts} (100%) rename tests/type-definitions/entries/stable/{entries.stable.test.ts => entries.ts} (100%) diff --git a/tests/type-definitions/entries/actual/entries.actual.test.ts b/tests/type-definitions/entries/actual/entries.ts similarity index 100% rename from tests/type-definitions/entries/actual/entries.actual.test.ts rename to tests/type-definitions/entries/actual/entries.ts diff --git a/tests/type-definitions/entries/actual/tsconfig.json b/tests/type-definitions/entries/actual/tsconfig.json index 0c077220aa24..6a33da986402 100644 --- a/tests/type-definitions/entries/actual/tsconfig.json +++ b/tests/type-definitions/entries/actual/tsconfig.json @@ -1,6 +1,4 @@ { "extends": "../../tsconfig.json", - "include": [ - "./entries.actual.test.ts" - ] + "include": ["./entries.ts"] } diff --git a/tests/type-definitions/entries/configurator/global/configurator.global.test.ts b/tests/type-definitions/entries/configurator/global/configurator.ts similarity index 100% rename from tests/type-definitions/entries/configurator/global/configurator.global.test.ts rename to tests/type-definitions/entries/configurator/global/configurator.ts diff --git a/tests/type-definitions/entries/configurator/global/tsconfig.json b/tests/type-definitions/entries/configurator/global/tsconfig.json index b267339aac62..9212a1b7b314 100644 --- a/tests/type-definitions/entries/configurator/global/tsconfig.json +++ b/tests/type-definitions/entries/configurator/global/tsconfig.json @@ -1,8 +1,6 @@ { "extends": "../../../tsconfig.json", - "include": [ - "./configurator.global.test.ts" - ], + "include": ["./configurator.ts"], "compilerOptions": { "types": [ "@core-js/types" diff --git a/tests/type-definitions/entries/configurator/import/configurator.import.test.ts b/tests/type-definitions/entries/configurator/import/configurator.ts similarity index 100% rename from tests/type-definitions/entries/configurator/import/configurator.import.test.ts rename to tests/type-definitions/entries/configurator/import/configurator.ts diff --git a/tests/type-definitions/entries/configurator/import/tsconfig.json b/tests/type-definitions/entries/configurator/import/tsconfig.json index f68c1d31a954..49cb748ee483 100644 --- a/tests/type-definitions/entries/configurator/import/tsconfig.json +++ b/tests/type-definitions/entries/configurator/import/tsconfig.json @@ -1,6 +1,4 @@ { "extends": "../../../tsconfig.json", - "include": [ - "./configurator.import.test.ts" - ] + "include": ["./configurator.ts"] } diff --git a/tests/type-definitions/entries/es/entries.es.test.ts b/tests/type-definitions/entries/es/entries.ts similarity index 100% rename from tests/type-definitions/entries/es/entries.es.test.ts rename to tests/type-definitions/entries/es/entries.ts diff --git a/tests/type-definitions/entries/es/tsconfig.json b/tests/type-definitions/entries/es/tsconfig.json index a9c9c798139b..6a33da986402 100644 --- a/tests/type-definitions/entries/es/tsconfig.json +++ b/tests/type-definitions/entries/es/tsconfig.json @@ -1,6 +1,4 @@ { "extends": "../../tsconfig.json", - "include": [ - "./entries.es.test.ts" - ] + "include": ["./entries.ts"] } diff --git a/tests/type-definitions/entries/full/entries.full.test.ts b/tests/type-definitions/entries/full/entries.ts similarity index 100% rename from tests/type-definitions/entries/full/entries.full.test.ts rename to tests/type-definitions/entries/full/entries.ts diff --git a/tests/type-definitions/entries/full/tsconfig.json b/tests/type-definitions/entries/full/tsconfig.json index c96132e9d3f0..6a33da986402 100644 --- a/tests/type-definitions/entries/full/tsconfig.json +++ b/tests/type-definitions/entries/full/tsconfig.json @@ -1,6 +1,4 @@ { "extends": "../../tsconfig.json", - "include": [ - "./entries.full.test.ts" - ] + "include": ["./entries.ts"] } diff --git a/tests/type-definitions/entries/global/imports.global.test.ts b/tests/type-definitions/entries/global/imports.ts similarity index 100% rename from tests/type-definitions/entries/global/imports.global.test.ts rename to tests/type-definitions/entries/global/imports.ts diff --git a/tests/type-definitions/entries/global/tsconfig.json b/tests/type-definitions/entries/global/tsconfig.json index 8d3adea9ba57..3a2fb2f85d59 100644 --- a/tests/type-definitions/entries/global/tsconfig.json +++ b/tests/type-definitions/entries/global/tsconfig.json @@ -1,8 +1,6 @@ { "extends": "../../tsconfig.json", - "include": [ - "./imports.global.test.ts" - ], + "include": ["./imports.ts"], "compilerOptions": { "types": ["@core-js/types"] } diff --git a/tests/type-definitions/entries/proposals/entries.proposals.test.ts b/tests/type-definitions/entries/proposals/entries.ts similarity index 100% rename from tests/type-definitions/entries/proposals/entries.proposals.test.ts rename to tests/type-definitions/entries/proposals/entries.ts diff --git a/tests/type-definitions/entries/proposals/tsconfig.json b/tests/type-definitions/entries/proposals/tsconfig.json index 94fae1f45eb1..6a33da986402 100644 --- a/tests/type-definitions/entries/proposals/tsconfig.json +++ b/tests/type-definitions/entries/proposals/tsconfig.json @@ -1,6 +1,4 @@ { "extends": "../../tsconfig.json", - "include": [ - "./entries.proposals.test.ts" - ] + "include": ["./entries.ts"] } diff --git a/tests/type-definitions/entries/pure/imports.pure.test.ts b/tests/type-definitions/entries/pure/imports.ts similarity index 100% rename from tests/type-definitions/entries/pure/imports.pure.test.ts rename to tests/type-definitions/entries/pure/imports.ts diff --git a/tests/type-definitions/entries/pure/tsconfig.json b/tests/type-definitions/entries/pure/tsconfig.json index 473bd4e3233e..87b6595a8b0c 100644 --- a/tests/type-definitions/entries/pure/tsconfig.json +++ b/tests/type-definitions/entries/pure/tsconfig.json @@ -1,8 +1,6 @@ { "extends": "../../tsconfig.json", - "include": [ - "./imports.pure.test.ts" - ], + "include": ["./imports.ts"], "compilerOptions": { "types": ["@core-js/types/pure"] } diff --git a/tests/type-definitions/entries/stable/entries.stable.test.ts b/tests/type-definitions/entries/stable/entries.ts similarity index 100% rename from tests/type-definitions/entries/stable/entries.stable.test.ts rename to tests/type-definitions/entries/stable/entries.ts diff --git a/tests/type-definitions/entries/stable/tsconfig.json b/tests/type-definitions/entries/stable/tsconfig.json index 4697660823b7..6a33da986402 100644 --- a/tests/type-definitions/entries/stable/tsconfig.json +++ b/tests/type-definitions/entries/stable/tsconfig.json @@ -1,6 +1,4 @@ { "extends": "../../tsconfig.json", - "include": [ - "./entries.stable.test.ts" - ] + "include": ["./entries.ts"] } From e5a53a4f601f4b67016aa7ab4be0c2cfe3ed9452 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 6 Feb 2026 02:46:21 +0700 Subject: [PATCH 183/315] Types for configurator --- .../src/base/configurator-custom.d.ts | 3 ++ .../core-js-types/src/base/configurator.d.ts | 1 - .../build-entries-and-types/build-types.mjs | 29 ++++++++++++------- scripts/build-entries-and-types/templates.mjs | 10 +++++++ .../{import/configurator.ts => entries.ts} | 1 + .../configurator/global/configurator.ts | 1 - .../entries/configurator/global/tsconfig.json | 9 ------ .../entries/configurator/import/tsconfig.json | 4 --- .../entries/configurator/tsconfig.json | 4 +++ tests/type-definitions/runner.mjs | 3 +- 10 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 packages/core-js-types/src/base/configurator-custom.d.ts delete mode 100644 packages/core-js-types/src/base/configurator.d.ts rename tests/type-definitions/entries/configurator/{import/configurator.ts => entries.ts} (61%) delete mode 100644 tests/type-definitions/entries/configurator/global/configurator.ts delete mode 100644 tests/type-definitions/entries/configurator/global/tsconfig.json delete mode 100644 tests/type-definitions/entries/configurator/import/tsconfig.json create mode 100644 tests/type-definitions/entries/configurator/tsconfig.json diff --git a/packages/core-js-types/src/base/configurator-custom.d.ts b/packages/core-js-types/src/base/configurator-custom.d.ts new file mode 100644 index 000000000000..661f01c707db --- /dev/null +++ b/packages/core-js-types/src/base/configurator-custom.d.ts @@ -0,0 +1,3 @@ +declare namespace CoreJS { + export function Configurator(options: Record): void; +} diff --git a/packages/core-js-types/src/base/configurator.d.ts b/packages/core-js-types/src/base/configurator.d.ts deleted file mode 100644 index dd4932f53bfc..000000000000 --- a/packages/core-js-types/src/base/configurator.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare function configurator(options: Record): void; diff --git a/scripts/build-entries-and-types/build-types.mjs b/scripts/build-entries-and-types/build-types.mjs index 571fc1842d9f..8d7ea077c2c4 100644 --- a/scripts/build-entries-and-types/build-types.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -1,5 +1,5 @@ import { features, proposals } from './entries-definitions.mjs'; -import { $namespace, $path, $proposal, $typeDummy } from './templates.mjs'; +import { $functionWithCustomType, $path, $proposal, $typeDummy } from './templates.mjs'; import { modules as AllModules } from '@core-js/compat/src/data.mjs'; import { getModulesMetadata } from './get-dependencies.mjs'; import { expandModules, modulesToStage } from './helpers.mjs'; @@ -42,7 +42,9 @@ function addType(tsVersion, subset, template, options) { function addEntryTypes(tsVersion, template, options) { addType(tsVersion, 'index', template, { ...options, packageName: PACKAGE_NAME }); - addType(tsVersion, 'pure', template, { ...options, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); + if (!options.noPure) { + addType(tsVersion, 'pure', template, { ...options, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX }); + } if (options.exportForSubset) { addType(tsVersion, options.subset, template, { ...options, packageName: PACKAGE_NAME }); } @@ -54,6 +56,7 @@ async function buildType(entry, options) { subset = entryFromNamespace ?? 'full', typeDummy = false, globalType = true, + noPure = false, template, templateStable, templateActual, templateFull, filter, modules, enforceEntryCreation, customType, tsVersion, proposal, types, ownEntryPoint, } = options; @@ -84,10 +87,13 @@ async function buildType(entry, options) { const level = entry.split('/').length - 1; if (!types) { - if (!enforceEntryCreation && !expandModules(modules[0], filter, AllModules).length) return; - modules = expandModules(modules, filter, AllModules); - const { types: typePaths } = await getModulesMetadata(modules); - types = typePaths; + types = []; + if (!customType) { + if (!enforceEntryCreation && !expandModules(modules[0], filter, AllModules).length) return; + modules = expandModules(modules, filter, AllModules); + const { types: typePaths } = await getModulesMetadata(modules); + types = typePaths; + } } if (typesFilter) { @@ -99,7 +105,7 @@ async function buildType(entry, options) { imports.index.add(type); imports[subset].add(type); } - imports.pure.add(path.join('pure', type)); + if (!noPure) imports.pure.add(path.join('pure', type)); }); if (customType) { @@ -107,9 +113,9 @@ async function buildType(entry, options) { imports.index.add(customType); imports[subset].add(customType); } - imports.pure.add(path.join('pure', customType)); + if (!noPure) imports.pure.add(path.join('pure', customType)); } - options = { ...options, modules, level, entry, types, subset }; + options = { ...options, modules, level, entry, types, subset, noPure }; addEntryTypes(tsVersion, template, options); if (!entry.endsWith('/')) { // add alias with .js ending @@ -231,13 +237,14 @@ async function buildTypesForTSVersion(tsVersion) { await buildType('index', { template: $path, modules: ActualModules, tsVersion }); await buildType('configurator', { + customType: 'configurator-custom', entryFromNamespace: 'configurator', - template: $namespace, + template: $functionWithCustomType, modules: ['configurator'], name: 'configurator', tsVersion, - types: ['configurator'], exportForSubset: true, + noPure: true, }); await prependImports(tsVersion); diff --git a/scripts/build-entries-and-types/templates.mjs b/scripts/build-entries-and-types/templates.mjs index 37d2e137fd40..514068bf16e3 100644 --- a/scripts/build-entries-and-types/templates.mjs +++ b/scripts/build-entries-and-types/templates.mjs @@ -492,3 +492,13 @@ export const $typeDummy = p => ({ } `, }); + +export const $functionWithCustomType = p => ({ + entry: '', + types: dedent` + declare module '${ buildModulePath(p) }' { + const resultFunction: typeof ${ buildCoreJSTypeName('', p.name) }; + export = resultFunction; + } + `, +}); diff --git a/tests/type-definitions/entries/configurator/import/configurator.ts b/tests/type-definitions/entries/configurator/entries.ts similarity index 61% rename from tests/type-definitions/entries/configurator/import/configurator.ts rename to tests/type-definitions/entries/configurator/entries.ts index 24728bd991a7..d5b048991c26 100644 --- a/tests/type-definitions/entries/configurator/import/configurator.ts +++ b/tests/type-definitions/entries/configurator/entries.ts @@ -1,3 +1,4 @@ import '@core-js/types/configurator'; +import configurator from 'core-js/configurator'; configurator({ something: 'value' }); diff --git a/tests/type-definitions/entries/configurator/global/configurator.ts b/tests/type-definitions/entries/configurator/global/configurator.ts deleted file mode 100644 index f7cfbbfd3953..000000000000 --- a/tests/type-definitions/entries/configurator/global/configurator.ts +++ /dev/null @@ -1 +0,0 @@ -configurator({ something: 'value' }); diff --git a/tests/type-definitions/entries/configurator/global/tsconfig.json b/tests/type-definitions/entries/configurator/global/tsconfig.json deleted file mode 100644 index 9212a1b7b314..000000000000 --- a/tests/type-definitions/entries/configurator/global/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../../tsconfig.json", - "include": ["./configurator.ts"], - "compilerOptions": { - "types": [ - "@core-js/types" - ] - } -} diff --git a/tests/type-definitions/entries/configurator/import/tsconfig.json b/tests/type-definitions/entries/configurator/import/tsconfig.json deleted file mode 100644 index 49cb748ee483..000000000000 --- a/tests/type-definitions/entries/configurator/import/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../../tsconfig.json", - "include": ["./configurator.ts"] -} diff --git a/tests/type-definitions/entries/configurator/tsconfig.json b/tests/type-definitions/entries/configurator/tsconfig.json new file mode 100644 index 000000000000..6a33da986402 --- /dev/null +++ b/tests/type-definitions/entries/configurator/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./entries.ts"] +} diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index abb9b18703b8..82aa5105bca3 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -166,8 +166,7 @@ tasks.push( { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/proposals/tsconfig.json'] }, { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/global/tsconfig.json'] }, { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/pure/tsconfig.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/configurator/global/tsconfig.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/configurator/import/tsconfig.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/configurator/tsconfig.json'] }, ); let envs; From b6b3c9060a150e500954e53fecb7f0fd6a0c96c1 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 6 Feb 2026 02:50:19 +0700 Subject: [PATCH 184/315] Add annex-b tests --- tests/type-definitions/global/annex-b/object-proto.test.ts | 3 ++- .../annex-b/object-prototype-accessor-methods.test.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/type-definitions/global/annex-b/object-prototype-accessor-methods.test.ts diff --git a/tests/type-definitions/global/annex-b/object-proto.test.ts b/tests/type-definitions/global/annex-b/object-proto.test.ts index 28c9d7acee13..4060b1cd8f69 100644 --- a/tests/type-definitions/global/annex-b/object-proto.test.ts +++ b/tests/type-definitions/global/annex-b/object-proto.test.ts @@ -1,3 +1,4 @@ import 'core-js/full'; -const objectProto: object | null = {}.__proto__; +declare const obj: Object; +const objectProto: object | null = obj.__proto__; diff --git a/tests/type-definitions/global/annex-b/object-prototype-accessor-methods.test.ts b/tests/type-definitions/global/annex-b/object-prototype-accessor-methods.test.ts new file mode 100644 index 000000000000..4f8a6be2fd82 --- /dev/null +++ b/tests/type-definitions/global/annex-b/object-prototype-accessor-methods.test.ts @@ -0,0 +1,7 @@ +import 'core-js/full'; + +declare const obj: Object; +obj.__defineGetter__('num', () => 42); +obj.__defineSetter__('num', (val: number) => {}); +const getter: (() => any) | undefined = obj.__lookupGetter__('num'); +const setter: ((val: number) => any) | undefined = obj.__lookupSetter__('num'); From 7d24f81112befd6d37d43cf3bc7272ef9d22e8ab Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 6 Feb 2026 03:15:08 +0700 Subject: [PATCH 185/315] Rename entries tests --- tests/type-definitions/entries/actual/{entries.ts => test.ts} | 0 tests/type-definitions/entries/actual/tsconfig.json | 4 +++- .../entries/configurator/{entries.ts => test.ts} | 0 tests/type-definitions/entries/configurator/tsconfig.json | 4 +++- tests/type-definitions/entries/es/{entries.ts => test.ts} | 0 tests/type-definitions/entries/es/tsconfig.json | 4 +++- tests/type-definitions/entries/full/{entries.ts => test.ts} | 0 tests/type-definitions/entries/full/tsconfig.json | 4 +++- .../entries/{global/imports.ts => global-symlinks/test.ts} | 0 .../entries/{global => global-symlinks}/tsconfig.json | 4 +++- .../entries/proposals/{entries.ts => test.ts} | 0 tests/type-definitions/entries/proposals/tsconfig.json | 4 +++- .../entries/{pure/imports.ts => pure-symlinks/test.ts} | 0 .../entries/{pure => pure-symlinks}/tsconfig.json | 4 +++- tests/type-definitions/entries/stable/{entries.ts => test.ts} | 0 tests/type-definitions/entries/stable/tsconfig.json | 4 +++- tests/type-definitions/runner.mjs | 4 ++-- 17 files changed, 26 insertions(+), 10 deletions(-) rename tests/type-definitions/entries/actual/{entries.ts => test.ts} (100%) rename tests/type-definitions/entries/configurator/{entries.ts => test.ts} (100%) rename tests/type-definitions/entries/es/{entries.ts => test.ts} (100%) rename tests/type-definitions/entries/full/{entries.ts => test.ts} (100%) rename tests/type-definitions/entries/{global/imports.ts => global-symlinks/test.ts} (100%) rename tests/type-definitions/entries/{global => global-symlinks}/tsconfig.json (73%) rename tests/type-definitions/entries/proposals/{entries.ts => test.ts} (100%) rename tests/type-definitions/entries/{pure/imports.ts => pure-symlinks/test.ts} (100%) rename tests/type-definitions/entries/{pure => pure-symlinks}/tsconfig.json (74%) rename tests/type-definitions/entries/stable/{entries.ts => test.ts} (100%) diff --git a/tests/type-definitions/entries/actual/entries.ts b/tests/type-definitions/entries/actual/test.ts similarity index 100% rename from tests/type-definitions/entries/actual/entries.ts rename to tests/type-definitions/entries/actual/test.ts diff --git a/tests/type-definitions/entries/actual/tsconfig.json b/tests/type-definitions/entries/actual/tsconfig.json index 6a33da986402..af766fab017b 100644 --- a/tests/type-definitions/entries/actual/tsconfig.json +++ b/tests/type-definitions/entries/actual/tsconfig.json @@ -1,4 +1,6 @@ { "extends": "../../tsconfig.json", - "include": ["./entries.ts"] + "include": [ + "./test.ts" + ] } diff --git a/tests/type-definitions/entries/configurator/entries.ts b/tests/type-definitions/entries/configurator/test.ts similarity index 100% rename from tests/type-definitions/entries/configurator/entries.ts rename to tests/type-definitions/entries/configurator/test.ts diff --git a/tests/type-definitions/entries/configurator/tsconfig.json b/tests/type-definitions/entries/configurator/tsconfig.json index 6a33da986402..af766fab017b 100644 --- a/tests/type-definitions/entries/configurator/tsconfig.json +++ b/tests/type-definitions/entries/configurator/tsconfig.json @@ -1,4 +1,6 @@ { "extends": "../../tsconfig.json", - "include": ["./entries.ts"] + "include": [ + "./test.ts" + ] } diff --git a/tests/type-definitions/entries/es/entries.ts b/tests/type-definitions/entries/es/test.ts similarity index 100% rename from tests/type-definitions/entries/es/entries.ts rename to tests/type-definitions/entries/es/test.ts diff --git a/tests/type-definitions/entries/es/tsconfig.json b/tests/type-definitions/entries/es/tsconfig.json index 6a33da986402..af766fab017b 100644 --- a/tests/type-definitions/entries/es/tsconfig.json +++ b/tests/type-definitions/entries/es/tsconfig.json @@ -1,4 +1,6 @@ { "extends": "../../tsconfig.json", - "include": ["./entries.ts"] + "include": [ + "./test.ts" + ] } diff --git a/tests/type-definitions/entries/full/entries.ts b/tests/type-definitions/entries/full/test.ts similarity index 100% rename from tests/type-definitions/entries/full/entries.ts rename to tests/type-definitions/entries/full/test.ts diff --git a/tests/type-definitions/entries/full/tsconfig.json b/tests/type-definitions/entries/full/tsconfig.json index 6a33da986402..af766fab017b 100644 --- a/tests/type-definitions/entries/full/tsconfig.json +++ b/tests/type-definitions/entries/full/tsconfig.json @@ -1,4 +1,6 @@ { "extends": "../../tsconfig.json", - "include": ["./entries.ts"] + "include": [ + "./test.ts" + ] } diff --git a/tests/type-definitions/entries/global/imports.ts b/tests/type-definitions/entries/global-symlinks/test.ts similarity index 100% rename from tests/type-definitions/entries/global/imports.ts rename to tests/type-definitions/entries/global-symlinks/test.ts diff --git a/tests/type-definitions/entries/global/tsconfig.json b/tests/type-definitions/entries/global-symlinks/tsconfig.json similarity index 73% rename from tests/type-definitions/entries/global/tsconfig.json rename to tests/type-definitions/entries/global-symlinks/tsconfig.json index 3a2fb2f85d59..ff4c8fd208b3 100644 --- a/tests/type-definitions/entries/global/tsconfig.json +++ b/tests/type-definitions/entries/global-symlinks/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.json", - "include": ["./imports.ts"], + "include": [ + "./test.ts" + ], "compilerOptions": { "types": ["@core-js/types"] } diff --git a/tests/type-definitions/entries/proposals/entries.ts b/tests/type-definitions/entries/proposals/test.ts similarity index 100% rename from tests/type-definitions/entries/proposals/entries.ts rename to tests/type-definitions/entries/proposals/test.ts diff --git a/tests/type-definitions/entries/proposals/tsconfig.json b/tests/type-definitions/entries/proposals/tsconfig.json index 6a33da986402..af766fab017b 100644 --- a/tests/type-definitions/entries/proposals/tsconfig.json +++ b/tests/type-definitions/entries/proposals/tsconfig.json @@ -1,4 +1,6 @@ { "extends": "../../tsconfig.json", - "include": ["./entries.ts"] + "include": [ + "./test.ts" + ] } diff --git a/tests/type-definitions/entries/pure/imports.ts b/tests/type-definitions/entries/pure-symlinks/test.ts similarity index 100% rename from tests/type-definitions/entries/pure/imports.ts rename to tests/type-definitions/entries/pure-symlinks/test.ts diff --git a/tests/type-definitions/entries/pure/tsconfig.json b/tests/type-definitions/entries/pure-symlinks/tsconfig.json similarity index 74% rename from tests/type-definitions/entries/pure/tsconfig.json rename to tests/type-definitions/entries/pure-symlinks/tsconfig.json index 87b6595a8b0c..36fc3f454b75 100644 --- a/tests/type-definitions/entries/pure/tsconfig.json +++ b/tests/type-definitions/entries/pure-symlinks/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.json", - "include": ["./imports.ts"], + "include": [ + "./test.ts" + ], "compilerOptions": { "types": ["@core-js/types/pure"] } diff --git a/tests/type-definitions/entries/stable/entries.ts b/tests/type-definitions/entries/stable/test.ts similarity index 100% rename from tests/type-definitions/entries/stable/entries.ts rename to tests/type-definitions/entries/stable/test.ts diff --git a/tests/type-definitions/entries/stable/tsconfig.json b/tests/type-definitions/entries/stable/tsconfig.json index 6a33da986402..af766fab017b 100644 --- a/tests/type-definitions/entries/stable/tsconfig.json +++ b/tests/type-definitions/entries/stable/tsconfig.json @@ -1,4 +1,6 @@ { "extends": "../../tsconfig.json", - "include": ["./entries.ts"] + "include": [ + "./test.ts" + ] } diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 82aa5105bca3..a1088bf26d67 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -164,8 +164,8 @@ tasks.push( { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/stable/tsconfig.json'] }, { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/es/tsconfig.json'] }, { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/proposals/tsconfig.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/global/tsconfig.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/pure/tsconfig.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/global-symlinks/tsconfig.json'] }, + { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/pure-symlinks/tsconfig.json'] }, { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/configurator/tsconfig.json'] }, ); From 79cd8a1ce9c6c8c225c5878b009c8c386739a743 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sun, 8 Feb 2026 14:51:53 +0200 Subject: [PATCH 186/315] update after rebasing --- tests/eslint/eslint.config.js | 5 +- tests/eslint/package-lock.json | 90 +++++++++++++++++------- tests/eslint/package.json | 1 + tests/type-definitions/package-lock.json | 22 +++++- tests/type-definitions/package.json | 5 +- 5 files changed, 93 insertions(+), 30 deletions(-) diff --git a/tests/eslint/eslint.config.js b/tests/eslint/eslint.config.js index e4b6991824ca..36e033c1ad84 100644 --- a/tests/eslint/eslint.config.js +++ b/tests/eslint/eslint.config.js @@ -1,3 +1,4 @@ +import { fixupPluginRules } from '@eslint/compat'; import globals from 'globals'; import confusingBrowserGlobals from 'confusing-browser-globals'; import * as parserJSONC from 'jsonc-eslint-parser'; @@ -23,10 +24,12 @@ import pluginRegExp from 'eslint-plugin-regexp'; import pluginSonarJS from 'eslint-plugin-sonarjs'; import pluginStylistic from '@stylistic/eslint-plugin'; import pluginTypeScript from '@typescript-eslint/eslint-plugin'; -import pluginTSDoc from 'eslint-plugin-tsdoc'; +import $pluginTSDoc from 'eslint-plugin-tsdoc'; import pluginUnicorn from 'eslint-plugin-unicorn'; import { yaml as pluginYaml } from 'eslint-yaml'; +const pluginTSDoc = fixupPluginRules($pluginTSDoc); + const PACKAGES_NODE_VERSIONS = '^20.19'; const DEV_NODE_VERSIONS = '^20.19'; diff --git a/tests/eslint/package-lock.json b/tests/eslint/package-lock.json index 3f3d03cab731..055e1d6c9d73 100644 --- a/tests/eslint/package-lock.json +++ b/tests/eslint/package-lock.json @@ -7,6 +7,7 @@ "name": "tests/eslint", "devDependencies": { "@eslint-community/eslint-plugin-eslint-comments": "^4.6.0", + "@eslint/compat": "^2.0.2", "@eslint/markdown": "^7.5.1", "@stylistic/eslint-plugin": "^5.9.0", "@typescript-eslint/eslint-plugin": "^8.56.0", @@ -150,6 +151,27 @@ "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, + "node_modules/@eslint/compat": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-2.0.2.tgz", + "integrity": "sha512-pR1DoD0h3HfF675QZx0xsyrsU8q70Z/plx7880NOhS02NuWLgBCOMDL787nUeQ7EWLkxv3bPQJaarjcPQb2Dwg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^1.1.0" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "peerDependencies": { + "eslint": "^8.40 || 9 || 10" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, "node_modules/@eslint/config-array": { "version": "0.23.2", "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.2.tgz", @@ -194,7 +216,7 @@ "node": "^20.19.0 || ^22.13.0 || >=24" } }, - "node_modules/@eslint/config-helpers/node_modules/@eslint/core": { + "node_modules/@eslint/core": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@eslint/core/-/core-1.1.0.tgz", "integrity": "sha512-/nr9K9wkr3P1EzFTdFdMoLuo1PmIxjmwvPozwoSodjNBdefGujXQUF93u1DDZpEaTuDvMsIQddsd35BwtrW9Xw==", @@ -207,19 +229,6 @@ "node": "^20.19.0 || ^22.13.0 || >=24" } }, - "node_modules/@eslint/core": { - "version": "0.17.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", - "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@types/json-schema": "^7.0.15" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, "node_modules/@eslint/eslintrc": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.3.tgz", @@ -356,6 +365,19 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@eslint/markdown/node_modules/@eslint/core": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", + "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/@eslint/object-schema": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-3.0.2.tgz", @@ -380,6 +402,19 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@eslint/plugin-kit/node_modules/@eslint/core": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", + "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/@humanfs/core": { "version": "0.19.1", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", @@ -2397,6 +2432,20 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/core": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", + "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/object-schema": { "version": "2.1.7", "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz", @@ -2811,19 +2860,6 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "node_modules/eslint/node_modules/@eslint/core": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-1.1.0.tgz", - "integrity": "sha512-/nr9K9wkr3P1EzFTdFdMoLuo1PmIxjmwvPozwoSodjNBdefGujXQUF93u1DDZpEaTuDvMsIQddsd35BwtrW9Xw==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@types/json-schema": "^7.0.15" - }, - "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" - } - }, "node_modules/eslint/node_modules/@eslint/plugin-kit": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.6.0.tgz", diff --git a/tests/eslint/package.json b/tests/eslint/package.json index 5cc1732c302b..a3dd19945266 100644 --- a/tests/eslint/package.json +++ b/tests/eslint/package.json @@ -2,6 +2,7 @@ "name": "tests/eslint", "type": "module", "devDependencies": { + "@eslint/compat": "^2.0.2", "@eslint/markdown": "^7.5.1", "@eslint-community/eslint-plugin-eslint-comments": "^4.6.0", "@stylistic/eslint-plugin": "^5.9.0", diff --git a/tests/type-definitions/package-lock.json b/tests/type-definitions/package-lock.json index d36672ed25f6..0cebcb627d7f 100644 --- a/tests/type-definitions/package-lock.json +++ b/tests/type-definitions/package-lock.json @@ -4,7 +4,27 @@ "requires": true, "packages": { "": { - "name": "tests/type-definitions" + "name": "tests/type-definitions", + "devDependencies": { + "@types/node": "^25.2.2" + } + }, + "node_modules/@types/node": { + "version": "25.2.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.2.2.tgz", + "integrity": "sha512-BkmoP5/FhRYek5izySdkOneRyXYN35I860MFAGupTdebyE66uZaR+bXLHq8k4DirE5DwQi3NuhvRU1jqTVwUrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.16.0" + } + }, + "node_modules/undici-types": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "dev": true, + "license": "MIT" } } } diff --git a/tests/type-definitions/package.json b/tests/type-definitions/package.json index fcf49f09a0c2..c77e29d65bf1 100644 --- a/tests/type-definitions/package.json +++ b/tests/type-definitions/package.json @@ -1,3 +1,6 @@ { - "name": "tests/type-definitions" + "name": "tests/type-definitions", + "devDependencies": { + "@types/node": "^25.2.2" + } } From 3b260e304e967393353bb6e565a1bceb3acac124 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sun, 8 Feb 2026 16:25:27 +0200 Subject: [PATCH 187/315] add types for `Object.keysLength` --- .../base/proposals/object-keys-length.d.ts | 9 +++++ .../modules/esnext.object.keys-length.js | 1 + .../proposals/object-keys-length.test.ts | 34 +++++++++++++++++++ .../pure/proposals/object-keys-length.test.ts | 21 ++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 packages/core-js-types/src/base/proposals/object-keys-length.d.ts create mode 100644 tests/type-definitions/global/proposals/object-keys-length.test.ts create mode 100644 tests/type-definitions/pure/proposals/object-keys-length.test.ts diff --git a/packages/core-js-types/src/base/proposals/object-keys-length.d.ts b/packages/core-js-types/src/base/proposals/object-keys-length.d.ts new file mode 100644 index 000000000000..1d6054e86821 --- /dev/null +++ b/packages/core-js-types/src/base/proposals/object-keys-length.d.ts @@ -0,0 +1,9 @@ +// https://github.com/tc39/proposal-object-keys-length + +interface ObjectConstructor { + /** + * Returns the number of enumerable own 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. + */ + keysLength(o: {}): number; +} diff --git a/packages/core-js/modules/esnext.object.keys-length.js b/packages/core-js/modules/esnext.object.keys-length.js index 58157cbff4c0..4d56d262c870 100644 --- a/packages/core-js/modules/esnext.object.keys-length.js +++ b/packages/core-js/modules/esnext.object.keys-length.js @@ -1,3 +1,4 @@ +// @types: proposals/object-keys-length 'use strict'; var $ = require('../internals/export'); var toObject = require('../internals/to-object'); diff --git a/tests/type-definitions/global/proposals/object-keys-length.test.ts b/tests/type-definitions/global/proposals/object-keys-length.test.ts new file mode 100644 index 000000000000..b66e223fb13e --- /dev/null +++ b/tests/type-definitions/global/proposals/object-keys-length.test.ts @@ -0,0 +1,34 @@ +import 'core-js/full'; +import keysLength from 'core-js/full/object/keys-length'; +import { assertNumber } from '../../helpers'; + +const obj = { a: 1, b: 2 }; +const arr = [1, 2, 3]; +const strArr = ['a', 'b', 'c']; +const arrLike: ArrayLike = { 0: 10, 1: 20, length: 2 }; +const emptyObj = {}; +const string = 'abc'; + +assertNumber(keysLength(obj)); +assertNumber(keysLength(arr)); +assertNumber(keysLength(strArr)); +assertNumber(keysLength(arrLike)); +assertNumber(keysLength(emptyObj)); +assertNumber(keysLength(string)); + +assertNumber(Object.keysLength(obj)); +assertNumber(Object.keysLength(arr)); +assertNumber(Object.keysLength(strArr)); +assertNumber(Object.keysLength(arrLike)); +assertNumber(Object.keysLength(emptyObj)); +assertNumber(Object.keysLength(string)); + +// @ts-expect-error +keysLength(); +// @ts-expect-error +keysLength(null); + +// @ts-expect-error +Object.keysLength(); +// @ts-expect-error +Object.keysLength(null); diff --git a/tests/type-definitions/pure/proposals/object-keys-length.test.ts b/tests/type-definitions/pure/proposals/object-keys-length.test.ts new file mode 100644 index 000000000000..035114a3d7b1 --- /dev/null +++ b/tests/type-definitions/pure/proposals/object-keys-length.test.ts @@ -0,0 +1,21 @@ +import keysLength from '@core-js/pure/full/object/keys-length'; +import { assertNumber } from '../../helpers'; + +const obj = { a: 1, b: 2 }; +const arr = [1, 2, 3]; +const strArr = ['a', 'b', 'c']; +const arrLike: ArrayLike = { 0: 10, 1: 20, length: 2 }; +const emptyObj = {}; +const string = 'abc'; + +assertNumber(keysLength(obj)); +assertNumber(keysLength(arr)); +assertNumber(keysLength(strArr)); +assertNumber(keysLength(arrLike)); +assertNumber(keysLength(emptyObj)); +assertNumber(keysLength(string)); + +// @ts-expect-error +keysLength(); +// @ts-expect-error +keysLength(null); From 7371bdea7d53976419cb41b61e0677332d51b62b Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sun, 8 Feb 2026 20:07:43 +0200 Subject: [PATCH 188/315] simplify type definitions tests runner config, rework runner and change the style of output --- tests/type-definitions/runner.mjs | 63 ++++++++++++++----------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index a1088bf26d67..e8d25b2fb5fd 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -64,21 +64,18 @@ async function runLimited(tasks, limit) { await Promise.all(Array.from({ length: limit }, worker)); } -async function runTask(config) { - $.verbose = false; - const command = `$ npx ${ config.args.join(' ') }`; +async function runTask({ cwd, ts, config, args = [] }) { + const task = $({ cwd, verbose: false })`npx --package typescript@${ ts } tsc --project ${ config } ${ args }`; + // eslint-disable-next-line no-underscore-dangle -- third-party code + const { cmd } = task._snapshot; + echo`run ${ chalk.cyan(cmd) }`; + tested++; try { - tested++; - echo(command); - if (config.cwd) { - await $({ cwd: config.cwd })`npx ${ config.args }`.quiet(); - } else { - await $`npx ${ config.args }`.quiet(); - } - echo(chalk.green(command)); + await task; + echo(chalk.green(`success ${ chalk.cyan(cmd) }`)); } catch (error) { failed++; - echo(chalk.red(`${ command }\n ${ error }`)); + echo(chalk.red(`fail ${ chalk.cyan(cmd) }:\n${ chalk.grey(error) }`)); } } @@ -86,19 +83,18 @@ function buildTasks(types, targets, typeScriptVersions, envs, libs) { const tasks = []; for (const type of types) { for (const target of targets) { - for (const typeScriptVersion of typeScriptVersions) { + for (const ts of typeScriptVersions) { for (const env of envs) { for (const lib of libs) { let tsConfigPostfix = TARGET_RULES[target] ? `.${ target }` : ''; tsConfigPostfix += lib && LIB_RULES[lib] ? `.${ lib }` : ''; const libsStr = lib ? `${ target },${ lib }` : target; - const tsConfigPath = env ? `./tsconfig.${ type }${ tsConfigPostfix }.json` : `${ type }/tsconfig${ tsConfigPostfix }.json`; - const taskConfig = { + const config = env ? `./tsconfig.${ type }${ tsConfigPostfix }.json` : `${ type }/tsconfig${ tsConfigPostfix }.json`; + const task = { cwd: getEnvPath(env), + ts, + config, args: [ - '-p', `typescript@${ typeScriptVersion }`, - 'tsc', - '-p', tsConfigPath, '--target', target, '--lib', `${ libsStr }`, ], @@ -107,9 +103,9 @@ function buildTasks(types, targets, typeScriptVersions, envs, libs) { if (type) { const typesSuffix = type === 'pure' ? '/pure' : ''; const envLibName = env ? `,${ env.substring(0, env.lastIndexOf('@')) }` : ''; - taskConfig.args.push('--types', `@core-js/types${ typesSuffix }${ envLibName }`); + task.args.push('--types', `@core-js/types${ typesSuffix }${ envLibName }`); } - tasks.push(taskConfig); + tasks.push(task); } } } @@ -154,20 +150,19 @@ async function prepareEnvironment(environments, coreJsTypes) { } } -let tasks = []; -tasks.push( - { args: ['-p', 'typescript@5.9', 'tsc'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'templates/tsconfig.json'] }, - { args: ['-p', 'typescript@5.9', '-p', '@types/node@24', 'tsc', '-p', 'templates/tsconfig.require.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/full/tsconfig.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/actual/tsconfig.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/stable/tsconfig.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/es/tsconfig.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/proposals/tsconfig.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/global-symlinks/tsconfig.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/pure-symlinks/tsconfig.json'] }, - { args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/configurator/tsconfig.json'] }, -); +let tasks = [ + { ts: '5.9', config: 'tsconfig.json' }, + { ts: '5.9', config: 'templates/tsconfig.json' }, + { ts: '5.9', config: 'templates/tsconfig.require.json' }, + { ts: '5.9', config: 'entries/full/tsconfig.json' }, + { ts: '5.9', config: 'entries/actual/tsconfig.json' }, + { ts: '5.9', config: 'entries/stable/tsconfig.json' }, + { ts: '5.9', config: 'entries/es/tsconfig.json' }, + { ts: '5.9', config: 'entries/proposals/tsconfig.json' }, + { ts: '5.9', config: 'entries/global-symlinks/tsconfig.json' }, + { ts: '5.9', config: 'entries/pure-symlinks/tsconfig.json' }, + { ts: '5.9', config: 'entries/configurator/tsconfig.json' }, +]; let envs; if (ALL_TESTS) { From ad895a1e747fd3c3564a70a5306cc2900d2d7fc5 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sun, 8 Feb 2026 20:22:08 +0200 Subject: [PATCH 189/315] move tools definitions tests to a separate directory --- tests/type-definitions/runner.mjs | 2 +- tests/type-definitions/{ => tools}/builder.ts | 0 tests/type-definitions/{ => tools}/compat.ts | 0 tests/type-definitions/tools/tsconfig.json | 7 +++++++ tests/type-definitions/tsconfig.json | 6 +----- 5 files changed, 9 insertions(+), 6 deletions(-) rename tests/type-definitions/{ => tools}/builder.ts (100%) rename tests/type-definitions/{ => tools}/compat.ts (100%) create mode 100644 tests/type-definitions/tools/tsconfig.json diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index e8d25b2fb5fd..a3f5644ff393 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -151,7 +151,7 @@ async function prepareEnvironment(environments, coreJsTypes) { } let tasks = [ - { ts: '5.9', config: 'tsconfig.json' }, + { ts: '5.9', config: 'tools/tsconfig.json' }, { ts: '5.9', config: 'templates/tsconfig.json' }, { ts: '5.9', config: 'templates/tsconfig.require.json' }, { ts: '5.9', config: 'entries/full/tsconfig.json' }, diff --git a/tests/type-definitions/builder.ts b/tests/type-definitions/tools/builder.ts similarity index 100% rename from tests/type-definitions/builder.ts rename to tests/type-definitions/tools/builder.ts diff --git a/tests/type-definitions/compat.ts b/tests/type-definitions/tools/compat.ts similarity index 100% rename from tests/type-definitions/compat.ts rename to tests/type-definitions/tools/compat.ts diff --git a/tests/type-definitions/tools/tsconfig.json b/tests/type-definitions/tools/tsconfig.json new file mode 100644 index 000000000000..f6056948dd92 --- /dev/null +++ b/tests/type-definitions/tools/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig.json", + "include": [ + "./builder.ts", + "./compat.ts" + ] +} diff --git a/tests/type-definitions/tsconfig.json b/tests/type-definitions/tsconfig.json index 773f34200e8d..c6ab1a6cbea8 100644 --- a/tests/type-definitions/tsconfig.json +++ b/tests/type-definitions/tsconfig.json @@ -6,9 +6,5 @@ "esModuleInterop": true, "moduleResolution": "node", "noEmit": true - }, - "include": [ - "./builder.ts", - "./compat.ts" - ] + } } From d7be130d2036aa6220cf922e26494f44bb217392 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sun, 8 Feb 2026 20:34:42 +0200 Subject: [PATCH 190/315] enable testing without `dom` library on ci --- tests/type-definitions/runner.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index a3f5644ff393..bdfa086363cc 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -35,7 +35,7 @@ const TYPES = [ ]; const LIBS = [ 'dom', - // null, // fails on web types + null, ]; const TARGET_RULES = { es6: ['**/*es2018*test.ts'], From b00299bbdc132f64933689b0810a951d153f0f73 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sun, 8 Feb 2026 21:28:27 +0200 Subject: [PATCH 191/315] add node 22 to types tests matrix --- tests/type-definitions/runner.mjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index bdfa086363cc..88ee53a119c7 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -22,7 +22,9 @@ const TYPE_SCRIPT_VERSIONS = [ ]; const ENVS = [ null, + // '@types/node@25', // fails '@types/node@24', + '@types/node@22', '@types/node@20', '@types/node@18', '@types/node@16', From 3b2c09673cb9827bc61458f08f3eb0336e2b315e Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sun, 8 Feb 2026 23:30:03 +0200 Subject: [PATCH 192/315] refactor type definitions tests runner --- tests/type-definitions/runner.mjs | 59 ++++++++++++++++--------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 88ee53a119c7..79ae6dd9c591 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -1,26 +1,33 @@ -import os from 'node:os'; +import { cpus } from 'node:os'; import { fs } from 'zx'; const { mkdir, writeJson } = fs; -const TMP_DIR = './tmp/'; + const ALL_TESTS = process.env.ALL_TYPE_DEFINITIONS_TESTS === '1'; +const NUM_CPUS = cpus().length; +const TMP_DIR = './tmp/'; const TARGETS = [ 'esnext', 'es2022', 'es6', ]; -const TYPE_SCRIPT_VERSIONS = [ + +const TYPE_SCRIPT_VERSIONS = ALL_TESTS ? [ '5.9', '5.8', '5.7', '5.6', - // '5.5', fails with node types: Named property 'next' of types 'AsyncIterator' and 'AsyncIteratorObject' are not identical. + // '5.5', // fails with node types: Named property 'next' of types 'AsyncIterator' and 'AsyncIteratorObject' are not identical. // '5.4', // '5.3', // '5.2', +] : [ + '5.9', + '5.6', ]; -const ENVS = [ + +const ENVS = ALL_TESTS ? [ null, // '@types/node@25', // fails '@types/node@24', @@ -30,15 +37,22 @@ const ENVS = [ '@types/node@16', // '@types/node@15', // fails // '@types/bun@latest', // conflicts with DOM types (TextDecorator, SharedArrayBuffer...) + // '@types/deno@latest', // fails +] : [ + null, + '@types/node@24', ]; + const TYPES = [ 'global', 'pure', ]; + const LIBS = [ 'dom', null, ]; + const TARGET_RULES = { es6: ['**/*es2018*test.ts'], }; @@ -57,13 +71,10 @@ function getEnvPath(env) { async function runLimited(tasks, limit) { let i = 0; - async function worker() { - while (i < tasks.length) { - const idx = i++; - await runTask(tasks[idx]); - } - } - await Promise.all(Array.from({ length: limit }, worker)); + + await Promise.all(Array(limit).fill().map(async () => { + while (i < tasks.length) await runTask(tasks[i++]); + })); } async function runTask({ cwd, ts, config, args = [] }) { @@ -81,8 +92,7 @@ async function runTask({ cwd, ts, config, args = [] }) { } } -function buildTasks(types, targets, typeScriptVersions, envs, libs) { - const tasks = []; +function * buildTasks(types, targets, typeScriptVersions, envs, libs) { for (const type of types) { for (const target of targets) { for (const ts of typeScriptVersions) { @@ -107,13 +117,12 @@ function buildTasks(types, targets, typeScriptVersions, envs, libs) { const envLibName = env ? `,${ env.substring(0, env.lastIndexOf('@')) }` : ''; task.args.push('--types', `@core-js/types${ typesSuffix }${ envLibName }`); } - tasks.push(task); + yield task; } } } } } - return tasks; } async function clearTmpDir() { @@ -152,7 +161,7 @@ async function prepareEnvironment(environments, coreJsTypes) { } } -let tasks = [ +const tasks = [ { ts: '5.9', config: 'tools/tsconfig.json' }, { ts: '5.9', config: 'templates/tsconfig.json' }, { ts: '5.9', config: 'templates/tsconfig.require.json' }, @@ -164,19 +173,13 @@ let tasks = [ { ts: '5.9', config: 'entries/global-symlinks/tsconfig.json' }, { ts: '5.9', config: 'entries/pure-symlinks/tsconfig.json' }, { ts: '5.9', config: 'entries/configurator/tsconfig.json' }, + ...buildTasks(TYPES, TARGETS, TYPE_SCRIPT_VERSIONS, ENVS, LIBS), ]; -let envs; -if (ALL_TESTS) { - envs = ENVS; - tasks = [...tasks, ...buildTasks(TYPES, TARGETS, TYPE_SCRIPT_VERSIONS, envs, LIBS)]; -} else { - envs = [null, '@types/node@24']; - tasks = [...tasks, ...buildTasks(TYPES, ['esnext', 'es2022', 'es6'], ['5.9', '5.6'], envs, ['dom', null])]; -} -const numCPUs = os.cpus().length; -await prepareEnvironment(envs, TYPES); -await runLimited(tasks, Math.max(numCPUs - 1, 1)); +await prepareEnvironment(ENVS, TYPES); +await runLimited(tasks, Math.max(NUM_CPUS - 1, 1)); await clearTmpDir(); + echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); + if (failed) throw new Error('Some tests have failed'); From 0480d0691bb009e0d348681d524ff07601450fcf Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Mon, 9 Feb 2026 01:43:33 +0200 Subject: [PATCH 193/315] refactor type definitions tests runner --- tests/type-definitions/runner.mjs | 98 +++++++++++++++---------------- 1 file changed, 46 insertions(+), 52 deletions(-) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 79ae6dd9c591..499a611279b0 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -1,19 +1,20 @@ import { cpus } from 'node:os'; import { fs } from 'zx'; -const { mkdir, writeJson } = fs; +const { mkdir, rm, writeJson } = fs; const ALL_TESTS = process.env.ALL_TYPE_DEFINITIONS_TESTS === '1'; const NUM_CPUS = cpus().length; const TMP_DIR = './tmp/'; -const TARGETS = [ +const ES_TARGETS = [ 'esnext', 'es2022', 'es6', ]; const TYPE_SCRIPT_VERSIONS = ALL_TESTS ? [ + // '6.0.0-dev.20260208', '5.9', '5.8', '5.7', @@ -27,7 +28,7 @@ const TYPE_SCRIPT_VERSIONS = ALL_TESTS ? [ '5.6', ]; -const ENVS = ALL_TESTS ? [ +const ENVIRONMENTS = ALL_TESTS ? [ null, // '@types/node@25', // fails '@types/node@24', @@ -43,7 +44,7 @@ const ENVS = ALL_TESTS ? [ '@types/node@24', ]; -const TYPES = [ +const CORE_JS_MODES = [ 'global', 'pure', ]; @@ -64,12 +65,13 @@ const LIB_RULES = { let tested = 0; let failed = 0; -function getEnvPath(env) { +function getTmpEnvDir(env) { if (!env) return null; return path.join(TMP_DIR, env.replaceAll('/', '-').replaceAll('@', '')); } -async function runLimited(tasks, limit) { +async function runTasksInParallel() { + const limit = Math.max(NUM_CPUS - 1, 1); let i = 0; await Promise.all(Array(limit).fill().map(async () => { @@ -92,32 +94,24 @@ async function runTask({ cwd, ts, config, args = [] }) { } } -function * buildTasks(types, targets, typeScriptVersions, envs, libs) { - for (const type of types) { - for (const target of targets) { - for (const ts of typeScriptVersions) { - for (const env of envs) { - for (const lib of libs) { - let tsConfigPostfix = TARGET_RULES[target] ? `.${ target }` : ''; - tsConfigPostfix += lib && LIB_RULES[lib] ? `.${ lib }` : ''; - const libsStr = lib ? `${ target },${ lib }` : target; - const config = env ? `./tsconfig.${ type }${ tsConfigPostfix }.json` : `${ type }/tsconfig${ tsConfigPostfix }.json`; - const task = { - cwd: getEnvPath(env), - ts, - config, - args: [ - '--target', target, - '--lib', `${ libsStr }`, - ], - }; - // eslint-disable-next-line max-depth -- it's needed here - if (type) { - const typesSuffix = type === 'pure' ? '/pure' : ''; - const envLibName = env ? `,${ env.substring(0, env.lastIndexOf('@')) }` : ''; - task.args.push('--types', `@core-js/types${ typesSuffix }${ envLibName }`); - } - yield task; +function * buildTasks() { + for (const mode of CORE_JS_MODES) { + for (const target of ES_TARGETS) { + for (const ts of TYPE_SCRIPT_VERSIONS) { + for (const env of ENVIRONMENTS) { + for (const lib of LIBS) { + const tsConfigPostfix = `${ TARGET_RULES[target] ? `.${ target }` : '' }${ LIB_RULES[lib] ? `.${ lib }` : '' }`; + const config = env ? `./tsconfig.${ mode }${ tsConfigPostfix }.json` : `${ mode }/tsconfig${ tsConfigPostfix }.json`; + const libWithTarget = lib ? `${ target },${ lib }` : target; + const types = [`@core-js/types${ mode === 'pure' ? '/pure' : '' }`]; + // eslint-disable-next-line max-depth -- ok + if (env) types.push(env.replace(/^(?@?[^@]+)@.+$/, '$')); + const args = [ + '--target', target, + '--lib', libWithTarget, + '--types', types.join(','), + ]; + yield { cwd: getTmpEnvDir(env), ts, config, args }; } } } @@ -126,36 +120,36 @@ function * buildTasks(types, targets, typeScriptVersions, envs, libs) { } async function clearTmpDir() { - await $`rm -rf ${ TMP_DIR }`; + await rm(TMP_DIR, { recursive: true, force: true }); } -async function prepareEnvironment(environments, coreJsTypes) { +async function prepareEnvironments() { await clearTmpDir(); - for (const env of environments) { + for (const env of ENVIRONMENTS) { if (!env) continue; - const tmpEnvDir = getEnvPath(env); + const tmpEnvDir = getTmpEnvDir(env); await mkdir(tmpEnvDir, { recursive: true }); - await $({ cwd: tmpEnvDir })`npm init -y > /dev/null 2>&1`; + await $({ cwd: tmpEnvDir, verbose: false })`npm init --yes`; await $({ cwd: tmpEnvDir })`npm install ${ env }`; - for (const type of coreJsTypes) { - await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.json`), { + for (const mode of CORE_JS_MODES) { + await writeJson(path.join(tmpEnvDir, `tsconfig.${ mode }.json`), { extends: '../../tsconfig.json', - include: [`../../${ type }/**/*.ts`], - exclude: [`../../${ type }/**/${ LIB_RULES.dom }`], + include: [`../../${ mode }/**/*.ts`], + exclude: [`../../${ mode }/**/${ LIB_RULES.dom }`], }); - await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.dom.json`), { + await writeJson(path.join(tmpEnvDir, `tsconfig.${ mode }.dom.json`), { extends: '../../tsconfig.json', - include: [`../../${ type }/**/*.ts`], + include: [`../../${ mode }/**/*.ts`], }); - await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.es6.json`), { + await writeJson(path.join(tmpEnvDir, `tsconfig.${ mode }.es6.json`), { extends: '../../tsconfig.json', - include: [`../../${ type }/**/*.ts`], - exclude: [`../../${ type }/**/${ TARGET_RULES.es6 }`, `../../${ type }/${ LIB_RULES.dom }`], + include: [`../../${ mode }/**/*.ts`], + exclude: [`../../${ mode }/**/${ TARGET_RULES.es6 }`, `../../${ mode }/${ LIB_RULES.dom }`], }); - await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.es6.dom.json`), { + await writeJson(path.join(tmpEnvDir, `tsconfig.${ mode }.es6.dom.json`), { extends: '../../tsconfig.json', - include: [`../../${ type }/**/*.ts`], - exclude: [`../../${ type }/**/${ TARGET_RULES.es6 }`], + include: [`../../${ mode }/**/*.ts`], + exclude: [`../../${ mode }/**/${ TARGET_RULES.es6 }`], }); } } @@ -173,11 +167,11 @@ const tasks = [ { ts: '5.9', config: 'entries/global-symlinks/tsconfig.json' }, { ts: '5.9', config: 'entries/pure-symlinks/tsconfig.json' }, { ts: '5.9', config: 'entries/configurator/tsconfig.json' }, - ...buildTasks(TYPES, TARGETS, TYPE_SCRIPT_VERSIONS, ENVS, LIBS), + ...buildTasks(), ]; -await prepareEnvironment(ENVS, TYPES); -await runLimited(tasks, Math.max(NUM_CPUS - 1, 1)); +await prepareEnvironments(); +await runTasksInParallel(); await clearTmpDir(); echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`); From fb76ca6fb88199470afb463141ea43127db5eb94 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sun, 8 Feb 2026 23:30:49 +0200 Subject: [PATCH 194/315] add TS6 to tests --- .../type-definitions/global/proposals/array-filtering.test.ts | 2 +- .../global/proposals/array-find-from-last.test.ts | 2 +- .../type-definitions/global/proposals/array-flat-map.test.ts | 2 +- .../type-definitions/global/proposals/array-includes.test.ts | 2 +- .../global/proposals/array-is-template-object.test.ts | 2 +- tests/type-definitions/global/proposals/array-unique.test.ts | 2 +- .../global/proposals/change-array-by-copy.test.ts | 2 +- tests/type-definitions/global/proposals/float16.test.ts | 2 +- tests/type-definitions/global/proposals/is-error.test.ts | 2 +- .../global/proposals/iterator-helpers.test.ts | 2 +- tests/type-definitions/global/proposals/iterator-join.test.ts | 2 +- .../global/proposals/json-parse-with-source.test.ts | 2 +- tests/type-definitions/global/proposals/map-upsert.test.ts | 2 +- tests/type-definitions/global/proposals/math-sum.test.ts | 2 +- tests/type-definitions/global/proposals/number-clamp.test.ts | 2 +- .../global/proposals/object-keys-length.test.ts | 2 +- .../global/proposals/object-values-entries.test.ts | 2 +- .../type-definitions/global/proposals/regexp-escaping.test.ts | 2 +- tests/type-definitions/global/proposals/string-cooked.test.ts | 2 +- tests/type-definitions/global/proposals/string-dedent.test.ts | 2 +- .../global/proposals/string-left-right-trim.test.ts | 2 +- .../type-definitions/global/proposals/string-padding.test.ts | 2 +- .../global/proposals/string-replace-all.test.ts | 2 +- .../global/proposals/symbol-predicates.test.ts | 2 +- .../global/proposals/well-formed-unicode-strings.test.ts | 2 +- tests/type-definitions/global/web/atob.test.ts | 2 +- tests/type-definitions/global/web/btoa.test.ts | 2 +- tests/type-definitions/global/web/structured-clone.test.ts | 2 +- tests/type-definitions/package.json | 1 + .../type-definitions/pure/proposals/array-from-async.test.ts | 2 +- tests/type-definitions/pure/proposals/array-grouping.test.ts | 2 +- .../pure/proposals/async-iterator-helper.test.ts | 2 +- .../type-definitions/pure/proposals/await-dictionary.test.ts | 2 +- .../pure/proposals/collection-of-from.test.ts | 2 +- tests/type-definitions/pure/proposals/error-cause.test.ts | 2 +- .../pure/proposals/explicit-resource-management.test.ts | 2 +- .../type-definitions/pure/proposals/iterator-chunking.test.ts | 2 +- .../type-definitions/pure/proposals/iterator-helpers.test.ts | 2 +- tests/type-definitions/pure/proposals/iterator-joint.test.ts | 2 +- tests/type-definitions/pure/proposals/iterator-range.test.ts | 2 +- .../pure/proposals/iterator-sequencing.test.ts | 2 +- .../pure/proposals/object-keys-length.test.ts | 2 +- .../pure/proposals/promise-all-settled.test.ts | 2 +- tests/type-definitions/pure/proposals/promise-any.test.ts | 2 +- tests/type-definitions/pure/proposals/promise-finally.test.ts | 2 +- tests/type-definitions/pure/proposals/promise-try.test.ts | 2 +- .../pure/proposals/promise-with-resolvers.test.ts | 2 +- tests/type-definitions/pure/proposals/set-methods.test.ts | 2 +- tests/type-definitions/runner.mjs | 2 +- tests/type-definitions/tsconfig.json | 4 ++-- 50 files changed, 51 insertions(+), 50 deletions(-) diff --git a/tests/type-definitions/global/proposals/array-filtering.test.ts b/tests/type-definitions/global/proposals/array-filtering.test.ts index da4103bb2b3d..103d142619b8 100644 --- a/tests/type-definitions/global/proposals/array-filtering.test.ts +++ b/tests/type-definitions/global/proposals/array-filtering.test.ts @@ -1,7 +1,7 @@ import 'core-js/full'; import filterReject from 'core-js/full/array/filter-reject'; import filterRejectJS from 'core-js/full/array/filter-reject.js'; -import { assertNumberArray } from '../../helpers'; +import { assertNumberArray } from '../../helpers.js'; filterReject([1, 2, 3], (v, i, arr) => v > 1); filterRejectJS([1, 2, 3], (v, i, arr) => v > 1); diff --git a/tests/type-definitions/global/proposals/array-find-from-last.test.ts b/tests/type-definitions/global/proposals/array-find-from-last.test.ts index 9ea98f535a1e..bca460cc2f7d 100644 --- a/tests/type-definitions/global/proposals/array-find-from-last.test.ts +++ b/tests/type-definitions/global/proposals/array-find-from-last.test.ts @@ -3,7 +3,7 @@ import findLast from 'core-js/es/array/find-last'; import findLastJS from 'core-js/es/array/find-last.js'; import findLastIndex from 'core-js/es/array/find-last-index'; import findLastIndexJS from 'core-js/es/array/find-last-index.js'; -import { assertNumber } from '../../helpers'; +import { assertNumber } from '../../helpers.js'; const resNS1: number | undefined = findLast([1, 2, 3], v => v > 1); const resNS2: number | undefined = findLastJS([1, 2, 3], v => v > 1); diff --git a/tests/type-definitions/global/proposals/array-flat-map.test.ts b/tests/type-definitions/global/proposals/array-flat-map.test.ts index 6aba1574bb4c..45575a2ef365 100644 --- a/tests/type-definitions/global/proposals/array-flat-map.test.ts +++ b/tests/type-definitions/global/proposals/array-flat-map.test.ts @@ -1,7 +1,7 @@ import 'core-js/es'; import flatMap from 'core-js/es/array/flat-map'; import flatMapJS from 'core-js/es/array/flat-map.js'; -import { assertNumberArray, assertStringArray } from '../../helpers'; +import { assertNumberArray, assertStringArray } from '../../helpers.js'; assertNumberArray(flatMap([1, 2, 3], x => [x, x * 2])); assertNumberArray(flatMapJS([1, 2, 3], x => [x, x * 2])); diff --git a/tests/type-definitions/global/proposals/array-includes.test.ts b/tests/type-definitions/global/proposals/array-includes.test.ts index cfd29c326bcc..46673a5941b6 100644 --- a/tests/type-definitions/global/proposals/array-includes.test.ts +++ b/tests/type-definitions/global/proposals/array-includes.test.ts @@ -1,6 +1,6 @@ import 'core-js/es'; import includes from 'core-js/es/array/includes'; -import { assertBool } from '../../helpers'; +import { assertBool } from '../../helpers.js'; const arr = [1, 2, 3]; diff --git a/tests/type-definitions/global/proposals/array-is-template-object.test.ts b/tests/type-definitions/global/proposals/array-is-template-object.test.ts index f7b2f2c396e1..15f11a97b5b7 100644 --- a/tests/type-definitions/global/proposals/array-is-template-object.test.ts +++ b/tests/type-definitions/global/proposals/array-is-template-object.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; import isTemplateObject from 'core-js/full/array/is-template-object'; -import { assertBool } from '../../helpers'; +import { assertBool } from '../../helpers.js'; const res: boolean = isTemplateObject([]); diff --git a/tests/type-definitions/global/proposals/array-unique.test.ts b/tests/type-definitions/global/proposals/array-unique.test.ts index d94c0d2bcc1a..10c34e94c127 100644 --- a/tests/type-definitions/global/proposals/array-unique.test.ts +++ b/tests/type-definitions/global/proposals/array-unique.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; import uniqueBy from 'core-js/full/array/unique-by'; -import { assertNumberArray } from '../../helpers'; +import { assertNumberArray } from '../../helpers.js'; const uniqueByNS: number[] = uniqueBy([1, 2, 1, 3]); diff --git a/tests/type-definitions/global/proposals/change-array-by-copy.test.ts b/tests/type-definitions/global/proposals/change-array-by-copy.test.ts index c09b9918348f..8105b43c9406 100644 --- a/tests/type-definitions/global/proposals/change-array-by-copy.test.ts +++ b/tests/type-definitions/global/proposals/change-array-by-copy.test.ts @@ -3,7 +3,7 @@ import toSorted from 'core-js/es/array/to-sorted'; import toSpliced from 'core-js/es/array/to-spliced'; import toReversed from 'core-js/es/array/to-reversed'; import withArray from 'core-js/es/array/with'; -import { assertNumberArray, assertStringArray } from '../../helpers'; +import { assertNumberArray, assertStringArray } from '../../helpers.js'; const arr: number[] = [1, 2, 3]; diff --git a/tests/type-definitions/global/proposals/float16.test.ts b/tests/type-definitions/global/proposals/float16.test.ts index ac3bbdaa80b2..bd412464d7ed 100644 --- a/tests/type-definitions/global/proposals/float16.test.ts +++ b/tests/type-definitions/global/proposals/float16.test.ts @@ -1,6 +1,6 @@ import 'core-js/es'; import f16round from 'core-js/es/math/f16round'; -import { assertNumber } from '../../helpers'; +import { assertNumber } from '../../helpers.js'; assertNumber(f16round(1)); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/is-error.test.ts b/tests/type-definitions/global/proposals/is-error.test.ts index 3abba25aa53f..f3a1131efa1a 100644 --- a/tests/type-definitions/global/proposals/is-error.test.ts +++ b/tests/type-definitions/global/proposals/is-error.test.ts @@ -1,6 +1,6 @@ import 'core-js/es'; import isError from 'core-js/es/error/is-error'; -import { assertBool } from '../../helpers'; +import { assertBool } from '../../helpers.js'; const e = new Error(); const ne = { foo: 1 }; diff --git a/tests/type-definitions/global/proposals/iterator-helpers.test.ts b/tests/type-definitions/global/proposals/iterator-helpers.test.ts index 578b49f45fd7..4c348d3deedb 100644 --- a/tests/type-definitions/global/proposals/iterator-helpers.test.ts +++ b/tests/type-definitions/global/proposals/iterator-helpers.test.ts @@ -9,7 +9,7 @@ import forEach from 'core-js/es/iterator/for-each'; import some from 'core-js/es/iterator/some'; import every from 'core-js/es/iterator/every'; import find from 'core-js/es/iterator/find'; -import { assertBool, assertNumber, assertNumberArray, assertString } from '../../helpers'; +import { assertBool, assertNumber, assertNumberArray, assertString } from '../../helpers.js'; declare const it: Iterator; declare const itStr: Iterator; diff --git a/tests/type-definitions/global/proposals/iterator-join.test.ts b/tests/type-definitions/global/proposals/iterator-join.test.ts index 499d98fcb635..605c493f1cf1 100644 --- a/tests/type-definitions/global/proposals/iterator-join.test.ts +++ b/tests/type-definitions/global/proposals/iterator-join.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; import join from 'core-js/full/iterator/join'; -import { assertString } from '../../helpers'; +import { assertString } from '../../helpers.js'; declare const it: Iterator; diff --git a/tests/type-definitions/global/proposals/json-parse-with-source.test.ts b/tests/type-definitions/global/proposals/json-parse-with-source.test.ts index 619214349875..37576c7d63a3 100644 --- a/tests/type-definitions/global/proposals/json-parse-with-source.test.ts +++ b/tests/type-definitions/global/proposals/json-parse-with-source.test.ts @@ -1,7 +1,7 @@ import 'core-js/es'; import rawJSON from 'core-js/es/json/raw-json'; import isRawJSON from 'core-js/es/json/is-raw-json'; -import { assertBool } from '../../helpers'; +import { assertBool } from '../../helpers.js'; const resNS: CoreJSRawJSON = rawJSON('{"a":123}'); assertBool(isRawJSON(resNS)); diff --git a/tests/type-definitions/global/proposals/map-upsert.test.ts b/tests/type-definitions/global/proposals/map-upsert.test.ts index 93467f45133e..7381ec1a51c2 100644 --- a/tests/type-definitions/global/proposals/map-upsert.test.ts +++ b/tests/type-definitions/global/proposals/map-upsert.test.ts @@ -3,7 +3,7 @@ import mapGetOrInsert from 'core-js/es/map/get-or-insert'; import mapGetOrInsertComputed from 'core-js/es/map/get-or-insert-computed'; import wMapGetOrInsert from 'core-js/es/weak-map/get-or-insert'; import wMapGetOrInsertComputed from 'core-js/es/weak-map/get-or-insert-computed'; -import { assertBool, assertNumber } from '../../helpers'; +import { assertBool, assertNumber } from '../../helpers.js'; declare const map: Map; diff --git a/tests/type-definitions/global/proposals/math-sum.test.ts b/tests/type-definitions/global/proposals/math-sum.test.ts index e490c77e489f..9f5a46d00822 100644 --- a/tests/type-definitions/global/proposals/math-sum.test.ts +++ b/tests/type-definitions/global/proposals/math-sum.test.ts @@ -1,6 +1,6 @@ import 'core-js/es'; import sumPrecise from 'core-js/es/math/sum-precise'; -import { assertNumber } from '../../helpers'; +import { assertNumber } from '../../helpers.js'; declare const it: Iterable; diff --git a/tests/type-definitions/global/proposals/number-clamp.test.ts b/tests/type-definitions/global/proposals/number-clamp.test.ts index 6b18a92329f7..ec1f11381cc3 100644 --- a/tests/type-definitions/global/proposals/number-clamp.test.ts +++ b/tests/type-definitions/global/proposals/number-clamp.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; import clamp from 'core-js/full/number/clamp'; -import { assertNumber } from '../../helpers'; +import { assertNumber } from '../../helpers.js'; declare const num: number; diff --git a/tests/type-definitions/global/proposals/object-keys-length.test.ts b/tests/type-definitions/global/proposals/object-keys-length.test.ts index b66e223fb13e..db957e3e99f4 100644 --- a/tests/type-definitions/global/proposals/object-keys-length.test.ts +++ b/tests/type-definitions/global/proposals/object-keys-length.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; import keysLength from 'core-js/full/object/keys-length'; -import { assertNumber } from '../../helpers'; +import { assertNumber } from '../../helpers.js'; const obj = { a: 1, b: 2 }; const arr = [1, 2, 3]; diff --git a/tests/type-definitions/global/proposals/object-values-entries.test.ts b/tests/type-definitions/global/proposals/object-values-entries.test.ts index c16c0ee2d557..2d910f2c36cf 100644 --- a/tests/type-definitions/global/proposals/object-values-entries.test.ts +++ b/tests/type-definitions/global/proposals/object-values-entries.test.ts @@ -1,7 +1,7 @@ import 'core-js/es'; import values from 'core-js/es/object/values'; import entries from 'core-js/es/object/entries'; -import { assertNumberArray, assertStringArray } from '../../helpers'; +import { assertNumberArray, assertStringArray } from '../../helpers.js'; const obj = { a: 1, b: 2 }; const arr = [1, 2, 3]; diff --git a/tests/type-definitions/global/proposals/regexp-escaping.test.ts b/tests/type-definitions/global/proposals/regexp-escaping.test.ts index 7fe3d7757e95..27c9cc24de9f 100644 --- a/tests/type-definitions/global/proposals/regexp-escaping.test.ts +++ b/tests/type-definitions/global/proposals/regexp-escaping.test.ts @@ -1,6 +1,6 @@ import 'core-js/es'; import escape from 'core-js/es/regexp/escape'; -import { assertString } from '../../helpers'; +import { assertString } from '../../helpers.js'; assertString(escape('foo.*+?^${}()|[]\\')); assertString(RegExp.escape('foo.*+?^${}()|[]\\')); diff --git a/tests/type-definitions/global/proposals/string-cooked.test.ts b/tests/type-definitions/global/proposals/string-cooked.test.ts index 164a93e42da8..e1798fe3a502 100644 --- a/tests/type-definitions/global/proposals/string-cooked.test.ts +++ b/tests/type-definitions/global/proposals/string-cooked.test.ts @@ -1,7 +1,7 @@ import 'core-js/full'; import cooked from 'core-js/full/string/cooked'; import $String from 'core-js/full/string'; -import { assertString } from '../../helpers'; +import { assertString } from '../../helpers.js'; assertString(cooked([])); $String.cooked([]); diff --git a/tests/type-definitions/global/proposals/string-dedent.test.ts b/tests/type-definitions/global/proposals/string-dedent.test.ts index 3bfcfd12ff14..ded2c794bdad 100644 --- a/tests/type-definitions/global/proposals/string-dedent.test.ts +++ b/tests/type-definitions/global/proposals/string-dedent.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; import dedent from 'core-js/full/string/dedent'; -import { assertString } from '../../helpers'; +import { assertString } from '../../helpers.js'; assertString(dedent`foo\nbar`); diff --git a/tests/type-definitions/global/proposals/string-left-right-trim.test.ts b/tests/type-definitions/global/proposals/string-left-right-trim.test.ts index 30dda7feab60..83045256dc57 100644 --- a/tests/type-definitions/global/proposals/string-left-right-trim.test.ts +++ b/tests/type-definitions/global/proposals/string-left-right-trim.test.ts @@ -3,7 +3,7 @@ import trimEnd from 'core-js/es/string/trim-end'; import trimStart from 'core-js/es/string/trim-start'; import trimLeft from 'core-js/es/string/trim-left'; import trimRight from 'core-js/es/string/trim-right'; -import { assertString } from '../../helpers'; +import { assertString } from '../../helpers.js'; const s = 'abc'; diff --git a/tests/type-definitions/global/proposals/string-padding.test.ts b/tests/type-definitions/global/proposals/string-padding.test.ts index 1247fc2d806f..2ed8443fb3e7 100644 --- a/tests/type-definitions/global/proposals/string-padding.test.ts +++ b/tests/type-definitions/global/proposals/string-padding.test.ts @@ -1,7 +1,7 @@ import 'core-js/es'; import padStart from 'core-js/es/string/pad-start'; import padEnd from 'core-js/es/string/pad-end'; -import { assertString } from '../../helpers'; +import { assertString } from '../../helpers.js'; const s = 'foo'; diff --git a/tests/type-definitions/global/proposals/string-replace-all.test.ts b/tests/type-definitions/global/proposals/string-replace-all.test.ts index 0d550475cad5..1fc021535a7b 100644 --- a/tests/type-definitions/global/proposals/string-replace-all.test.ts +++ b/tests/type-definitions/global/proposals/string-replace-all.test.ts @@ -1,6 +1,6 @@ import 'core-js/es'; import replaceAll from 'core-js/es/string/replace-all'; -import { assertString } from '../../helpers'; +import { assertString } from '../../helpers.js'; const s = 'foo bar foo'; diff --git a/tests/type-definitions/global/proposals/symbol-predicates.test.ts b/tests/type-definitions/global/proposals/symbol-predicates.test.ts index 84a3bd542878..2f3d9f2a9515 100644 --- a/tests/type-definitions/global/proposals/symbol-predicates.test.ts +++ b/tests/type-definitions/global/proposals/symbol-predicates.test.ts @@ -2,7 +2,7 @@ import 'core-js/full'; import isRegisteredSymbol from 'core-js/full/symbol/is-registered-symbol'; import isWellKnownSymbol from 'core-js/full/symbol/is-well-known-symbol'; import $Symbol from 'core-js/full/symbol'; -import { assertBool } from '../../helpers'; +import { assertBool } from '../../helpers.js'; assertBool(isRegisteredSymbol($Symbol.for('foo'))); assertBool(isWellKnownSymbol($Symbol.iterator)); diff --git a/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts b/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts index f4ea33a34548..cdb0348b8de3 100644 --- a/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts +++ b/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts @@ -1,7 +1,7 @@ import 'core-js/es'; import isWellFormed from 'core-js/es/string/is-well-formed'; import toWellFormed from 'core-js/es/string/to-well-formed'; -import { assertBool, assertString } from '../../helpers'; +import { assertBool, assertString } from '../../helpers.js'; const s = 'test'; diff --git a/tests/type-definitions/global/web/atob.test.ts b/tests/type-definitions/global/web/atob.test.ts index 724da5b9b376..b8c41250223f 100644 --- a/tests/type-definitions/global/web/atob.test.ts +++ b/tests/type-definitions/global/web/atob.test.ts @@ -1,6 +1,6 @@ import 'core-js/stable'; import $atob from 'core-js/stable/atob'; -import { assertString } from '../../helpers'; +import { assertString } from '../../helpers.js'; assertString($atob('SGVsbG8gd29ybGQ=')); diff --git a/tests/type-definitions/global/web/btoa.test.ts b/tests/type-definitions/global/web/btoa.test.ts index ed018354cbc1..9ad82c560db2 100644 --- a/tests/type-definitions/global/web/btoa.test.ts +++ b/tests/type-definitions/global/web/btoa.test.ts @@ -1,6 +1,6 @@ import 'core-js/stable'; import $btoa from 'core-js/stable/btoa'; -import { assertString } from '../../helpers'; +import { assertString } from '../../helpers.js'; assertString($btoa('SGVsbG8gd29ybGQ=')); diff --git a/tests/type-definitions/global/web/structured-clone.test.ts b/tests/type-definitions/global/web/structured-clone.test.ts index 231ce3cbf910..7a5264ab69a1 100644 --- a/tests/type-definitions/global/web/structured-clone.test.ts +++ b/tests/type-definitions/global/web/structured-clone.test.ts @@ -1,6 +1,6 @@ import 'core-js/stable'; import $structuredClone from 'core-js/stable/structured-clone'; -import { assertNumber, assertString } from '../../helpers'; +import { assertNumber, assertString } from '../../helpers.js'; assertNumber($structuredClone(5)); diff --git a/tests/type-definitions/package.json b/tests/type-definitions/package.json index c77e29d65bf1..eec96daed7c8 100644 --- a/tests/type-definitions/package.json +++ b/tests/type-definitions/package.json @@ -1,5 +1,6 @@ { "name": "tests/type-definitions", + "type": "module", "devDependencies": { "@types/node": "^25.2.2" } diff --git a/tests/type-definitions/pure/proposals/array-from-async.test.ts b/tests/type-definitions/pure/proposals/array-from-async.test.ts index 3ede7dbf32a5..8b06f51f51ee 100644 --- a/tests/type-definitions/pure/proposals/array-from-async.test.ts +++ b/tests/type-definitions/pure/proposals/array-from-async.test.ts @@ -1,6 +1,6 @@ import arrayFromAsync from '@core-js/pure/full/array/from-async'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers.pure'; +import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; const p1 = arrayFromAsync([1, 2, 3]); assertCoreJSPromiseLike(p1); diff --git a/tests/type-definitions/pure/proposals/array-grouping.test.ts b/tests/type-definitions/pure/proposals/array-grouping.test.ts index 774520160b58..d7b02b4e8c20 100644 --- a/tests/type-definitions/pure/proposals/array-grouping.test.ts +++ b/tests/type-definitions/pure/proposals/array-grouping.test.ts @@ -1,6 +1,6 @@ import objectGroupBy from '@core-js/pure/full/object/group-by'; import mapGroupBy from '@core-js/pure/full/map/group-by'; -import { assertCoreJSMapLike } from '../../helpers.pure'; +import { assertCoreJSMapLike } from '../../helpers.pure.js'; const arr = [1, 2, 3, 4, 5]; const objGroup: Partial> = objectGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 5a3a2f15a938..3574644707ac 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -11,7 +11,7 @@ import some from '@core-js/pure/full/async-iterator/some'; import take from '@core-js/pure/full/async-iterator/take'; import toArray from '@core-js/pure/full/async-iterator/to-array'; import toAsync from '@core-js/pure/full/iterator/to-async'; -import { assertCoreJSAsyncIteratorLike, assertCoreJSPromiseLike } from '../../helpers.pure'; +import { assertCoreJSAsyncIteratorLike, assertCoreJSPromiseLike } from '../../helpers.pure.js'; const aitn = from([1]); assertCoreJSAsyncIteratorLike(aitn); diff --git a/tests/type-definitions/pure/proposals/await-dictionary.test.ts b/tests/type-definitions/pure/proposals/await-dictionary.test.ts index 1e4c61ee078d..fd07ebc9f72c 100644 --- a/tests/type-definitions/pure/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/pure/proposals/await-dictionary.test.ts @@ -1,7 +1,7 @@ import promiseAllKeyed from '@core-js/pure/full/promise/all-keyed'; import promiseAllSettledKeyed from '@core-js/pure/full/promise/all-settled-keyed'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers.pure'; +import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; const res = promiseAllKeyed({ a: promiseResolve(1), diff --git a/tests/type-definitions/pure/proposals/collection-of-from.test.ts b/tests/type-definitions/pure/proposals/collection-of-from.test.ts index 31dad6e3a457..b88885b76f62 100644 --- a/tests/type-definitions/pure/proposals/collection-of-from.test.ts +++ b/tests/type-definitions/pure/proposals/collection-of-from.test.ts @@ -6,7 +6,7 @@ import weakMapFrom from '@core-js/pure/full/weak-map/from'; import weakMapOf from '@core-js/pure/full/weak-map/of'; import weakSetFrom from '@core-js/pure/full/weak-set/from'; import weakSetOf from '@core-js/pure/full/weak-set/of'; -import { assertCoreJSMapLike, assertCoreJSSetLike, assertCoreJSWeakMapLike, assertCoreJSWeakSetLike } from '../../helpers.pure'; +import { assertCoreJSMapLike, assertCoreJSSetLike, assertCoreJSWeakMapLike, assertCoreJSWeakSetLike } from '../../helpers.pure.js'; const rm = mapFrom([[1, 'a'], [2, 'b']] as [number, string][]); assertCoreJSMapLike(rm); diff --git a/tests/type-definitions/pure/proposals/error-cause.test.ts b/tests/type-definitions/pure/proposals/error-cause.test.ts index df58bfd33352..e169752f9d57 100644 --- a/tests/type-definitions/pure/proposals/error-cause.test.ts +++ b/tests/type-definitions/pure/proposals/error-cause.test.ts @@ -1,6 +1,6 @@ import $AggregateError from '@core-js/pure/full/aggregate-error'; // import $Error from '@core-js/pure/full/error'; TODO separated entry points -import { assertHasCause } from '../../helpers.pure'; +import { assertHasCause } from '../../helpers.pure.js'; const prevError = new Error('Prev error'); const someError = new Error('Some error'); diff --git a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts index 4dff03fc1ed4..122c5f93f900 100644 --- a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts @@ -7,7 +7,7 @@ import asyncIteratorFrom from '@core-js/pure/full/async-iterator/from'; import $SuppressedError from '@core-js/pure/full/suppressed-error/constructor'; import $DisposableStack from '@core-js/pure/full/disposable-stack/constructor'; import $AsyncDisposableStack from '@core-js/pure/full/async-disposable-stack/constructor'; -import { assertCoreJSPromiseLike } from '../../helpers.pure'; +import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; const d: symbol = symbolDispose; const ad: symbol = symbolAsyncDispose; diff --git a/tests/type-definitions/pure/proposals/iterator-chunking.test.ts b/tests/type-definitions/pure/proposals/iterator-chunking.test.ts index 3114612aa2db..e0130aa7e72d 100644 --- a/tests/type-definitions/pure/proposals/iterator-chunking.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-chunking.test.ts @@ -1,6 +1,6 @@ import iteratorChunks from '@core-js/pure/full/iterator/chunks'; import iteratorWindows from '@core-js/pure/full/iterator/windows'; -import { assertCoreJSIteratorLike } from '../../helpers.pure'; +import { assertCoreJSIteratorLike } from '../../helpers.pure.js'; declare function getNumberIterator(): Iterator; diff --git a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts index b51136a7cfab..6c312949818a 100644 --- a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts @@ -9,7 +9,7 @@ import iteratorForEach from '@core-js/pure/full/iterator/for-each'; import iteratorSome from '@core-js/pure/full/iterator/some'; import iteratorEvery from '@core-js/pure/full/iterator/every'; import iteratorFind from '@core-js/pure/full/iterator/find'; -import { assertCoreJSIteratorLike } from '../../helpers.pure'; +import { assertCoreJSIteratorLike } from '../../helpers.pure.js'; declare const it: Iterator; declare const itStr: Iterator; diff --git a/tests/type-definitions/pure/proposals/iterator-joint.test.ts b/tests/type-definitions/pure/proposals/iterator-joint.test.ts index 3a952a217ea7..1a0fc1fcd11c 100644 --- a/tests/type-definitions/pure/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-joint.test.ts @@ -1,6 +1,6 @@ import iteratorZip from '@core-js/pure/full/iterator/zip'; import iteratorZipKeyed from '@core-js/pure/full/iterator/zip-keyed'; -import { assertCoreJSIteratorLike } from '../../helpers.pure'; +import { assertCoreJSIteratorLike } from '../../helpers.pure.js'; const zipped1 = iteratorZip([[1, 2, 3], [4, 5, 6]]); assertCoreJSIteratorLike(zipped1); diff --git a/tests/type-definitions/pure/proposals/iterator-range.test.ts b/tests/type-definitions/pure/proposals/iterator-range.test.ts index 458c2c5c6fb7..97556edfeec2 100644 --- a/tests/type-definitions/pure/proposals/iterator-range.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-range.test.ts @@ -1,5 +1,5 @@ import iteratorRange from '@core-js/pure/full/iterator/range'; -import { assertCoreJSIteratorLike } from '../../helpers.pure'; +import { assertCoreJSIteratorLike } from '../../helpers.pure.js'; const rir1 = iteratorRange(1, 10); assertCoreJSIteratorLike(rir1); diff --git a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts index 8b74cbbcf7c3..3a3d8b4611ae 100644 --- a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts @@ -1,5 +1,5 @@ import iteratorConcat from '@core-js/pure/full/iterator/concat'; -import { assertCoreJSIteratorLike } from '../../helpers.pure'; +import { assertCoreJSIteratorLike } from '../../helpers.pure.js'; declare const its1: Iterable; declare const arrs: string[]; diff --git a/tests/type-definitions/pure/proposals/object-keys-length.test.ts b/tests/type-definitions/pure/proposals/object-keys-length.test.ts index 035114a3d7b1..c459f786fdb1 100644 --- a/tests/type-definitions/pure/proposals/object-keys-length.test.ts +++ b/tests/type-definitions/pure/proposals/object-keys-length.test.ts @@ -1,5 +1,5 @@ import keysLength from '@core-js/pure/full/object/keys-length'; -import { assertNumber } from '../../helpers'; +import { assertNumber } from '../../helpers.js'; const obj = { a: 1, b: 2 }; const arr = [1, 2, 3]; diff --git a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts index 43e3eab0c0e3..ee28903914f5 100644 --- a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts @@ -1,6 +1,6 @@ import promiseAllSettled from '@core-js/pure/full/promise/all-settled'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers.pure'; +import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; interface CoreJSPromiseResult { status: string; diff --git a/tests/type-definitions/pure/proposals/promise-any.test.ts b/tests/type-definitions/pure/proposals/promise-any.test.ts index b75277ff5fef..01f30bbae85f 100644 --- a/tests/type-definitions/pure/proposals/promise-any.test.ts +++ b/tests/type-definitions/pure/proposals/promise-any.test.ts @@ -1,6 +1,6 @@ import promiseAny from '@core-js/pure/full/promise/any'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers.pure'; +import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; const arr = [promiseResolve(1), promiseResolve('foo'), 3] as const; const justNumbers = [1, 2, 3]; diff --git a/tests/type-definitions/pure/proposals/promise-finally.test.ts b/tests/type-definitions/pure/proposals/promise-finally.test.ts index 8d4b8edb87dc..cfd272801b52 100644 --- a/tests/type-definitions/pure/proposals/promise-finally.test.ts +++ b/tests/type-definitions/pure/proposals/promise-finally.test.ts @@ -1,7 +1,7 @@ import promiseFinally from '@core-js/pure/full/promise/finally'; import promiseResolve from '@core-js/pure/full/promise/resolve'; import promiseReject from '@core-js/pure/full/promise/reject'; -import { assertCoreJSPromiseLike } from '../../helpers.pure'; +import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; const pr1 = promiseResolve(42); assertCoreJSPromiseLike(pr1); diff --git a/tests/type-definitions/pure/proposals/promise-try.test.ts b/tests/type-definitions/pure/proposals/promise-try.test.ts index 6c75e85cac19..cad3f277e7f1 100644 --- a/tests/type-definitions/pure/proposals/promise-try.test.ts +++ b/tests/type-definitions/pure/proposals/promise-try.test.ts @@ -1,6 +1,6 @@ import promiseTry from '@core-js/pure/full/promise/try'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers.pure'; +import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; const pt1 = promiseTry(() => 42); assertCoreJSPromiseLike(pt1); diff --git a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts index a215cf0ce93e..b998cc0c755f 100644 --- a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts +++ b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts @@ -1,6 +1,6 @@ import promiseWithResolvers from '@core-js/pure/full/promise/with-resolvers'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers.pure'; +import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; const pr = promiseWithResolvers(); const pr2 = promiseWithResolvers(); diff --git a/tests/type-definitions/pure/proposals/set-methods.test.ts b/tests/type-definitions/pure/proposals/set-methods.test.ts index f7e02a909629..8a5bb0a20158 100644 --- a/tests/type-definitions/pure/proposals/set-methods.test.ts +++ b/tests/type-definitions/pure/proposals/set-methods.test.ts @@ -6,7 +6,7 @@ import setSymmetricDifference from '@core-js/pure/full/set/symmetric-difference' import setIsSubsetOf from '@core-js/pure/full/set/is-subset-of'; import setIsSupersetOf from '@core-js/pure/full/set/is-superset-of'; import setIsDisjointFrom from '@core-js/pure/full/set/is-disjoint-from'; -import { assertCoreJSSetLike } from '../../helpers.pure'; +import { assertCoreJSSetLike } from '../../helpers.pure.js'; const setA = new $Set([1, 2, 3]); const setB = new $Set(['a', 'b', 'c']); diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 499a611279b0..8a121ee351b5 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -14,7 +14,7 @@ const ES_TARGETS = [ ]; const TYPE_SCRIPT_VERSIONS = ALL_TESTS ? [ - // '6.0.0-dev.20260208', + '6.0.0-dev.20260208', '5.9', '5.8', '5.7', diff --git a/tests/type-definitions/tsconfig.json b/tests/type-definitions/tsconfig.json index c6ab1a6cbea8..c2d0dbe5fc5e 100644 --- a/tests/type-definitions/tsconfig.json +++ b/tests/type-definitions/tsconfig.json @@ -2,9 +2,9 @@ "compilerOptions": { "strict": true, "target": "esnext", - "module": "esnext", + "module": "nodenext", "esModuleInterop": true, - "moduleResolution": "node", + "moduleResolution": "nodenext", "noEmit": true } } From 0f95954a5cc4ae7c709e4534c1e1096a36b4b5d8 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 10 Feb 2026 02:56:21 +0700 Subject: [PATCH 195/315] Fix SharedArrayBuffer conflict in TS < 5.9 and @types/node@25 --- .../base/proposals/array-buffer-transfer.d.ts | 31 +++++++++++++++++++ tests/type-definitions/runner.mjs | 6 ++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts index 83a70998ae2f..02783ae98ab7 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts @@ -25,3 +25,34 @@ interface ArrayBuffer { */ transferToFixedLength(newByteLength?: number): ArrayBuffer; } + +// Type compatibility hack for AllowSharedBufferSource in TypeScript < 5.9 +interface SharedArrayBuffer { + readonly resizable: boolean; + + readonly detached: boolean; + + /** + * Creates a new `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. + * @param newByteLength - If provided, specifies the `byteLength` of the new `ArrayBuffer` + * @throws RangeError If this `ArrayBuffer` is resizable and newByteLength is greater than the `maxByteLength` of this `ArrayBuffer` + * @throws TypeError If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @returns A new `ArrayBuffer` object + */ + transfer(newByteLength?: number): ArrayBuffer; + + /** + * Creates a new non-resizable `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. + * @param newByteLength - If provided, specifies the `byteLength` of the new `ArrayBuffer` + * @throws TypeError If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @returns A new `ArrayBuffer` object + */ + transferToFixedLength(newByteLength?: number): ArrayBuffer; + + /** + * Resizes the ArrayBuffer to the specified size (in bytes). + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resize) + */ + resize(newByteLength?: number): void; +} diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 8a121ee351b5..638a8007919c 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -25,23 +25,25 @@ const TYPE_SCRIPT_VERSIONS = ALL_TESTS ? [ // '5.2', ] : [ '5.9', + '5.7', '5.6', ]; const ENVIRONMENTS = ALL_TESTS ? [ null, - // '@types/node@25', // fails + '@types/node@25', '@types/node@24', '@types/node@22', '@types/node@20', '@types/node@18', '@types/node@16', // '@types/node@15', // fails - // '@types/bun@latest', // conflicts with DOM types (TextDecorator, SharedArrayBuffer...) + // '@types/bun@latest', // ArrayBuffer.resize signature incorrect. Return type ArrayBuffer instead of void. // '@types/deno@latest', // fails ] : [ null, '@types/node@24', + '@types/node@25', ]; const CORE_JS_MODES = [ From 967be5648cdb24f1e42abbf7a68aef7944530f50 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 10 Feb 2026 20:16:47 +0700 Subject: [PATCH 196/315] Fix SharedArrayBuffer conflict in TS < 5.9 and @types/node@25 in pure version --- .../pure/proposals/array-buffer-transfer.d.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts index 1e8eee89bce4..360b40de9dba 100644 --- a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts @@ -36,3 +36,34 @@ declare namespace CoreJS { var CoreJSArrayBuffer: CoreJSArrayBufferConstructor; } + +// Type compatibility hack for AllowSharedBufferSource in TypeScript < 5.9 +interface SharedArrayBuffer { + readonly resizable: boolean; + + readonly detached: boolean; + + /** + * Creates a new `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. + * @param newByteLength - If provided, specifies the `byteLength` of the new `ArrayBuffer` + * @throws RangeError If this `ArrayBuffer` is resizable and newByteLength is greater than the `maxByteLength` of this `ArrayBuffer` + * @throws TypeError If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @returns A new `ArrayBuffer` object + */ + transfer(newByteLength?: number): ArrayBuffer; + + /** + * Creates a new non-resizable `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. + * @param newByteLength - If provided, specifies the `byteLength` of the new `ArrayBuffer` + * @throws TypeError If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @returns A new `ArrayBuffer` object + */ + transferToFixedLength(newByteLength?: number): ArrayBuffer; + + /** + * Resizes the ArrayBuffer to the specified size (in bytes). + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resize) + */ + resize(newByteLength?: number): void; +} From 5a1e978cd529eb40328c9498159ed79958f4e0e6 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 10 Feb 2026 21:14:12 +0700 Subject: [PATCH 197/315] Some improvements --- .../src/base/proposals/array-buffer-transfer.d.ts | 2 +- .../src/base/pure/proposals/array-buffer-transfer.d.ts | 2 +- tests/type-definitions/entries/actual/test.ts | 2 ++ tests/type-definitions/entries/es/test.ts | 2 ++ tests/type-definitions/entries/full/test.ts | 2 ++ .../entries/{global-symlinks => global-imports}/test.ts | 0 .../{global-symlinks => global-imports}/tsconfig.json | 0 .../entries/{pure-symlinks => pure-imports}/test.ts | 0 .../entries/{pure-symlinks => pure-imports}/tsconfig.json | 0 tests/type-definitions/entries/stable/test.ts | 7 ++----- tests/type-definitions/runner.mjs | 4 ++-- 11 files changed, 12 insertions(+), 9 deletions(-) rename tests/type-definitions/entries/{global-symlinks => global-imports}/test.ts (100%) rename tests/type-definitions/entries/{global-symlinks => global-imports}/tsconfig.json (100%) rename tests/type-definitions/entries/{pure-symlinks => pure-imports}/test.ts (100%) rename tests/type-definitions/entries/{pure-symlinks => pure-imports}/tsconfig.json (100%) diff --git a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts index 02783ae98ab7..55f0f98081cf 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts @@ -26,7 +26,7 @@ interface ArrayBuffer { transferToFixedLength(newByteLength?: number): ArrayBuffer; } -// Type compatibility hack for AllowSharedBufferSource in TypeScript < 5.9 +// Type compatibility hack for AllowSharedBufferSource in TypeScript < 5.9: https://github.com/microsoft/TypeScript/issues/61480 interface SharedArrayBuffer { readonly resizable: boolean; diff --git a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts index 360b40de9dba..7d8baf7265fe 100644 --- a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts @@ -37,7 +37,7 @@ declare namespace CoreJS { var CoreJSArrayBuffer: CoreJSArrayBufferConstructor; } -// Type compatibility hack for AllowSharedBufferSource in TypeScript < 5.9 +// Type compatibility hack for AllowSharedBufferSource in TypeScript < 5.9: https://github.com/microsoft/TypeScript/issues/61480 interface SharedArrayBuffer { readonly resizable: boolean; diff --git a/tests/type-definitions/entries/actual/test.ts b/tests/type-definitions/entries/actual/test.ts index 274fa3d7e1ba..7ed534129af7 100644 --- a/tests/type-definitions/entries/actual/test.ts +++ b/tests/type-definitions/entries/actual/test.ts @@ -2,6 +2,8 @@ import '@core-js/types/actual'; const concat = Iterator.concat([1, 2, 3]); +structuredClone({ name: 'core-js' }); + Iterator.zipKeyed({ a: [1, 2], b: [3, 4] }); Iterator.zip([[1, 2, 3], [4, 5, 6]]); diff --git a/tests/type-definitions/entries/es/test.ts b/tests/type-definitions/entries/es/test.ts index 78b6d2577891..67c60625879d 100644 --- a/tests/type-definitions/entries/es/test.ts +++ b/tests/type-definitions/entries/es/test.ts @@ -2,6 +2,8 @@ import '@core-js/types/es'; const concat = Iterator.concat([1, 2, 3]); +structuredClone({ name: 'core-js' }); + // @ts-expect-error Iterator.zipKeyed({ a: [1, 2], b: [3, 4] }); // @ts-expect-error diff --git a/tests/type-definitions/entries/full/test.ts b/tests/type-definitions/entries/full/test.ts index d238d7116134..4b3716a5ba05 100644 --- a/tests/type-definitions/entries/full/test.ts +++ b/tests/type-definitions/entries/full/test.ts @@ -2,6 +2,8 @@ import '@core-js/types/full'; const concat = Iterator.concat([1, 2, 3]); +structuredClone({ name: 'core-js' }); + Iterator.zipKeyed({ a: [1, 2], b: [3, 4] }); Iterator.zip([[1, 2, 3], [4, 5, 6]]); diff --git a/tests/type-definitions/entries/global-symlinks/test.ts b/tests/type-definitions/entries/global-imports/test.ts similarity index 100% rename from tests/type-definitions/entries/global-symlinks/test.ts rename to tests/type-definitions/entries/global-imports/test.ts diff --git a/tests/type-definitions/entries/global-symlinks/tsconfig.json b/tests/type-definitions/entries/global-imports/tsconfig.json similarity index 100% rename from tests/type-definitions/entries/global-symlinks/tsconfig.json rename to tests/type-definitions/entries/global-imports/tsconfig.json diff --git a/tests/type-definitions/entries/pure-symlinks/test.ts b/tests/type-definitions/entries/pure-imports/test.ts similarity index 100% rename from tests/type-definitions/entries/pure-symlinks/test.ts rename to tests/type-definitions/entries/pure-imports/test.ts diff --git a/tests/type-definitions/entries/pure-symlinks/tsconfig.json b/tests/type-definitions/entries/pure-imports/tsconfig.json similarity index 100% rename from tests/type-definitions/entries/pure-symlinks/tsconfig.json rename to tests/type-definitions/entries/pure-imports/tsconfig.json diff --git a/tests/type-definitions/entries/stable/test.ts b/tests/type-definitions/entries/stable/test.ts index 9d0c1a174550..e9b2a31d95ec 100644 --- a/tests/type-definitions/entries/stable/test.ts +++ b/tests/type-definitions/entries/stable/test.ts @@ -2,6 +2,8 @@ import '@core-js/types/stable'; const concat = Iterator.concat([1, 2, 3]); +structuredClone({ name: 'core-js' }); + // @ts-expect-error Iterator.zipKeyed({ a: [1, 2], b: [3, 4] }); // @ts-expect-error @@ -12,11 +14,6 @@ concat.chunks(2); // @ts-expect-error concat.windows(3); -// @ts-expect-error -concat.chunks(2); -// @ts-expect-error -concat.windows(3); - Promise.all([1, 2, 3]); // @ts-expect-error Promise.allKeyed({ diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 638a8007919c..b8501422e233 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -166,8 +166,8 @@ const tasks = [ { ts: '5.9', config: 'entries/stable/tsconfig.json' }, { ts: '5.9', config: 'entries/es/tsconfig.json' }, { ts: '5.9', config: 'entries/proposals/tsconfig.json' }, - { ts: '5.9', config: 'entries/global-symlinks/tsconfig.json' }, - { ts: '5.9', config: 'entries/pure-symlinks/tsconfig.json' }, + { ts: '5.9', config: 'entries/global-imports/tsconfig.json' }, + { ts: '5.9', config: 'entries/pure-imports/tsconfig.json' }, { ts: '5.9', config: 'entries/configurator/tsconfig.json' }, ...buildTasks(), ]; From 49b32c0b40774f66dc4a456fdf9b8bd9a9f541af Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 12 Feb 2026 02:35:52 +0700 Subject: [PATCH 198/315] Update envs list for local tests --- tests/type-definitions/runner.mjs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index b8501422e233..4972bae139cd 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -25,7 +25,6 @@ const TYPE_SCRIPT_VERSIONS = ALL_TESTS ? [ // '5.2', ] : [ '5.9', - '5.7', '5.6', ]; @@ -42,7 +41,6 @@ const ENVIRONMENTS = ALL_TESTS ? [ // '@types/deno@latest', // fails ] : [ null, - '@types/node@24', '@types/node@25', ]; From 8311f4f92be516ccc10a83227bfb7cdf7b842de1 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 9 Feb 2026 23:09:48 +0700 Subject: [PATCH 199/315] Add exports to compat's package.json & make builder export in ESM style & add ts6 to local types tests & update internal compat imports --- packages/core-js-builder/index.d.ts | 2 +- packages/core-js-compat/package.json | 50 +++++++++++++++++++ scripts/build-compat/built-in-definitions.mjs | 2 +- scripts/build-compat/data.mjs | 8 +-- scripts/build-compat/modules-by-versions.mjs | 2 +- .../build-entries-and-types/build-entries.mjs | 2 +- .../build-entries-and-types/build-types.mjs | 2 +- .../get-dependencies.mjs | 2 +- scripts/check-compat-data-mapping.mjs | 2 +- scripts/check-unused-modules.mjs | 2 +- tests/compat-data/tests-coverage.mjs | 2 +- .../debug-get-dependencies.mjs | 2 +- tests/type-definitions/coverage.mjs | 2 +- 13 files changed, 65 insertions(+), 15 deletions(-) diff --git a/packages/core-js-builder/index.d.ts b/packages/core-js-builder/index.d.ts index e70930b4ebdf..d7764b113f79 100644 --- a/packages/core-js-builder/index.d.ts +++ b/packages/core-js-builder/index.d.ts @@ -30,4 +30,4 @@ type Options = Pick & { declare function builder(options?: Options): Promise; -export = builder; +export default builder; diff --git a/packages/core-js-compat/package.json b/packages/core-js-compat/package.json index 3eb5442efbd9..562871c00222 100644 --- a/packages/core-js-compat/package.json +++ b/packages/core-js-compat/package.json @@ -28,6 +28,56 @@ "sideEffects": false, "main": "index.js", "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "default": "./index.js" + }, + "./index.js": { + "types": "./index.d.ts", + "default": "./index.js" + }, + "./built-in-definitions": "./built-in-definitions.json", + "./built-in-definitions.json": "./built-in-definitions.json", + "./compat": { + "types": "./compat.d.ts", + "default": "./compat.js" + }, + "./compat.js": { + "types": "./compat.d.ts", + "default": "./compat.js" + }, + "./data": "./data.json", + "./data.json": "./data.json", + "./entries": "./entries.json", + "./entries.json": "./entries.json", + "./entries-by-versions": "./entries-by-versions.json", + "./entries-by-versions.json": "./entries-by-versions.json", + "./external": "./external.json", + "./external.json": "./external.json", + "./get-entries-list-for-target-version": { + "types": "./get-entries-list-for-target-version.d.ts", + "default": "./get-entries-list-for-target-version.js" + }, + "./get-entries-list-for-target-version.js": { + "types": "./get-entries-list-for-target-version.d.ts", + "default": "./get-entries-list-for-target-version.js" + }, + "./get-modules-list-for-target-version": { + "types": "./get-modules-list-for-target-version.d.ts", + "default": "./get-modules-list-for-target-version.js" + }, + "./get-modules-list-for-target-version.js": { + "types": "./get-modules-list-for-target-version.d.ts", + "default": "./get-modules-list-for-target-version.js" + }, + "./modules": "./modules.json", + "./modules.json": "./modules.json", + "./modules-by-versions": "./modules-by-versions.json", + "./modules-by-versions.json": "./modules-by-versions.json", + "./targets-parser": "./targets-parser.js", + "./targets-parser.js": "./targets-parser.js" + }, "dependencies": { "browserslist": "^4.28.1" } diff --git a/scripts/build-compat/built-in-definitions.mjs b/scripts/build-compat/built-in-definitions.mjs index 7b47a9a57bee..39788c7ccd50 100644 --- a/scripts/build-compat/built-in-definitions.mjs +++ b/scripts/build-compat/built-in-definitions.mjs @@ -2,7 +2,7 @@ import { Globals, StaticProperties, InstanceProperties, -} from '@core-js/compat/src/built-in-definitions.mjs'; +} from '../../packages/core-js-compat/src/built-in-definitions.mjs'; const entries = new Set(Object.keys(await fs.readJson('packages/core-js-compat/entries.json'))); diff --git a/scripts/build-compat/data.mjs b/scripts/build-compat/data.mjs index a37784c0b679..cc946f83039d 100644 --- a/scripts/build-compat/data.mjs +++ b/scripts/build-compat/data.mjs @@ -1,8 +1,8 @@ /* https://github.com/import-js/eslint-plugin-import/issues/2181 */ -import { dataWithIgnored as data, ignored, modules } from '@core-js/compat/src/data.mjs'; -import external from '@core-js/compat/src/external.mjs'; -import mappings from '@core-js/compat/src/mapping.mjs'; -import helpers from '@core-js/compat/helpers.js'; +import { dataWithIgnored as data, ignored, modules } from '../../packages/core-js-compat/src/data.mjs'; +import external from '../../packages/core-js-compat/src/external.mjs'; +import mappings from '../../packages/core-js-compat/src/mapping.mjs'; +import helpers from '../../packages/core-js-compat/helpers.js'; const { compare, semver, sortObjectByKey } = helpers; const { hasOwn } = Object; diff --git a/scripts/build-compat/modules-by-versions.mjs b/scripts/build-compat/modules-by-versions.mjs index d2439671150e..55dba8050621 100644 --- a/scripts/build-compat/modules-by-versions.mjs +++ b/scripts/build-compat/modules-by-versions.mjs @@ -1,5 +1,5 @@ import coerce from 'semver/functions/coerce.js'; -import { modules } from '@core-js/compat/src/data.mjs'; +import { modules } from '../../packages/core-js-compat/src/data.mjs'; const { version } = await fs.readJson('package.json'); const $version = coerce(version); diff --git a/scripts/build-entries-and-types/build-entries.mjs b/scripts/build-entries-and-types/build-entries.mjs index 675f1185e642..676bb7d9849e 100644 --- a/scripts/build-entries-and-types/build-entries.mjs +++ b/scripts/build-entries-and-types/build-entries.mjs @@ -1,7 +1,7 @@ import { getModulesMetadata } from './get-dependencies.mjs'; import { features, proposals } from './entries-definitions.mjs'; import { $proposal, $path, wrapEntryInStrict } from './templates.mjs'; -import { modules as AllModules } from '@core-js/compat/src/data.mjs'; +import { modules as AllModules } from '../../packages/core-js-compat/src/data.mjs'; import { expandModules, modulesToStage } from './helpers.mjs'; const { mkdir, writeFile, readJson, writeJson } = fs; diff --git a/scripts/build-entries-and-types/build-types.mjs b/scripts/build-entries-and-types/build-types.mjs index 8d7ea077c2c4..49cfccb9b89d 100644 --- a/scripts/build-entries-and-types/build-types.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -1,6 +1,6 @@ import { features, proposals } from './entries-definitions.mjs'; import { $functionWithCustomType, $path, $proposal, $typeDummy } from './templates.mjs'; -import { modules as AllModules } from '@core-js/compat/src/data.mjs'; +import { modules as AllModules } from '../../packages/core-js-compat/src/data.mjs'; import { getModulesMetadata } from './get-dependencies.mjs'; import { expandModules, modulesToStage } from './helpers.mjs'; import { preparePureTypes } from './build-types-pure.mjs'; diff --git a/scripts/build-entries-and-types/get-dependencies.mjs b/scripts/build-entries-and-types/get-dependencies.mjs index f330774a259b..62b9be08a7c6 100644 --- a/scripts/build-entries-and-types/get-dependencies.mjs +++ b/scripts/build-entries-and-types/get-dependencies.mjs @@ -1,5 +1,5 @@ import konan from 'konan'; -import { modules } from '@core-js/compat/src/data.mjs'; +import { modules } from '../../packages/core-js-compat/src/data.mjs'; const { cyan, red } = chalk; diff --git a/scripts/check-compat-data-mapping.mjs b/scripts/check-compat-data-mapping.mjs index f34851190b25..0ceae7de8b55 100644 --- a/scripts/check-compat-data-mapping.mjs +++ b/scripts/check-compat-data-mapping.mjs @@ -1,5 +1,5 @@ import semver from 'semver'; -import mapping from '@core-js/compat/src/mapping.mjs'; +import mapping from '../packages/core-js-compat/src/mapping.mjs'; const { coerce, cmp } = semver; let updated = true; diff --git a/scripts/check-unused-modules.mjs b/scripts/check-unused-modules.mjs index a3128ca11629..a73dcada6d45 100644 --- a/scripts/check-unused-modules.mjs +++ b/scripts/check-unused-modules.mjs @@ -1,5 +1,5 @@ import konan from 'konan'; -import { modules, ignored } from '@core-js/compat/src/data.mjs'; +import { modules, ignored } from '../packages/core-js-compat/src/data.mjs'; async function jsModulesFrom(path) { const directory = await fs.readdir(path); diff --git a/tests/compat-data/tests-coverage.mjs b/tests/compat-data/tests-coverage.mjs index 370821600dc2..9f4daa13f4b9 100644 --- a/tests/compat-data/tests-coverage.mjs +++ b/tests/compat-data/tests-coverage.mjs @@ -1,4 +1,4 @@ -import { modules, ignored } from '@core-js/compat/src/data.mjs'; +import { modules, ignored } from '../../packages/core-js-compat/src/data.mjs'; import '../compat/tests.js'; const modulesSet = new Set([ diff --git a/tests/debug-get-dependencies/debug-get-dependencies.mjs b/tests/debug-get-dependencies/debug-get-dependencies.mjs index c278eba21150..fe1b85ea3e32 100644 --- a/tests/debug-get-dependencies/debug-get-dependencies.mjs +++ b/tests/debug-get-dependencies/debug-get-dependencies.mjs @@ -1,4 +1,4 @@ -import { modules } from '@core-js/compat/src/data.mjs'; +import { modules } from '../../packages/core-js-compat/src/data.mjs'; import { getModulesMetadata } from '../../scripts/build-entries-and-types/get-dependencies.mjs'; for (const module of modules) console.log(module, await getModulesMetadata([module])); diff --git a/tests/type-definitions/coverage.mjs b/tests/type-definitions/coverage.mjs index 7861b973d27e..a552073e798a 100644 --- a/tests/type-definitions/coverage.mjs +++ b/tests/type-definitions/coverage.mjs @@ -1,4 +1,4 @@ -import { modules as AllModules } from '@core-js/compat/src/data.mjs'; +import { modules as AllModules } from '../../packages/core-js-compat/src/data.mjs'; const { readFile } = fs; const { red } = chalk; From ec4f5e9be285a1d26fb800417c1f274b242f1ef9 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 12 Feb 2026 02:50:15 +0700 Subject: [PATCH 200/315] Update hack comment in array buffer transfer types --- .../src/base/proposals/array-buffer-transfer.d.ts | 3 ++- .../src/base/pure/proposals/array-buffer-transfer.d.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts index 55f0f98081cf..a94e1b917865 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts @@ -26,7 +26,8 @@ interface ArrayBuffer { transferToFixedLength(newByteLength?: number): ArrayBuffer; } -// Type compatibility hack for AllowSharedBufferSource in TypeScript < 5.9: https://github.com/microsoft/TypeScript/issues/61480 +// Type compatibility hack for AllowSharedBufferSource in TypeScript < 5.9 +// https://github.com/microsoft/TypeScript/issues/61480 interface SharedArrayBuffer { readonly resizable: boolean; diff --git a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts index 7d8baf7265fe..e92edee2b16b 100644 --- a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts @@ -37,7 +37,8 @@ declare namespace CoreJS { var CoreJSArrayBuffer: CoreJSArrayBufferConstructor; } -// Type compatibility hack for AllowSharedBufferSource in TypeScript < 5.9: https://github.com/microsoft/TypeScript/issues/61480 +// Type compatibility hack for AllowSharedBufferSource in TypeScript < 5.9 +// https://github.com/microsoft/TypeScript/issues/61480 interface SharedArrayBuffer { readonly resizable: boolean; From 10b5bd6515a79602c8376adfb05859ca32b6dd60 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Wed, 11 Feb 2026 22:01:19 +0200 Subject: [PATCH 201/315] Merge pull request #1512 from zloirock/v4-types-ts6 From b64f03d8e1c443c8388dcdf02c6434da3a9d4d08 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Thu, 12 Feb 2026 10:18:29 +0200 Subject: [PATCH 202/315] update ts6 to beta --- tests/type-definitions/runner.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 4972bae139cd..d05751ea3c75 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -14,7 +14,7 @@ const ES_TARGETS = [ ]; const TYPE_SCRIPT_VERSIONS = ALL_TESTS ? [ - '6.0.0-dev.20260208', + '6.0.0-beta', '5.9', '5.8', '5.7', From 2a29ddf1e2acc230749933ccbd91c654b0de0e75 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Thu, 12 Feb 2026 10:33:25 +0200 Subject: [PATCH 203/315] update dependencies --- tests/eslint/package-lock.json | 13 ------------- tests/type-definitions/package-lock.json | 16 ++++++++-------- tests/type-definitions/package.json | 2 +- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/tests/eslint/package-lock.json b/tests/eslint/package-lock.json index 055e1d6c9d73..3629009c4737 100644 --- a/tests/eslint/package-lock.json +++ b/tests/eslint/package-lock.json @@ -2065,19 +2065,6 @@ "eslint": ">=9.38.0" } }, - "node_modules/eslint-plugin-jsonc/node_modules/@eslint/core": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-1.1.0.tgz", - "integrity": "sha512-/nr9K9wkr3P1EzFTdFdMoLuo1PmIxjmwvPozwoSodjNBdefGujXQUF93u1DDZpEaTuDvMsIQddsd35BwtrW9Xw==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@types/json-schema": "^7.0.15" - }, - "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" - } - }, "node_modules/eslint-plugin-jsonc/node_modules/@eslint/plugin-kit": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.6.0.tgz", diff --git a/tests/type-definitions/package-lock.json b/tests/type-definitions/package-lock.json index 0cebcb627d7f..d8a3483156f7 100644 --- a/tests/type-definitions/package-lock.json +++ b/tests/type-definitions/package-lock.json @@ -6,23 +6,23 @@ "": { "name": "tests/type-definitions", "devDependencies": { - "@types/node": "^25.2.2" + "@types/node": "^25.3.0" } }, "node_modules/@types/node": { - "version": "25.2.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.2.2.tgz", - "integrity": "sha512-BkmoP5/FhRYek5izySdkOneRyXYN35I860MFAGupTdebyE66uZaR+bXLHq8k4DirE5DwQi3NuhvRU1jqTVwUrQ==", + "version": "25.3.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.3.0.tgz", + "integrity": "sha512-4K3bqJpXpqfg2XKGK9bpDTc6xO/xoUP/RBWS7AtRMug6zZFaRekiLzjVtAoZMquxoAbzBvy5nxQ7veS5eYzf8A==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~7.16.0" + "undici-types": "~7.18.0" } }, "node_modules/undici-types": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", - "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "version": "7.18.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", + "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==", "dev": true, "license": "MIT" } diff --git a/tests/type-definitions/package.json b/tests/type-definitions/package.json index eec96daed7c8..b3e5447bace7 100644 --- a/tests/type-definitions/package.json +++ b/tests/type-definitions/package.json @@ -2,6 +2,6 @@ "name": "tests/type-definitions", "type": "module", "devDependencies": { - "@types/node": "^25.2.2" + "@types/node": "^25.3.0" } } From f9d901b4e876c0451eec0fed654b0d2b5648eb17 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 12 Feb 2026 21:10:34 +0700 Subject: [PATCH 204/315] Types refactoring --- .../base/core-js-types/async-iterator.d.ts | 22 +++++++++++++ .../src/base/core-js-types/core-js-types.d.ts | 32 ------------------- .../base/core-js-types/iterator-object.d.ts | 4 +-- .../src/base/proposals/array-flat-map.d.ts | 2 +- .../src/base/proposals/array-from-async.d.ts | 2 +- .../proposals/async-iterator-helpers.d.ts | 2 +- .../src/base/proposals/iterator-chunking.d.ts | 6 ++-- .../src/base/proposals/iterator-helpers.d.ts | 2 +- .../base/proposals/iterator-sequencing.d.ts | 4 +-- .../pure/core-js-types/iterator-object.d.ts | 2 +- .../src/base/pure/core-js-types/url.d.ts | 2 +- .../pure/proposals/collection-of-from.d.ts | 8 ++--- .../pure/proposals/decorator-metadata.d.ts | 2 +- .../explicit-resource-management.d.ts | 2 +- .../proposals/iterator-helpers-custom.d.ts | 2 +- .../proposals/relative-indexing-method.d.ts | 2 +- .../pure/proposals/set-methods-custom.d.ts | 2 +- .../proposals/string-left-right-trim.d.ts | 2 +- .../base/pure/proposals/string-match-all.d.ts | 4 +-- .../base/pure/proposals/string-padding.d.ts | 2 +- .../pure/proposals/string-replace-all.d.ts | 2 +- .../well-formed-unicode-strings.d.ts | 2 +- .../pure/core-js-types/iterator-object.d.ts | 2 +- 23 files changed, 50 insertions(+), 62 deletions(-) create mode 100644 packages/core-js-types/src/base/core-js-types/async-iterator.d.ts delete mode 100644 packages/core-js-types/src/base/core-js-types/core-js-types.d.ts diff --git a/packages/core-js-types/src/base/core-js-types/async-iterator.d.ts b/packages/core-js-types/src/base/core-js-types/async-iterator.d.ts new file mode 100644 index 000000000000..cc35ba90c022 --- /dev/null +++ b/packages/core-js-types/src/base/core-js-types/async-iterator.d.ts @@ -0,0 +1,22 @@ +interface AsyncIteratorObject extends AsyncIterator { + [Symbol.asyncIterator](): AsyncIteratorObject; +} + +interface AsyncIterableIterator extends AsyncIterator { + [Symbol.asyncIterator](): AsyncIterableIterator; +} + +interface AsyncIterator { + // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. + next(...[value]: [] | [TNext]): Promise>; + return?(value?: TReturn | PromiseLike): Promise>; + throw?(e?: any): Promise>; +} + +interface AsyncIteratorConstructor {} + +declare var AsyncIterator: AsyncIteratorConstructor; + +interface AsyncIterable { + [Symbol.asyncIterator](): AsyncIterator; +} diff --git a/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts b/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts deleted file mode 100644 index 03c4cc2c2fa0..000000000000 --- a/packages/core-js-types/src/base/core-js-types/core-js-types.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2019.array.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare global { - interface IteratorObject extends Iterator {} - - interface AsyncIteratorObject extends AsyncIterator { - [Symbol.asyncIterator](): AsyncIteratorObject; - } - - interface AsyncIterableIterator extends AsyncIterator { - [Symbol.asyncIterator](): AsyncIterableIterator; - } - - interface AsyncIterator { - // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. - next(...[value]: [] | [TNext]): Promise>; - return?(value?: TReturn | PromiseLike): Promise>; - throw?(e?: any): Promise>; - } - - interface AsyncIteratorConstructor {} - - var AsyncIterator: AsyncIteratorConstructor; - - interface AsyncIterable { - [Symbol.asyncIterator](): AsyncIterator; - } -} - -export {}; diff --git a/packages/core-js-types/src/base/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/base/core-js-types/iterator-object.d.ts index e31f8f4a64f3..74e9865b3c44 100644 --- a/packages/core-js-types/src/base/core-js-types/iterator-object.d.ts +++ b/packages/core-js-types/src/base/core-js-types/iterator-object.d.ts @@ -1,3 +1 @@ -declare namespace CoreJS { - export interface CoreJSIteratorObject extends Iterator {} -} +interface IteratorObject extends Iterator {} diff --git a/packages/core-js-types/src/base/proposals/array-flat-map.d.ts b/packages/core-js-types/src/base/proposals/array-flat-map.d.ts index 78fcf21c8f7d..ffb11c7c69ba 100644 --- a/packages/core-js-types/src/base/proposals/array-flat-map.d.ts +++ b/packages/core-js-types/src/base/proposals/array-flat-map.d.ts @@ -1,4 +1,4 @@ -/// +/// // https://github.com/tc39/proposal-flatMap diff --git a/packages/core-js-types/src/base/proposals/array-from-async.d.ts b/packages/core-js-types/src/base/proposals/array-from-async.d.ts index 7b8c0d1b99b9..4c5210bfac68 100644 --- a/packages/core-js-types/src/base/proposals/array-from-async.d.ts +++ b/packages/core-js-types/src/base/proposals/array-from-async.d.ts @@ -1,4 +1,4 @@ -/// +/// // https://github.com/tc39/proposal-array-from-async diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index 3a07db4a77cd..933ce40f3a5b 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -1,4 +1,4 @@ -/// +/// // https://github.com/tc39/proposal-async-iterator-helpers diff --git a/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts b/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts index c5c121ed044c..ce788e15202a 100644 --- a/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts @@ -1,4 +1,4 @@ -/// +/// // https://github.com/tc39/proposal-iterator-chunking @@ -9,7 +9,7 @@ interface Iterator { * @param chunkSize - The maximum number of elements per chunk. Must be a positive integer. * @returns An iterator yielding arrays of at most `chunkSize` elements from the source iterator. */ - chunks(chunkSize: number): CoreJS.CoreJSIteratorObject; + chunks(chunkSize: number): IteratorObject; /** * Yields overlapping arrays (windows) of the given size from the iterator. @@ -17,5 +17,5 @@ interface Iterator { * @param undersized - 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. * @returns An iterator yielding arrays of the specified window size. */ - windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJS.CoreJSIteratorObject; + windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): IteratorObject; } diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts index 9c6458fa0f82..2acc526214ed 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts @@ -1,4 +1,4 @@ -/// +/// // https://github.com/tc39/proposal-iterator-helpers diff --git a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts index 87e76c25d731..f4a82de3b908 100644 --- a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts @@ -1,4 +1,4 @@ -/// +/// // https://github.com/tc39/proposal-iterator-sequencing @@ -8,7 +8,7 @@ interface IteratorConstructor { // @type-options: no-extends * @param iterators - The iterables to concatenate. * @returns An iterator yielding values from each input iterable in sequence. */ - concat(...iterators: Iterable[]): CoreJS.CoreJSIteratorObject; + concat(...iterators: Iterable[]): IteratorObject; } declare var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts index 2c30f11185e5..d55de7c05c4c 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts @@ -1,4 +1,4 @@ -/// +/// declare namespace CoreJS { export interface CoreJSIteratorObject extends CoreJSIterator {} diff --git a/packages/core-js-types/src/base/pure/core-js-types/url.d.ts b/packages/core-js-types/src/base/pure/core-js-types/url.d.ts index b97a0234865e..a7f4e6d89027 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/url.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/url.d.ts @@ -1,4 +1,4 @@ -/// +/// declare namespace CoreJS { export interface CoreJSURL { diff --git a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts index 01666876bfb3..5c6b4d9f5e5a 100644 --- a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts @@ -1,7 +1,7 @@ -/// -/// -/// -/// +/// +/// +/// +/// // Motivation: import our own Map/Set/WeakMap/WeakSet types & redefine return types diff --git a/packages/core-js-types/src/base/pure/proposals/decorator-metadata.d.ts b/packages/core-js-types/src/base/pure/proposals/decorator-metadata.d.ts index 4228026c7e05..2cf663ea0242 100644 --- a/packages/core-js-types/src/base/pure/proposals/decorator-metadata.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/decorator-metadata.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: Symbol is replaced with our own diff --git a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts index 4f6c020fb91d..248e558bf4b0 100644 --- a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: Symbol is replaced with our own diff --git a/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts index 28cd5e3ada67..840a6064780a 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: Using our own type for IteratorObject diff --git a/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts index 81ce831156a9..044075165189 100644 --- a/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: We should use String without the matchAll method to avoid signature conflicts diff --git a/packages/core-js-types/src/base/pure/proposals/set-methods-custom.d.ts b/packages/core-js-types/src/base/pure/proposals/set-methods-custom.d.ts index 444a27fda980..53737eddf9f8 100644 --- a/packages/core-js-types/src/base/pure/proposals/set-methods-custom.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/set-methods-custom.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: Custom type needed to keep generics strict & return our CoreJSSet type diff --git a/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts index 33625af56374..0c03e6bb48d4 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: We should use String without the matchAll method to avoid signature conflicts diff --git a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts index a9e97cc1bcc0..b6212107d623 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// // Motivation: We should use String without the matchAll method to avoid signature conflicts diff --git a/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts b/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts index db24740db9af..812864a9daf5 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: We should use String without the matchAll method to avoid signature conflicts diff --git a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts index 0216028ffac4..09006ce603c7 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: We should use String without the matchAll method to avoid signature conflicts diff --git a/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts index c85a165d89ac..18c28003226b 100644 --- a/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: We should use String without the matchAll method to avoid signature conflicts diff --git a/packages/core-js-types/src/ts5-2/pure/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/ts5-2/pure/core-js-types/iterator-object.d.ts index 85721af98d3c..6584953be4b1 100644 --- a/packages/core-js-types/src/ts5-2/pure/core-js-types/iterator-object.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/core-js-types/iterator-object.d.ts @@ -1,4 +1,4 @@ -/// +/// // Motivation: Iterator until TS 5.6 used undefined as TNext defaults From 2af328e50e9c83753b9afbf872268dfe8dd12480 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 13 Feb 2026 05:22:16 +0700 Subject: [PATCH 205/315] Types refactoring --- .../base/proposals/array-find-from-last.d.ts | 9 + .../async-iterator-helpers-custom.d.ts | 13 ++ .../proposals/async-iterator-helpers.d.ts | 17 +- .../src/base/proposals/await-dictionary.d.ts | 4 +- .../base/proposals/change-array-by-copy.d.ts | 8 +- .../base/proposals/collection-of-from.d.ts | 40 ++-- .../explicit-resource-management.d.ts | 28 +-- .../src/base/proposals/iterator-helpers.d.ts | 203 +++++++++--------- .../src/base/proposals/map-upsert.d.ts | 44 ++-- .../proposals/string-replace-all-custom.d.ts | 2 +- .../src/base/pure/common/parse-int.d.ts | 2 +- .../pure/core-js-types/url-search-params.d.ts | 12 ++ .../src/base/pure/core-js-types/url.d.ts | 2 +- .../async-iterator-helpers-custom.d.ts | 14 ++ .../proposals/async-iterator-helpers.d.ts | 10 +- .../explicit-resource-management.d.ts | 5 +- .../src/base/pure/proposals/symbol.d.ts | 3 + .../src/base/pure/web/dom-exception.d.ts | 3 +- .../base/web/iterable-dom-collections.d.ts | 31 +-- .../src/ts5-2/proposals/iterator-helpers.d.ts | 2 +- .../ts5-2/web/iterable-dom-collections.d.ts | 31 +-- .../build-types-pure.mjs | 4 +- .../build-entries-and-types/build-types.mjs | 2 +- .../entries-definitions.mjs | 12 +- scripts/build-entries-and-types/templates.mjs | 6 +- .../proposals/async-iterator-helper.test.ts | 8 +- tests/type-definitions/helpers.pure.ts | 14 +- .../proposals/async-iterator-helper.test.ts | 28 +-- 28 files changed, 298 insertions(+), 259 deletions(-) create mode 100644 packages/core-js-types/src/base/proposals/async-iterator-helpers-custom.d.ts create mode 100644 packages/core-js-types/src/base/pure/proposals/async-iterator-helpers-custom.d.ts diff --git a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts index cb7f277b2a63..7f8b5a156e27 100644 --- a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts @@ -267,6 +267,15 @@ interface Float64Array { // @type-options: no-export findLast(predicate: (value: number, index: number, array: this) => value is S, thisArg?: any): S | undefined; findLast(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number | undefined; + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate - findLastIndex calls predicate once for each element of the array, in descending + * 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 this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number; } diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers-custom.d.ts new file mode 100644 index 000000000000..3ffb48aece14 --- /dev/null +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers-custom.d.ts @@ -0,0 +1,13 @@ +/// + +// Motivation: Custom type needed to keep generics strict + +// https://github.com/tc39/proposal-async-iterator-helpers + +declare namespace CoreJS { + export type AsyncIteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable | AsyncIterator | AsyncIterable) => AsyncIteratorObject; + + export type AsyncIteratorMap = (callback: (value: T, index: number) => U) => AsyncIteratorObject; + + export type AsyncIteratorReduce = (callback: (accumulator: U, value: T, index: number) => U, initialValue?: U) => Promise; +} diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index 933ce40f3a5b..4ea2570c701c 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -26,13 +26,14 @@ interface AsyncIterator { * @param predicate - A function that tests each element of the iterator * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` */ - every(predicate: (value: T, index: number) => boolean): Promise; + every(predicate: (value: T, index: number) => unknown): Promise; /** * Creates a new `AsyncIterator` that contains only the elements that pass the `predicate` function. * @param predicate - A function that tests each element of the iterator * @returns A new `AsyncIterator` */ + filter(predicate: (value: T, index: number) => value is S): AsyncIteratorObject; filter(predicate: (value: T, index: number) => boolean): AsyncIteratorObject; /** @@ -40,14 +41,15 @@ interface AsyncIterator { * @param predicate - A function that tests each element of the iterator * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` */ - find(predicate: (value: T, index: number) => boolean): Promise; + find(predicate: (value: T, index: number) => value is S): Promise; + find(predicate: (value: T, index: number) => boolean): Promise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. - * @param mapper - A function that transforms each element of the iterator + * @param callback - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - flatMap(mapper: (value: T, index: number) => any): AsyncIteratorObject; + flatMap(callback: (value: T, index: number) => Iterator | Iterable | AsyncIterator | AsyncIterable): AsyncIteratorObject; /** * Executes a provided function once for each element in the iterator. @@ -61,7 +63,7 @@ interface AsyncIterator { * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - map(mapper: (value: T, index: number) => any): AsyncIteratorObject; + map(mapper: (value: T, index: number) => U): AsyncIteratorObject; /** * Reduces the elements of the iterator to a single value using the `reducer` function. @@ -69,14 +71,15 @@ interface AsyncIterator { * @param initialValue - An optional initial value to start the reduction * @returns A `Promise` that resolves to the reduced value */ - reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): Promise; + reduce(reducer: (accumulator: U, value: T, index: number) => U, initialValue?: U): Promise; + reduce(reducer: (accumulator: T, value: T, index: number) => T, initialValue?: T): Promise; /** * Checks if any value in the iterator matches a given `predicate` * @param predicate - A function that tests each element of the iterator * @returns A `Promise` that resolves to `true` if any element passes the `predicate`, otherwise `false` */ - some(predicate: (value: T, index: number) => boolean): Promise; + some(predicate: (value: T, index: number) => unknown): Promise; /** * Creates a new `AsyncIterator` that yields only the first `limit` elements from the original iterator. diff --git a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts index d42ed20ab767..4c6237a25fe9 100644 --- a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts @@ -9,7 +9,7 @@ interface PromiseConstructor { * @param promises - An object of promises * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. */ - allKeyed>>(promises: D): Promise <{ [k in keyof D]: Awaited }>; + allKeyed>>(promises: D): Promise<{ [k in keyof D]: Awaited }>; /** * Takes an object whose values are promises and returns a single `Promise` that resolves @@ -18,7 +18,7 @@ interface PromiseConstructor { * @returns A new Promise that resolves to an object with the same keys as the input object, * where each key maps to the settlement result (`{ status, value }` or `{ status, reason }`) of the corresponding promise. */ - allSettledKeyed>>(promises: D): Promise <{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; + allSettledKeyed>>(promises: D): Promise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; } declare var Promise: PromiseConstructor; diff --git a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts index 3ae8331c45e9..f047438c3b16 100644 --- a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts +++ b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts @@ -274,8 +274,8 @@ interface Uint32Array { // @type-options: no-export * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts - * const myNums = Int32Array.from([11, 2, -22, 1]); - * myNums.toSorted((a, b) => a - b) // Int32Array(4) [-22, 1, 2, 11] + * const myNums = Uint32Array.from([11, 2, -22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint32Array(4) [-22, 1, 2, 11] * ``` */ toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; @@ -303,7 +303,7 @@ interface Float32Array { // @type-options: no-export * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts * const myNums = Float32Array.from([11.25, 2, -22.5, 1]); - * myNums.toSorted((a, b) => a - b) // Float32Array(4) [-22.5, 1, 2, 11.5] + * myNums.toSorted((a, b) => a - b) // Float32Array(4) [-22.5, 1, 2, 11.25] * ``` */ toSorted(compareFn?: (a: number, b: number) => number): Float32Array; @@ -331,7 +331,7 @@ interface Float64Array { // @type-options: no-export * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts * const myNums = Float64Array.from([11.25, 2, -22.5, 1]); - * myNums.toSorted((a, b) => a - b) // Float64Array(4) [-22.5, 1, 2, 11.5] + * myNums.toSorted((a, b) => a - b) // Float64Array(4) [-22.5, 1, 2, 11.25] * ``` */ toSorted(compareFn?: (a: number, b: number) => number): Float64Array; diff --git a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts index 34d92e0824d0..867a8e25f963 100644 --- a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts @@ -24,20 +24,19 @@ declare var Map: MapConstructor; interface SetConstructor { /** - * Creates a new `Set` instance from an iterable or array-like object of [key, value] pairs. - * Optionally, applies a mapping function to each pair. - * @param source - Iterable or array-like object of [key, value] pairs. - * @param mapFn - Function to call on every [key, value] pair before adding to the `Set`. - * @param thisArg - Value to use as this when executing mapFn. - * @returns A new `Set` instance. + * Creates a new `Set` instance from an iterable, optionally transforming elements with a mapping function. + * @param source - Iterable whose elements will be added to the new Set. + * @param mapFn - Optional mapping function. Transforms each element before adding to Set. + * @param thisArg - Value to use as `this` when executing `mapFn`. + * @returns A new `Set` instance */ from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): Set; /** - * Creates a new `Set` instance from a variable number of arguments, - * where each pair of arguments is interpreted as a key and a value. - * @param items - An even number of arguments representing key-value pairs. - * @returns A new `Set` instance. + * Creates a new `Set` instance from a variable number of arguments. + * Each argument becomes an element of the Set. + * @param items - Zero or more arguments to add as Set elements. + * @returns A new `Set` instance */ of(...items: T[]): Set; } @@ -59,7 +58,7 @@ interface WeakMapConstructor { * Creates a new `WeakMap` instance from a variable number of arguments, * where each pair of arguments is interpreted as a key and a value. * @param items - An even number of arguments representing key-value pairs. - * @returns A new `Weak` instance. + * @returns A new `WeakMap` instance. */ of(...items: [K, V][]): WeakMap; } @@ -68,20 +67,19 @@ declare var WeakMap: WeakMapConstructor; interface WeakSetConstructor { /** - * Creates a new `WeakSet` instance from an iterable or array-like object of [key, value] pairs. - * Optionally, applies a mapping function to each pair. - * @param source - Iterable or array-like object of [key, value] pairs. - * @param mapFn - Function to call on every [key, value] pair before adding to the `WeakSet`. - * @param thisArg - Value to use as this when executing mapFn. - * @returns A new `WeakSet` instance. + * Creates a new `WeakSet` instance from an iterable of objects, optionally transforming with mapFn. + * + * @param source - Iterable of objects to add to WeakSet. + * @param mapFn - Optional mapping function transforming each object. + * @param thisArg - Value to use as `this` in `mapFn`. + * @returns New `WeakSet` instance. */ from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): WeakSet; /** - * Creates a new `WeakSet` instance from a variable number of arguments, - * where each pair of arguments is interpreted as a key and a value. - * @param items - An even number of arguments representing key-value pairs. - * @returns A new `WeakSet` instance. + * Creates a new `WeakSet` instance from object arguments. + * @param items - Zero or more objects to add as WeakSet elements. + * @returns New `WeakSet` instance. */ of(...items: T[]): WeakSet; } diff --git a/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts index dabbe5e280dc..edd81c706bd4 100644 --- a/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/proposals/explicit-resource-management.d.ts @@ -148,33 +148,7 @@ interface AsyncDisposableStack { defer(onDisposeAsync: () => PromiseLike | void): void; /** - * Move all resources out of this stack and into a new `DisposableStack`, and marks this stack as disposed. - * @example - * ```ts - * class C { - * #res1: Disposable; - * #res2: Disposable; - * #disposables: DisposableStack; - * constructor() { - * // stack will be disposed when exiting constructor for any reason - * using stack = new DisposableStack(); - * - * // get first resource - * this.#res1 = stack.use(getResource1()); - * - * // get second resource. If this fails, both `stack` and `#res1` will be disposed. - * this.#res2 = stack.use(getResource2()); - * - * // all operations succeeded, move resources out of `stack` so that they aren't disposed - * // when constructor exits - * this.#disposables = stack.move(); - * } - * - * [Symbol.dispose]() { - * this.#disposables.dispose(); - * } - * } - * ``` + * Move all resources out of this stack and into a new `AsyncDisposableStack`, and marks this stack as disposed. */ move(): AsyncDisposableStack; diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts index 2acc526214ed..bce592dc12a6 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts @@ -5,110 +5,105 @@ // For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.iterator.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt +interface Iterator { + /** + * Creates an iterator whose values are the result of applying the callback to the values from this iterator. + * @param callbackfn - A function that accepts up to two arguments to be used to transform values from the underlying iterator. + */ + map(callbackfn: (value: T, index: number) => U): IteratorObject; + + /** + * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. + * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. + */ + filter(predicate: (value: T, index: number) => value is S): IteratorObject; + /** + * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. + * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. + */ + filter(predicate: (value: T, index: number) => unknown): IteratorObject; + + /** + * Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached. + * @param limit - The maximum number of values to yield. + */ + take(limit: number): IteratorObject; + + /** + * Creates an iterator whose values are the values from this iterator after skipping the provided count. + * @param count - The number of values to drop. + */ + drop(count: number): IteratorObject; + + /** + * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. + * @param callback - A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. + */ + flatMap(callback: (value: T, index: number) => Iterator | Iterable): IteratorObject; + + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; + /** + * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. + * @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 a value from the iterator. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; + + /** + * Creates a new array from the values yielded by this iterator. + */ + toArray(): T[]; + + /** + * Performs the specified action for each element in the iterator. + * @param callbackfn - A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. + */ + forEach(callbackfn: (value: T, index: number) => void): void; + + /** + * Determines whether the specified callback function returns true for any element of this iterator. + * @param predicate - A function that accepts up to two arguments. The `some` method calls + * the predicate function for each element in this iterator until the predicate returns a value + * true, or until the end of the iterator. + */ + some(predicate: (value: T, index: number) => unknown): boolean; + + /** + * Determines whether all the members of this iterator satisfy the specified test. + * @param predicate - A function that accepts up to two arguments. The every method calls + * the predicate function for each element in this iterator until the predicate returns + * false, or until the end of this iterator. + */ + every(predicate: (value: T, index: number) => unknown): boolean; + + /** + * Returns the value of the first element in this iterator where predicate is true, and undefined + * otherwise. + * @param predicate - find calls predicate once for each element of this iterator, in + * 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. + */ + find(predicate: (value: T, index: number) => value is S): S | undefined; + find(predicate: (value: T, index: number) => unknown): T | undefined; +} -declare global { - interface Iterator { - /** - * Creates an iterator whose values are the result of applying the callback to the values from this iterator. - * @param callbackfn - A function that accepts up to two arguments to be used to transform values from the underlying iterator. - */ - map(callbackfn: (value: T, index: number) => U): IteratorObject; - - /** - * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. - * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. - */ - filter(predicate: (value: T, index: number) => value is S): IteratorObject; - /** - * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. - * @param predicate - A function that accepts up to two arguments to be used to test values from the underlying iterator. - */ - filter(predicate: (value: T, index: number) => unknown): IteratorObject; - - /** - * Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached. - * @param limit - The maximum number of values to yield. - */ - take(limit: number): IteratorObject; - - /** - * Creates an iterator whose values are the values from this iterator after skipping the provided count. - * @param count - The number of values to drop. - */ - drop(count: number): IteratorObject; - - /** - * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. - * @param callback - A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. - */ - flatMap(callback: (value: T, index: number) => Iterator | Iterable): IteratorObject; // ts < 5.6 Iterable - - /** - * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. - */ - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; - /** - * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. - * @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 a value from the iterator. - */ - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; - /** - * Calls the specified callback function for all the elements in this iterator. 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 three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. - * @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 a value from the iterator. - */ - reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; - - /** - * Creates a new array from the values yielded by this iterator. - */ - toArray(): T[]; - - /** - * Performs the specified action for each element in the iterator. - * @param callbackfn - A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. - */ - forEach(callbackfn: (value: T, index: number) => void): void; - - /** - * Determines whether the specified callback function returns true for any element of this iterator. - * @param predicate - A function that accepts up to two arguments. The `some` method calls - * the predicate function for each element in this iterator until the predicate returns a value - * true, or until the end of the iterator. - */ - some(predicate: (value: T, index: number) => unknown): boolean; - - /** - * Determines whether all the members of this iterator satisfy the specified test. - * @param predicate - A function that accepts up to two arguments. The every method calls - * the predicate function for each element in this iterator until the predicate returns - * false, or until the end of this iterator. - */ - every(predicate: (value: T, index: number) => unknown): boolean; - - /** - * Returns the value of the first element in this iterator where predicate is true, and undefined - * otherwise. - * @param predicate - find calls predicate once for each element of this iterator, in - * 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. - */ - find(predicate: (value: T, index: number) => value is S): S | undefined; - find(predicate: (value: T, index: number) => unknown): T | undefined; - } - - interface IteratorConstructor { // @type-options: no-extends - /** - * Creates a native iterator from an iterator or iterable object. - * Returns its input if the input already inherits from the built-in Iterator class. - * @param value - An iterator or iterable object to convert a native iterator. - */ - from(value: Iterator | Iterable): IteratorObject; - } - - var Iterator: IteratorConstructor; +interface IteratorConstructor { // @type-options: no-extends + /** + * Creates a native iterator from an iterator or iterable object. + * Returns its input if the input already inherits from the built-in Iterator class. + * @param value - An iterator or iterable object to convert a native iterator. + */ + from(value: Iterator | Iterable): IteratorObject; } -export {}; +declare var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/base/proposals/map-upsert.d.ts b/packages/core-js-types/src/base/proposals/map-upsert.d.ts index 6ef9256711c0..32763598548e 100644 --- a/packages/core-js-types/src/base/proposals/map-upsert.d.ts +++ b/packages/core-js-types/src/base/proposals/map-upsert.d.ts @@ -1,39 +1,35 @@ // https://github.com/tc39/proposal-upsert +// For ensuring compatibility with TypeScript standard types, this code is aligned with: +// https://github.com/microsoft/TypeScript/blob/cdc205d5e6338d96b0fb54657af33d473d480a9c/src/lib/esnext.collection.d.ts#L15 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + interface Map { // @type-options: no-redefine /** - * Gets the value for the given key. If the key does not exist, inserts the provided value and returns it. - * @param key - The key to look up. - * @param value - The value to insert if the key does not exist. - * @returns The existing or inserted value. + * Returns a specified element from the Map object. + * If no element is associated with the specified key, a new element with the value `defaultValue` will be inserted into the Map and returned. + * @returns The element associated with the specified key, which will be `defaultValue` if no element previously existed. */ - getOrInsert(key: K, value: V): V; - + getOrInsert(key: K, defaultValue: V): V; /** - * Gets the value for the given key. If the key does not exist, - * computes the value using the provided callback function, inserts it, and returns it. - * @param key - The key to look up. - * @param callbackFn - A function that computes the value to insert if the key does not exist. - * @returns The existing or computed and inserted value. + * Returns a specified element from the Map object. + * If no element is associated with the specified key, the result of passing the specified key to the `callback` function will be inserted into the Map and returned. + * @returns The element associated with the specific key, which will be the newly computed value if no element previously existed. */ - getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; + getOrInsertComputed(key: K, callback: (key: K) => V): V; } interface WeakMap { // @type-options: no-redefine /** - * Gets the value for the given key. If the key does not exist, inserts the provided value and returns it. - * @param key - The key to look up. - * @param value - The value to insert if the key does not exist. - * @returns The existing or inserted value. + * Returns a specified element from the WeakMap object. + * If no element is associated with the specified key, a new element with the value `defaultValue` will be inserted into the WeakMap and returned. + * @returns The element associated with the specified key, which will be `defaultValue` if no element previously existed. */ - getOrInsert(key: K, value: V): V; - + getOrInsert(key: K, defaultValue: V): V; /** - * Gets the value for the given key. If the key does not exist, - * computes the value using the provided callback function, inserts it, and returns it. - * @param key - The key to look up. - * @param callbackFn - A function that computes the value to insert if the key does not exist. - * @returns The existing or computed and inserted value. + * Returns a specified element from the WeakMap object. + * If no element is associated with the specified key, the result of passing the specified key to the `callback` function will be inserted into the WeakMap and returned. + * @returns The element associated with the specific key, which will be the newly computed value if no element previously existed. */ - getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; + getOrInsertComputed(key: K, callback: (key: K) => V): V; } diff --git a/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts b/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts index 28b8d73b8d62..55306cf40840 100644 --- a/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts @@ -3,7 +3,7 @@ // https://github.com/tc39/proposal-string-replaceall // For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2017.string.d.ts +// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2021.string.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt declare namespace CoreJS { diff --git a/packages/core-js-types/src/base/pure/common/parse-int.d.ts b/packages/core-js-types/src/base/pure/common/parse-int.d.ts index ade6b636890c..eba4a7aba2be 100644 --- a/packages/core-js-types/src/base/pure/common/parse-int.d.ts +++ b/packages/core-js-types/src/base/pure/common/parse-int.d.ts @@ -1,3 +1,3 @@ declare namespace CoreJS { - export function CoreJSparseInt(string: string): number; + export function CoreJSparseInt(string: string, radix?: number): number; } diff --git a/packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts b/packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts index 536d0b7109d5..e022619cf53f 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts @@ -1,3 +1,6 @@ +/// +/// + declare namespace CoreJS { export interface CoreJSURLSearchParams { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size) */ @@ -43,6 +46,15 @@ declare namespace CoreJS { /** Returns a string containing a query string suitable for use in a URL. Does not include the question mark. */ toString(): string; forEach(callbackfn: (value: string, key: string, parent: CoreJSURLSearchParams) => void, thisArg?: any): void; + + [CoreJS.CoreJSSymbol.iterator](): CoreJSURLSearchParamsIterator<[string, string]>; + entries(): CoreJSURLSearchParamsIterator<[string, string]>; + keys(): CoreJSURLSearchParamsIterator; + values(): CoreJSURLSearchParamsIterator; + } + + interface CoreJSURLSearchParamsIterator extends CoreJSIteratorObject { + [Symbol.iterator](): CoreJSURLSearchParamsIterator; } export interface CoreJSURLSearchParamsConstructor { diff --git a/packages/core-js-types/src/base/pure/core-js-types/url.d.ts b/packages/core-js-types/src/base/pure/core-js-types/url.d.ts index a7f4e6d89027..d813f590a0c0 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/url.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/url.d.ts @@ -45,7 +45,7 @@ declare namespace CoreJS { } export interface CoreJSURLConstructor { - new(url: string, base?: string): CoreJSURL; + new(url: string | CoreJSURL, base?: string): CoreJSURL; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */ canParse(url: string, base?: string): boolean; diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers-custom.d.ts new file mode 100644 index 000000000000..df9bc6a21178 --- /dev/null +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers-custom.d.ts @@ -0,0 +1,14 @@ +/// +/// + +// Motivation: Using our own type for AsyncIteratorObject + +// https://github.com/tc39/proposal-async-iterator-helpers + +declare namespace CoreJS { + export type AsyncIteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable | CoreJS.CoreJSAsyncIterator | CoreJS.CoreJSAsyncIterable) => CoreJS.CoreJSAsyncIteratorObject; + + export type AsyncIteratorMap = (callback: (value: T, index: number) => U) => CoreJS.CoreJSAsyncIteratorObject; + + export type AsyncIteratorReduce = (callback: (accumulator: U, value: T, index: number) => U, initialValue?: U) => CoreJS.CoreJSPromise; +} diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index 00d4e7e70f18..98220158c292 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -31,13 +31,14 @@ declare namespace CoreJS { * @param predicate - A function that tests each element of the iterator * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` */ - every(predicate: (value: T, index: number) => boolean): CoreJSPromise; + every(predicate: (value: T, index: number) => unknown): CoreJSPromise; /** * Creates a new `AsyncIterator` that contains only the elements that pass the `predicate` function. * @param predicate - A function that tests each element of the iterator * @returns A new `AsyncIterator` */ + filter(predicate: (value: T, index: number) => value is S): CoreJSAsyncIteratorObject; filter(predicate: (value: T, index: number) => boolean): CoreJSAsyncIteratorObject; /** @@ -45,7 +46,8 @@ declare namespace CoreJS { * @param predicate - A function that tests each element of the iterator * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` */ - find(predicate: (value: T, index: number) => boolean): CoreJSPromise; + find(predicate: (value: T, index: number) => value is S): CoreJSPromise; + find(predicate: (value: T, index: number) => boolean): CoreJSPromise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. @@ -66,7 +68,7 @@ declare namespace CoreJS { * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - map(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorObject; + map(mapper: (value: T, index: number) => U): CoreJSAsyncIteratorObject; /** * Reduces the elements of the iterator to a single value using the `reducer` function. @@ -81,7 +83,7 @@ declare namespace CoreJS { * @param predicate - A function that tests each element of the iterator * @returns A `Promise` that resolves to `true` if any element passes the `predicate`, otherwise `false` */ - some(predicate: (value: T, index: number) => boolean): CoreJSPromise; + some(predicate: (value: T, index: number) => unknown): CoreJSPromise; /** * Creates a new `AsyncIterator` that yields only the first `limit` elements from the original iterator. diff --git a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts index 248e558bf4b0..f6bef592638d 100644 --- a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts @@ -1,4 +1,5 @@ /// +/// // Motivation: Symbol is replaced with our own @@ -125,7 +126,7 @@ declare namespace CoreJS { /** * Disposes each resource in the stack in the reverse order that they were added. */ - disposeAsync(): CoreJSPromise; + disposeAsync(): CoreJS.CoreJSPromise; /** * Adds a disposable resource to the stack, returning the resource. @@ -179,7 +180,7 @@ declare namespace CoreJS { */ move(): CoreJSAsyncDisposableStack; - [CoreJSSymbol.asyncDispose](): Promise; + [CoreJSSymbol.asyncDispose](): CoreJS.CoreJSPromise; } export interface CoreJSAsyncDisposableStackConstructor { diff --git a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts index 02be9fd600d6..e07af7f54004 100644 --- a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts @@ -45,6 +45,7 @@ declare namespace CoreJS { type CoreJSCustomMatcherSymbolType = typeof CoreJSCustomMatcherSymbol; type CoreJSMetadataSymbolType = typeof CoreJSMetadataSymbol; type CoreJSMatchAllSymbolType = typeof CoreJSMatchAllSymbol; + type CoreJSIteratorSymbolType = typeof CoreJSMatchAllSymbol; type GetNativeWithFallback = K extends keyof T ? T[K] : Fallback; @@ -82,6 +83,8 @@ declare namespace CoreJS { readonly metadata: GetNativeWithFallback; readonly matchAll: GetNativeWithFallback; + + readonly iterator: GetNativeWithFallback; } export interface CoreJSSymbol extends Symbol { diff --git a/packages/core-js-types/src/base/pure/web/dom-exception.d.ts b/packages/core-js-types/src/base/pure/web/dom-exception.d.ts index 7b5f52d818c3..83c885b7f201 100644 --- a/packages/core-js-types/src/base/pure/web/dom-exception.d.ts +++ b/packages/core-js-types/src/base/pure/web/dom-exception.d.ts @@ -40,6 +40,7 @@ declare namespace CoreJS { interface CoreJSDomExceptionConstructor { prototype: CoreJSDOMException; new(message?: string, name?: string): CoreJSDOMException; + new(message?: string, options?: { name?: string; cause?: unknown }): CoreJSDOMException; readonly INDEX_SIZE_ERR: 1; readonly DOMSTRING_SIZE_ERR: 2; readonly HIERARCHY_REQUEST_ERR: 3; @@ -67,5 +68,5 @@ declare namespace CoreJS { readonly DATA_CLONE_ERR: 25; } - var CoreJSDOMException: CoreJSDOMException; + var CoreJSDOMException: CoreJSDomExceptionConstructor; } diff --git a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts index acacdb43bc50..0406da9c0731 100644 --- a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts +++ b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts @@ -4,6 +4,11 @@ interface Element {} // @type-options: no-export interface Node {} // @type-options: no-export interface HTMLOptionElement {} // @type-options: no-export +interface CSSValue {} // @type-options: no-export +interface CSSRule {} // @type-options: no-export +interface ClientRect {} // @type-options: no-export +interface DOMRect {} // @type-options: no-export +interface StyleSheet {} // @type-options: no-export interface ArrayIterator extends IteratorObject { // @type-options: no-export [Symbol.iterator](): ArrayIterator; @@ -36,7 +41,7 @@ interface DOMTokenList { // @type-options: no-export */ entries(): IterableIterator<[number, Element]>; - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface NodeList { // @type-options: no-export @@ -74,37 +79,37 @@ interface NodeList { // @type-options: no-export interface CSSRuleList { // @type-options: no-export /** - * Returns an iterable of values in the CSSRuleList. + * Returns an iterable of CSSRule values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface CSSStyleDeclaration { // @type-options: no-export /** - * Returns an iterable of values in the CSSStyleDeclaration. + * Returns an iterable of string values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface CSSValueList { // @type-options: no-export /** - * Returns an iterable of values in the CSSValueList. + * Returns an iterable of CSSValue values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface ClientRectList { // @type-options: no-export /** - * Returns an iterable of values in the ClientRectList. + * Returns an iterable of ClientRect values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface DOMRectList { // @type-options: no-export /** - * Returns an iterable of values in the DOMRectList. + * Returns an iterable of DOMRect values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface DOMStringList { // @type-options: no-export @@ -249,10 +254,10 @@ interface SourceBufferList { // @type-options: no-export interface StyleSheetList { // @type-options: no-export /** - * Returns an iterable of values in the StyleSheetList. + * Returns an iterable of StyleSheet values. * */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface TextTrackCueList { // @type-options: no-export diff --git a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts index ff4fcebec530..c5b5c0943d18 100644 --- a/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/iterator-helpers.d.ts @@ -107,7 +107,7 @@ declare global { * Returns its input if the input already inherits from the built-in Iterator class. * @param value - An iterator or iterable object to convert a native iterator. */ - from(value: Iterator | Iterable): CoreJS.CoreJSIteratorObject; + from(value: Iterator | Iterable): CoreJS.CoreJSIteratorObject; } var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts index 81477345722c..3ca9b5b31c3c 100644 --- a/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts +++ b/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts @@ -2,6 +2,11 @@ interface Element {} // @type-options: no-export interface Node {} // @type-options: no-export interface HTMLOptionElement {} // @type-options: no-export +interface CSSValue {} // @type-options: no-export +interface CSSRule {} // @type-options: no-export +interface ClientRect {} // @type-options: no-export +interface DOMRect {} // @type-options: no-export +interface StyleSheet {} // @type-options: no-export interface ArrayIterator extends IteratorObject { // @type-options: no-export [Symbol.iterator](): ArrayIterator; @@ -34,7 +39,7 @@ interface DOMTokenList { // @type-options: no-export */ entries(): IterableIterator<[number, Element]>; - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface NodeList { // @type-options: no-export @@ -72,37 +77,37 @@ interface NodeList { // @type-options: no-export interface CSSRuleList { // @type-options: no-export /** - * Returns an iterable of values in the CSSRuleList. + * Returns an iterable of CSSRule values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface CSSStyleDeclaration { // @type-options: no-export /** - * Returns an iterable of values in the CSSStyleDeclaration. + * Returns an iterable of string values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface CSSValueList { // @type-options: no-export /** - * Returns an iterable of values in the CSSValueList. + * Returns an iterable of CSSValue values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface ClientRectList { // @type-options: no-export /** - * Returns an iterable of values in the ClientRectList. + * Returns an iterable of ClientRect values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface DOMRectList { // @type-options: no-export /** - * Returns an iterable of values in the DOMRectList. + * Returns an iterable of DOMRect values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface DOMStringList { // @type-options: no-export @@ -247,10 +252,10 @@ interface SourceBufferList { // @type-options: no-export interface StyleSheetList { // @type-options: no-export /** - * Returns an iterable of values in the StyleSheetList. + * Returns an iterable of StyleSheet values. * */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface TextTrackCueList { // @type-options: no-export diff --git a/scripts/build-entries-and-types/build-types-pure.mjs b/scripts/build-entries-and-types/build-types-pure.mjs index 79f697c86734..32882ad2671a 100644 --- a/scripts/build-entries-and-types/build-types-pure.mjs +++ b/scripts/build-entries-and-types/build-types-pure.mjs @@ -85,9 +85,9 @@ function processLines(lines) { } // Replace prefixed types in the entire file - if (/(?::|\|)\s*\w/.test(line)) { + if (/:\s*\w/.test(line)) { prefixed.toSorted((a, b) => b.length - a.length).forEach(item => { - const reg = new RegExp(`(?:||) ${ item }(?[,;<)])`, 'g'); + const reg = new RegExp(`(?:) ${ item }(?[,;<)])`, 'g'); line = line.replace(reg, `$ ${ NAMESPACE }${ item }$`); }); } diff --git a/scripts/build-entries-and-types/build-types.mjs b/scripts/build-entries-and-types/build-types.mjs index 49cfccb9b89d..7606eae59aa1 100644 --- a/scripts/build-entries-and-types/build-types.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -164,7 +164,7 @@ async function fillCustomImportsForPure(typesPath, initialPath) { await fillCustomImportsForPure(path.join(typesPath, entry.name), initialPath); } else { const filePath = path.join(typesPath, entry.name); - const fileContent = await readFile(filePath).toString(); + const fileContent = (await readFile(filePath)).toString(); if (fileContent.startsWith('// empty')) continue; imports.pure.add(filePath.replace(`${ initialPath }/`, '').replace('.d.ts', '')); } diff --git a/scripts/build-entries-and-types/entries-definitions.mjs b/scripts/build-entries-and-types/entries-definitions.mjs index 4a7b657e3d43..f74633ff3193 100644 --- a/scripts/build-entries-and-types/entries-definitions.mjs +++ b/scripts/build-entries-and-types/entries-definitions.mjs @@ -716,9 +716,11 @@ export const features = { }, 'async-iterator/flat-map': { modules: ['esnext.async-iterator.flat-map'], - template: $uncurried, + template: $uncurriedWithCustomType, namespace: 'AsyncIterator', name: 'flatMap', + customType: 'proposals/async-iterator-helpers-custom', + genericsCount: 2, }, 'async-iterator/prototype/flat-map': { modules: ['esnext.async-iterator.flat-map'], @@ -740,9 +742,11 @@ export const features = { }, 'async-iterator/map': { modules: ['esnext.async-iterator.map'], - template: $uncurried, + template: $uncurriedWithCustomType, namespace: 'AsyncIterator', name: 'map', + customType: 'proposals/async-iterator-helpers-custom', + genericsCount: 2, }, 'async-iterator/prototype/map': { modules: ['esnext.async-iterator.map'], @@ -752,9 +756,11 @@ export const features = { }, 'async-iterator/reduce': { modules: ['esnext.async-iterator.reduce'], - template: $uncurried, + template: $uncurriedWithCustomType, namespace: 'AsyncIterator', name: 'reduce', + customType: 'proposals/async-iterator-helpers-custom', + genericsCount: 2, }, 'async-iterator/prototype/reduce': { modules: ['esnext.async-iterator.reduce'], diff --git a/scripts/build-entries-and-types/templates.mjs b/scripts/build-entries-and-types/templates.mjs index 514068bf16e3..15b481b4a7e4 100644 --- a/scripts/build-entries-and-types/templates.mjs +++ b/scripts/build-entries-and-types/templates.mjs @@ -9,6 +9,8 @@ const importModules = ({ modules, level }) => modules.map(module => importModule const buildCoreJSTypeName = (namespace, name) => `CoreJS.${ namespace }${ name.charAt(0).toUpperCase() + name.slice(1) }`; +const buildSelfForNamespace = (namespace, prefix) => `${ prefix && missingNamespacesInES6.includes(namespace) ? prefix : '' }${ namespace }${ getCommonGenericsForNamespace(namespace) }`; + const buildModulePath = ({ entry, packageName }) => `${ packageName }${ entry }`; function isAllowedFunctionName(name) { @@ -136,7 +138,7 @@ export const $uncurried = p => ({ types: dedent` declare module '${ buildModulePath(p) }' { type method${ getGenericsForNamespace(p.namespace) } = ${ p.prefix ?? '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }['${ p.name }']; - const resultMethod: ${ getGenericsForNamespace(p.namespace) }(self: ${ p.prefix && missingNamespacesInES6.includes(p.namespace) ? p.prefix : '' }${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters) => ReturnType; + const resultMethod: ${ getGenericsForNamespace(p.namespace) }(self: ${ buildSelfForNamespace(p.namespace, p.prefix) }, ...args: Parameters) => ReturnType; export = resultMethod; } `, @@ -152,7 +154,7 @@ export const $uncurriedWithCustomType = p => ({ `, types: dedent` declare module '${ buildModulePath(p) }' { - const resultMethod: ${ getCustomGenerics(p.genericsCount) }(self: ${ p.namespace }${ getCommonGenericsForNamespace(p.namespace) }, ...args: Parameters<${ buildCoreJSTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>) => ReturnType<${ buildCoreJSTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>; + const resultMethod: ${ getCustomGenerics(p.genericsCount) }(self: ${ buildSelfForNamespace(p.namespace, p.prefix) }, ...args: Parameters<${ buildCoreJSTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>) => ReturnType<${ buildCoreJSTypeName(p.namespace, p.name) }${ getCustomGenerics(p.genericsCount) }>; export = resultMethod; } `, diff --git a/tests/type-definitions/global/proposals/async-iterator-helper.test.ts b/tests/type-definitions/global/proposals/async-iterator-helper.test.ts index a9c128e64c4f..b0a182a254f2 100644 --- a/tests/type-definitions/global/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/global/proposals/async-iterator-helper.test.ts @@ -17,7 +17,7 @@ drop(ait, 1); every(ait, (v: number, i: number) => v > 0); filter(ait, (v: number, i: number) => v > 0); find(ait, (v: number, i: number) => v > 0); -flatMap(ait, (v: number, i: number) => v); +flatMap(ait, (v: number, i: number) => [v, v * 2]); forEach(ait, (v: number, i: number) => { }); map(ait, (v: number, i: number) => v * 2); reduce(ait, (acc: number, v: number, i: number) => acc + v, 0); @@ -66,8 +66,8 @@ const raitn: AsyncIterator = itn.toAsync(); const r1: AsyncIterator = ain.drop(3); const r2: Promise = ain.every((v: number, i: number) => v > 0); const r3: AsyncIterator = ain.filter((v: number, i: number) => v > 0); -const r4: Promise = ain.find((v: number, i: number) => v > 0); -const r5: AsyncIterator = ain.flatMap((v: number, i: number) => v); +const r4: Promise = ain.find((v: number, i: number) => v > 0); +const r5: AsyncIterator = ain.flatMap((v: number, i: number) => [v, v * 2]); const r6: Promise = ain.forEach((v: number, i: number) => { }); const r7: AsyncIterator = ain.map((v: number, i: number) => v * 2); const r8: Promise = ain.reduce((acc: number, v: number, i: number) => acc + v, 0); @@ -99,7 +99,7 @@ ain.take(); ain.toArray(1); const s0: Promise = ais.toArray(); -const f0: Promise = ais.find((v: string, i: number) => v.length === 1); +const f0: Promise = ais.find((v: string, i: number) => v.length === 1); // @ts-expect-error ais.map((v: string, i: number) => v.length === 1, 'extra'); diff --git a/tests/type-definitions/helpers.pure.ts b/tests/type-definitions/helpers.pure.ts index 1b089a55c45b..4614c67d90c8 100644 --- a/tests/type-definitions/helpers.pure.ts +++ b/tests/type-definitions/helpers.pure.ts @@ -6,16 +6,16 @@ interface CoreJSPromiseLike { export function assertCoreJSPromiseLike(value: CoreJSPromiseLike): asserts value is CoreJSPromiseLike {} export interface CoreJSMapLike extends Map { - getOrInsert(key: K, value: V): V; + getOrInsert(key: K, defaultValue: V): V; - getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; + getOrInsertComputed(key: K, callback: (key: K) => V): V; } export function assertCoreJSMapLike(value: CoreJSMapLike): asserts value is CoreJSMapLike {} export interface CoreJSWeakMapLike extends WeakMap { - getOrInsert(key: K, value: V): V; + getOrInsert(key: K, defaultValue: V): V; - getOrInsertComputed(key: K, callbackFn: (key: K) => R): R; + getOrInsertComputed(key: K, callback: (key: K) => V): V; } export function assertCoreJSWeakMapLike(value: CoreJSWeakMapLike): asserts value is CoreJSWeakMapLike {} @@ -52,14 +52,14 @@ export interface CoreJSIteratorLike e } export function assertCoreJSIteratorLike(value: CoreJSIteratorLike): asserts value is CoreJSIteratorLike {} -interface CoreJSAsyncIteratorLike { +interface CoreJSAsyncIteratorLike { drop(...args: any[]): any; every(...args: any[]): any; - filter(predicate: (value: T, index: number) => boolean): CoreJSAsyncIteratorLike; + filter(...args: any[]): CoreJSAsyncIteratorLike; find(...args: any[]): any; flatMap(...args: any[]): any; forEach(...args: any[]): any; - map(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorLike; + map(mapper: (value: T, index: number) => U): CoreJSAsyncIteratorLike; reduce(...args: any[]): any; some(...args: any[]): any; take(limit: number): CoreJSAsyncIteratorLike; diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 3574644707ac..daf6c52d8095 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -41,7 +41,7 @@ from({ next: () => 1 }); const r1 = every(aiton, (v: number, i: number) => v > 0); assertCoreJSPromiseLike(r1); const r2 = find(aiton, (v: number, i: number) => v > 0); -assertCoreJSPromiseLike(r2); +assertCoreJSPromiseLike(r2); const r3 = forEach(aiton, (v: number, i: number) => { }); assertCoreJSPromiseLike(r3); const r4 = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); @@ -67,32 +67,32 @@ assertCoreJSAsyncIteratorLike(ait6); toAsync(is); // @ts-expect-error -drop(ain); +drop(aitn); // @ts-expect-error -every(ain); +every(aitn); // @ts-expect-error -filter(ain); +filter(aitn); // @ts-expect-error -find(ain); +find(aitn); // @ts-expect-error -flatMap(ain); +flatMap(aitn); // @ts-expect-error -forEach(ain); +forEach(aitn); // @ts-expect-error -map(ain); +map(aitn); // @ts-expect-error -reduce(ain); +reduce(aitn); // @ts-expect-error -some(ain); +some(aitn); // @ts-expect-error -take(ain); +take(aitn); // @ts-expect-error -toArray(ain, 1); +toArray(aitn, 1); const s0 = toArray(aiton); assertCoreJSPromiseLike(s0); const f0 = find(aitos, (v: string, i: number) => v.length === 1); -assertCoreJSPromiseLike(f0); +assertCoreJSPromiseLike(f0); // @ts-expect-error -map(ais, (v: string, i: number) => v.length === 1, 'extra'); +map(aitos, (v: string, i: number) => v.length === 1, 'extra'); From b8cb2872bdf6072cc97f32a9a4a0d16b36506eea Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 16 Feb 2026 20:28:45 +0700 Subject: [PATCH 206/315] Type definition helpers move & fix IteratorLike pure helper --- tests/type-definitions/global/proposals/array-filtering.test.ts | 2 +- .../global/proposals/array-find-from-last.test.ts | 2 +- tests/type-definitions/global/proposals/array-flat-map.test.ts | 2 +- tests/type-definitions/global/proposals/array-includes.test.ts | 2 +- .../global/proposals/array-is-template-object.test.ts | 2 +- tests/type-definitions/global/proposals/array-unique.test.ts | 2 +- .../global/proposals/change-array-by-copy.test.ts | 2 +- tests/type-definitions/global/proposals/float16.test.ts | 2 +- tests/type-definitions/global/proposals/is-error.test.ts | 2 +- .../type-definitions/global/proposals/iterator-helpers.test.ts | 2 +- tests/type-definitions/global/proposals/iterator-join.test.ts | 2 +- .../global/proposals/json-parse-with-source.test.ts | 2 +- tests/type-definitions/global/proposals/map-upsert.test.ts | 2 +- tests/type-definitions/global/proposals/math-sum.test.ts | 2 +- tests/type-definitions/global/proposals/number-clamp.test.ts | 2 +- .../global/proposals/object-keys-length.test.ts | 2 +- .../global/proposals/object-values-entries.test.ts | 2 +- tests/type-definitions/global/proposals/regexp-escaping.test.ts | 2 +- tests/type-definitions/global/proposals/string-cooked.test.ts | 2 +- tests/type-definitions/global/proposals/string-dedent.test.ts | 2 +- .../global/proposals/string-left-right-trim.test.ts | 2 +- tests/type-definitions/global/proposals/string-padding.test.ts | 2 +- .../global/proposals/string-replace-all.test.ts | 2 +- .../type-definitions/global/proposals/symbol-predicates.test.ts | 2 +- .../global/proposals/well-formed-unicode-strings.test.ts | 2 +- tests/type-definitions/global/web/atob.test.ts | 2 +- tests/type-definitions/global/web/btoa.test.ts | 2 +- tests/type-definitions/global/web/structured-clone.test.ts | 2 +- tests/type-definitions/{ => helpers}/helpers.pure.ts | 2 +- tests/type-definitions/{ => helpers}/helpers.ts | 0 tests/type-definitions/pure/proposals/array-from-async.test.ts | 2 +- tests/type-definitions/pure/proposals/array-grouping.test.ts | 2 +- .../pure/proposals/async-iterator-helper.test.ts | 2 +- tests/type-definitions/pure/proposals/await-dictionary.test.ts | 2 +- .../type-definitions/pure/proposals/collection-of-from.test.ts | 2 +- tests/type-definitions/pure/proposals/error-cause.test.ts | 2 +- .../pure/proposals/explicit-resource-management.test.ts | 2 +- tests/type-definitions/pure/proposals/iterator-chunking.test.ts | 2 +- tests/type-definitions/pure/proposals/iterator-helpers.test.ts | 2 +- tests/type-definitions/pure/proposals/iterator-joint.test.ts | 2 +- tests/type-definitions/pure/proposals/iterator-range.test.ts | 2 +- .../type-definitions/pure/proposals/iterator-sequencing.test.ts | 2 +- .../type-definitions/pure/proposals/object-keys-length.test.ts | 2 +- .../type-definitions/pure/proposals/promise-all-settled.test.ts | 2 +- tests/type-definitions/pure/proposals/promise-any.test.ts | 2 +- tests/type-definitions/pure/proposals/promise-finally.test.ts | 2 +- tests/type-definitions/pure/proposals/promise-try.test.ts | 2 +- .../pure/proposals/promise-with-resolvers.test.ts | 2 +- tests/type-definitions/pure/proposals/set-methods.test.ts | 2 +- 49 files changed, 48 insertions(+), 48 deletions(-) rename tests/type-definitions/{ => helpers}/helpers.pure.ts (98%) rename tests/type-definitions/{ => helpers}/helpers.ts (100%) diff --git a/tests/type-definitions/global/proposals/array-filtering.test.ts b/tests/type-definitions/global/proposals/array-filtering.test.ts index 103d142619b8..67dd16dacc8c 100644 --- a/tests/type-definitions/global/proposals/array-filtering.test.ts +++ b/tests/type-definitions/global/proposals/array-filtering.test.ts @@ -1,7 +1,7 @@ import 'core-js/full'; import filterReject from 'core-js/full/array/filter-reject'; import filterRejectJS from 'core-js/full/array/filter-reject.js'; -import { assertNumberArray } from '../../helpers.js'; +import { assertNumberArray } from '../../helpers/helpers.js'; filterReject([1, 2, 3], (v, i, arr) => v > 1); filterRejectJS([1, 2, 3], (v, i, arr) => v > 1); diff --git a/tests/type-definitions/global/proposals/array-find-from-last.test.ts b/tests/type-definitions/global/proposals/array-find-from-last.test.ts index bca460cc2f7d..3b1ed3056e1a 100644 --- a/tests/type-definitions/global/proposals/array-find-from-last.test.ts +++ b/tests/type-definitions/global/proposals/array-find-from-last.test.ts @@ -3,7 +3,7 @@ import findLast from 'core-js/es/array/find-last'; import findLastJS from 'core-js/es/array/find-last.js'; import findLastIndex from 'core-js/es/array/find-last-index'; import findLastIndexJS from 'core-js/es/array/find-last-index.js'; -import { assertNumber } from '../../helpers.js'; +import { assertNumber } from '../../helpers/helpers.js'; const resNS1: number | undefined = findLast([1, 2, 3], v => v > 1); const resNS2: number | undefined = findLastJS([1, 2, 3], v => v > 1); diff --git a/tests/type-definitions/global/proposals/array-flat-map.test.ts b/tests/type-definitions/global/proposals/array-flat-map.test.ts index 45575a2ef365..98665c17ead5 100644 --- a/tests/type-definitions/global/proposals/array-flat-map.test.ts +++ b/tests/type-definitions/global/proposals/array-flat-map.test.ts @@ -1,7 +1,7 @@ import 'core-js/es'; import flatMap from 'core-js/es/array/flat-map'; import flatMapJS from 'core-js/es/array/flat-map.js'; -import { assertNumberArray, assertStringArray } from '../../helpers.js'; +import { assertNumberArray, assertStringArray } from '../../helpers/helpers.js'; assertNumberArray(flatMap([1, 2, 3], x => [x, x * 2])); assertNumberArray(flatMapJS([1, 2, 3], x => [x, x * 2])); diff --git a/tests/type-definitions/global/proposals/array-includes.test.ts b/tests/type-definitions/global/proposals/array-includes.test.ts index 46673a5941b6..0b0ed0efc6bb 100644 --- a/tests/type-definitions/global/proposals/array-includes.test.ts +++ b/tests/type-definitions/global/proposals/array-includes.test.ts @@ -1,6 +1,6 @@ import 'core-js/es'; import includes from 'core-js/es/array/includes'; -import { assertBool } from '../../helpers.js'; +import { assertBool } from '../../helpers/helpers.js'; const arr = [1, 2, 3]; diff --git a/tests/type-definitions/global/proposals/array-is-template-object.test.ts b/tests/type-definitions/global/proposals/array-is-template-object.test.ts index 15f11a97b5b7..bc3c423a953b 100644 --- a/tests/type-definitions/global/proposals/array-is-template-object.test.ts +++ b/tests/type-definitions/global/proposals/array-is-template-object.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; import isTemplateObject from 'core-js/full/array/is-template-object'; -import { assertBool } from '../../helpers.js'; +import { assertBool } from '../../helpers/helpers.js'; const res: boolean = isTemplateObject([]); diff --git a/tests/type-definitions/global/proposals/array-unique.test.ts b/tests/type-definitions/global/proposals/array-unique.test.ts index 10c34e94c127..5e4ca1fd83e7 100644 --- a/tests/type-definitions/global/proposals/array-unique.test.ts +++ b/tests/type-definitions/global/proposals/array-unique.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; import uniqueBy from 'core-js/full/array/unique-by'; -import { assertNumberArray } from '../../helpers.js'; +import { assertNumberArray } from '../../helpers/helpers.js'; const uniqueByNS: number[] = uniqueBy([1, 2, 1, 3]); diff --git a/tests/type-definitions/global/proposals/change-array-by-copy.test.ts b/tests/type-definitions/global/proposals/change-array-by-copy.test.ts index 8105b43c9406..3a6e7fd0bf81 100644 --- a/tests/type-definitions/global/proposals/change-array-by-copy.test.ts +++ b/tests/type-definitions/global/proposals/change-array-by-copy.test.ts @@ -3,7 +3,7 @@ import toSorted from 'core-js/es/array/to-sorted'; import toSpliced from 'core-js/es/array/to-spliced'; import toReversed from 'core-js/es/array/to-reversed'; import withArray from 'core-js/es/array/with'; -import { assertNumberArray, assertStringArray } from '../../helpers.js'; +import { assertNumberArray, assertStringArray } from '../../helpers/helpers.js'; const arr: number[] = [1, 2, 3]; diff --git a/tests/type-definitions/global/proposals/float16.test.ts b/tests/type-definitions/global/proposals/float16.test.ts index bd412464d7ed..61b7f45e50b6 100644 --- a/tests/type-definitions/global/proposals/float16.test.ts +++ b/tests/type-definitions/global/proposals/float16.test.ts @@ -1,6 +1,6 @@ import 'core-js/es'; import f16round from 'core-js/es/math/f16round'; -import { assertNumber } from '../../helpers.js'; +import { assertNumber } from '../../helpers/helpers.js'; assertNumber(f16round(1)); // @ts-expect-error diff --git a/tests/type-definitions/global/proposals/is-error.test.ts b/tests/type-definitions/global/proposals/is-error.test.ts index f3a1131efa1a..ef0ed8e75201 100644 --- a/tests/type-definitions/global/proposals/is-error.test.ts +++ b/tests/type-definitions/global/proposals/is-error.test.ts @@ -1,6 +1,6 @@ import 'core-js/es'; import isError from 'core-js/es/error/is-error'; -import { assertBool } from '../../helpers.js'; +import { assertBool } from '../../helpers/helpers.js'; const e = new Error(); const ne = { foo: 1 }; diff --git a/tests/type-definitions/global/proposals/iterator-helpers.test.ts b/tests/type-definitions/global/proposals/iterator-helpers.test.ts index 4c348d3deedb..e3594e16af43 100644 --- a/tests/type-definitions/global/proposals/iterator-helpers.test.ts +++ b/tests/type-definitions/global/proposals/iterator-helpers.test.ts @@ -9,7 +9,7 @@ import forEach from 'core-js/es/iterator/for-each'; import some from 'core-js/es/iterator/some'; import every from 'core-js/es/iterator/every'; import find from 'core-js/es/iterator/find'; -import { assertBool, assertNumber, assertNumberArray, assertString } from '../../helpers.js'; +import { assertBool, assertNumber, assertNumberArray, assertString } from '../../helpers/helpers.js'; declare const it: Iterator; declare const itStr: Iterator; diff --git a/tests/type-definitions/global/proposals/iterator-join.test.ts b/tests/type-definitions/global/proposals/iterator-join.test.ts index 605c493f1cf1..ddcf677a4274 100644 --- a/tests/type-definitions/global/proposals/iterator-join.test.ts +++ b/tests/type-definitions/global/proposals/iterator-join.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; import join from 'core-js/full/iterator/join'; -import { assertString } from '../../helpers.js'; +import { assertString } from '../../helpers/helpers.js'; declare const it: Iterator; diff --git a/tests/type-definitions/global/proposals/json-parse-with-source.test.ts b/tests/type-definitions/global/proposals/json-parse-with-source.test.ts index 37576c7d63a3..71c0f00a301d 100644 --- a/tests/type-definitions/global/proposals/json-parse-with-source.test.ts +++ b/tests/type-definitions/global/proposals/json-parse-with-source.test.ts @@ -1,7 +1,7 @@ import 'core-js/es'; import rawJSON from 'core-js/es/json/raw-json'; import isRawJSON from 'core-js/es/json/is-raw-json'; -import { assertBool } from '../../helpers.js'; +import { assertBool } from '../../helpers/helpers.js'; const resNS: CoreJSRawJSON = rawJSON('{"a":123}'); assertBool(isRawJSON(resNS)); diff --git a/tests/type-definitions/global/proposals/map-upsert.test.ts b/tests/type-definitions/global/proposals/map-upsert.test.ts index 7381ec1a51c2..894e10c92e5f 100644 --- a/tests/type-definitions/global/proposals/map-upsert.test.ts +++ b/tests/type-definitions/global/proposals/map-upsert.test.ts @@ -3,7 +3,7 @@ import mapGetOrInsert from 'core-js/es/map/get-or-insert'; import mapGetOrInsertComputed from 'core-js/es/map/get-or-insert-computed'; import wMapGetOrInsert from 'core-js/es/weak-map/get-or-insert'; import wMapGetOrInsertComputed from 'core-js/es/weak-map/get-or-insert-computed'; -import { assertBool, assertNumber } from '../../helpers.js'; +import { assertBool, assertNumber } from '../../helpers/helpers.js'; declare const map: Map; diff --git a/tests/type-definitions/global/proposals/math-sum.test.ts b/tests/type-definitions/global/proposals/math-sum.test.ts index 9f5a46d00822..69b00c6486f1 100644 --- a/tests/type-definitions/global/proposals/math-sum.test.ts +++ b/tests/type-definitions/global/proposals/math-sum.test.ts @@ -1,6 +1,6 @@ import 'core-js/es'; import sumPrecise from 'core-js/es/math/sum-precise'; -import { assertNumber } from '../../helpers.js'; +import { assertNumber } from '../../helpers/helpers.js'; declare const it: Iterable; diff --git a/tests/type-definitions/global/proposals/number-clamp.test.ts b/tests/type-definitions/global/proposals/number-clamp.test.ts index ec1f11381cc3..85db8bdb5837 100644 --- a/tests/type-definitions/global/proposals/number-clamp.test.ts +++ b/tests/type-definitions/global/proposals/number-clamp.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; import clamp from 'core-js/full/number/clamp'; -import { assertNumber } from '../../helpers.js'; +import { assertNumber } from '../../helpers/helpers.js'; declare const num: number; diff --git a/tests/type-definitions/global/proposals/object-keys-length.test.ts b/tests/type-definitions/global/proposals/object-keys-length.test.ts index db957e3e99f4..21d587f56422 100644 --- a/tests/type-definitions/global/proposals/object-keys-length.test.ts +++ b/tests/type-definitions/global/proposals/object-keys-length.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; import keysLength from 'core-js/full/object/keys-length'; -import { assertNumber } from '../../helpers.js'; +import { assertNumber } from '../../helpers/helpers.js'; const obj = { a: 1, b: 2 }; const arr = [1, 2, 3]; diff --git a/tests/type-definitions/global/proposals/object-values-entries.test.ts b/tests/type-definitions/global/proposals/object-values-entries.test.ts index 2d910f2c36cf..8cae22a00994 100644 --- a/tests/type-definitions/global/proposals/object-values-entries.test.ts +++ b/tests/type-definitions/global/proposals/object-values-entries.test.ts @@ -1,7 +1,7 @@ import 'core-js/es'; import values from 'core-js/es/object/values'; import entries from 'core-js/es/object/entries'; -import { assertNumberArray, assertStringArray } from '../../helpers.js'; +import { assertNumberArray, assertStringArray } from '../../helpers/helpers.js'; const obj = { a: 1, b: 2 }; const arr = [1, 2, 3]; diff --git a/tests/type-definitions/global/proposals/regexp-escaping.test.ts b/tests/type-definitions/global/proposals/regexp-escaping.test.ts index 27c9cc24de9f..57b37ab45dc1 100644 --- a/tests/type-definitions/global/proposals/regexp-escaping.test.ts +++ b/tests/type-definitions/global/proposals/regexp-escaping.test.ts @@ -1,6 +1,6 @@ import 'core-js/es'; import escape from 'core-js/es/regexp/escape'; -import { assertString } from '../../helpers.js'; +import { assertString } from '../../helpers/helpers.js'; assertString(escape('foo.*+?^${}()|[]\\')); assertString(RegExp.escape('foo.*+?^${}()|[]\\')); diff --git a/tests/type-definitions/global/proposals/string-cooked.test.ts b/tests/type-definitions/global/proposals/string-cooked.test.ts index e1798fe3a502..503a71ec84d1 100644 --- a/tests/type-definitions/global/proposals/string-cooked.test.ts +++ b/tests/type-definitions/global/proposals/string-cooked.test.ts @@ -1,7 +1,7 @@ import 'core-js/full'; import cooked from 'core-js/full/string/cooked'; import $String from 'core-js/full/string'; -import { assertString } from '../../helpers.js'; +import { assertString } from '../../helpers/helpers.js'; assertString(cooked([])); $String.cooked([]); diff --git a/tests/type-definitions/global/proposals/string-dedent.test.ts b/tests/type-definitions/global/proposals/string-dedent.test.ts index ded2c794bdad..fd3954089e36 100644 --- a/tests/type-definitions/global/proposals/string-dedent.test.ts +++ b/tests/type-definitions/global/proposals/string-dedent.test.ts @@ -1,6 +1,6 @@ import 'core-js/full'; import dedent from 'core-js/full/string/dedent'; -import { assertString } from '../../helpers.js'; +import { assertString } from '../../helpers/helpers.js'; assertString(dedent`foo\nbar`); diff --git a/tests/type-definitions/global/proposals/string-left-right-trim.test.ts b/tests/type-definitions/global/proposals/string-left-right-trim.test.ts index 83045256dc57..e5e890008ed3 100644 --- a/tests/type-definitions/global/proposals/string-left-right-trim.test.ts +++ b/tests/type-definitions/global/proposals/string-left-right-trim.test.ts @@ -3,7 +3,7 @@ import trimEnd from 'core-js/es/string/trim-end'; import trimStart from 'core-js/es/string/trim-start'; import trimLeft from 'core-js/es/string/trim-left'; import trimRight from 'core-js/es/string/trim-right'; -import { assertString } from '../../helpers.js'; +import { assertString } from '../../helpers/helpers.js'; const s = 'abc'; diff --git a/tests/type-definitions/global/proposals/string-padding.test.ts b/tests/type-definitions/global/proposals/string-padding.test.ts index 2ed8443fb3e7..5882b05cc416 100644 --- a/tests/type-definitions/global/proposals/string-padding.test.ts +++ b/tests/type-definitions/global/proposals/string-padding.test.ts @@ -1,7 +1,7 @@ import 'core-js/es'; import padStart from 'core-js/es/string/pad-start'; import padEnd from 'core-js/es/string/pad-end'; -import { assertString } from '../../helpers.js'; +import { assertString } from '../../helpers/helpers.js'; const s = 'foo'; diff --git a/tests/type-definitions/global/proposals/string-replace-all.test.ts b/tests/type-definitions/global/proposals/string-replace-all.test.ts index 1fc021535a7b..7b6d72de47ac 100644 --- a/tests/type-definitions/global/proposals/string-replace-all.test.ts +++ b/tests/type-definitions/global/proposals/string-replace-all.test.ts @@ -1,6 +1,6 @@ import 'core-js/es'; import replaceAll from 'core-js/es/string/replace-all'; -import { assertString } from '../../helpers.js'; +import { assertString } from '../../helpers/helpers.js'; const s = 'foo bar foo'; diff --git a/tests/type-definitions/global/proposals/symbol-predicates.test.ts b/tests/type-definitions/global/proposals/symbol-predicates.test.ts index 2f3d9f2a9515..af7cc673700c 100644 --- a/tests/type-definitions/global/proposals/symbol-predicates.test.ts +++ b/tests/type-definitions/global/proposals/symbol-predicates.test.ts @@ -2,7 +2,7 @@ import 'core-js/full'; import isRegisteredSymbol from 'core-js/full/symbol/is-registered-symbol'; import isWellKnownSymbol from 'core-js/full/symbol/is-well-known-symbol'; import $Symbol from 'core-js/full/symbol'; -import { assertBool } from '../../helpers.js'; +import { assertBool } from '../../helpers/helpers.js'; assertBool(isRegisteredSymbol($Symbol.for('foo'))); assertBool(isWellKnownSymbol($Symbol.iterator)); diff --git a/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts b/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts index cdb0348b8de3..d9ab3a1bd066 100644 --- a/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts +++ b/tests/type-definitions/global/proposals/well-formed-unicode-strings.test.ts @@ -1,7 +1,7 @@ import 'core-js/es'; import isWellFormed from 'core-js/es/string/is-well-formed'; import toWellFormed from 'core-js/es/string/to-well-formed'; -import { assertBool, assertString } from '../../helpers.js'; +import { assertBool, assertString } from '../../helpers/helpers.js'; const s = 'test'; diff --git a/tests/type-definitions/global/web/atob.test.ts b/tests/type-definitions/global/web/atob.test.ts index b8c41250223f..128467b7acbd 100644 --- a/tests/type-definitions/global/web/atob.test.ts +++ b/tests/type-definitions/global/web/atob.test.ts @@ -1,6 +1,6 @@ import 'core-js/stable'; import $atob from 'core-js/stable/atob'; -import { assertString } from '../../helpers.js'; +import { assertString } from '../../helpers/helpers.js'; assertString($atob('SGVsbG8gd29ybGQ=')); diff --git a/tests/type-definitions/global/web/btoa.test.ts b/tests/type-definitions/global/web/btoa.test.ts index 9ad82c560db2..d7b951c20610 100644 --- a/tests/type-definitions/global/web/btoa.test.ts +++ b/tests/type-definitions/global/web/btoa.test.ts @@ -1,6 +1,6 @@ import 'core-js/stable'; import $btoa from 'core-js/stable/btoa'; -import { assertString } from '../../helpers.js'; +import { assertString } from '../../helpers/helpers.js'; assertString($btoa('SGVsbG8gd29ybGQ=')); diff --git a/tests/type-definitions/global/web/structured-clone.test.ts b/tests/type-definitions/global/web/structured-clone.test.ts index 7a5264ab69a1..273d6e81131a 100644 --- a/tests/type-definitions/global/web/structured-clone.test.ts +++ b/tests/type-definitions/global/web/structured-clone.test.ts @@ -1,6 +1,6 @@ import 'core-js/stable'; import $structuredClone from 'core-js/stable/structured-clone'; -import { assertNumber, assertString } from '../../helpers.js'; +import { assertNumber, assertString } from '../../helpers/helpers.js'; assertNumber($structuredClone(5)); diff --git a/tests/type-definitions/helpers.pure.ts b/tests/type-definitions/helpers/helpers.pure.ts similarity index 98% rename from tests/type-definitions/helpers.pure.ts rename to tests/type-definitions/helpers/helpers.pure.ts index 4614c67d90c8..a1f04db92fef 100644 --- a/tests/type-definitions/helpers.pure.ts +++ b/tests/type-definitions/helpers/helpers.pure.ts @@ -42,7 +42,7 @@ export interface CoreJSIteratorLike e take(...args: any[]): CoreJSIteratorLike; drop(...args: any[]): CoreJSIteratorLike; flatMap(...args: any[]): CoreJSIteratorLike; - reduce(...args: any[]): CoreJSIteratorLike; + reduce(...args: any[]): U; toArray(): T[]; forEach(...args: any[]): void; some(...args: any[]): boolean; diff --git a/tests/type-definitions/helpers.ts b/tests/type-definitions/helpers/helpers.ts similarity index 100% rename from tests/type-definitions/helpers.ts rename to tests/type-definitions/helpers/helpers.ts diff --git a/tests/type-definitions/pure/proposals/array-from-async.test.ts b/tests/type-definitions/pure/proposals/array-from-async.test.ts index 8b06f51f51ee..973c75ea42cd 100644 --- a/tests/type-definitions/pure/proposals/array-from-async.test.ts +++ b/tests/type-definitions/pure/proposals/array-from-async.test.ts @@ -1,6 +1,6 @@ import arrayFromAsync from '@core-js/pure/full/array/from-async'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; +import { assertCoreJSPromiseLike } from '../../helpers/helpers.pure.js'; const p1 = arrayFromAsync([1, 2, 3]); assertCoreJSPromiseLike(p1); diff --git a/tests/type-definitions/pure/proposals/array-grouping.test.ts b/tests/type-definitions/pure/proposals/array-grouping.test.ts index d7b02b4e8c20..7c2cf93d9c09 100644 --- a/tests/type-definitions/pure/proposals/array-grouping.test.ts +++ b/tests/type-definitions/pure/proposals/array-grouping.test.ts @@ -1,6 +1,6 @@ import objectGroupBy from '@core-js/pure/full/object/group-by'; import mapGroupBy from '@core-js/pure/full/map/group-by'; -import { assertCoreJSMapLike } from '../../helpers.pure.js'; +import { assertCoreJSMapLike } from '../../helpers/helpers.pure.js'; const arr = [1, 2, 3, 4, 5]; const objGroup: Partial> = objectGroupBy(arr, x => x % 2 === 0 ? 'even' : 'odd'); diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index daf6c52d8095..ef4826f84b43 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -11,7 +11,7 @@ import some from '@core-js/pure/full/async-iterator/some'; import take from '@core-js/pure/full/async-iterator/take'; import toArray from '@core-js/pure/full/async-iterator/to-array'; import toAsync from '@core-js/pure/full/iterator/to-async'; -import { assertCoreJSAsyncIteratorLike, assertCoreJSPromiseLike } from '../../helpers.pure.js'; +import { assertCoreJSAsyncIteratorLike, assertCoreJSPromiseLike } from '../../helpers/helpers.pure.js'; const aitn = from([1]); assertCoreJSAsyncIteratorLike(aitn); diff --git a/tests/type-definitions/pure/proposals/await-dictionary.test.ts b/tests/type-definitions/pure/proposals/await-dictionary.test.ts index fd07ebc9f72c..2651a38ce988 100644 --- a/tests/type-definitions/pure/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/pure/proposals/await-dictionary.test.ts @@ -1,7 +1,7 @@ import promiseAllKeyed from '@core-js/pure/full/promise/all-keyed'; import promiseAllSettledKeyed from '@core-js/pure/full/promise/all-settled-keyed'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; +import { assertCoreJSPromiseLike } from '../../helpers/helpers.pure.js'; const res = promiseAllKeyed({ a: promiseResolve(1), diff --git a/tests/type-definitions/pure/proposals/collection-of-from.test.ts b/tests/type-definitions/pure/proposals/collection-of-from.test.ts index b88885b76f62..5cf302d5a7de 100644 --- a/tests/type-definitions/pure/proposals/collection-of-from.test.ts +++ b/tests/type-definitions/pure/proposals/collection-of-from.test.ts @@ -6,7 +6,7 @@ import weakMapFrom from '@core-js/pure/full/weak-map/from'; import weakMapOf from '@core-js/pure/full/weak-map/of'; import weakSetFrom from '@core-js/pure/full/weak-set/from'; import weakSetOf from '@core-js/pure/full/weak-set/of'; -import { assertCoreJSMapLike, assertCoreJSSetLike, assertCoreJSWeakMapLike, assertCoreJSWeakSetLike } from '../../helpers.pure.js'; +import { assertCoreJSMapLike, assertCoreJSSetLike, assertCoreJSWeakMapLike, assertCoreJSWeakSetLike } from '../../helpers/helpers.pure.js'; const rm = mapFrom([[1, 'a'], [2, 'b']] as [number, string][]); assertCoreJSMapLike(rm); diff --git a/tests/type-definitions/pure/proposals/error-cause.test.ts b/tests/type-definitions/pure/proposals/error-cause.test.ts index e169752f9d57..7636631b02b9 100644 --- a/tests/type-definitions/pure/proposals/error-cause.test.ts +++ b/tests/type-definitions/pure/proposals/error-cause.test.ts @@ -1,6 +1,6 @@ import $AggregateError from '@core-js/pure/full/aggregate-error'; // import $Error from '@core-js/pure/full/error'; TODO separated entry points -import { assertHasCause } from '../../helpers.pure.js'; +import { assertHasCause } from '../../helpers/helpers.pure.js'; const prevError = new Error('Prev error'); const someError = new Error('Some error'); diff --git a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts index 122c5f93f900..198e5d38aac2 100644 --- a/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/pure/proposals/explicit-resource-management.test.ts @@ -7,7 +7,7 @@ import asyncIteratorFrom from '@core-js/pure/full/async-iterator/from'; import $SuppressedError from '@core-js/pure/full/suppressed-error/constructor'; import $DisposableStack from '@core-js/pure/full/disposable-stack/constructor'; import $AsyncDisposableStack from '@core-js/pure/full/async-disposable-stack/constructor'; -import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; +import { assertCoreJSPromiseLike } from '../../helpers/helpers.pure.js'; const d: symbol = symbolDispose; const ad: symbol = symbolAsyncDispose; diff --git a/tests/type-definitions/pure/proposals/iterator-chunking.test.ts b/tests/type-definitions/pure/proposals/iterator-chunking.test.ts index e0130aa7e72d..48c2d23add62 100644 --- a/tests/type-definitions/pure/proposals/iterator-chunking.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-chunking.test.ts @@ -1,6 +1,6 @@ import iteratorChunks from '@core-js/pure/full/iterator/chunks'; import iteratorWindows from '@core-js/pure/full/iterator/windows'; -import { assertCoreJSIteratorLike } from '../../helpers.pure.js'; +import { assertCoreJSIteratorLike } from '../../helpers/helpers.pure.js'; declare function getNumberIterator(): Iterator; diff --git a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts index 6c312949818a..e7f3db54399a 100644 --- a/tests/type-definitions/pure/proposals/iterator-helpers.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-helpers.test.ts @@ -9,7 +9,7 @@ import iteratorForEach from '@core-js/pure/full/iterator/for-each'; import iteratorSome from '@core-js/pure/full/iterator/some'; import iteratorEvery from '@core-js/pure/full/iterator/every'; import iteratorFind from '@core-js/pure/full/iterator/find'; -import { assertCoreJSIteratorLike } from '../../helpers.pure.js'; +import { assertCoreJSIteratorLike } from '../../helpers/helpers.pure.js'; declare const it: Iterator; declare const itStr: Iterator; diff --git a/tests/type-definitions/pure/proposals/iterator-joint.test.ts b/tests/type-definitions/pure/proposals/iterator-joint.test.ts index 1a0fc1fcd11c..24a6f5941068 100644 --- a/tests/type-definitions/pure/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-joint.test.ts @@ -1,6 +1,6 @@ import iteratorZip from '@core-js/pure/full/iterator/zip'; import iteratorZipKeyed from '@core-js/pure/full/iterator/zip-keyed'; -import { assertCoreJSIteratorLike } from '../../helpers.pure.js'; +import { assertCoreJSIteratorLike } from '../../helpers/helpers.pure.js'; const zipped1 = iteratorZip([[1, 2, 3], [4, 5, 6]]); assertCoreJSIteratorLike(zipped1); diff --git a/tests/type-definitions/pure/proposals/iterator-range.test.ts b/tests/type-definitions/pure/proposals/iterator-range.test.ts index 97556edfeec2..fbfd68366442 100644 --- a/tests/type-definitions/pure/proposals/iterator-range.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-range.test.ts @@ -1,5 +1,5 @@ import iteratorRange from '@core-js/pure/full/iterator/range'; -import { assertCoreJSIteratorLike } from '../../helpers.pure.js'; +import { assertCoreJSIteratorLike } from '../../helpers/helpers.pure.js'; const rir1 = iteratorRange(1, 10); assertCoreJSIteratorLike(rir1); diff --git a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts index 3a3d8b4611ae..8929e2dbe7a4 100644 --- a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts @@ -1,5 +1,5 @@ import iteratorConcat from '@core-js/pure/full/iterator/concat'; -import { assertCoreJSIteratorLike } from '../../helpers.pure.js'; +import { assertCoreJSIteratorLike } from '../../helpers/helpers.pure.js'; declare const its1: Iterable; declare const arrs: string[]; diff --git a/tests/type-definitions/pure/proposals/object-keys-length.test.ts b/tests/type-definitions/pure/proposals/object-keys-length.test.ts index c459f786fdb1..9879289e820c 100644 --- a/tests/type-definitions/pure/proposals/object-keys-length.test.ts +++ b/tests/type-definitions/pure/proposals/object-keys-length.test.ts @@ -1,5 +1,5 @@ import keysLength from '@core-js/pure/full/object/keys-length'; -import { assertNumber } from '../../helpers.js'; +import { assertNumber } from '../../helpers/helpers.js'; const obj = { a: 1, b: 2 }; const arr = [1, 2, 3]; diff --git a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts index ee28903914f5..3a37e3e9d530 100644 --- a/tests/type-definitions/pure/proposals/promise-all-settled.test.ts +++ b/tests/type-definitions/pure/proposals/promise-all-settled.test.ts @@ -1,6 +1,6 @@ import promiseAllSettled from '@core-js/pure/full/promise/all-settled'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; +import { assertCoreJSPromiseLike } from '../../helpers/helpers.pure.js'; interface CoreJSPromiseResult { status: string; diff --git a/tests/type-definitions/pure/proposals/promise-any.test.ts b/tests/type-definitions/pure/proposals/promise-any.test.ts index 01f30bbae85f..f3cc515496be 100644 --- a/tests/type-definitions/pure/proposals/promise-any.test.ts +++ b/tests/type-definitions/pure/proposals/promise-any.test.ts @@ -1,6 +1,6 @@ import promiseAny from '@core-js/pure/full/promise/any'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; +import { assertCoreJSPromiseLike } from '../../helpers/helpers.pure.js'; const arr = [promiseResolve(1), promiseResolve('foo'), 3] as const; const justNumbers = [1, 2, 3]; diff --git a/tests/type-definitions/pure/proposals/promise-finally.test.ts b/tests/type-definitions/pure/proposals/promise-finally.test.ts index cfd272801b52..5e91a97d3a4b 100644 --- a/tests/type-definitions/pure/proposals/promise-finally.test.ts +++ b/tests/type-definitions/pure/proposals/promise-finally.test.ts @@ -1,7 +1,7 @@ import promiseFinally from '@core-js/pure/full/promise/finally'; import promiseResolve from '@core-js/pure/full/promise/resolve'; import promiseReject from '@core-js/pure/full/promise/reject'; -import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; +import { assertCoreJSPromiseLike } from '../../helpers/helpers.pure.js'; const pr1 = promiseResolve(42); assertCoreJSPromiseLike(pr1); diff --git a/tests/type-definitions/pure/proposals/promise-try.test.ts b/tests/type-definitions/pure/proposals/promise-try.test.ts index cad3f277e7f1..e24ecb453256 100644 --- a/tests/type-definitions/pure/proposals/promise-try.test.ts +++ b/tests/type-definitions/pure/proposals/promise-try.test.ts @@ -1,6 +1,6 @@ import promiseTry from '@core-js/pure/full/promise/try'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; +import { assertCoreJSPromiseLike } from '../../helpers/helpers.pure.js'; const pt1 = promiseTry(() => 42); assertCoreJSPromiseLike(pt1); diff --git a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts index b998cc0c755f..688e15d2a15a 100644 --- a/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts +++ b/tests/type-definitions/pure/proposals/promise-with-resolvers.test.ts @@ -1,6 +1,6 @@ import promiseWithResolvers from '@core-js/pure/full/promise/with-resolvers'; import promiseResolve from '@core-js/pure/full/promise/resolve'; -import { assertCoreJSPromiseLike } from '../../helpers.pure.js'; +import { assertCoreJSPromiseLike } from '../../helpers/helpers.pure.js'; const pr = promiseWithResolvers(); const pr2 = promiseWithResolvers(); diff --git a/tests/type-definitions/pure/proposals/set-methods.test.ts b/tests/type-definitions/pure/proposals/set-methods.test.ts index 8a5bb0a20158..00732e2c60a0 100644 --- a/tests/type-definitions/pure/proposals/set-methods.test.ts +++ b/tests/type-definitions/pure/proposals/set-methods.test.ts @@ -6,7 +6,7 @@ import setSymmetricDifference from '@core-js/pure/full/set/symmetric-difference' import setIsSubsetOf from '@core-js/pure/full/set/is-subset-of'; import setIsSupersetOf from '@core-js/pure/full/set/is-superset-of'; import setIsDisjointFrom from '@core-js/pure/full/set/is-disjoint-from'; -import { assertCoreJSSetLike } from '../../helpers.pure.js'; +import { assertCoreJSSetLike } from '../../helpers/helpers.pure.js'; const setA = new $Set([1, 2, 3]); const setB = new $Set(['a', 'b', 'c']); From 174f39f26002034ccab08189fb0d11fd2f317aa6 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 16 Feb 2026 20:43:00 +0700 Subject: [PATCH 207/315] Extend {Map|WeakMap}Constructors from base constructors for pure version --- packages/core-js-types/src/base/pure/core-js-types/map.d.ts | 2 +- .../core-js-types/src/base/pure/core-js-types/weak-map.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/pure/core-js-types/map.d.ts b/packages/core-js-types/src/base/pure/core-js-types/map.d.ts index d069a5cf031b..c4f513a1fbb0 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/map.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/map.d.ts @@ -1,7 +1,7 @@ declare namespace CoreJS { export interface CoreJSMap extends Map {} - export interface CoreJSMapConstructor { + export interface CoreJSMapConstructor extends MapConstructor { readonly prototype: CoreJSMap; new (): CoreJSMap; diff --git a/packages/core-js-types/src/base/pure/core-js-types/weak-map.d.ts b/packages/core-js-types/src/base/pure/core-js-types/weak-map.d.ts index ba7034267bf1..70e1dd133de0 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/weak-map.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/weak-map.d.ts @@ -1,7 +1,7 @@ declare namespace CoreJS { export interface CoreJSWeakMap extends WeakMap {} - export interface CoreJSWeakMapConstructor { + export interface CoreJSWeakMapConstructor extends WeakMapConstructor { readonly prototype: CoreJSWeakMap; new(entries?: readonly (readonly [K, V])[] | null): CoreJSWeakMap; From 77e8ddd3e7a8dc91b0bcf8c7944f0e4bdb28e499 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 16 Feb 2026 21:28:24 +0700 Subject: [PATCH 208/315] Fix async-iterator-helpers tests --- .../global/proposals/async-iterator-helper.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/type-definitions/global/proposals/async-iterator-helper.test.ts b/tests/type-definitions/global/proposals/async-iterator-helper.test.ts index b0a182a254f2..c773aee13cdb 100644 --- a/tests/type-definitions/global/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/global/proposals/async-iterator-helper.test.ts @@ -69,7 +69,7 @@ const r3: AsyncIterator = ain.filter((v: number, i: number) => v > 0); const r4: Promise = ain.find((v: number, i: number) => v > 0); const r5: AsyncIterator = ain.flatMap((v: number, i: number) => [v, v * 2]); const r6: Promise = ain.forEach((v: number, i: number) => { }); -const r7: AsyncIterator = ain.map((v: number, i: number) => v * 2); +const r7: AsyncIterator = ain.map((v: number, i: number) => v.toString()); const r8: Promise = ain.reduce((acc: number, v: number, i: number) => acc + v, 0); const r9: Promise = ain.some((v: number, i: number) => v > 0); const r10: AsyncIterator = ain.take(10); From 5c2c6b5ffeb197a0d8176ab8c75b4ad7c6862a09 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 16 Feb 2026 21:32:56 +0700 Subject: [PATCH 209/315] Fix Iterable type in comments --- packages/core-js-types/src/base/pure/proposals/iterator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index b6bed732c488..0f8e07e4660f 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -113,7 +113,7 @@ declare namespace CoreJS { * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. * @param callback - A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. */ - flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; // ts < 5.6 Iterable + flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; // ts < 5.6 Iterable /** * Calls the specified callback function for all the elements in this iterator. 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. From 131ec774d1e73ecff9bd966963a75ae7321652d6 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 16 Feb 2026 21:45:03 +0700 Subject: [PATCH 210/315] Add TReturn & TNext to all IteratorObject usages --- .../src/base/pure/proposals/iterator.d.ts | 14 +++++++------- .../src/ts5-2/pure/proposals/iterator.d.ts | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 0f8e07e4660f..0f6db04e8b20 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -70,7 +70,7 @@ declare namespace CoreJS { * @param chunkSize - The maximum number of elements per chunk. Must be a positive integer. * @returns An iterator yielding arrays of at most `chunkSize` elements from the source iterator. */ - chunks(chunkSize: number): CoreJSIteratorObject; + chunks(chunkSize: number): CoreJSIteratorObject; /** * Yields overlapping arrays (windows) of the given size from the iterator. @@ -78,7 +78,7 @@ declare namespace CoreJS { * @param undersized - 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. * @returns An iterator yielding arrays of the specified window size. */ - windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJSIteratorObject; + windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJSIteratorObject; /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator. @@ -179,7 +179,7 @@ declare namespace CoreJS { * Returns its input if the input already inherits from the built-in Iterator class. * @param value - An iterator or iterable object to convert a native iterator. */ - from(value: Iterator | Iterable): CoreJSIteratorObject; + from(value: Iterator | Iterable): CoreJSIteratorObject; /** * Takes an iterable of iterables and produces an iterable of arrays where position corresponds @@ -190,7 +190,7 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. */ - zip(iterables: Iterable>, options?: ZipOptions): CoreJSIteratorObject; + zip(iterables: Iterable>, options?: ZipOptions): CoreJSIteratorObject; /** * takes an object whose values are iterables and produces an iterable of objects where keys. @@ -201,7 +201,7 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. */ - zipKeyed }>(record: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }>; + zipKeyed }>(record: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; /** * Returns an iterator that generates a sequence of numbers or bigints within a range. @@ -212,14 +212,14 @@ declare namespace CoreJS { * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of numbers or bigints. */ - range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): CoreJSIteratorObject + range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): CoreJSIteratorObject /** * Creates an iterator that sequentially yields values from the provided iterables. * @param iterators - The iterables to concatenate. * @returns An iterator yielding values from each input iterable in sequence. */ - concat(...iterators: Iterable[]): CoreJSIteratorObject; + concat(...iterators: Iterable[]): CoreJSIteratorObject; } var CoreJSIterator: CoreJSIteratorConstructor; diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index 9b0c60a2cb11..9f8fe580d04b 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -71,7 +71,7 @@ declare namespace CoreJS { * @param chunkSize - The maximum number of elements per chunk. Must be a positive integer. * @returns An iterator yielding arrays of at most `chunkSize` elements from the source iterator. */ - chunks(chunkSize: number): CoreJSIteratorObject; + chunks(chunkSize: number): CoreJSIteratorObject; /** * Yields overlapping arrays (windows) of the given size from the iterator. @@ -79,7 +79,7 @@ declare namespace CoreJS { * @param undersized - 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. * @returns An iterator yielding arrays of the specified window size. */ - windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJSIteratorObject; + windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): CoreJSIteratorObject; /** * Creates an iterator whose values are the result of applying the callback to the values from this iterator. @@ -180,7 +180,7 @@ declare namespace CoreJS { * Returns its input if the input already inherits from the built-in Iterator class. * @param value - An iterator or iterable object to convert a native iterator. */ - from(value: Iterator | Iterable): CoreJSIteratorObject; + from(value: Iterator | Iterable): CoreJSIteratorObject; /** * Takes an iterable of iterables and produces an iterable of arrays where position corresponds @@ -191,7 +191,7 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. */ - zip(iterables: Iterable>, options?: ZipOptions): CoreJSIteratorObject; + zip(iterables: Iterable>, options?: ZipOptions): CoreJSIteratorObject; /** * takes an object whose values are iterables and produces an iterable of objects where keys. @@ -202,7 +202,7 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. */ - zipKeyed }>(record: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }>; + zipKeyed }>(record: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; /** * Returns an iterator that generates a sequence of numbers or bigints within a range. @@ -213,14 +213,14 @@ declare namespace CoreJS { * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of numbers or bigints. */ - range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): CoreJSIteratorObject + range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): CoreJSIteratorObject /** * Creates an iterator that sequentially yields values from the provided iterables. * @param iterators - The iterables to concatenate. * @returns An iterator yielding values from each input iterable in sequence. */ - concat(...iterators: Iterable[]): CoreJSIteratorObject; + concat(...iterators: Iterable[]): CoreJSIteratorObject; } var CoreJSIterator: CoreJSIteratorConstructor; From 5a3e6e71e3a2fd63b4e05c734c64291cc6a045c4 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 16 Feb 2026 21:48:58 +0700 Subject: [PATCH 211/315] Rename custom constructor for DOMException --- packages/core-js-types/src/base/pure/web/dom-exception.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/pure/web/dom-exception.d.ts b/packages/core-js-types/src/base/pure/web/dom-exception.d.ts index 83c885b7f201..205eb12c9318 100644 --- a/packages/core-js-types/src/base/pure/web/dom-exception.d.ts +++ b/packages/core-js-types/src/base/pure/web/dom-exception.d.ts @@ -37,7 +37,7 @@ declare namespace CoreJS { readonly DATA_CLONE_ERR: 25; } - interface CoreJSDomExceptionConstructor { + interface CoreJSDOMExceptionConstructor { prototype: CoreJSDOMException; new(message?: string, name?: string): CoreJSDOMException; new(message?: string, options?: { name?: string; cause?: unknown }): CoreJSDOMException; @@ -68,5 +68,5 @@ declare namespace CoreJS { readonly DATA_CLONE_ERR: 25; } - var CoreJSDOMException: CoreJSDomExceptionConstructor; + var CoreJSDOMException: CoreJSDOMExceptionConstructor; } From 23897f19af6c52471a58d0d9a6abd0101001fb9d Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 16 Feb 2026 21:51:55 +0700 Subject: [PATCH 212/315] Fix URL.canParse & URL.parse argument type --- packages/core-js-types/src/base/pure/core-js-types/url.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/pure/core-js-types/url.d.ts b/packages/core-js-types/src/base/pure/core-js-types/url.d.ts index d813f590a0c0..41f6e1ac68ae 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/url.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/url.d.ts @@ -48,13 +48,13 @@ declare namespace CoreJS { new(url: string | CoreJSURL, base?: string): CoreJSURL; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */ - canParse(url: string, base?: string): boolean; + canParse(url: string | CoreJSURL, base?: string): boolean; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) */ createObjectURL(obj: any): string; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static) */ - parse(url: string, base?: string): CoreJSURL | null; + parse(url: string | CoreJSURL, base?: string): CoreJSURL | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) */ revokeObjectURL(url: string): void; From 354c8209bfee6a7a04daec6452fbcbf170f2e2d9 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 16 Feb 2026 22:13:59 +0700 Subject: [PATCH 213/315] Remove redundant custom type for String.replaceAll and fix type --- .../src/base/proposals/string-replace-all-custom.d.ts | 2 +- .../src/base/proposals/string-replace-all.d.ts | 10 ++-------- .../src/base/pure/proposals/string-replace-all.d.ts | 10 ++-------- .../build-entries-and-types/entries-definitions.mjs | 4 +--- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts b/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts index 55306cf40840..ca137894a5f5 100644 --- a/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts @@ -7,5 +7,5 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt declare namespace CoreJS { - export type StringReplaceAll = ((searchValue: string | RegExp, replaceValue: string) => string) | ((searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string) => string); + export type StringReplaceAll = ((searchValue: string | RegExp, replaceValue: string) => string) | ((searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string) => string); } diff --git a/packages/core-js-types/src/base/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/proposals/string-replace-all.d.ts index 0b881c20a654..231b67269c4c 100644 --- a/packages/core-js-types/src/base/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/base/proposals/string-replace-all.d.ts @@ -8,14 +8,8 @@ interface String { // @type-options: no-redefine /** * Replace all instances of a substring in a string, using a regular expression or search string. * @param searchValue - A string to search for. - * @param replaceValue - A string containing the text to replace for every successful match of searchValue in this string. - */ - replaceAll(searchValue: string | RegExp, replaceValue: string): string; - - /** - * Replace all instances of a substring in a string, using a regular expression or search string. - * @param searchValue - A string to search for. + * @param replacer - A string containing the text to replace for every successful match of searchValue in this string. * @param replacer - A function that returns the replacement text. */ - replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; + replaceAll(searchValue: string | RegExp, replacer: string | ((substring: string, ...args: any[]) => string)): string; } diff --git a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts index 09006ce603c7..9feb789a29ac 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts @@ -15,15 +15,9 @@ declare namespace CoreJS { /** * Replace all instances of a substring in a string, using a regular expression or search string. * @param searchValue - A string to search for. - * @param replaceValue - A string containing the text to replace for every successful match of searchValue in this string. - */ - replaceAll(searchValue: string | RegExp, replaceValue: string): string; - - /** - * Replace all instances of a substring in a string, using a regular expression or search string. - * @param searchValue - A string to search for. + * @param replacer - A string containing the text to replace for every successful match of searchValue in this string. * @param replacer - A function that returns the replacement text. */ - replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; + replaceAll(searchValue: string | RegExp, replacer: string | ((substring: string, ...args: any[]) => string)): string; } } diff --git a/scripts/build-entries-and-types/entries-definitions.mjs b/scripts/build-entries-and-types/entries-definitions.mjs index f74633ff3193..ea7d821729a1 100644 --- a/scripts/build-entries-and-types/entries-definitions.mjs +++ b/scripts/build-entries-and-types/entries-definitions.mjs @@ -2553,11 +2553,9 @@ export const features = { }, 'string/replace-all': { modules: ['es.string.replace-all'], - template: $uncurriedWithCustomType, + template: $uncurried, namespace: 'String', name: 'replaceAll', - customType: 'proposals/string-replace-all-custom', - genericsCount: 2, }, 'string/prototype/replace-all': { modules: ['es.string.replace-all'], From f4329b4e3dbf6a9cb6599f480d78a6e23c5c3f80 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 16 Feb 2026 22:45:34 +0700 Subject: [PATCH 214/315] Add @type-options documentation comment --- scripts/build-entries-and-types/build-types-pure.mjs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/build-entries-and-types/build-types-pure.mjs b/scripts/build-entries-and-types/build-types-pure.mjs index 32882ad2671a..400c78b0cfdc 100644 --- a/scripts/build-entries-and-types/build-types-pure.mjs +++ b/scripts/build-entries-and-types/build-types-pure.mjs @@ -2,6 +2,18 @@ const { outputFile, pathExists, readdir, readFile } = fs; const NAMESPACE = 'CoreJS'; +/** + * @param line - A line of code from the type declaration file, potentially containing a @type-options comment + * @return {{ + * noExtends, // Don’t make interfaces extend the original ones + * noPrefix, // Don’t prefix the interface name with the namespace + * noConstructor, // Don’t emit a backing var (constructor) for the interface + * exportBaseConstructor, // When emitting a constructor for an interface, export the original interface as the type of the constructor + * noExport, // Don’t export the interface at all + * noRedefine, // Don’t emit a backing var (constructor) for the interface + * prefixReturnType // Prefix return types with the namespace + * }} + */ function parseOptions(line) { const hasOptions = line.includes('@type-options'); const optionsStr = hasOptions ? line.match(/@type-options:\s+(?[A-Za-z][\s\w,-]+)$/)?.groups?.options : ''; From e38fc111ab87a691d3d08d8136fd5cad92ccd889 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 17 Feb 2026 14:34:44 +0700 Subject: [PATCH 215/315] AsyncIterator.reduce types improvements --- .../base/proposals/async-iterator-helpers.d.ts | 9 ++++++++- .../pure/proposals/async-iterator-helpers.d.ts | 17 +++++++++++++++++ .../ts5-2/proposals/async-iterator-helpers.d.ts | 17 +++++++++++++++++ .../pure/proposals/async-iterator-helpers.d.ts | 17 +++++++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index 4ea2570c701c..5d11027dd2de 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -65,13 +65,20 @@ interface AsyncIterator { */ map(mapper: (value: T, index: number) => U): AsyncIteratorObject; + /** + * Reduces the elements of the iterator to a single value using the `reducer` function. + * @param reducer - A function that combines two elements of the iterator + * @param initialValue - The initial value to start the accumulation. Required when the accumulator type differs from the element type. + * @returns A `Promise` that resolves to the reduced value + */ + reduce(reducer: (accumulator: U, value: T, index: number) => U, initialValue: U): Promise; + /** * Reduces the elements of the iterator to a single value using the `reducer` function. * @param reducer - A function that combines two elements of the iterator * @param initialValue - An optional initial value to start the reduction * @returns A `Promise` that resolves to the reduced value */ - reduce(reducer: (accumulator: U, value: T, index: number) => U, initialValue?: U): Promise; reduce(reducer: (accumulator: T, value: T, index: number) => T, initialValue?: T): Promise; /** diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index 98220158c292..ac7331c2951d 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -73,6 +73,23 @@ declare namespace CoreJS { /** * Reduces the elements of the iterator to a single value using the `reducer` function. * @param reducer - A function that combines two elements of the iterator + * @param initialValue - The initial value to start the accumulation. Required when the accumulator type differs from the element type. + * @returns A `Promise` that resolves to the reduced value + */ + + reduce(reducer: (accumulator: U, value: T, index: number) => U, initialValue: U): CoreJSPromise; + /** + * Reduces the elements of the iterator to a single value using the `reducer` function. + * @param reducer - A function that combines two elements of the iterator + * @param initialValue - An optional initial value to start the reduction + * @returns A `Promise` that resolves to the reduced value + */ + reduce(reducer: (accumulator: T, value: T, index: number) => T, initialValue?: T): CoreJSPromise; + + /** + * Reduces the elements of the iterator to a single value using the `reducer` function. + * For maximum flexibility with any types. + * @param reducer - A function that combines two elements of the iterator * @param initialValue - An optional initial value to start the reduction * @returns A `Promise` that resolves to the reduced value */ diff --git a/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts index 01a42fb583af..e718ff6f1ccd 100644 --- a/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts @@ -66,6 +66,23 @@ interface AsyncIterator { /** * Reduces the elements of the iterator to a single value using the `reducer` function. * @param reducer - A function that combines two elements of the iterator + * @param initialValue - The initial value to start the accumulation. Required when the accumulator type differs from the element type. + * @returns A `Promise` that resolves to the reduced value + */ + reduce(reducer: (accumulator: U, value: T, index: number) => U, initialValue: U): Promise; + + /** + * Reduces the elements of the iterator to a single value using the `reducer` function. + * @param reducer - A function that combines two elements of the iterator + * @param initialValue - An optional initial value to start the reduction + * @returns A `Promise` that resolves to the reduced value + */ + reduce(reducer: (accumulator: T, value: T, index: number) => T, initialValue?: T): Promise; + + /** + * Reduces the elements of the iterator to a single value using the `reducer` function. + * For maximum flexibility with any types. + * @param reducer - A function that combines two elements of the iterator * @param initialValue - An optional initial value to start the reduction * @returns A `Promise` that resolves to the reduced value */ diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts index 05019f8e4259..b04a0ade094b 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts @@ -72,6 +72,23 @@ declare namespace CoreJS { /** * Reduces the elements of the iterator to a single value using the `reducer` function. * @param reducer - A function that combines two elements of the iterator + * @param initialValue - The initial value to start the accumulation. Required when the accumulator type differs from the element type. + * @returns A `Promise` that resolves to the reduced value + */ + reduce(reducer: (accumulator: U, value: T, index: number) => U, initialValue: U): CoreJSPromise; + + /** + * Reduces the elements of the iterator to a single value using the `reducer` function. + * @param reducer - A function that combines two elements of the iterator + * @param initialValue - An optional initial value to start the reduction + * @returns A `Promise` that resolves to the reduced value + */ + reduce(reducer: (accumulator: T, value: T, index: number) => T, initialValue?: T): CoreJSPromise; + + /** + * Reduces the elements of the iterator to a single value using the `reducer` function. + * For maximum flexibility with any types. + * @param reducer - A function that combines two elements of the iterator * @param initialValue - An optional initial value to start the reduction * @returns A `Promise` that resolves to the reduced value */ From e6d85ee5e42d025cc22e02e60c632b13e713a73f Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 15:52:35 +0700 Subject: [PATCH 216/315] Fix iterator symbol fallback --- packages/core-js-types/src/base/pure/proposals/symbol.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts index e07af7f54004..33abb201be13 100644 --- a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts @@ -38,6 +38,7 @@ declare namespace CoreJS { const CoreJSCustomMatcherSymbol: unique symbol; const CoreJSMetadataSymbol: unique symbol; const CoreJSMatchAllSymbol: unique symbol; + const CoreJSIteratorSymbol: unique symbol; type CoreJSDisposeSymbolType = typeof CoreJSDisposeSymbol; type CoreJSAsyncDisposeSymbolType = typeof CoreJSAsyncDisposeSymbol; @@ -45,7 +46,7 @@ declare namespace CoreJS { type CoreJSCustomMatcherSymbolType = typeof CoreJSCustomMatcherSymbol; type CoreJSMetadataSymbolType = typeof CoreJSMetadataSymbol; type CoreJSMatchAllSymbolType = typeof CoreJSMatchAllSymbol; - type CoreJSIteratorSymbolType = typeof CoreJSMatchAllSymbol; + type CoreJSIteratorSymbolType = typeof CoreJSIteratorSymbol; type GetNativeWithFallback = K extends keyof T ? T[K] : Fallback; From f7fc04c0c33a7b917319342ee73eff4bb518f071 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 15:58:10 +0700 Subject: [PATCH 217/315] Add await to writeJson --- scripts/build-entries-and-types/build-types.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-entries-and-types/build-types.mjs b/scripts/build-entries-and-types/build-types.mjs index 7606eae59aa1..95ed8aabbb09 100644 --- a/scripts/build-entries-and-types/build-types.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -281,7 +281,7 @@ async function buildPackageJson(breakpoints, namespaces) { }); packageJson.exports = exports; - writeJson(path.join(PACKAGE_JSON_DIR, 'package.json'), packageJson, { spaces: 2 }); + await writeJson(path.join(PACKAGE_JSON_DIR, 'package.json'), packageJson, { spaces: 2 }); } async function clearPackage() { From 00423c366f89f23e399c9a3d87f22143c200aabe Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 15:58:44 +0700 Subject: [PATCH 218/315] Fix `AsyncIterator.from` return type --- .../src/base/proposals/async-iterator-helpers.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index 5d11027dd2de..23f6af55cfc8 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -8,7 +8,7 @@ interface AsyncIteratorConstructor { * @param iterable - An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` * @returns A new `AsyncIterator` instance */ - from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; + from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIterator; } declare var AsyncIterator: AsyncIteratorConstructor; From 815188efd918afd24f8e9fbc5dbddcd3f58d08dd Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 18:12:50 +0700 Subject: [PATCH 219/315] Fix `Iterator.from` return type --- packages/core-js-types/src/base/proposals/iterator-helpers.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts index bce592dc12a6..00f6c184cc98 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts @@ -103,7 +103,7 @@ interface IteratorConstructor { // @type-options: no-extends * Returns its input if the input already inherits from the built-in Iterator class. * @param value - An iterator or iterable object to convert a native iterator. */ - from(value: Iterator | Iterable): IteratorObject; + from(value: Iterator | Iterable): Iterator; } declare var Iterator: IteratorConstructor; From 3f09bff729795e3e2abaffa0e814bb65975ace8c Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 18:17:07 +0700 Subject: [PATCH 220/315] Fix `Iterator#find` and `Iterator#filter` signatures --- .../src/base/proposals/async-iterator-helpers.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index 23f6af55cfc8..302c958fcefd 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -34,7 +34,7 @@ interface AsyncIterator { * @returns A new `AsyncIterator` */ filter(predicate: (value: T, index: number) => value is S): AsyncIteratorObject; - filter(predicate: (value: T, index: number) => boolean): AsyncIteratorObject; + filter(predicate: (value: T, index: number) => unknown): AsyncIteratorObject; /** * Finds the first element in the iterator that satisfies the `predicate` function. @@ -42,7 +42,7 @@ interface AsyncIterator { * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` */ find(predicate: (value: T, index: number) => value is S): Promise; - find(predicate: (value: T, index: number) => boolean): Promise; + find(predicate: (value: T, index: number) => unknown): Promise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. From 12042a7f853ba89ca7c25ce0246cb48fd323816c Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 18:20:38 +0700 Subject: [PATCH 221/315] Fix `Iterator#range` signatures --- packages/core-js-types/src/base/proposals/iterator-range.d.ts | 2 +- packages/core-js-types/src/base/pure/proposals/iterator.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/iterator-range.d.ts b/packages/core-js-types/src/base/proposals/iterator-range.d.ts index 9271a97a67ba..94f7feed25be 100644 --- a/packages/core-js-types/src/base/proposals/iterator-range.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-range.d.ts @@ -16,7 +16,7 @@ interface IteratorConstructor { // @type-options: no-extends * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of numbers or bigints. */ - range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): IteratorObject; // @type-options: prefix-return-type + range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): IteratorObject; // @type-options: prefix-return-type } declare var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 0f6db04e8b20..081878212a3f 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -212,7 +212,7 @@ declare namespace CoreJS { * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of numbers or bigints. */ - range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): CoreJSIteratorObject + range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): CoreJSIteratorObject /** * Creates an iterator that sequentially yields values from the provided iterables. From 69ab95366c844ab72c29b9ddaaad1a5cca8ed461 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 18:51:16 +0700 Subject: [PATCH 222/315] Rollback `Iterator.from` return type --- .../src/base/proposals/async-iterator-helpers.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index 302c958fcefd..acba2fd636eb 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -8,7 +8,7 @@ interface AsyncIteratorConstructor { * @param iterable - An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` * @returns A new `AsyncIterator` instance */ - from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIterator; + from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; } declare var AsyncIterator: AsyncIteratorConstructor; From 892bfad7db7b84fda81630d70d0baaf7afe77533 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 18:51:53 +0700 Subject: [PATCH 223/315] Fix `Iterator#flatMap` type signature for pure version --- .../src/base/pure/proposals/async-iterator-helpers.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index ac7331c2951d..78daa562e449 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -54,7 +54,7 @@ declare namespace CoreJS { * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - flatMap(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorObject; + flatMap(mapper: (value: T, index: number) => Iterator | Iterable | CoreJSAsyncIterator | CoreJSAsyncIterable): CoreJSAsyncIteratorObject; /** * Executes a provided function once for each element in the iterator. From 1d6dce818f0b23abf9ae63efbd6e0cfb5e915c8c Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 18:58:38 +0700 Subject: [PATCH 224/315] Fix Iterator joint proposal type signature --- packages/core-js-types/src/base/proposals/iterator-joint.d.ts | 2 +- packages/core-js-types/src/base/pure/proposals/iterator.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts index 84f829796c77..8ab339c915e9 100644 --- a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts @@ -3,7 +3,7 @@ interface ZipOptions { mode?: 'shortest' | 'longest' | 'strict'; - padding?: object; + padding?: Iterable; } interface IteratorConstructor { // @type-options: no-extends diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 081878212a3f..2920aba753e1 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -30,7 +30,7 @@ declare namespace CoreJS { interface ZipOptions { mode?: 'shortest' | 'longest' | 'strict'; - padding?: object; + padding?: Iterable; } interface IteratorRangeOptions { From 42188524b3acdd973c9aab87bfaf75cfb84a2d07 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 19:02:54 +0700 Subject: [PATCH 225/315] Prefixed custom types for array buffer base64 --- .../base/proposals/array-buffer-base64.d.ts | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts index d86e71111870..8add85e6a149 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts @@ -4,21 +4,21 @@ // https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.typedarrays.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -type alphabet = 'base64' | 'base64url'; +type CoreJSAlphabet = 'base64' | 'base64url'; -type lastChunkHandling = 'loose' | 'strict' | 'stop-before-partial'; +type CoreJSLastChunkHandling = 'loose' | 'strict' | 'stop-before-partial'; -interface fromBase64Options { - alphabet?: alphabet; - lastChunkHandling?: lastChunkHandling; +interface CoreJSFromBase64Options { + alphabet?: CoreJSAlphabet; + lastChunkHandling?: CoreJSLastChunkHandling; } -interface toBase64Options { - alphabet?: alphabet; +interface CoreJSToBase64Options { + alphabet?: CoreJSAlphabet; omitPadding?: boolean; } -interface processMetadata { +interface CoreJSProcessMetadata { read: number; written: number; } @@ -32,7 +32,7 @@ interface Uint8ArrayConstructor { * @throws SyntaxError If the input string contains characters outside the specified alphabet, or if the last * chunk is inconsistent with the `lastChunkHandling` option. */ - fromBase64(string: string, options?: fromBase64Options): Uint8Array; + fromBase64(string: string, options?: CoreJSFromBase64Options): Uint8Array; /** * Creates a new `Uint8Array` from a base16-encoded string. @@ -50,21 +50,21 @@ interface Uint8Array { * @throws SyntaxError If the input string contains characters outside the specified alphabet, or if the last * chunk is inconsistent with the `lastChunkHandling` option. */ - setFromBase64(string: string, options?: fromBase64Options): processMetadata; + setFromBase64(string: string, options?: CoreJSFromBase64Options): CoreJSProcessMetadata; /** * Sets the `Uint8Array` from a base16-encoded string. * @param string - The base16-encoded string. * @returns An object containing the number of bytes read and written. */ - setFromHex(string: string): processMetadata; + setFromHex(string: string): CoreJSProcessMetadata; /** * Converts the `Uint8Array` to a base64-encoded string. * @param options - If provided, sets the alphabet and padding behavior used. * @returns A base64-encoded string. */ - toBase64(options?: toBase64Options): string; + toBase64(options?: CoreJSToBase64Options): string; /** * Converts the `Uint8Array` to a base16-encoded string. From f97037703a66f81539682889a0d574b7c977f0f8 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 21:19:34 +0700 Subject: [PATCH 226/315] Add comment to dom-exception types --- packages/core-js-types/src/base/web/dom-exception.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core-js-types/src/base/web/dom-exception.d.ts b/packages/core-js-types/src/base/web/dom-exception.d.ts index ce420a7e27fe..2b3374389fcb 100644 --- a/packages/core-js-types/src/base/web/dom-exception.d.ts +++ b/packages/core-js-types/src/base/web/dom-exception.d.ts @@ -37,6 +37,7 @@ declare global { : { prototype: DOMException; new(message?: string, name?: string): DOMException; + // core-js not realize the second argument options-bag, but it's necessary for compatibility with @type/node lib new(message?: string, options?: { name?: string; cause?: unknown }): DOMException; readonly INDEX_SIZE_ERR: 1; readonly DOMSTRING_SIZE_ERR: 2; From d1fd855bd18a2294814e559a21c7367c0134efd1 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 21:27:52 +0700 Subject: [PATCH 227/315] Clear imports for every breakpoint --- .../build-entries-and-types/build-types.mjs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/scripts/build-entries-and-types/build-types.mjs b/scripts/build-entries-and-types/build-types.mjs index 95ed8aabbb09..66d016eb3949 100644 --- a/scripts/build-entries-and-types/build-types.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -18,17 +18,21 @@ const SRC_BASE = 'base'; const TS_VERSION_BREAKPOINTS = [5.6]; const TYPE_PREFIX = 'CoreJS.CoreJS'; -const imports = { - es: new Set(), - stable: new Set(), - actual: new Set(), - full: new Set(), - pure: new Set(), - index: new Set(), - configurator: new Set(), -}; +let imports; let outputFiles = {}; +function setDefaultNamespacesForImports() { + imports = { + es: new Set(), + stable: new Set(), + actual: new Set(), + full: new Set(), + pure: new Set(), + index: new Set(), + configurator: new Set(), + }; +} + function addType(tsVersion, subset, template, options) { const exportGlobalType = options.globalType ?? true; if (!exportGlobalType && subset !== 'pure') { @@ -303,6 +307,7 @@ async function saveOutputFiles() { await clearPackage(); for (const version of TS_VERSION_BREAKPOINTS) { + setDefaultNamespacesForImports(); await buildTypesForTSVersion(version); } From 10f77c215aa09c0a063ca413f1d2bc95ebc9531a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 21:34:30 +0700 Subject: [PATCH 228/315] Add default redirect to package.json for typeVersions --- scripts/build-entries-and-types/build-types.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/build-entries-and-types/build-types.mjs b/scripts/build-entries-and-types/build-types.mjs index 66d016eb3949..a69fd7aa6e3c 100644 --- a/scripts/build-entries-and-types/build-types.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -257,10 +257,11 @@ async function buildTypesForTSVersion(tsVersion) { async function buildPackageJson(breakpoints, namespaces) { breakpoints = breakpoints.sort().reverse(); - const defaultBreakpoint = Math.max(...breakpoints); + const defaultBreakpoint = Math.max(...breakpoints).toString().replace('.', '-'); const packageJson = await readJson(PACKAGE_TEMPLATE); packageJson.typesVersions = {}; + packageJson.typesVersions['*'] = { '*': [`./ts${ defaultBreakpoint }/*`] }; breakpoints.forEach(breakpoint => { packageJson.typesVersions[`>=${ breakpoint }`] = { '*': [`./ts${ breakpoint.toString().replace('.', '-') }/*`], @@ -276,7 +277,7 @@ async function buildPackageJson(breakpoints, namespaces) { const breakpointString = `ts${ breakpoint.toString().replace('.', '-') }`; packageJson.exports[namespaceKey][`types${ isLast ? '' : `@>=${ breakpoint }` }`] = `./${ breakpointString }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; }); - packageJson.exports[namespaceKey].default = `./ts${ defaultBreakpoint.toString().replace('.', '-') }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; + packageJson.exports[namespaceKey].default = `./ts${ defaultBreakpoint }/${ namespace }${ options.isDir ? '/*' : '' }.d.ts`; }); const exportsKeys = Object.keys(packageJson.exports).sort(); const exports = {}; From e0d0c078e53bc5498fc032d6ef565fbfd3e7e74b Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 21:38:32 +0700 Subject: [PATCH 229/315] Use custom symbols in pure version --- .../src/base/pure/core-js-types/url-search-params.d.ts | 2 +- .../src/base/pure/proposals/string-match-all.d.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts b/packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts index e022619cf53f..8c12104f8fb3 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts @@ -54,7 +54,7 @@ declare namespace CoreJS { } interface CoreJSURLSearchParamsIterator extends CoreJSIteratorObject { - [Symbol.iterator](): CoreJSURLSearchParamsIterator; + [CoreJS.CoreJSSymbol.iterator](): CoreJSURLSearchParamsIterator; } export interface CoreJSURLSearchParamsConstructor { diff --git a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts index b6212107d623..3c3f1812b7d1 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts @@ -1,5 +1,6 @@ /// /// +/// // Motivation: We should use String without the matchAll method to avoid signature conflicts @@ -12,7 +13,7 @@ declare namespace CoreJS { interface CoreJSRegExpStringIterator extends CoreJSIteratorObject { - [Symbol.iterator](): CoreJSRegExpStringIterator; + [CoreJS.CoreJSSymbol.iterator](): CoreJSRegExpStringIterator; } export interface CoreJSString extends StringBase { From 71d92c81c67391cc05c590ec4a5bc9b33cebe4c3 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 21:47:34 +0700 Subject: [PATCH 230/315] Fix types & tests for iterable-dom-collections --- .../src/base/web/iterable-dom-collections.d.ts | 4 ++-- .../global/web/iterable-dom-collections.dom.test.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts index 0406da9c0731..0e9ce4c299e4 100644 --- a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts +++ b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts @@ -22,7 +22,7 @@ interface DOMTokenList { // @type-options: no-export * @param thisArg - Value to use as this when executing `callbackfn`. */ forEach( - callbackfn: (value: Element, index: number, collection: DOMTokenList) => void, + callbackfn: (value: string, index: number, collection: DOMTokenList) => void, thisArg?: any ): void; @@ -34,7 +34,7 @@ interface DOMTokenList { // @type-options: no-export /** * Returns an iterable of values in the DOMTokenList. */ - values(): IterableIterator; + values(): IterableIterator; /** * Returns an iterable of key, value pairs in the DOMTokenList. diff --git a/tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts b/tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts index f84aa1caa547..df9c2778db93 100644 --- a/tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts +++ b/tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts @@ -20,8 +20,8 @@ nodeList.entries('string'); declare const domTokenList: DOMTokenList; -domTokenList.forEach((value: Node, key: number, list: DOMTokenList): void => {}); -domTokenList.forEach((value: Node, key: number, list: DOMTokenList): void => {}, []); +domTokenList.forEach((value: string, key: number, list: DOMTokenList): void => {}); +domTokenList.forEach((value: string, key: number, list: DOMTokenList): void => {}, []); // @ts-expect-error domTokenList.forEach(); @@ -29,7 +29,7 @@ const fomKeys: IterableIterator = domTokenList.keys(); // @ts-expect-error domTokenList.keys('string'); -const domValues: IterableIterator = domTokenList.values(); +const domValues: IterableIterator = domTokenList.values(); // @ts-expect-error domTokenList.values('string'); From 1dc6495e3d56e5933f69f5643a0e94af30127cf6 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 21:58:09 +0700 Subject: [PATCH 231/315] Fix TSDocs for collection-of-from proposal --- .../base/proposals/collection-of-from.d.ts | 1 - .../pure/proposals/collection-of-from.d.ts | 37 +++++++++---------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts index 867a8e25f963..e49bc42aa1e2 100644 --- a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts @@ -68,7 +68,6 @@ declare var WeakMap: WeakMapConstructor; interface WeakSetConstructor { /** * Creates a new `WeakSet` instance from an iterable of objects, optionally transforming with mapFn. - * * @param source - Iterable of objects to add to WeakSet. * @param mapFn - Optional mapping function transforming each object. * @param thisArg - Value to use as `this` in `mapFn`. diff --git a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts index 5c6b4d9f5e5a..516a5cf67072 100644 --- a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts @@ -32,20 +32,19 @@ declare namespace CoreJS { export interface CoreJSSetConstructor extends SetConstructor { /** - * Creates a new `Set` instance from an iterable or array-like object of [key, value] pairs. - * Optionally, applies a mapping function to each pair. - * @param source - Iterable or array-like object of [key, value] pairs. - * @param mapFn - Function to call on every [key, value] pair before adding to the `Set`. - * @param thisArg - Value to use as this when executing mapFn. - * @returns A new `Set` instance. + * Creates a new `Set` instance from an iterable, optionally transforming elements with a mapping function. + * @param source - Iterable whose elements will be added to the new Set. + * @param mapFn - Optional mapping function. Transforms each element before adding to Set. + * @param thisArg - Value to use as `this` when executing `mapFn`. + * @returns A new `Set` instance */ from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): CoreJS.CoreJSSet; /** - * Creates a new `Set` instance from a variable number of arguments, - * where each pair of arguments is interpreted as a key and a value. - * @param items - An even number of arguments representing key-value pairs. - * @returns A new `Set` instance. + * Creates a new `Set` instance from a variable number of arguments. + * Each argument becomes an element of the Set. + * @param items - Zero or more arguments to add as Set elements. + * @returns A new `Set` instance */ of(...items: T[]): CoreJS.CoreJSSet; } @@ -76,20 +75,18 @@ declare namespace CoreJS { export interface CoreJSWeakSetConstructor extends WeakSetConstructor { /** - * Creates a new `WeakSet` instance from an iterable or array-like object of [key, value] pairs. - * Optionally, applies a mapping function to each pair. - * @param source - Iterable or array-like object of [key, value] pairs. - * @param mapFn - Function to call on every [key, value] pair before adding to the `WeakSet`. - * @param thisArg - Value to use as this when executing mapFn. - * @returns A new `WeakSet` instance. + * Creates a new `WeakSet` instance from an iterable of objects, optionally transforming with mapFn. + * @param source - Iterable of objects to add to WeakSet. + * @param mapFn - Optional mapping function transforming each object. + * @param thisArg - Value to use as `this` in `mapFn`. + * @returns New `WeakSet` instance. */ from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): CoreJS.CoreJSWeakSet; /** - * Creates a new `WeakSet` instance from a variable number of arguments, - * where each pair of arguments is interpreted as a key and a value. - * @param items - An even number of arguments representing key-value pairs. - * @returns A new `WeakSet` instance. + * Creates a new `WeakSet` instance from object arguments. + * @param items - Zero or more objects to add as WeakSet elements. + * @returns New `WeakSet` instance. */ of(...items: T[]): CoreJS.CoreJSWeakSet; } From f50664356ca94d29d6ae4fa6a55a969ff08cda99 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 22:08:44 +0700 Subject: [PATCH 232/315] Update types for json parse with source proposal --- .../src/base/proposals/json-parse-with-source.d.ts | 2 +- .../pure/proposals/json-parse-with-source.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts index 354d0ed2cba6..a5c131cacd0d 100644 --- a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts +++ b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts @@ -3,7 +3,7 @@ interface CoreJSReviverContext { // @type-options: no-extends, no-prefix readonly __brand: unique symbol; - source: string; + source: string | undefined; } interface CoreJSRawJSON { // @type-options: no-extends, no-prefix diff --git a/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts b/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts index b78ee7698a1d..6f9e3bda7d9e 100644 --- a/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts +++ b/tests/type-definitions/pure/proposals/json-parse-with-source.test.ts @@ -7,7 +7,7 @@ interface CoreJSRawJSON { } interface CoreJSReviverContext { - source: string; + source: string | undefined; } const r: CoreJSRawJSON = $rawJSON('{"a":123}'); From ee748622df4ff442a15056c428cbdb1bc2eae7cd Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 22:12:52 +0700 Subject: [PATCH 233/315] Update types for ReaonlyArray#filterReject --- packages/core-js-types/src/base/proposals/array-filtering.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/proposals/array-filtering.d.ts b/packages/core-js-types/src/base/proposals/array-filtering.d.ts index c63b0f32f4f2..5c175c6c51ca 100644 --- a/packages/core-js-types/src/base/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/base/proposals/array-filtering.d.ts @@ -19,7 +19,7 @@ interface ReadonlyArray { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; + filterReject(callbackFn: (value: T, index: number, target: readonly T[]) => boolean, thisArg?: any): T[]; } interface Int8Array { // @type-options: no-export From e422dc3f91c2a4878839c2a99a8370f38250a711 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 22:23:47 +0700 Subject: [PATCH 234/315] Fix callback return type of typed arrays filterReject methods --- .../src/base/proposals/array-filtering.d.ts | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/array-filtering.d.ts b/packages/core-js-types/src/base/proposals/array-filtering.d.ts index 5c175c6c51ca..1fcebb5326ad 100644 --- a/packages/core-js-types/src/base/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/base/proposals/array-filtering.d.ts @@ -8,7 +8,7 @@ interface Array { // @type-options: no-redefine * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[]; + filterReject(callbackFn: (value: T, index: number, target: T[]) => unknown, thisArg?: any): T[]; } interface ReadonlyArray { // @type-options: no-export @@ -19,7 +19,7 @@ interface ReadonlyArray { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: T, index: number, target: readonly T[]) => boolean, thisArg?: any): T[]; + filterReject(callbackFn: (value: T, index: number, target: readonly T[]) => unknown, thisArg?: any): T[]; } interface Int8Array { // @type-options: no-export @@ -30,7 +30,7 @@ interface Int8Array { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: number, index: number, target: Int8Array) => boolean, thisArg?: any): Int8Array; + filterReject(callbackFn: (value: number, index: number, target: Int8Array) => unknown, thisArg?: any): Int8Array; } interface Uint8Array { // @type-options: no-export @@ -41,7 +41,7 @@ interface Uint8Array { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: number, index: number, target: Uint8Array) => boolean, thisArg?: any): Uint8Array; + filterReject(callbackFn: (value: number, index: number, target: Uint8Array) => unknown, thisArg?: any): Uint8Array; } interface Uint8ClampedArray { // @type-options: no-export @@ -52,7 +52,7 @@ interface Uint8ClampedArray { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: number, index: number, target: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + filterReject(callbackFn: (value: number, index: number, target: Uint8ClampedArray) => unknown, thisArg?: any): Uint8ClampedArray; } interface Int16Array { // @type-options: no-export @@ -63,7 +63,7 @@ interface Int16Array { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: number, index: number, target: Int16Array) => boolean, thisArg?: any): Int16Array; + filterReject(callbackFn: (value: number, index: number, target: Int16Array) => unknown, thisArg?: any): Int16Array; } interface Uint16Array { // @type-options: no-export @@ -74,7 +74,7 @@ interface Uint16Array { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: number, index: number, target: Uint16Array) => boolean, thisArg?: any): Uint16Array; + filterReject(callbackFn: (value: number, index: number, target: Uint16Array) => unknown, thisArg?: any): Uint16Array; } interface Int32Array { // @type-options: no-export @@ -85,7 +85,7 @@ interface Int32Array { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: number, index: number, target: Int32Array) => boolean, thisArg?: any): Int32Array; + filterReject(callbackFn: (value: number, index: number, target: Int32Array) => unknown, thisArg?: any): Int32Array; } interface Uint32Array { // @type-options: no-export @@ -96,7 +96,7 @@ interface Uint32Array { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: number, index: number, target: Uint32Array) => boolean, thisArg?: any): Uint32Array; + filterReject(callbackFn: (value: number, index: number, target: Uint32Array) => unknown, thisArg?: any): Uint32Array; } interface Float32Array { // @type-options: no-export @@ -107,7 +107,7 @@ interface Float32Array { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: number, index: number, target: Float32Array) => boolean, thisArg?: any): Float32Array; + filterReject(callbackFn: (value: number, index: number, target: Float32Array) => unknown, thisArg?: any): Float32Array; } interface Float64Array { // @type-options: no-export @@ -118,7 +118,7 @@ interface Float64Array { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: number, index: number, target: Float64Array) => boolean, thisArg?: any): Float64Array; + filterReject(callbackFn: (value: number, index: number, target: Float64Array) => unknown, thisArg?: any): Float64Array; } interface BigInt64Array { // @type-options: no-export @@ -129,7 +129,7 @@ interface BigInt64Array { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array; + filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => unknown, thisArg?: any): BigInt64Array; } interface BigUint64Array { // @type-options: no-export @@ -140,5 +140,5 @@ interface BigUint64Array { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - filterReject(callbackFn: (value: bigint, index: number, target: BigUint64Array) => boolean, thisArg?: any): BigUint64Array; + filterReject(callbackFn: (value: bigint, index: number, target: BigUint64Array) => unknown, thisArg?: any): BigUint64Array; } From cb3187b4bdf236dabc118e1ef47ef7b8fb26011a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 22:57:57 +0700 Subject: [PATCH 235/315] Use custom PromiseSettledResult --- .../src/base/core-js-types/promise-settled-result.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/core-js-types/src/base/core-js-types/promise-settled-result.d.ts b/packages/core-js-types/src/base/core-js-types/promise-settled-result.d.ts index 9d32e1439239..9fcfeb929a68 100644 --- a/packages/core-js-types/src/base/core-js-types/promise-settled-result.d.ts +++ b/packages/core-js-types/src/base/core-js-types/promise-settled-result.d.ts @@ -1,9 +1,7 @@ declare namespace CoreJS { interface PromiseFulfilledResult { status: 'fulfilled'; value: T; } - interface PromiseRejectedResult { status: 'rejected'; reason: any; } + interface PromiseRejectedResult { status: 'rejected'; reason: unknown; } - export type CoreJSPromiseSettledResult = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020 - ? O - : PromiseFulfilledResult | PromiseRejectedResult; + export type CoreJSPromiseSettledResult = PromiseFulfilledResult | PromiseRejectedResult; } From e79244bf0ebd80ee55226434286c78562dd87ee4 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 23:06:08 +0700 Subject: [PATCH 236/315] Aligning the type of CoreJSAsyncIterator and CoreJSAsyncIteratorObject --- .../base/pure/core-js-types/async-iterator-object.d.ts | 2 +- .../src/base/pure/core-js-types/async-iterator.d.ts | 2 +- .../src/base/pure/core-js-types/iterator-object.d.ts | 2 +- .../src/base/pure/proposals/async-iterator-helpers.d.ts | 2 +- .../core-js-types/src/base/pure/proposals/iterator.d.ts | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/core-js-types/src/base/pure/core-js-types/async-iterator-object.d.ts b/packages/core-js-types/src/base/pure/core-js-types/async-iterator-object.d.ts index 25f3fbc18591..996ed0827b3a 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/async-iterator-object.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/async-iterator-object.d.ts @@ -2,7 +2,7 @@ /// declare namespace CoreJS { - export interface CoreJSAsyncIteratorObject extends CoreJS.CoreJSAsyncIterator { + export interface CoreJSAsyncIteratorObject extends CoreJS.CoreJSAsyncIterator { [CoreJS.CoreJSSymbol.asyncIterator](): CoreJSAsyncIteratorObject; } } diff --git a/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts b/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts index d53cff67a235..99e92cd2df55 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts @@ -1,7 +1,7 @@ /// declare namespace CoreJS { - export interface CoreJSAsyncIterator { + export interface CoreJSAsyncIterator { next(...[value]: [] | [TNext]): CoreJS.CoreJSPromise>; return?(value?: TReturn | PromiseLike): CoreJS.CoreJSPromise>; diff --git a/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts index d55de7c05c4c..1e9fa0071c69 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts @@ -1,5 +1,5 @@ /// declare namespace CoreJS { - export interface CoreJSIteratorObject extends CoreJSIterator {} + export interface CoreJSIteratorObject extends CoreJSIterator {} } diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index 78daa562e449..37387174c05d 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -17,7 +17,7 @@ declare namespace CoreJS { from(iterable: CoreJSAsyncIterable | Iterable | CoreJSAsyncIteratorObject): CoreJSAsyncIteratorObject; } - export interface CoreJSAsyncIterator { + export interface CoreJSAsyncIterator { /** * Drops elements from the iterator until the limit is reached diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 2920aba753e1..e29048c8c6b0 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -49,19 +49,19 @@ declare namespace CoreJS { then(onfulfilled?: ((value: T) => TResult1 | CoreJSPromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | CoreJSPromiseLike) | undefined | null): CoreJSPromiseLike; } - interface CoreJSAsyncIterator { + interface CoreJSAsyncIterator { next(...[value]: [] | [TNext]): CoreJS.CoreJSPromise>; return?(value?: TReturn | CoreJSPromiseLike): CoreJS.CoreJSPromise>; throw?(e?: any): CoreJS.CoreJSPromise>; } - export interface CoreJSAsyncIteratorObject extends CoreJSAsyncIterator {} - export interface CoreJSAsyncIteratorObject extends CoreJSAsyncDisposable {} + export interface CoreJSAsyncIteratorObject extends CoreJSAsyncIterator {} + export interface CoreJSAsyncIteratorObject extends CoreJSAsyncDisposable {} export interface CoreJSAsyncIterable { [CoreJSSymbol.asyncIterator](): CoreJSAsyncIterator; } - export interface CoreJSIteratorObject extends CoreJSDisposable {} + export interface CoreJSIteratorObject extends CoreJSDisposable {} export interface CoreJSIterator extends Iterator { /** From c709171361c9838050548f8aa82c7fbe3b39073b Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 23:15:08 +0700 Subject: [PATCH 237/315] Aligning the type of Iterator, IteratorObject, AsyncIteratorObject --- .../src/base/proposals/async-iterator-helpers.d.ts | 10 +++++----- .../src/base/proposals/iterator-chunking.d.ts | 4 ++-- .../src/base/proposals/iterator-joint.d.ts | 4 ++-- .../src/base/proposals/iterator-sequencing.d.ts | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index acba2fd636eb..ffa8224bb844 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -8,7 +8,7 @@ interface AsyncIteratorConstructor { * @param iterable - An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` * @returns A new `AsyncIterator` instance */ - from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; + from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; } declare var AsyncIterator: AsyncIteratorConstructor; @@ -19,7 +19,7 @@ interface AsyncIterator { * @param limit - The number of elements to drop * @returns A new `AsyncIterator` */ - drop(limit: number): AsyncIteratorObject; + drop(limit: number): AsyncIteratorObject; /** * Check if every value generated by the iterator passes the `predicate` function. @@ -34,7 +34,7 @@ interface AsyncIterator { * @returns A new `AsyncIterator` */ filter(predicate: (value: T, index: number) => value is S): AsyncIteratorObject; - filter(predicate: (value: T, index: number) => unknown): AsyncIteratorObject; + filter(predicate: (value: T, index: number) => unknown): AsyncIteratorObject; /** * Finds the first element in the iterator that satisfies the `predicate` function. @@ -93,7 +93,7 @@ interface AsyncIterator { * @param limit - The maximum number of elements to take * @returns A new `AsyncIterator` */ - take(limit: number): AsyncIteratorObject; + take(limit: number): AsyncIteratorObject; /** * Collects all elements from the iterator into an array. @@ -107,5 +107,5 @@ interface Iterator { * Creates an `AsyncIterator` from the current `Iterator` * @returns A new `AsyncIterator` instance */ - toAsync(): AsyncIteratorObject; + toAsync(): AsyncIteratorObject; } diff --git a/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts b/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts index ce788e15202a..7c56fd26ffa7 100644 --- a/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-chunking.d.ts @@ -9,7 +9,7 @@ interface Iterator { * @param chunkSize - The maximum number of elements per chunk. Must be a positive integer. * @returns An iterator yielding arrays of at most `chunkSize` elements from the source iterator. */ - chunks(chunkSize: number): IteratorObject; + chunks(chunkSize: number): IteratorObject; /** * Yields overlapping arrays (windows) of the given size from the iterator. @@ -17,5 +17,5 @@ interface Iterator { * @param undersized - 'only-full' (default) to yield only full windows | 'allow-partial' to yield all windows. * @returns An iterator yielding arrays of the specified window size. */ - windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): IteratorObject; + windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): IteratorObject; } diff --git a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts index 8ab339c915e9..50d1fd3caf85 100644 --- a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts @@ -16,7 +16,7 @@ interface IteratorConstructor { // @type-options: no-extends * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. */ - zip(iterables: Iterable>, options?: ZipOptions): IteratorObject; // @type-options: prefix-return-type + zip(iterables: Iterable>, options?: ZipOptions): IteratorObject; // @type-options: prefix-return-type /** * takes an object whose values are iterables and produces an iterable of objects where keys. @@ -27,7 +27,7 @@ interface IteratorConstructor { // @type-options: no-extends * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. */ - zipKeyed }>(record: T, options?: ZipOptions): IteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }>; // @type-options: prefix-return-type + zipKeyed }>(record: T, options?: ZipOptions): IteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; // @type-options: prefix-return-type } declare var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts index f4a82de3b908..8b0ce3d82440 100644 --- a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts @@ -8,7 +8,7 @@ interface IteratorConstructor { // @type-options: no-extends * @param iterators - The iterables to concatenate. * @returns An iterator yielding values from each input iterable in sequence. */ - concat(...iterators: Iterable[]): IteratorObject; + concat(...iterators: Iterable[]): IteratorObject; } declare var Iterator: IteratorConstructor; From 4632ed73b3fc2e3b16998fce5af279e2c252e43f Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 23:21:21 +0700 Subject: [PATCH 238/315] Remove example from AsyncDisposableStack TSDocs & fix description --- .../explicit-resource-management.d.ts | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts index f6bef592638d..16cc316d90a7 100644 --- a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts @@ -150,33 +150,7 @@ declare namespace CoreJS { defer(onDisposeAsync: () => PromiseLike | void): void; /** - * Move all resources out of this stack and into a new `DisposableStack`, and marks this stack as disposed. - * @example - * ```ts - * class C { - * #res1: CoreJSDisposable; - * #res2: CoreJSDisposable; - * #disposables: CoreJSDisposableStack; - * constructor() { - * // stack will be disposed when exiting constructor for any reason - * using stack = new DisposableStack(); - * - * // get first resource - * this.#res1 = stack.use(getResource1()); - * - * // get second resource. If this fails, both `stack` and `#res1` will be disposed. - * this.#res2 = stack.use(getResource2()); - * - * // all operations succeeded, move resources out of `stack` so that they aren't disposed - * // when constructor exits - * this.#disposables = stack.move(); - * } - * - * [CoreJSSymbol.dispose]() { - * this.#disposables.dispose(); - * } - * } - * ``` + * Move all resources out of this stack and into a new `AsyncDisposableStack`, and marks this stack as disposed. */ move(): CoreJSAsyncDisposableStack; From 281e35c98a88500824fba4b05026db069400c9e5 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 18 Feb 2026 23:39:39 +0700 Subject: [PATCH 239/315] Add pure pollutions test --- .../entries/pure-pollutions/test.ts | 14 ++++++++++++++ .../entries/pure-pollutions/tsconfig.json | 9 +++++++++ tests/type-definitions/runner.mjs | 1 + 3 files changed, 24 insertions(+) create mode 100644 tests/type-definitions/entries/pure-pollutions/test.ts create mode 100644 tests/type-definitions/entries/pure-pollutions/tsconfig.json diff --git a/tests/type-definitions/entries/pure-pollutions/test.ts b/tests/type-definitions/entries/pure-pollutions/test.ts new file mode 100644 index 000000000000..1df43509df63 --- /dev/null +++ b/tests/type-definitions/entries/pure-pollutions/test.ts @@ -0,0 +1,14 @@ +import '@core-js/types/pure'; + +// no global pollution +// @ts-expect-error +Iterator.chunks(num, 2); +// @ts-expect-error +Iterator.zipKeyed({ a: [1, 2], b: [3, 4] }); +// @ts-expect-error +Iterator.zip([[1, 2, 3], [4, 5, 6]]); +// @ts-expect-error +Promise.allKeyed({ + a: Promise.resolve(1), + b: Promise.resolve('string'), +}); diff --git a/tests/type-definitions/entries/pure-pollutions/tsconfig.json b/tests/type-definitions/entries/pure-pollutions/tsconfig.json new file mode 100644 index 000000000000..36fc3f454b75 --- /dev/null +++ b/tests/type-definitions/entries/pure-pollutions/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "include": [ + "./test.ts" + ], + "compilerOptions": { + "types": ["@core-js/types/pure"] + } +} diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index d05751ea3c75..fa9a590f0d0f 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -167,6 +167,7 @@ const tasks = [ { ts: '5.9', config: 'entries/global-imports/tsconfig.json' }, { ts: '5.9', config: 'entries/pure-imports/tsconfig.json' }, { ts: '5.9', config: 'entries/configurator/tsconfig.json' }, + { ts: '5.9', config: 'entries/pure-pollutions/tsconfig.json' }, ...buildTasks(), ]; From 75689aca9336325ba1328c6f92b64cc1bb3ebb0a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 00:35:24 +0700 Subject: [PATCH 240/315] Remove proposal stage comments from types --- .../src/base/pure/proposals/array-buffer-transfer.d.ts | 1 - .../src/base/pure/proposals/array-constructor.d.ts | 2 -- .../src/base/pure/proposals/async-iterator-helpers.d.ts | 1 - .../src/base/pure/proposals/decorator-metadata.d.ts | 1 - .../base/pure/proposals/explicit-resource-management.d.ts | 1 - .../core-js-types/src/base/pure/proposals/iterator.d.ts | 6 ------ .../src/base/pure/proposals/relative-indexing-method.d.ts | 1 - .../src/base/pure/proposals/string-left-right-trim.d.ts | 1 - .../src/base/pure/proposals/string-match-all.d.ts | 1 - .../src/base/pure/proposals/string-padding.d.ts | 1 - .../src/base/pure/proposals/string-replace-all.d.ts | 1 - packages/core-js-types/src/base/pure/proposals/symbol.d.ts | 7 ------- .../base/pure/proposals/well-formed-unicode-strings.d.ts | 1 - .../src/ts5-2/pure/proposals/async-iterator-helpers.d.ts | 1 - .../core-js-types/src/ts5-2/pure/proposals/iterator.d.ts | 6 ------ 15 files changed, 32 deletions(-) diff --git a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts index e92edee2b16b..21677840bbd9 100644 --- a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts @@ -1,7 +1,6 @@ // Motivation: We can use a readonly properties in the pure version, e.g. ArrayBuffer.detached. // Motivation: We must create a constructor interface to allow creating our own ArrayBuffer implementation. -// proposal stage: 4 // https://github.com/tc39/proposal-arraybuffer-transfer // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts b/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts index 57013547682f..492d272b2bf2 100644 --- a/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts @@ -3,10 +3,8 @@ // Motivation: We must omit methods `fromAsync` and `isTemplateObject` because they cause a signature mismatch error. -// proposal stage: 2 // https://github.com/tc39/proposal-array-is-template-object -// proposal stage: 3 // https://github.com/tc39/proposal-array-from-async // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index 37387174c05d..7843047a52b5 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -4,7 +4,6 @@ // Motivation: Has dependencies on internal types, e.g. AsyncIterable, AsyncIteratorObject -// proposal stage: 2 // https://github.com/tc39/proposal-async-iterator-helpers declare namespace CoreJS { diff --git a/packages/core-js-types/src/base/pure/proposals/decorator-metadata.d.ts b/packages/core-js-types/src/base/pure/proposals/decorator-metadata.d.ts index 2cf663ea0242..b78c80bd344d 100644 --- a/packages/core-js-types/src/base/pure/proposals/decorator-metadata.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/decorator-metadata.d.ts @@ -2,7 +2,6 @@ // Motivation: Symbol is replaced with our own -// proposal stage: 3 // https://github.com/tc39/proposal-decorator-metadata declare namespace CoreJS { diff --git a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts index 16cc316d90a7..e83d32ee2e06 100644 --- a/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/explicit-resource-management.d.ts @@ -3,7 +3,6 @@ // Motivation: Symbol is replaced with our own -// proposal stage: 3 // https://github.com/tc39/proposal-explicit-resource-management // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index e29048c8c6b0..02906b4ad92d 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -4,22 +4,16 @@ // Motivation: Has dependencies on internal types -// proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-chunking -// proposal stage: 4 // https://github.com/tc39/proposal-iterator-helpers -// proposal stage: 0 // https://github.com/bakkot/proposal-iterator-join -// proposal stage: 2.7 // https://github.com/tc39/proposal-joint-iteration -// proposal stage: 2 // https://github.com/tc39/proposal-iterator.range -// proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-sequencing // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts b/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts index 044075165189..f69f8d3d6f96 100644 --- a/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/relative-indexing-method.d.ts @@ -2,7 +2,6 @@ // Motivation: We should use String without the matchAll method to avoid signature conflicts -// proposal stage: 4 // https://github.com/tc39/proposal-relative-indexing-method // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts b/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts index 0c03e6bb48d4..59bdf0872ff4 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-left-right-trim.d.ts @@ -2,7 +2,6 @@ // Motivation: We should use String without the matchAll method to avoid signature conflicts -// proposal stage: 4 // https://github.com/tc39/proposal-string-left-right-trim // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts index 3c3f1812b7d1..75d22139a366 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts @@ -4,7 +4,6 @@ // Motivation: We should use String without the matchAll method to avoid signature conflicts -// proposal stage: 4 // https://github.com/tc39/proposal-string-matchall // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts b/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts index 812864a9daf5..495545a0d2e3 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-padding.d.ts @@ -2,7 +2,6 @@ // Motivation: We should use String without the matchAll method to avoid signature conflicts -// proposal stage: 4 // https://github.com/tc39/proposal-string-pad-start-end // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts index 9feb789a29ac..e36dc30fed26 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts @@ -2,7 +2,6 @@ // Motivation: We should use String without the matchAll method to avoid signature conflicts -// proposal stage: 4 // https://github.com/tc39/proposal-string-replaceall // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts index 33abb201be13..e9d2c3480908 100644 --- a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts @@ -1,30 +1,23 @@ // Motivation: We should use all unique symbols in SymbolConstructor with fallback -// proposal stage: 3 // https://github.com/tc39/proposal-explicit-resource-management -// proposal stage: 2 // https://github.com/tc39/proposal-symbol-predicates -// proposal stage: 4 // https://github.com/tc39/proposal-async-iteration -// proposal stage: 1 // https://github.com/tc39/proposal-pattern-matching // For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2018.asynciterable.d.ts#L4 -// proposal stage: 3 // https://github.com/tc39/proposal-decorator-metadata -// proposal stage: 4 // https://github.com/tc39/proposal-string-matchall // For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2020.string.d.ts -// proposal stage: 4 // https://github.com/tc39/proposal-Symbol-description // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts b/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts index 18c28003226b..ed164914a013 100644 --- a/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/well-formed-unicode-strings.d.ts @@ -2,7 +2,6 @@ // Motivation: We should use String without the matchAll method to avoid signature conflicts -// proposal stage: 4 // https://github.com/tc39/proposal-is-usv-string // For ensuring compatibility with TypeScript standard types, this code is aligned with: diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts index b04a0ade094b..cf0059b79435 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts @@ -5,7 +5,6 @@ // Motivation: Has dependencies on internal types, e.g. AsyncIterable, AsyncIteratorObject // Motivation: Iterator until TS 5.6 used undefined as TNext defaults -// proposal stage: 2 // https://github.com/tc39/proposal-async-iterator-helpers declare namespace CoreJS { diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index 9f8fe580d04b..9595a8d858d0 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -5,22 +5,16 @@ // Motivation: Has dependencies on internal types // Motivation: Iterable until TS 5.6 used only one type parameter -// proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-chunking -// proposal stage: 4 // https://github.com/tc39/proposal-iterator-helpers -// proposal stage: 0 // https://github.com/bakkot/proposal-iterator-join -// proposal stage: 2.7 // https://github.com/tc39/proposal-joint-iteration -// proposal stage: 2 // https://github.com/tc39/proposal-iterator.range -// proposal stage: 2.7 // https://github.com/tc39/proposal-iterator-sequencing // For ensuring compatibility with TypeScript standard types, this code is aligned with: From 2b38708715199247c4f66ace40f4b6d95cff9949 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 00:38:48 +0700 Subject: [PATCH 241/315] Iterator.range overloads improvements --- .../src/base/pure/proposals/iterator.d.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 02906b4ad92d..bf457508fea0 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -107,7 +107,7 @@ declare namespace CoreJS { * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. * @param callback - A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. */ - flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; // ts < 5.6 Iterable + flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; /** * Calls the specified callback function for all the elements in this iterator. 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. @@ -198,15 +198,26 @@ declare namespace CoreJS { zipKeyed }>(record: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; /** - * Returns an iterator that generates a sequence of numbers or bigints within a range. + * Returns an iterator that generates a sequence of numbers within a range. * @param start - The starting value of the sequence. * @param end - The end value of the sequence (exclusive by default). * @param options - Optional object: * - step: The difference between consecutive values (default is 1). * - inclusive: If true, the end value is included in the range (default is false). - * @returns An iterator of numbers or bigints. + * @returns An iterator of numbers. */ - range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): CoreJSIteratorObject + range(start: number, end: number | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: number | IteratorRangeOptions): CoreJSIteratorObject + + /** + * Returns an iterator that generates a sequence of bigints within a range. + * @param start - The starting value of the sequence. + * @param end - The end value of the sequence (exclusive by default). + * @param options - Optional object: + * - step: The difference between consecutive values (default is 1n). + * - inclusive: If true, the end value is included in the range (default is false). + * @returns An iterator of bigints. + */ + range(start: bigint, end: bigint, options?: bigint | IteratorRangeOptions): CoreJSIteratorObject /** * Creates an iterator that sequentially yields values from the provided iterables. From 5bb0daeb1ea19925b64812e6ed254efea71e3fe9 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 00:40:08 +0700 Subject: [PATCH 242/315] Iterator type alignment of 5.6 and 5.2 versions --- .../src/ts5-2/pure/proposals/iterator.d.ts | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index 9595a8d858d0..ed61b27c80f5 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -25,7 +25,7 @@ declare namespace CoreJS { interface ZipOptions { mode?: 'shortest' | 'longest' | 'strict'; - padding?: object; + padding?: Iterable; } interface IteratorRangeOptions { @@ -44,14 +44,14 @@ declare namespace CoreJS { then(onfulfilled?: ((value: T) => TResult1 | CoreJSPromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | CoreJSPromiseLike) | undefined | null): CoreJSPromiseLike; } - interface CoreJSAsyncIterator { + interface CoreJSAsyncIterator { next(...[value]: [] | [TNext]): CoreJS.CoreJSPromise>; return?(value?: TReturn | CoreJSPromiseLike): CoreJS.CoreJSPromise>; throw?(e?: any): CoreJS.CoreJSPromise>; } - export interface CoreJSAsyncIteratorObject extends CoreJSAsyncIterator {} - export interface CoreJSAsyncIteratorObject extends CoreJSAsyncDisposable {} + export interface CoreJSAsyncIteratorObject extends CoreJSAsyncIterator {} + export interface CoreJSAsyncIteratorObject extends CoreJSAsyncDisposable {} export interface CoreJSAsyncIterable { [CoreJSSymbol.asyncIterator](): CoreJSAsyncIterator; } @@ -108,7 +108,7 @@ declare namespace CoreJS { * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. * @param callback - A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. */ - flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; + flatMap(callback: (value: T, index: number) => Iterator | Iterable): CoreJSIteratorObject; // ts < 5.6 Iterable /** * Calls the specified callback function for all the elements in this iterator. 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. @@ -199,15 +199,26 @@ declare namespace CoreJS { zipKeyed }>(record: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; /** - * Returns an iterator that generates a sequence of numbers or bigints within a range. + * Returns an iterator that generates a sequence of numbers within a range. * @param start - The starting value of the sequence. * @param end - The end value of the sequence (exclusive by default). * @param options - Optional object: * - step: The difference between consecutive values (default is 1). * - inclusive: If true, the end value is included in the range (default is false). - * @returns An iterator of numbers or bigints. + * @returns An iterator of numbers. */ - range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): CoreJSIteratorObject + range(start: number, end: number | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: number | IteratorRangeOptions): CoreJSIteratorObject + + /** + * Returns an iterator that generates a sequence of bigints within a range. + * @param start - The starting value of the sequence. + * @param end - The end value of the sequence (exclusive by default). + * @param options - Optional object: + * - step: The difference between consecutive values (default is 1n). + * - inclusive: If true, the end value is included in the range (default is false). + * @returns An iterator of bigints. + */ + range(start: bigint, end: bigint, options?: bigint | IteratorRangeOptions): CoreJSIteratorObject /** * Creates an iterator that sequentially yields values from the provided iterables. From ea87d02e2f5efa677edd14cda508ec638f2809aa Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 00:41:11 +0700 Subject: [PATCH 243/315] AsyncIterator.reduce overloads improvements --- .../base/proposals/async-iterator-helpers.d.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index ffa8224bb844..617a3178d8b8 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -68,18 +68,25 @@ interface AsyncIterator { /** * Reduces the elements of the iterator to a single value using the `reducer` function. * @param reducer - A function that combines two elements of the iterator - * @param initialValue - The initial value to start the accumulation. Required when the accumulator type differs from the element type. - * @returns A `Promise` that resolves to the reduced value + * @returns A promise that resolves to the reduced value */ - reduce(reducer: (accumulator: U, value: T, index: number) => U, initialValue: U): Promise; + reduce(reducer: (accumulator: T, value: T, index: number) => T): Promise; /** * Reduces the elements of the iterator to a single value using the `reducer` function. * @param reducer - A function that combines two elements of the iterator - * @param initialValue - An optional initial value to start the reduction + * @param initialValue - The initial value to start the reduction + * @returns A promise that resolves to the reduced value + */ + reduce(reducer: (accumulator: T, value: T, index: number) => T, initialValue: T): Promise; + + /** + * Reduces the elements of the iterator to a single value using the `reducer` function. + * @param reducer - A function that combines two elements of the iterator + * @param initialValue - The initial value to start the accumulation. Required when the accumulator type differs from the element type. * @returns A `Promise` that resolves to the reduced value */ - reduce(reducer: (accumulator: T, value: T, index: number) => T, initialValue?: T): Promise; + reduce(reducer: (accumulator: U, value: T, index: number) => U, initialValue: U): Promise; /** * Checks if any value in the iterator matches a given `predicate` From 3fb02a1f4ed5585e323ae07a62bb001a9967cb56 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 00:42:21 +0700 Subject: [PATCH 244/315] Iterator dom collections types & tests fixes --- .../core-js-types/src/base/web/iterable-dom-collections.d.ts | 2 +- .../core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts | 4 ++-- .../global/web/iterable-dom-collections.dom.test.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts index 0e9ce4c299e4..5962cb7020db 100644 --- a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts +++ b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts @@ -39,7 +39,7 @@ interface DOMTokenList { // @type-options: no-export /** * Returns an iterable of key, value pairs in the DOMTokenList. */ - entries(): IterableIterator<[number, Element]>; + entries(): IterableIterator<[number, string]>; [Symbol.iterator](): IterableIterator; } diff --git a/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts index 3ca9b5b31c3c..ac7a351c2d3d 100644 --- a/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts +++ b/packages/core-js-types/src/ts5-2/web/iterable-dom-collections.d.ts @@ -20,7 +20,7 @@ interface DOMTokenList { // @type-options: no-export * @param thisArg - Value to use as this when executing `callbackfn`. */ forEach( - callbackfn: (value: Element, index: number, collection: DOMTokenList) => void, + callbackfn: (value: string, index: number, collection: DOMTokenList) => void, thisArg?: any ): void; @@ -32,7 +32,7 @@ interface DOMTokenList { // @type-options: no-export /** * Returns an iterable of values in the DOMTokenList. */ - values(): IterableIterator; + values(): IterableIterator; /** * Returns an iterable of key, value pairs in the DOMTokenList. diff --git a/tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts b/tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts index df9c2778db93..50eac5cc8021 100644 --- a/tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts +++ b/tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts @@ -33,6 +33,6 @@ const domValues: IterableIterator = domTokenList.values(); // @ts-expect-error domTokenList.values('string'); -const domEntries: IterableIterator<[number, Element]> = domTokenList.entries(); +const domEntries: IterableIterator<[number, string]> = domTokenList.entries(); // @ts-expect-error domTokenList.entries('string'); From 1760591b1bc9be7d66a177d3a75d72d4c06b18d2 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 00:43:10 +0700 Subject: [PATCH 245/315] Add iterator joint proposal tests with strict mode --- .../type-definitions/global/proposals/iterator-joint.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/type-definitions/global/proposals/iterator-joint.test.ts b/tests/type-definitions/global/proposals/iterator-joint.test.ts index a058b6870d63..cbe2616cd3df 100644 --- a/tests/type-definitions/global/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/global/proposals/iterator-joint.test.ts @@ -11,14 +11,18 @@ $Iterator.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); Iterator.zip([[1, 2, 3], [4, 5, 6]]); Iterator.zip([['a', 'b', 'c'], ['d', 'e', 'f']]); Iterator.zip([[1, 2, 3], [4, 5, 6]], { mode: 'shortest' }); +Iterator.zip([[1, 2, 3], [4, 5, 6]], { mode: 'strict' }); Iterator.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); Iterator.zipKeyed({ a: ['a', 'b', 'c', 'd'], b: ['e', 'f'] }, { mode: 'shortest' }); +Iterator.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }, { mode: 'strict' }); // @ts-expect-error Iterator.zip(true); // @ts-expect-error Iterator.zip([[1, 2, 3], [4, 5, 6]], { mode: 'incorrect' }); // @ts-expect-error +Iterator.zip(arrays, { mode: 'invalid' }); +// @ts-expect-error Iterator.zipKeyed(42); // @ts-expect-error Iterator.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }, { foo: 'bar' }); From 278e5109bd43c5d547c4f6119e417db9357d341c Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 00:44:25 +0700 Subject: [PATCH 246/315] Add overload for Iterator.range with bigint --- .../src/base/proposals/iterator-range.d.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/iterator-range.d.ts b/packages/core-js-types/src/base/proposals/iterator-range.d.ts index 94f7feed25be..06293a9fe79d 100644 --- a/packages/core-js-types/src/base/proposals/iterator-range.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-range.d.ts @@ -8,15 +8,26 @@ interface IteratorRangeOptions { interface IteratorConstructor { // @type-options: no-extends /** - * Returns an iterator that generates a sequence of numbers or bigints within a range. + * Returns an iterator that generates a sequence of numbers within a range. * @param start - The starting value of the sequence. * @param end - The end value of the sequence (exclusive by default). * @param options - Optional object: * - step: The difference between consecutive values (default is 1). * - inclusive: If true, the end value is included in the range (default is false). - * @returns An iterator of numbers or bigints. + * @returns An iterator of numbers. */ - range(start: T, end: T | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: T | IteratorRangeOptions): IteratorObject; // @type-options: prefix-return-type + range(start: number, end: number | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: number | IteratorRangeOptions): IteratorObject; // @type-options: prefix-return-type + + /** + * Returns an iterator that generates a sequence of bigints within a range. + * @param start - The starting value of the sequence. + * @param end - The end value of the sequence (exclusive by default). + * @param options - Optional object: + * - step: The difference between consecutive values (default is 1n). + * - inclusive: If true, the end value is included in the range (default is false). + * @returns An iterator of bigints. + */ + range(start: bigint, end: bigint, options?: bigint | IteratorRangeOptions): IteratorObject; // @type-options: prefix-return-type } declare var Iterator: IteratorConstructor; From e24f73bf0c22cc1fcf096b457e686be489b73a6d Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 00:47:55 +0700 Subject: [PATCH 247/315] Linting fix --- .../src/base/proposals/async-iterator-helpers.d.ts | 2 +- packages/core-js-types/src/base/proposals/iterator-range.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index 617a3178d8b8..ec927ff9f364 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -79,7 +79,7 @@ interface AsyncIterator { * @returns A promise that resolves to the reduced value */ reduce(reducer: (accumulator: T, value: T, index: number) => T, initialValue: T): Promise; - + /** * Reduces the elements of the iterator to a single value using the `reducer` function. * @param reducer - A function that combines two elements of the iterator diff --git a/packages/core-js-types/src/base/proposals/iterator-range.d.ts b/packages/core-js-types/src/base/proposals/iterator-range.d.ts index 06293a9fe79d..502bbe4a9840 100644 --- a/packages/core-js-types/src/base/proposals/iterator-range.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-range.d.ts @@ -17,7 +17,7 @@ interface IteratorConstructor { // @type-options: no-extends * @returns An iterator of numbers. */ range(start: number, end: number | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: number | IteratorRangeOptions): IteratorObject; // @type-options: prefix-return-type - + /** * Returns an iterator that generates a sequence of bigints within a range. * @param start - The starting value of the sequence. From 426a2672b3d229eec8ff2a058db8f824e5b5e280 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 00:54:46 +0700 Subject: [PATCH 248/315] Iterator.zip test fix --- tests/type-definitions/global/proposals/iterator-joint.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/type-definitions/global/proposals/iterator-joint.test.ts b/tests/type-definitions/global/proposals/iterator-joint.test.ts index cbe2616cd3df..5782173d9292 100644 --- a/tests/type-definitions/global/proposals/iterator-joint.test.ts +++ b/tests/type-definitions/global/proposals/iterator-joint.test.ts @@ -21,7 +21,7 @@ Iterator.zip(true); // @ts-expect-error Iterator.zip([[1, 2, 3], [4, 5, 6]], { mode: 'incorrect' }); // @ts-expect-error -Iterator.zip(arrays, { mode: 'invalid' }); +Iterator.zip([[1, 2, 3], [4, 5, 6]], { mode: 'invalid' }); // @ts-expect-error Iterator.zipKeyed(42); // @ts-expect-error From bc25f29eb33221771ddd7e66f312d7a2b7194495 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 00:55:00 +0700 Subject: [PATCH 249/315] Linting fix --- packages/core-js-types/src/base/pure/proposals/iterator.d.ts | 4 ++-- packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index bf457508fea0..2b1fd1b97697 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -206,7 +206,7 @@ declare namespace CoreJS { * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of numbers. */ - range(start: number, end: number | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: number | IteratorRangeOptions): CoreJSIteratorObject + range(start: number, end: number | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: number | IteratorRangeOptions): CoreJSIteratorObject; /** * Returns an iterator that generates a sequence of bigints within a range. @@ -217,7 +217,7 @@ declare namespace CoreJS { * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of bigints. */ - range(start: bigint, end: bigint, options?: bigint | IteratorRangeOptions): CoreJSIteratorObject + range(start: bigint, end: bigint, options?: bigint | IteratorRangeOptions): CoreJSIteratorObject; /** * Creates an iterator that sequentially yields values from the provided iterables. diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index ed61b27c80f5..671b3154ad98 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -207,7 +207,7 @@ declare namespace CoreJS { * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of numbers. */ - range(start: number, end: number | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: number | IteratorRangeOptions): CoreJSIteratorObject + range(start: number, end: number | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: number | IteratorRangeOptions): CoreJSIteratorObject; /** * Returns an iterator that generates a sequence of bigints within a range. @@ -218,7 +218,7 @@ declare namespace CoreJS { * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of bigints. */ - range(start: bigint, end: bigint, options?: bigint | IteratorRangeOptions): CoreJSIteratorObject + range(start: bigint, end: bigint, options?: bigint | IteratorRangeOptions): CoreJSIteratorObject; /** * Creates an iterator that sequentially yields values from the provided iterables. From edadffc6c07697ce3953e48409f384cdd7a063ee Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 01:07:20 +0700 Subject: [PATCH 250/315] Type alignment of CoreJSIteratorObject --- packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index 671b3154ad98..b79ec6ddac1e 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -56,7 +56,7 @@ declare namespace CoreJS { [CoreJSSymbol.asyncIterator](): CoreJSAsyncIterator; } - export interface CoreJSIteratorObject extends CoreJSDisposable {} + export interface CoreJSIteratorObject extends CoreJSDisposable {} export interface CoreJSIterator extends Iterator { /** From 0ee753db43fc5a6c3b56bc5e8dcb20b4c9588432 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 01:07:55 +0700 Subject: [PATCH 251/315] Fix pure pollutions test --- tests/type-definitions/entries/pure-pollutions/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/type-definitions/entries/pure-pollutions/test.ts b/tests/type-definitions/entries/pure-pollutions/test.ts index 1df43509df63..6baaeb2f3672 100644 --- a/tests/type-definitions/entries/pure-pollutions/test.ts +++ b/tests/type-definitions/entries/pure-pollutions/test.ts @@ -2,7 +2,7 @@ import '@core-js/types/pure'; // no global pollution // @ts-expect-error -Iterator.chunks(num, 2); +Iterator.chunks([1, 2, 3], 2); // @ts-expect-error Iterator.zipKeyed({ a: [1, 2], b: [3, 4] }); // @ts-expect-error From 828f1a6fe7a71731a757fa32759bda7d4efe821e Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 21:53:12 +0700 Subject: [PATCH 252/315] Fix iterable dom collections types --- .../base/web/iterable-dom-collections.d.ts | 96 ++++++++++------- .../web/iterable-dom-collections.dom.test.ts | 100 ++++++++++++++++++ 2 files changed, 156 insertions(+), 40 deletions(-) diff --git a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts index 5962cb7020db..354a6c84f825 100644 --- a/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts +++ b/packages/core-js-types/src/base/web/iterable-dom-collections.d.ts @@ -9,6 +9,21 @@ interface CSSRule {} // @type-options: no-export interface ClientRect {} // @type-options: no-export interface DOMRect {} // @type-options: no-export interface StyleSheet {} // @type-options: no-export +interface DataTransferItem {} // @type-options: no-export +interface File {} // @type-options: no-export +interface MimeType {} // @type-options: no-export +interface Attr {} // @type-options: no-export +interface PaintRequest {} // @type-options: no-export +interface Plugin {} // @type-options: no-export +interface SVGLength {} // @type-options: no-export +interface SVGNumber {} // @type-options: no-export +interface SVGPathSeg {} // @type-options: no-export +interface DOMPoint {} // @type-options: no-export +interface SVGTransform {} // @type-options: no-export +interface SourceBuffer {} // @type-options: no-export +interface TextTrackCue {} // @type-options: no-export +interface TextTrack {} // @type-options: no-export +interface Touch {} // @type-options: no-export interface ArrayIterator extends IteratorObject { // @type-options: no-export [Symbol.iterator](): ArrayIterator; @@ -114,30 +129,30 @@ interface DOMRectList { // @type-options: no-export interface DOMStringList { // @type-options: no-export /** - * Returns an iterable of values in the DOMStringList. + * Returns an iterable of string values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface DataTransferItemList { // @type-options: no-export /** - * Returns an iterable of values in the DataTransferItemList. + * Returns an iterable of DataTransferItem values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface FileList { // @type-options: no-export /** - * Returns an iterable of values in the FileList. + * Returns an iterable of File values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface HTMLAllCollection { // @type-options: no-export /** - * Returns an iterable of values in the HTMLAllCollection. + * Returns an iterable of Element values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface HTMLCollection { // @type-options: no-export @@ -163,93 +178,94 @@ interface HTMLSelectElement { // @type-options: no-export interface MediaList { // @type-options: no-export /** - * Returns an iterable of values in the MediaList. + * Returns an iterable of string values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface MimeTypeArray { // @type-options: no-export /** - * Returns an iterable of values in the MimeTypeArray. + * Returns an iterable of MimeType values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface NamedNodeMap { // @type-options: no-export /** - * Returns an iterable of values in the NamedNodeMap. + * Returns an iterable of Attr values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface PaintRequestList { // @type-options: no-export /** - * Returns an iterable of values in the PaintRequestList. + * Returns an iterable of PaintRequest values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface Plugin { // @type-options: no-export /** - * Returns an iterable of values in the Plugin. + * Returns an iterable of MimeType values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface PluginArray { // @type-options: no-export /** - * Returns an iterable of values in the PluginArray. + * Returns an iterable of Plugin values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface SVGLengthList { // @type-options: no-export /** - * Returns an iterable of values in the SVGLengthList. + * Returns an iterable of SVGLength values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface SVGNumberList { // @type-options: no-export /** - * Returns an iterable of values in the SVGNumberList. + * Returns an iterable of SVGNumber values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface SVGPathSegList { // @type-options: no-export /** - * Returns an iterable of values in the SVGPathSegList. + * Returns an iterable of SVGPathSeg values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface SVGPointList { // @type-options: no-export /** - * Returns an iterable of values in the SVGPointList. + * Returns an iterable of DOMPoint values. + * DOMPoint is used instead of SVGPoint because SVGPoint is deprecated and DOMPoint is its replacement. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface SVGStringList { // @type-options: no-export /** - * Returns an iterable of values in the SVGStringList. + * Returns an iterable of string values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface SVGTransformList { // @type-options: no-export /** - * Returns an iterable of values in the SVGTransformList. + * Returns an iterable of SVGTransform values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface SourceBufferList { // @type-options: no-export /** - * Returns an iterable of values in the SourceBufferList. + * Returns an iterable of SourceBuffer values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface StyleSheetList { // @type-options: no-export @@ -262,21 +278,21 @@ interface StyleSheetList { // @type-options: no-export interface TextTrackCueList { // @type-options: no-export /** - * Returns an iterable of values in the TextTrackCueList. + * Returns an iterable of TextTrackCue values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface TextTrackList { // @type-options: no-export /** - * Returns an iterable of values in the TextTrackList. + * Returns an iterable of TextTrack values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface TouchList { // @type-options: no-export /** - * Returns an iterable of values in the TouchList. + * Returns an iterable of Touch values. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } diff --git a/tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts b/tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts index 50eac5cc8021..5cc27fea264e 100644 --- a/tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts +++ b/tests/type-definitions/global/web/iterable-dom-collections.dom.test.ts @@ -36,3 +36,103 @@ domTokenList.values('string'); const domEntries: IterableIterator<[number, string]> = domTokenList.entries(); // @ts-expect-error domTokenList.entries('string'); + +declare const domStringList: DOMStringList; +const dslIterator: IterableIterator = domStringList[Symbol.iterator](); +// @ts-expect-error +const dslWrong: IterableIterator = domStringList[Symbol.iterator](); + +declare const dataTransferItemList: DataTransferItemList; +const dtilIterator: IterableIterator = dataTransferItemList[Symbol.iterator](); +// @ts-expect-error +const dtilWrong: IterableIterator = dataTransferItemList[Symbol.iterator](); + +declare const fileList: FileList; +const flIterator: IterableIterator = fileList[Symbol.iterator](); +// @ts-expect-error +const flWrong: IterableIterator = fileList[Symbol.iterator](); + +declare const htmlAllCollection: HTMLAllCollection; +const hacIterator: IterableIterator = htmlAllCollection[Symbol.iterator](); +// @ts-expect-error +const hacWrong: IterableIterator = htmlAllCollection[Symbol.iterator](); + +declare const mediaList: MediaList; +const mlIterator: IterableIterator = mediaList[Symbol.iterator](); +// @ts-expect-error +const mlWrong: IterableIterator = mediaList[Symbol.iterator](); + +declare const mimeTypeArray: MimeTypeArray; +const mtaIterator: IterableIterator = mimeTypeArray[Symbol.iterator](); +// @ts-expect-error +const mtaWrong: IterableIterator = mimeTypeArray[Symbol.iterator](); + +declare const namedNodeMap: NamedNodeMap; +const nnmIterator: IterableIterator = namedNodeMap[Symbol.iterator](); +// @ts-expect-error +const nnmWrong: IterableIterator = namedNodeMap[Symbol.iterator](); + +declare const paintRequestList: PaintRequestList; +const prlIterator: IterableIterator = paintRequestList[Symbol.iterator](); +// @ts-expect-error +const prlWrong: IterableIterator = paintRequestList[Symbol.iterator](); + +declare const plugin: Plugin; +const pIterator: IterableIterator = plugin[Symbol.iterator](); +// @ts-expect-error +const pWrong: IterableIterator = plugin[Symbol.iterator](); + +declare const pluginArray: PluginArray; +const paIterator: IterableIterator = pluginArray[Symbol.iterator](); +// @ts-expect-error +const paWrong: IterableIterator = pluginArray[Symbol.iterator](); + +declare const svgLengthList: SVGLengthList; +const sllIterator: IterableIterator = svgLengthList[Symbol.iterator](); +// @ts-expect-error +const sllWrong: IterableIterator = svgLengthList[Symbol.iterator](); + +declare const svgNumberList: SVGNumberList; +const snlIterator: IterableIterator = svgNumberList[Symbol.iterator](); +// @ts-expect-error +const snlWrong: IterableIterator = svgNumberList[Symbol.iterator](); + +declare const svgPathSegList: SVGPathSegList; +const spslIterator: IterableIterator = svgPathSegList[Symbol.iterator](); +// @ts-expect-error +const spslWrong: IterableIterator = svgPathSegList[Symbol.iterator](); + +declare const svgPointList: SVGPointList; +const splIterator: IterableIterator = svgPointList[Symbol.iterator](); +// @ts-expect-error +const splWrong: IterableIterator = svgPointList[Symbol.iterator](); + +declare const svgStringList: SVGStringList; +const sslIterator: IterableIterator = svgStringList[Symbol.iterator](); +// @ts-expect-error +const sslWrong: IterableIterator = svgStringList[Symbol.iterator](); + +declare const svgTransformList: SVGTransformList; +const stlIterator: IterableIterator = svgTransformList[Symbol.iterator](); +// @ts-expect-error +const stlWrong: IterableIterator = svgTransformList[Symbol.iterator](); + +declare const sourceBufferList: SourceBufferList; +const sblIterator: IterableIterator = sourceBufferList[Symbol.iterator](); +// @ts-expect-error +const sblWrong: IterableIterator = sourceBufferList[Symbol.iterator](); + +declare const textTrackCueList: TextTrackCueList; +const ttclIterator: IterableIterator = textTrackCueList[Symbol.iterator](); +// @ts-expect-error +const ttclWrong: IterableIterator = textTrackCueList[Symbol.iterator](); + +declare const textTrackList: TextTrackList; +const ttlIterator: IterableIterator = textTrackList[Symbol.iterator](); +// @ts-expect-error +const ttlWrong: IterableIterator = textTrackList[Symbol.iterator](); + +declare const touchList: TouchList; +const tlIterator: IterableIterator = touchList[Symbol.iterator](); +// @ts-expect-error +const tlWrong: IterableIterator = touchList[Symbol.iterator](); From 8a479bcc0b9dedcaa09e51c4f952a7511710c286 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 22:56:24 +0700 Subject: [PATCH 253/315] Fix Iterator#find and Iterator#filter types & add tests --- .../pure/proposals/async-iterator-helpers.d.ts | 4 ++-- .../pure/proposals/async-iterator-helper.test.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index 7843047a52b5..5a37bf276683 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -38,7 +38,7 @@ declare namespace CoreJS { * @returns A new `AsyncIterator` */ filter(predicate: (value: T, index: number) => value is S): CoreJSAsyncIteratorObject; - filter(predicate: (value: T, index: number) => boolean): CoreJSAsyncIteratorObject; + filter(predicate: (value: T, index: number) => unknown): CoreJSAsyncIteratorObject; /** * Finds the first element in the iterator that satisfies the `predicate` function. @@ -46,7 +46,7 @@ declare namespace CoreJS { * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` */ find(predicate: (value: T, index: number) => value is S): CoreJSPromise; - find(predicate: (value: T, index: number) => boolean): CoreJSPromise; + find(predicate: (value: T, index: number) => unknown): CoreJSPromise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index ef4826f84b43..011c03b1177d 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -64,6 +64,20 @@ assertCoreJSAsyncIteratorLike(ait5); const ait6 = toAsync(itn); assertCoreJSAsyncIteratorLike(ait6); +const filterWithNull = filter(aiton, (v: number) => v > 0 ? v : null); +assertCoreJSAsyncIteratorLike(filterWithNull); +const filterWithString = filter(aiton, (v: number) => v > 0 ? 'yes' : ''); +assertCoreJSAsyncIteratorLike(filterWithString); +const filterWithNumber = filter(aiton, (v: number) => v); +assertCoreJSAsyncIteratorLike(filterWithNumber); + +const findWithNull = find(aiton, (v: number) => v > 0 ? v : null); +assertCoreJSPromiseLike(findWithNull); +const findWithString = find(aiton, (v: number) => v > 0 ? 'yes' : ''); +assertCoreJSPromiseLike(findWithString); +const findWithNumber = find(aiton, (v: number) => v); +assertCoreJSPromiseLike(findWithNumber); + toAsync(is); // @ts-expect-error From 843dbda1a89a36316a97e517b382cc3e1c0482b3 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 23:07:05 +0700 Subject: [PATCH 254/315] Fix AsyncIterator#flatMap pure type --- .../src/base/pure/proposals/async-iterator-helpers.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index 5a37bf276683..e81f923f4134 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -53,7 +53,7 @@ declare namespace CoreJS { * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - flatMap(mapper: (value: T, index: number) => Iterator | Iterable | CoreJSAsyncIterator | CoreJSAsyncIterable): CoreJSAsyncIteratorObject; + flatMap(mapper: (value: T, index: number) => Iterator | Iterable | CoreJSAsyncIterator | CoreJSAsyncIterable): CoreJSAsyncIteratorObject; /** * Executes a provided function once for each element in the iterator. From 4d5ac1eac05cda53bd6e41b97eb13157911db665 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 23:32:25 +0700 Subject: [PATCH 255/315] Fix AsyncIterator#reduce pure types & tests --- .../base/pure/proposals/async-iterator-helpers.d.ts | 12 +++++------- .../pure/proposals/async-iterator-helper.test.ts | 11 ++++++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index e81f923f4134..0a7e02b19b23 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -72,27 +72,25 @@ declare namespace CoreJS { /** * Reduces the elements of the iterator to a single value using the `reducer` function. * @param reducer - A function that combines two elements of the iterator - * @param initialValue - The initial value to start the accumulation. Required when the accumulator type differs from the element type. * @returns A `Promise` that resolves to the reduced value */ + reduce(reducer: (accumulator: T, value: T, index: number) => T): CoreJSPromise; - reduce(reducer: (accumulator: U, value: T, index: number) => U, initialValue: U): CoreJSPromise; /** * Reduces the elements of the iterator to a single value using the `reducer` function. * @param reducer - A function that combines two elements of the iterator - * @param initialValue - An optional initial value to start the reduction + * @param initialValue - The initial value to start the reduction * @returns A `Promise` that resolves to the reduced value */ - reduce(reducer: (accumulator: T, value: T, index: number) => T, initialValue?: T): CoreJSPromise; + reduce(reducer: (accumulator: T, value: T, index: number) => T, initialValue: T): CoreJSPromise; /** * Reduces the elements of the iterator to a single value using the `reducer` function. - * For maximum flexibility with any types. * @param reducer - A function that combines two elements of the iterator - * @param initialValue - An optional initial value to start the reduction + * @param initialValue - The initial value to start the accumulation. Required when the accumulator type differs from the element type. * @returns A `Promise` that resolves to the reduced value */ - reduce(reducer: (accumulator: any, value: T, index: number) => any, initialValue?: any): CoreJSPromise; + reduce(reducer: (accumulator: U, value: T, index: number) => U, initialValue: U): CoreJSPromise; /** * Checks if any value in the iterator matches a given `predicate` diff --git a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts index 011c03b1177d..fd9024de9779 100644 --- a/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/pure/proposals/async-iterator-helper.test.ts @@ -44,8 +44,12 @@ const r2 = find(aiton, (v: number, i: number) => v > 0); assertCoreJSPromiseLike(r2); const r3 = forEach(aiton, (v: number, i: number) => { }); assertCoreJSPromiseLike(r3); +const reduceNoInit = reduce(aiton, (acc: number, v: number) => acc + v); +assertCoreJSPromiseLike(reduceNoInit); const r4 = reduce(aiton, (acc: number, v: number, i: number) => acc + v, 0); assertCoreJSPromiseLike(r4); +const reduceDiffType = reduce(aiton, (acc: string, v: number) => acc + v, ''); +assertCoreJSPromiseLike(reduceDiffType); const r5 = some(aiton, (v: number, i: number) => v > 0); assertCoreJSPromiseLike(r5); const r6 = toArray(aiton); @@ -95,8 +99,12 @@ forEach(aitn); // @ts-expect-error map(aitn); // @ts-expect-error +map(aitos, (v: string, i: number) => v.length === 1, 'extra'); +// @ts-expect-error reduce(aitn); // @ts-expect-error +reduce(aiton, (acc: string, v: number) => acc + v, 1); +// @ts-expect-error some(aitn); // @ts-expect-error take(aitn); @@ -107,6 +115,3 @@ const s0 = toArray(aiton); assertCoreJSPromiseLike(s0); const f0 = find(aitos, (v: string, i: number) => v.length === 1); assertCoreJSPromiseLike(f0); - -// @ts-expect-error -map(aitos, (v: string, i: number) => v.length === 1, 'extra'); From babcdf3d3e0bf2fdc61ca3233676249554924c37 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 23:37:34 +0700 Subject: [PATCH 256/315] Fix Array#uniqueBy tests --- tests/type-definitions/pure/proposals/array-unique.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/type-definitions/pure/proposals/array-unique.test.ts b/tests/type-definitions/pure/proposals/array-unique.test.ts index bffb7e4b4864..16491b659180 100644 --- a/tests/type-definitions/pure/proposals/array-unique.test.ts +++ b/tests/type-definitions/pure/proposals/array-unique.test.ts @@ -23,8 +23,8 @@ arrayUniqueBy({}); arrayUniqueBy(''); // @ts-expect-error -numarrayUniqueBy(1); +arrayUniqueBy(1); // @ts-expect-error -numarrayUniqueBy({}); +arrayUniqueBy({}); // @ts-expect-error -numarrayUniqueBy(true); +arrayUniqueBy(true); From 032434832d3dcf9198891642bb86908db5d335f1 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 23:41:49 +0700 Subject: [PATCH 257/315] Fix JSON.parse type --- .../src/base/proposals/json-parse-with-source.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts index a5c131cacd0d..67fe7dac1355 100644 --- a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts +++ b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts @@ -29,7 +29,7 @@ interface JSON { // @type-options: no-constructor * containing the source text and position. * @returns Parsed JavaScript value. */ - parse(text: string, reviver?: (key: string, value: any, context: CoreJSReviverContext) => any): T; + parse(text: string, reviver?: (key: string, value: any, context: CoreJSReviverContext) => any): any; /** * Creates a RawJSON object from a JSON string. From 9b608b9ff79f9b89b8c8f816ddd4b6276d2103c7 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 23:44:46 +0700 Subject: [PATCH 258/315] Fix CoreJSReviverContext type --- .../src/base/proposals/json-parse-with-source.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts index 67fe7dac1355..edd47f6b777f 100644 --- a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts +++ b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts @@ -3,7 +3,7 @@ interface CoreJSReviverContext { // @type-options: no-extends, no-prefix readonly __brand: unique symbol; - source: string | undefined; + readonly source: string | undefined; } interface CoreJSRawJSON { // @type-options: no-extends, no-prefix From 35eeba525c708959374c763feac6f34467f1438d Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 23:47:35 +0700 Subject: [PATCH 259/315] Fix Immediate type --- .../src/base/web/efficient-script-yielding.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts b/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts index 50e65953c948..96e12d494c3b 100644 --- a/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts +++ b/packages/core-js-types/src/base/web/efficient-script-yielding.d.ts @@ -1,15 +1,13 @@ -type Immediate = number | object; - /** * Schedules the execution of a function as soon as possible after the current script yields. * @param handler - The function to execute. * @param args - Arguments to pass to the handler function. * @returns An identifier that can be used to cancel the scheduled function. */ -declare function setImmediate(handler: (...args: any[]) => void, ...args: any[]): Immediate; +declare function setImmediate(handler: (...args: any[]) => void, ...args: any[]): number | object; /** * Cancels a function scheduled with setImmediate. * @param immediate - The identifier of the scheduled function to cancel. */ -declare function clearImmediate(immediate: Immediate | undefined): void; // For compatibility with Node, `undefined` has been added +declare function clearImmediate(immediate: number | object | undefined): void; // For compatibility with Node, `undefined` has been added From 2029c7dd2c5ac966e207bef2fa64c140d382490c Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 23:50:30 +0700 Subject: [PATCH 260/315] Fix ReadonlyArray#findLast and ReadonlyArray#findLastIndex types --- .../src/base/proposals/array-find-from-last.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts index 7f8b5a156e27..fb1dfe687bd4 100644 --- a/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts +++ b/packages/core-js-types/src/base/proposals/array-find-from-last.d.ts @@ -39,8 +39,8 @@ interface ReadonlyArray { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T | undefined; + findLast(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S | undefined; + findLast(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -51,7 +51,7 @@ interface ReadonlyArray { // @type-options: no-export * @param thisArg - If provided, it will be used as this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; + findLastIndex(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): number; } interface Int8Array { // @type-options: no-export From 289da59fbdd925b40183d7bb321b408fe03e17af Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Thu, 19 Feb 2026 23:54:35 +0700 Subject: [PATCH 261/315] Fix Iterator.zip and Iterator.zipKeyed types --- .../core-js-types/src/base/proposals/iterator-joint.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts index 50d1fd3caf85..a67bc79861cb 100644 --- a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts @@ -6,6 +6,12 @@ interface ZipOptions { padding?: Iterable; } +interface ZipKeyedOptions { + mode?: 'shortest' | 'longest' | 'strict'; + + padding?: Record; +} + interface IteratorConstructor { // @type-options: no-extends /** * Takes an iterable of iterables and produces an iterable of arrays where position corresponds @@ -27,7 +33,7 @@ interface IteratorConstructor { // @type-options: no-extends * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. */ - zipKeyed }>(record: T, options?: ZipOptions): IteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; // @type-options: prefix-return-type + zipKeyed }>(record: T, options?: ZipKeyedOptions): IteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; // @type-options: prefix-return-type } declare var Iterator: IteratorConstructor; From aaff7cd52f442c4adb9ac5e8416b0fa4455e47e5 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 00:04:28 +0700 Subject: [PATCH 262/315] Fix PromiseLike type --- .../src/base/pure/core-js-types/promise-like.d.ts | 11 +++++++++++ .../src/base/pure/core-js-types/promise.d.ts | 6 ++++-- .../src/base/pure/proposals/iterator.d.ts | 13 ++----------- 3 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 packages/core-js-types/src/base/pure/core-js-types/promise-like.d.ts diff --git a/packages/core-js-types/src/base/pure/core-js-types/promise-like.d.ts b/packages/core-js-types/src/base/pure/core-js-types/promise-like.d.ts new file mode 100644 index 000000000000..f438eaebbc6f --- /dev/null +++ b/packages/core-js-types/src/base/pure/core-js-types/promise-like.d.ts @@ -0,0 +1,11 @@ +declare namespace CoreJS { + export interface CoreJSPromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled - The callback to execute when the Promise is resolved. + * @param onrejected - The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: ((value: T) => TResult1 | CoreJSPromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | CoreJSPromiseLike) | undefined | null): CoreJSPromiseLike; + } +} diff --git a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts index 4cebdda161bd..34db071f23fc 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts @@ -1,3 +1,5 @@ +/// + declare namespace CoreJS { export interface CoreJSPromise extends Promise {} @@ -10,7 +12,7 @@ declare namespace CoreJS { * a resolve callback used to resolve the promise with a value or the result of another promise, * and a reject callback used to reject the promise with a provided reason or error. */ - new(executor: (resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void) => void): CoreJSPromise; + new(executor: (resolve: (value: T | CoreJS.CoreJSPromiseLike) => void, reject: (reason?: any) => void) => void): CoreJSPromise; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -45,7 +47,7 @@ declare namespace CoreJS { * @param value - A promise. * @returns A promise whose internal state matches the provided promise. */ - resolve(value: T | PromiseLike): CoreJSPromise>; + resolve(value: T | CoreJS.CoreJSPromiseLike): CoreJSPromise>; } var CoreJSPromise: CoreJSPromiseConstructor; diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 2b1fd1b97697..891431858d49 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -1,6 +1,7 @@ /// /// /// +/// // Motivation: Has dependencies on internal types @@ -33,19 +34,9 @@ declare namespace CoreJS { inclusive?: boolean; } - interface CoreJSPromiseLike { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled - The callback to execute when the Promise is resolved. - * @param onrejected - The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: ((value: T) => TResult1 | CoreJSPromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | CoreJSPromiseLike) | undefined | null): CoreJSPromiseLike; - } - interface CoreJSAsyncIterator { next(...[value]: [] | [TNext]): CoreJS.CoreJSPromise>; - return?(value?: TReturn | CoreJSPromiseLike): CoreJS.CoreJSPromise>; + return?(value?: TReturn | CoreJS.CoreJSPromiseLike): CoreJS.CoreJSPromise>; throw?(e?: any): CoreJS.CoreJSPromise>; } From e0d40969bfd2bfae0d0e34490647a2ada69cf570 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 00:11:33 +0700 Subject: [PATCH 263/315] Fix Iterator pure types --- .../src/base/pure/proposals/iterator.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 891431858d49..df33545931e3 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -25,7 +25,7 @@ declare namespace CoreJS { interface ZipOptions { mode?: 'shortest' | 'longest' | 'strict'; - padding?: Iterable; + padding?: Iterable; } interface IteratorRangeOptions { @@ -164,7 +164,7 @@ declare namespace CoreJS { * Returns its input if the input already inherits from the built-in Iterator class. * @param value - An iterator or iterable object to convert a native iterator. */ - from(value: Iterator | Iterable): CoreJSIteratorObject; + from(value: Iterator | Iterable): CoreJSIteratorObject; /** * Takes an iterable of iterables and produces an iterable of arrays where position corresponds @@ -175,7 +175,7 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. */ - zip(iterables: Iterable>, options?: ZipOptions): CoreJSIteratorObject; + zip(iterables: Iterable>, options?: ZipOptions): CoreJSIteratorObject; /** * takes an object whose values are iterables and produces an iterable of objects where keys. @@ -186,7 +186,7 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. */ - zipKeyed }>(record: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; + zipKeyed }>(record: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; /** * Returns an iterator that generates a sequence of numbers within a range. @@ -215,7 +215,7 @@ declare namespace CoreJS { * @param iterators - The iterables to concatenate. * @returns An iterator yielding values from each input iterable in sequence. */ - concat(...iterators: Iterable[]): CoreJSIteratorObject; + concat(...iterators: Iterable[]): CoreJSIteratorObject; } var CoreJSIterator: CoreJSIteratorConstructor; From 5f88e5b9a2d0086b5c22f330782cefc6ac31ef1a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 00:16:23 +0700 Subject: [PATCH 264/315] Add exit code to coverage script --- tests/type-definitions/coverage.mjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/type-definitions/coverage.mjs b/tests/type-definitions/coverage.mjs index a552073e798a..080f67809691 100644 --- a/tests/type-definitions/coverage.mjs +++ b/tests/type-definitions/coverage.mjs @@ -5,10 +5,16 @@ const { red } = chalk; const MODULES_PATH = 'packages/core-js/modules/'; const Modules = AllModules.filter(it => it.match(/^(?:esnext|web)\./)); +let hasErrors = false; for (const moduleName of Modules) { const modulePath = path.join(MODULES_PATH, `${ moduleName }.js`); const content = await readFile(modulePath, 'utf8'); if (!/\/\/ (?:@types:|@no-types)/.test(content)) { echo(red('No types for module:'), path.resolve(modulePath)); + hasErrors = true; } } + +if (hasErrors) { + throw Error('Some modules have no types'); +} From 2fde2030318a7de06151928477b464429fb683ea Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 00:29:26 +0700 Subject: [PATCH 265/315] Fix regex --- scripts/build-entries-and-types/build-types-pure.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-entries-and-types/build-types-pure.mjs b/scripts/build-entries-and-types/build-types-pure.mjs index 400c78b0cfdc..893bbec0b43b 100644 --- a/scripts/build-entries-and-types/build-types-pure.mjs +++ b/scripts/build-entries-and-types/build-types-pure.mjs @@ -105,7 +105,7 @@ function processLines(lines) { } // Handle vars: prefix variable name, keep original type - if (/^\s*(?:declare)?\svar/.test(line)) { + if (/^\s*(?:declare\s+)?var/.test(line)) { const m = line.match(/^(?\s*)(?:declare\s+)?var\s+(?\w+):\s+(?\w+)/); return `${ m?.groups?.indent ?? '' }var ${ !options.noPrefix ? NAMESPACE : '' }${ m?.groups?.name ?? '' }: ${ m?.groups?.type };\n`; } From fc395e8781cd5c55b7343cd33820fc5b2eb51667 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 00:31:38 +0700 Subject: [PATCH 266/315] Fix Iterator.flatMap custom type fix --- .../src/base/proposals/iterator-helpers-custom.d.ts | 2 +- .../src/base/pure/proposals/iterator-helpers-custom.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts index 9eb42e21190d..b6943dfc70ba 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts @@ -9,7 +9,7 @@ declare namespace CoreJS { interface IteratorObject extends Iterator {} - export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => IteratorObject; + export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => IteratorObject; export type IteratorMap = (callback: (value: T, index: number) => U) => IteratorObject; diff --git a/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts index 840a6064780a..5ffb7ff1ef70 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts @@ -9,7 +9,7 @@ // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt declare namespace CoreJS { - export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => CoreJS.CoreJSIteratorObject; + export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => CoreJS.CoreJSIteratorObject; export type IteratorMap = (callback: (value: T, index: number) => U) => CoreJS.CoreJSIteratorObject; From 3f2b6703f5cb9df23ff43505e843039fcb58566d Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 00:34:06 +0700 Subject: [PATCH 267/315] Fix coverage script --- tests/type-definitions/coverage.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/type-definitions/coverage.mjs b/tests/type-definitions/coverage.mjs index 080f67809691..508bbad826ba 100644 --- a/tests/type-definitions/coverage.mjs +++ b/tests/type-definitions/coverage.mjs @@ -16,5 +16,5 @@ for (const moduleName of Modules) { } if (hasErrors) { - throw Error('Some modules have no types'); + throw new Error('Some modules have no types'); } From d2ede6e9c44986744d0641553fc0951c5de74c20 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 22:58:29 +0700 Subject: [PATCH 268/315] Make IteratorObject iterable --- .../core-js-types/src/base/core-js-types/iterator-object.d.ts | 4 +++- .../src/base/pure/core-js-types/iterator-object.d.ts | 4 +++- .../src/ts5-2/core-js-types/iterator-object.d.ts | 4 +++- .../src/ts5-2/pure/core-js-types/iterator-object.d.ts | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/core-js-types/src/base/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/base/core-js-types/iterator-object.d.ts index 74e9865b3c44..8356f1a668af 100644 --- a/packages/core-js-types/src/base/core-js-types/iterator-object.d.ts +++ b/packages/core-js-types/src/base/core-js-types/iterator-object.d.ts @@ -1 +1,3 @@ -interface IteratorObject extends Iterator {} +interface IteratorObject extends Iterator { + [Symbol.iterator](): IteratorObject; +} diff --git a/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts index 1e9fa0071c69..da206c3ddb0f 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/iterator-object.d.ts @@ -1,5 +1,7 @@ /// declare namespace CoreJS { - export interface CoreJSIteratorObject extends CoreJSIterator {} + export interface CoreJSIteratorObject extends CoreJSIterator { + [Symbol.iterator](): CoreJSIteratorObject; + } } diff --git a/packages/core-js-types/src/ts5-2/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/ts5-2/core-js-types/iterator-object.d.ts index 03a97c763925..a43c71459a8d 100644 --- a/packages/core-js-types/src/ts5-2/core-js-types/iterator-object.d.ts +++ b/packages/core-js-types/src/ts5-2/core-js-types/iterator-object.d.ts @@ -1,5 +1,7 @@ // Motivation: Iterator until TS 5.6 used undefined as TNext defaults declare namespace CoreJS { - export interface CoreJSIteratorObject extends Iterator {} + export interface CoreJSIteratorObject extends Iterator { + [Symbol.iterator](): CoreJSIteratorObject; + } } diff --git a/packages/core-js-types/src/ts5-2/pure/core-js-types/iterator-object.d.ts b/packages/core-js-types/src/ts5-2/pure/core-js-types/iterator-object.d.ts index 6584953be4b1..ae12b90ba61a 100644 --- a/packages/core-js-types/src/ts5-2/pure/core-js-types/iterator-object.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/core-js-types/iterator-object.d.ts @@ -3,5 +3,7 @@ // Motivation: Iterator until TS 5.6 used undefined as TNext defaults declare namespace CoreJS { - export interface CoreJSIteratorObject extends CoreJSIterator {} + export interface CoreJSIteratorObject extends CoreJSIterator { + [Symbol.iterator](): CoreJSIteratorObject; + } } From e9f979f23c52b3739995fb6bc5ab283cb6afccb5 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 23:08:06 +0700 Subject: [PATCH 269/315] Fix generics in AsyncIteratorObject & IteratorObject --- .../src/ts5-2/proposals/explicit-resource-management.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts index cd4ced374b72..836f1991c46c 100644 --- a/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/explicit-resource-management.d.ts @@ -193,9 +193,9 @@ interface AsyncDisposableStackConstructor { declare var AsyncDisposableStack: AsyncDisposableStackConstructor; -interface IteratorObject extends Disposable {} // @type-options: no-extends +interface IteratorObject extends Disposable {} // @type-options: no-extends -interface AsyncIteratorObject extends AsyncDisposable {} // @type-options: no-extends +interface AsyncIteratorObject extends AsyncDisposable {} // @type-options: no-extends interface AsyncIteratorConstructor {} From 21b4cf298e961c1f046c67ba510a9687884a01bc Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 23:10:46 +0700 Subject: [PATCH 270/315] Fix collection of from proposal types & tests --- .../src/base/proposals/collection-of-from.d.ts | 4 ++-- .../src/base/pure/proposals/collection-of-from.d.ts | 6 +++--- .../global/proposals/collection-of-from.test.ts | 8 ++++---- .../pure/proposals/collection-of-from.test.ts | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts index e49bc42aa1e2..a50fe7a2e5b4 100644 --- a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts @@ -9,7 +9,7 @@ interface MapConstructor { * @param thisArg - Value to use as this when executing mapFn. * @returns A new `Map` instance. */ - from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): Map; + from(source: Iterable<[K, V]>, mapFn?: (entry: [K, V], index: number) => [KOut, VOut], thisArg?: any): Map; /** * Creates a new `Map` instance from a variable number of arguments, @@ -52,7 +52,7 @@ interface WeakMapConstructor { * @param thisArg - Value to use as this when executing mapFn. * @returns A new `WeakMap` instance. */ - from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): WeakMap; + from(source: Iterable<[K, V]>, mapFn?: (entry: [K, V], index: number) => [KOut, VOut], thisArg?: any): WeakMap; /** * Creates a new `WeakMap` instance from a variable number of arguments, diff --git a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts index 516a5cf67072..e02fa3f268a1 100644 --- a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts @@ -17,7 +17,7 @@ declare namespace CoreJS { * @param thisArg - Value to use as this when executing mapFn. * @returns A new `Map` instance. */ - from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): CoreJS.CoreJSMap; + from(source: Iterable<[K, V]>, mapFn?: (entry: [K, V], index: number) => [KOut, VOut], thisArg?: any): CoreJS.CoreJSMap; /** * Creates a new `Map` instance from a variable number of arguments, @@ -60,13 +60,13 @@ declare namespace CoreJS { * @param thisArg - Value to use as this when executing mapFn. * @returns A new `WeakMap` instance. */ - from(source: Iterable<[K, V]>, mapFn?: (value: V, key: K) => VOut, thisArg?: any): CoreJS.CoreJSWeakMap; + from(source: Iterable<[K, V]>, mapFn?: (entry: [K, V], index: number) => [KOut, VOut], thisArg?: any): CoreJS.CoreJSWeakMap; /** * Creates a new `WeakMap` instance from a variable number of arguments, * where each pair of arguments is interpreted as a key and a value. * @param items - An even number of arguments representing key-value pairs. - * @returns A new `Weak` instance. + * @returns A new `WeakMap` instance. */ of(...items: [K, V][]): CoreJS.CoreJSWeakMap; } diff --git a/tests/type-definitions/global/proposals/collection-of-from.test.ts b/tests/type-definitions/global/proposals/collection-of-from.test.ts index 7d2b0a317e55..94b751ca2ada 100644 --- a/tests/type-definitions/global/proposals/collection-of-from.test.ts +++ b/tests/type-definitions/global/proposals/collection-of-from.test.ts @@ -10,11 +10,11 @@ import weakMapOf from 'core-js/full/weak-map/of'; const arrEntries: Array<[string, number]> = [['a', 1], ['b', 2]]; -const resNS: Map = mapFrom(arrEntries, v => String(v)); +const resNS: Map = mapFrom(arrEntries, ([k, v]) => [k, String(v)]); const resNS2: Map = mapOf(['a', 1], ['b', 2]); -const res: Map = Map.from(arrEntries, v => String(v)); -const res2: Map = Map.from(arrEntries, v => v > 1); +const res: Map = Map.from(arrEntries, ([k, v]) => [k, String(v)]); +const res2: Map = Map.from(arrEntries, ([k, v]) => [k, v > 1]); const res3: Map = Map.from(arrEntries); const res4: Map = Map.of(['a', 1], ['b', 2]); @@ -43,7 +43,7 @@ const resNS7: WeakMap = weakMapFrom(wmArr); const resNS8: WeakMap = weakMapOf([ws1, 1], [ws2, 2]); const res12: WeakMap = WeakMap.from(wmArr); -const res13: WeakMap = WeakMap.from(wmArr, v => Number(v.length)); +const res13: WeakMap = WeakMap.from(wmArr, ([k, v]) => [k, Number(v.length)]); const res14: WeakMap = WeakMap.of([ws1, 'a'], [ws2, 'b']); // @ts-expect-error diff --git a/tests/type-definitions/pure/proposals/collection-of-from.test.ts b/tests/type-definitions/pure/proposals/collection-of-from.test.ts index 5cf302d5a7de..c37e7952e81b 100644 --- a/tests/type-definitions/pure/proposals/collection-of-from.test.ts +++ b/tests/type-definitions/pure/proposals/collection-of-from.test.ts @@ -10,9 +10,9 @@ import { assertCoreJSMapLike, assertCoreJSSetLike, assertCoreJSWeakMapLike, asse const rm = mapFrom([[1, 'a'], [2, 'b']] as [number, string][]); assertCoreJSMapLike(rm); -const rm2 = mapFrom([[1, 10], [2, 20]] as [number, number][], (v: number, k: number) => v + k); +const rm2 = mapFrom([[1, 10], [2, 20]] as [number, number][], ([k, v]: [number, number]) => [k, v + k] as [number, number]); assertCoreJSMapLike(rm2); -mapFrom([[1, 10], [2, 20]] as [number, number][], function (this: { n: number }, v: number) { return v + this.n; }, { n: 2 }); +mapFrom([[1, 10], [2, 20]] as [number, number][], function (this: { n: number }, [k, v]: [number, number]) { return [k, v + this.n] as [number, number]; }, { n: 2 }); // @ts-expect-error mapFrom([['a', 1], ['b', 2]], (v: string, k: number) => v); // @ts-expect-error @@ -49,9 +49,9 @@ setOf({ foo: 'bar' }, 2); const rwm1 = weakMapFrom([[{ a: 1 }, 'x']] as [{ a: number }, string][]); assertCoreJSWeakMapLike<{ a: number }, string>(rwm1); -const rwm2 = weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], (v, k) => v.toString()); +const rwm2 = weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], ([k, v]) => [k, v.toString()] as [object, string]); assertCoreJSWeakMapLike(rwm2); -weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], function (this: { s: string }, v: number) { return this.s + v; }, { s: '-' }); +weakMapFrom([[{}, 1], [{}, 2]] as [object, number][], function (this: { s: string }, [k, v]: [object, number]) { return [k, this.s + v] as [object, string]; }, { s: '-' }); // @ts-expect-error weakMapFrom([[1, 2], [2, 3]]); // @ts-expect-error From b786585977450208f49ea8d69c789482eb0c5e11 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 23:12:47 +0700 Subject: [PATCH 271/315] Fix `Iterator.from` return type --- packages/core-js-types/src/base/proposals/iterator-helpers.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts index 00f6c184cc98..bce592dc12a6 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts @@ -103,7 +103,7 @@ interface IteratorConstructor { // @type-options: no-extends * Returns its input if the input already inherits from the built-in Iterator class. * @param value - An iterator or iterable object to convert a native iterator. */ - from(value: Iterator | Iterable): Iterator; + from(value: Iterator | Iterable): IteratorObject; } declare var Iterator: IteratorConstructor; From 004158100d79210d36e6f6c66fa31d0ad913ae24 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 23:16:07 +0700 Subject: [PATCH 272/315] Fix AsyncIterator types for pure versions --- .../proposals/async-iterator-helpers.d.ts | 14 ++++++------- .../proposals/async-iterator-helpers.d.ts | 20 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index 0a7e02b19b23..82fc9df1460f 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -13,7 +13,7 @@ declare namespace CoreJS { * @param iterable - An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` * @returns A new `AsyncIterator` instance */ - from(iterable: CoreJSAsyncIterable | Iterable | CoreJSAsyncIteratorObject): CoreJSAsyncIteratorObject; + from(iterable: CoreJSAsyncIterable | Iterable | CoreJSAsyncIteratorObject): CoreJSAsyncIteratorObject; } export interface CoreJSAsyncIterator { @@ -23,7 +23,7 @@ declare namespace CoreJS { * @param limit - The number of elements to drop * @returns A new `AsyncIterator` */ - drop(limit: number): CoreJSAsyncIteratorObject; + drop(limit: number): CoreJSAsyncIteratorObject; /** * Check if every value generated by the iterator passes the `predicate` function. @@ -37,8 +37,8 @@ declare namespace CoreJS { * @param predicate - A function that tests each element of the iterator * @returns A new `AsyncIterator` */ - filter(predicate: (value: T, index: number) => value is S): CoreJSAsyncIteratorObject; - filter(predicate: (value: T, index: number) => unknown): CoreJSAsyncIteratorObject; + filter(predicate: (value: T, index: number) => value is S): CoreJSAsyncIteratorObject; + filter(predicate: (value: T, index: number) => unknown): CoreJSAsyncIteratorObject; /** * Finds the first element in the iterator that satisfies the `predicate` function. @@ -67,7 +67,7 @@ declare namespace CoreJS { * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - map(mapper: (value: T, index: number) => U): CoreJSAsyncIteratorObject; + map(mapper: (value: T, index: number) => U): CoreJSAsyncIteratorObject; /** * Reduces the elements of the iterator to a single value using the `reducer` function. @@ -104,7 +104,7 @@ declare namespace CoreJS { * @param limit - The maximum number of elements to take * @returns A new `AsyncIterator` */ - take(limit: number): CoreJSAsyncIteratorObject; + take(limit: number): CoreJSAsyncIteratorObject; /** * Collects all elements from the iterator into an array. @@ -120,6 +120,6 @@ declare namespace CoreJS { * Creates an `AsyncIterator` from the current `Iterator` * @returns A new `AsyncIterator` instance */ - toAsync(): CoreJSAsyncIteratorObject; + toAsync(): CoreJSAsyncIteratorObject; } } diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts index cf0059b79435..72e67b57fbbd 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/async-iterator-helpers.d.ts @@ -14,17 +14,17 @@ declare namespace CoreJS { * @param iterable - An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` * @returns A new `AsyncIterator` instance */ - from(iterable: CoreJSAsyncIterable | Iterable | CoreJSAsyncIteratorObject): CoreJSAsyncIteratorObject; + from(iterable: CoreJSAsyncIterable | Iterable | CoreJSAsyncIteratorObject): CoreJSAsyncIteratorObject; } - export interface CoreJSAsyncIterator { + export interface CoreJSAsyncIterator { /** * Drops elements from the iterator until the limit is reached * @param limit - The number of elements to drop * @returns A new `AsyncIterator` */ - drop(limit: number): CoreJSAsyncIteratorObject; + drop(limit: number): CoreJSAsyncIteratorObject; /** * Check if every value generated by the iterator passes the `predicate` function. @@ -38,21 +38,23 @@ declare namespace CoreJS { * @param predicate - A function that tests each element of the iterator * @returns A new `AsyncIterator` */ - filter(predicate: (value: T, index: number) => boolean): CoreJSAsyncIteratorObject; + filter(predicate: (value: T, index: number) => value is S): CoreJSAsyncIteratorObject; + filter(predicate: (value: T, index: number) => unknown): CoreJSAsyncIteratorObject; /** * Finds the first element in the iterator that satisfies the `predicate` function. * @param predicate - A function that tests each element of the iterator * @returns A `Promise` that resolves to the found element, or `undefined` if no element satisfies the `predicate` */ - find(predicate: (value: T, index: number) => boolean): CoreJSPromise; + find(predicate: (value: T, index: number) => value is S): CoreJSPromise; + find(predicate: (value: T, index: number) => unknown): CoreJSPromise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - flatMap(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorObject; + flatMap(mapper: (value: T, index: number) => Iterable | CoreJSAsyncIterator | CoreJSAsyncIterable): CoreJSAsyncIteratorObject; /** * Executes a provided function once for each element in the iterator. @@ -66,7 +68,7 @@ declare namespace CoreJS { * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - map(mapper: (value: T, index: number) => any): CoreJSAsyncIteratorObject; + map(mapper: (value: T, index: number) => U): CoreJSAsyncIteratorObject; /** * Reduces the elements of the iterator to a single value using the `reducer` function. @@ -105,7 +107,7 @@ declare namespace CoreJS { * @param limit - The maximum number of elements to take * @returns A new `AsyncIterator` */ - take(limit: number): CoreJSAsyncIteratorObject; + take(limit: number): CoreJSAsyncIteratorObject; /** * Collects all elements from the iterator into an array. @@ -121,6 +123,6 @@ declare namespace CoreJS { * Creates an `AsyncIterator` from the current `Iterator` * @returns A new `AsyncIterator` instance */ - toAsync(): CoreJSAsyncIteratorObject; + toAsync(): CoreJSAsyncIteratorObject; } } From faf394b74f5fb70f99f1b5b78b0aa80b50ab23a1 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 23:17:31 +0700 Subject: [PATCH 273/315] Add separated type ZipKeyedOptions for Iterator.zipKeyed method --- .../core-js-types/src/base/pure/proposals/iterator.d.ts | 8 +++++++- .../core-js-types/src/ts5-2/pure/proposals/iterator.d.ts | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index df33545931e3..3e13b8948323 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -28,6 +28,12 @@ declare namespace CoreJS { padding?: Iterable; } + interface ZipKeyedOptions { + mode?: 'shortest' | 'longest' | 'strict'; + + padding?: Record; + } + interface IteratorRangeOptions { step?: T; @@ -186,7 +192,7 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. */ - zipKeyed }>(record: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; + zipKeyed }>(record: T, options?: ZipKeyedOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; /** * Returns an iterator that generates a sequence of numbers within a range. diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index b79ec6ddac1e..8f8f9c67e244 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -28,6 +28,12 @@ declare namespace CoreJS { padding?: Iterable; } + interface ZipKeyedOptions { + mode?: 'shortest' | 'longest' | 'strict'; + + padding?: Record; + } + interface IteratorRangeOptions { step?: T; @@ -196,7 +202,7 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. */ - zipKeyed }>(record: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; + zipKeyed }>(record: T, options?: ZipKeyedOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; /** * Returns an iterator that generates a sequence of numbers within a range. From 9b02a8a46efe828c1a143a66a536261aa48b8737 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 23:42:15 +0700 Subject: [PATCH 274/315] Fix different PromiseLike types in AsyncIterator pure --- .../src/base/pure/core-js-types/async-iterator.d.ts | 3 ++- packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts b/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts index 99e92cd2df55..bfc5044c3319 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts @@ -1,10 +1,11 @@ /// +/// declare namespace CoreJS { export interface CoreJSAsyncIterator { next(...[value]: [] | [TNext]): CoreJS.CoreJSPromise>; - return?(value?: TReturn | PromiseLike): CoreJS.CoreJSPromise>; + return?(value?: TReturn | CoreJS.CoreJSPromiseLike): CoreJS.CoreJSPromise>; throw?(e?: any): CoreJS.CoreJSPromise>; } diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index 8f8f9c67e244..4e85786b5dd6 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -1,5 +1,6 @@ /// /// +/// /// // Motivation: Has dependencies on internal types @@ -52,7 +53,7 @@ declare namespace CoreJS { interface CoreJSAsyncIterator { next(...[value]: [] | [TNext]): CoreJS.CoreJSPromise>; - return?(value?: TReturn | CoreJSPromiseLike): CoreJS.CoreJSPromise>; + return?(value?: TReturn | CoreJS.CoreJSPromiseLike): CoreJS.CoreJSPromise>; throw?(e?: any): CoreJS.CoreJSPromise>; } From 42f3cb909972f8ea0d71dcdd94fb5a8cc2121759 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 23:49:16 +0700 Subject: [PATCH 275/315] Fix generics in Promise.allKeyed & Promise.allSettledKeyed types --- .../core-js-types/src/base/proposals/await-dictionary.d.ts | 4 ++-- .../src/base/pure/proposals/await-dictionary.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts index 4c6237a25fe9..b6ea3c125a9c 100644 --- a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts @@ -9,7 +9,7 @@ interface PromiseConstructor { * @param promises - An object of promises * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. */ - allKeyed>>(promises: D): Promise<{ [k in keyof D]: Awaited }>; + allKeyed>>(promises: D): Promise<{ [k in keyof D]: Awaited }>; /** * Takes an object whose values are promises and returns a single `Promise` that resolves @@ -18,7 +18,7 @@ interface PromiseConstructor { * @returns A new Promise that resolves to an object with the same keys as the input object, * where each key maps to the settlement result (`{ status, value }` or `{ status, reason }`) of the corresponding promise. */ - allSettledKeyed>>(promises: D): Promise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; + allSettledKeyed>>(promises: D): Promise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; } declare var Promise: PromiseConstructor; diff --git a/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts index 1e94c9d386fb..f7f31cc59d8e 100644 --- a/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts @@ -13,7 +13,7 @@ declare namespace CoreJS { * @param promises - An object of promises * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. */ - allKeyed>>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: Awaited }>; + allKeyed>>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: Awaited }>; /** * Takes an object whose values are promises and returns a single `Promise` that resolves @@ -22,7 +22,7 @@ declare namespace CoreJS { * @returns A new Promise that resolves to an object with the same keys as the input object, * where each key maps to the settlement result (`{ status, value }` or `{ status, reason }`) of the corresponding promise. */ - allSettledKeyed>>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; + allSettledKeyed>>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; } var CoreJSPromise: CoreJSPromiseConstructor; From 60155888545a9e7845fe504f064eb477dacc670c Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 23:53:11 +0700 Subject: [PATCH 276/315] Fix String#replaceAll TSDocs --- .../core-js-types/src/base/proposals/string-replace-all.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/proposals/string-replace-all.d.ts index 231b67269c4c..005d3712034f 100644 --- a/packages/core-js-types/src/base/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/base/proposals/string-replace-all.d.ts @@ -8,8 +8,8 @@ interface String { // @type-options: no-redefine /** * Replace all instances of a substring in a string, using a regular expression or search string. * @param searchValue - A string to search for. - * @param replacer - A string containing the text to replace for every successful match of searchValue in this string. - * @param replacer - A function that returns the replacement text. + * @param replacer - A string containing the text to replace for every successful match of searchValue in this string + * - or function that returns the replacement text. */ replaceAll(searchValue: string | RegExp, replacer: string | ((substring: string, ...args: any[]) => string)): string; } From ae8e9e27040553b12825fd1e84c63604da5bdc75 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 23:54:00 +0700 Subject: [PATCH 277/315] Fix Array#uniqueBy types --- .../src/base/proposals/array-unique.d.ts | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/array-unique.d.ts b/packages/core-js-types/src/base/proposals/array-unique.d.ts index 3c9e18fe9a53..74d16cb72c90 100644 --- a/packages/core-js-types/src/base/proposals/array-unique.d.ts +++ b/packages/core-js-types/src/base/proposals/array-unique.d.ts @@ -7,7 +7,7 @@ interface Array { // @type-options: no-redefine * or a property key to compare the value from each item * @returns A new `Array` with unique items */ - uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; + uniqueBy(resolver?: keyof T | ((value: T) => unknown)): Array; } interface ReadonlyArray { // @type-options: no-export @@ -17,7 +17,7 @@ interface ReadonlyArray { // @type-options: no-export * or a property key to compare the value from each item * @returns A new `Array` with unique items */ - uniqueBy(resolver?: keyof T | ((value: T) => any)): Array; + uniqueBy(resolver?: keyof T | ((value: T) => unknown)): Array; } interface Int8Array { // @type-options: no-export @@ -27,7 +27,7 @@ interface Int8Array { // @type-options: no-export * or a property key to compare the value from each item * @returns A new `Array` with unique items */ - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int8Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Int8Array; } interface Uint8Array { // @type-options: no-export @@ -37,7 +37,7 @@ interface Uint8Array { // @type-options: no-export * or a property key to compare the value from each item * @returns A new `Array` with unique items */ - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Uint8Array; } interface Uint8ClampedArray { // @type-options: no-export @@ -47,7 +47,7 @@ interface Uint8ClampedArray { // @type-options: no-export * or a property key to compare the value from each item * @returns A new `Array` with unique items */ - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint8ClampedArray; + uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Uint8ClampedArray; } interface Int16Array { // @type-options: no-export @@ -57,7 +57,7 @@ interface Int16Array { // @type-options: no-export * or a property key to compare the value from each item * @returns A new `Array` with unique items */ - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int16Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Int16Array; } interface Uint16Array { // @type-options: no-export @@ -67,7 +67,7 @@ interface Uint16Array { // @type-options: no-export * or a property key to compare the value from each item * @returns A new `Array` with unique items */ - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint16Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Uint16Array; } interface Int32Array { // @type-options: no-export @@ -77,7 +77,7 @@ interface Int32Array { // @type-options: no-export * or a property key to compare the value from each item * @returns A new `Array` with unique items */ - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Int32Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Int32Array; } interface Uint32Array { // @type-options: no-export @@ -87,7 +87,7 @@ interface Uint32Array { // @type-options: no-export * or a property key to compare the value from each item * @returns A new `Array` with unique items */ - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Uint32Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Uint32Array; } interface Float32Array { // @type-options: no-export @@ -97,7 +97,7 @@ interface Float32Array { // @type-options: no-export * or a property key to compare the value from each item * @returns A new `Array` with unique items */ - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float32Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Float32Array; } interface Float64Array { // @type-options: no-export @@ -107,7 +107,7 @@ interface Float64Array { // @type-options: no-export * or a property key to compare the value from each item * @returns A new `Array` with unique items */ - uniqueBy(resolver?: PropertyKey | ((value: number) => any)): Float64Array; + uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Float64Array; } interface BigInt64Array { // @type-options: no-export @@ -117,7 +117,7 @@ interface BigInt64Array { // @type-options: no-export * or a property key to compare the value from each item * @returns A new `Array` with unique items */ - uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigInt64Array; + uniqueBy(resolver?: PropertyKey | ((value: bigint) => unknown)): BigInt64Array; } interface BigUint64Array { // @type-options: no-export @@ -127,5 +127,5 @@ interface BigUint64Array { // @type-options: no-export * or a property key to compare the value from each item * @returns A new `Array` with unique items */ - uniqueBy(resolver?: PropertyKey | ((value: bigint) => any)): BigUint64Array; + uniqueBy(resolver?: PropertyKey | ((value: bigint) => unknown)): BigUint64Array; } From 9ed3ae1f614d495cc5fd279841edb6b9d5b75949 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Fri, 20 Feb 2026 23:54:24 +0700 Subject: [PATCH 278/315] Fix import namespaces --- tests/type-definitions/global/proposals/error-cause.test.ts | 2 +- .../global/proposals/explicit-resource-management.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/type-definitions/global/proposals/error-cause.test.ts b/tests/type-definitions/global/proposals/error-cause.test.ts index 2391674bce08..95f33ef3bfdc 100644 --- a/tests/type-definitions/global/proposals/error-cause.test.ts +++ b/tests/type-definitions/global/proposals/error-cause.test.ts @@ -1,4 +1,4 @@ -import 'core-js/full'; +import 'core-js/es'; const prevError = new Error('Prev error'); diff --git a/tests/type-definitions/global/proposals/explicit-resource-management.test.ts b/tests/type-definitions/global/proposals/explicit-resource-management.test.ts index be7f6d605cc6..2ca8c02d5bd0 100644 --- a/tests/type-definitions/global/proposals/explicit-resource-management.test.ts +++ b/tests/type-definitions/global/proposals/explicit-resource-management.test.ts @@ -1,4 +1,4 @@ -import 'core-js/full'; +import 'core-js/es'; const d: symbol = Symbol.dispose; const ad: symbol = Symbol.asyncDispose; From 30cb923bca8c95e47712a9476657cd02a5fb7e38 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 21 Feb 2026 00:07:30 +0700 Subject: [PATCH 279/315] Add Promise.any & Promise.try to pure types --- .../src/base/pure/core-js-types/promise.d.ts | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts index 34db071f23fc..ed5389c5dbc3 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts @@ -1,6 +1,17 @@ /// +// For ensuring compatibility with TypeScript standard types, this code is aligned with: +// https://github.com/microsoft/TypeScript/blob/347254895823a36a1b1b1c80471422da54ad77de/src/lib/es2021.promise.d.ts#L16 +// https://github.com/microsoft/TypeScript/blob/347254895823a36a1b1b1c80471422da54ad77de/src/lib/es2025.promise.d.ts#L4 +// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt + declare namespace CoreJS { + interface CoreJSPromiseWithResolvers { + promise: CoreJSPromise; + resolve: (value: T | CoreJS.CoreJSPromiseLike) => void; + reject: (reason?: any) => void; + } + export interface CoreJSPromise extends Promise {} export interface CoreJSPromiseConstructor { @@ -48,6 +59,36 @@ declare namespace CoreJS { * @returns A promise whose internal state matches the provided promise. */ resolve(value: T | CoreJS.CoreJSPromiseLike): CoreJSPromise>; + + // allSettled, any, try + + /** + * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. + * @param values An array or iterable of Promises. + * @returns A new Promise. + */ + any(values: T): CoreJSPromise>; + /** + * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. + * @param values An array or iterable of Promises. + * @returns A new Promise. + */ + any(values: Iterable>): CoreJSPromise>; + + /** + * Takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result + * in a Promise. + * + * @param callbackFn A function that is called synchronously. It can do anything: either return + * a value, throw an error, or return a promise. + * @param args Additional arguments, that will be passed to the callback. + * + * @returns A Promise that is: + * - Already fulfilled, if the callback synchronously returns a value. + * - Already rejected, if the callback synchronously throws an error. + * - Asynchronously fulfilled or rejected, if the callback returns a promise. + */ + try(callbackFn: (...args: U) => T | CoreJS.CoreJSPromiseLike, ...args: U): CoreJSPromise>; } var CoreJSPromise: CoreJSPromiseConstructor; From 4eaa688f5adfa375f9244a7d6f3ed7dc4eb789f5 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 21 Feb 2026 00:16:50 +0700 Subject: [PATCH 280/315] Fix package.json for core-js-types --- packages/core-js-types/package.tpl.json | 1 - scripts/build-entries-and-types/build-types.mjs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/core-js-types/package.tpl.json b/packages/core-js-types/package.tpl.json index bb20757fcbbc..8022d5324de9 100644 --- a/packages/core-js-types/package.tpl.json +++ b/packages/core-js-types/package.tpl.json @@ -25,6 +25,5 @@ "email": "zloirock@zloirock.ru", "url": "http://zloirock.ru" }, - "types": "./index.d.ts", "sideEffects": false } diff --git a/scripts/build-entries-and-types/build-types.mjs b/scripts/build-entries-and-types/build-types.mjs index a69fd7aa6e3c..bf1fdccb8b5b 100644 --- a/scripts/build-entries-and-types/build-types.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -261,12 +261,12 @@ async function buildPackageJson(breakpoints, namespaces) { const packageJson = await readJson(PACKAGE_TEMPLATE); packageJson.typesVersions = {}; - packageJson.typesVersions['*'] = { '*': [`./ts${ defaultBreakpoint }/*`] }; breakpoints.forEach(breakpoint => { packageJson.typesVersions[`>=${ breakpoint }`] = { '*': [`./ts${ breakpoint.toString().replace('.', '-') }/*`], }; }); + packageJson.typesVersions['*'] = { '*': [`./ts${ defaultBreakpoint }/*`] }; packageJson.exports = {}; Object.entries(namespaces).forEach(([namespace, options]) => { From 26da940b39d2b86fed4c2c8c738f2eaf05d5ea9e Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 21 Feb 2026 00:24:21 +0700 Subject: [PATCH 281/315] Fix Promise TSDocs --- .../src/base/pure/core-js-types/promise.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts index ed5389c5dbc3..0359efff6126 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts @@ -64,13 +64,13 @@ declare namespace CoreJS { /** * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. - * @param values An array or iterable of Promises. + * @param values - An array or iterable of Promises. * @returns A new Promise. */ any(values: T): CoreJSPromise>; /** * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. - * @param values An array or iterable of Promises. + * @param values - An array or iterable of Promises. * @returns A new Promise. */ any(values: Iterable>): CoreJSPromise>; @@ -79,9 +79,9 @@ declare namespace CoreJS { * Takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result * in a Promise. * - * @param callbackFn A function that is called synchronously. It can do anything: either return + * @param callbackFn - A function that is called synchronously. It can do anything: either return * a value, throw an error, or return a promise. - * @param args Additional arguments, that will be passed to the callback. + * @param args - Additional arguments, that will be passed to the callback. * * @returns A Promise that is: * - Already fulfilled, if the callback synchronously returns a value. From d77686324ff5d5b6c2d0990d81fb523246ad3fed Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 21 Feb 2026 02:08:25 +0700 Subject: [PATCH 282/315] Fix collection of-from TSDocs --- .../src/base/proposals/collection-of-from.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts index a50fe7a2e5b4..65666cbba41c 100644 --- a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts @@ -2,9 +2,9 @@ interface MapConstructor { /** - * Creates a new `Map` instance from an iterable or array-like object of [key, value] pairs. + * Creates a new `Map` instance from an iterable object of [key, value] pairs. * Optionally, applies a mapping function to each pair. - * @param source - Iterable or array-like object of [key, value] pairs. + * @param source - Iterable object of [key, value] pairs. * @param mapFn - Function to call on every [key, value] pair before adding to the `Map`. * @param thisArg - Value to use as this when executing mapFn. * @returns A new `Map` instance. @@ -45,9 +45,9 @@ declare var Set: SetConstructor; interface WeakMapConstructor { /** - * Creates a new `WeakMap` instance from an iterable or array-like object of [key, value] pairs. + * Creates a new `WeakMap` instance from an iterable object of [key, value] pairs. * Optionally, applies a mapping function to each pair. - * @param source - Iterable or array-like object of [key, value] pairs. + * @param source - Iterable object of [key, value] pairs. * @param mapFn - Function to call on every [key, value] pair before adding to the `WeakMap`. * @param thisArg - Value to use as this when executing mapFn. * @returns A new `WeakMap` instance. From 67e7be8547434b252573d5f762257723c5145886 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 21 Feb 2026 02:29:02 +0700 Subject: [PATCH 283/315] Remove custom PromiseLike because it exists in ES6 --- .../src/base/proposals/async-iterator-helpers.d.ts | 2 +- .../src/base/pure/core-js-types/async-iterator.d.ts | 3 +-- .../src/base/pure/core-js-types/promise-like.d.ts | 11 ----------- .../src/base/pure/core-js-types/promise.d.ts | 12 +++++------- .../base/pure/proposals/async-iterator-helpers.d.ts | 2 +- .../src/base/pure/proposals/iterator.d.ts | 3 +-- .../src/ts5-2/pure/proposals/iterator.d.ts | 12 +----------- 7 files changed, 10 insertions(+), 35 deletions(-) delete mode 100644 packages/core-js-types/src/base/pure/core-js-types/promise-like.d.ts diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index ec927ff9f364..c77b9853c502 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -56,7 +56,7 @@ interface AsyncIterator { * @param callbackFn - A function that is called for each element of the iterator * @returns A `Promise` that resolves when all elements have been processed */ - forEach(callbackFn: (value: T, index: number) => void): Promise; + forEach(callbackFn: (value: T, index: number) => void | PromiseLike): Promise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. diff --git a/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts b/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts index bfc5044c3319..99e92cd2df55 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/async-iterator.d.ts @@ -1,11 +1,10 @@ /// -/// declare namespace CoreJS { export interface CoreJSAsyncIterator { next(...[value]: [] | [TNext]): CoreJS.CoreJSPromise>; - return?(value?: TReturn | CoreJS.CoreJSPromiseLike): CoreJS.CoreJSPromise>; + return?(value?: TReturn | PromiseLike): CoreJS.CoreJSPromise>; throw?(e?: any): CoreJS.CoreJSPromise>; } diff --git a/packages/core-js-types/src/base/pure/core-js-types/promise-like.d.ts b/packages/core-js-types/src/base/pure/core-js-types/promise-like.d.ts deleted file mode 100644 index f438eaebbc6f..000000000000 --- a/packages/core-js-types/src/base/pure/core-js-types/promise-like.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -declare namespace CoreJS { - export interface CoreJSPromiseLike { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled - The callback to execute when the Promise is resolved. - * @param onrejected - The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: ((value: T) => TResult1 | CoreJSPromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | CoreJSPromiseLike) | undefined | null): CoreJSPromiseLike; - } -} diff --git a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts index 0359efff6126..8bc5d64abeb4 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts @@ -1,5 +1,3 @@ -/// - // For ensuring compatibility with TypeScript standard types, this code is aligned with: // https://github.com/microsoft/TypeScript/blob/347254895823a36a1b1b1c80471422da54ad77de/src/lib/es2021.promise.d.ts#L16 // https://github.com/microsoft/TypeScript/blob/347254895823a36a1b1b1c80471422da54ad77de/src/lib/es2025.promise.d.ts#L4 @@ -8,7 +6,7 @@ declare namespace CoreJS { interface CoreJSPromiseWithResolvers { promise: CoreJSPromise; - resolve: (value: T | CoreJS.CoreJSPromiseLike) => void; + resolve: (value: T | PromiseLike) => void; reject: (reason?: any) => void; } @@ -23,7 +21,7 @@ declare namespace CoreJS { * a resolve callback used to resolve the promise with a value or the result of another promise, * and a reject callback used to reject the promise with a provided reason or error. */ - new(executor: (resolve: (value: T | CoreJS.CoreJSPromiseLike) => void, reject: (reason?: any) => void) => void): CoreJSPromise; + new(executor: (resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void) => void): CoreJSPromise; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -58,7 +56,7 @@ declare namespace CoreJS { * @param value - A promise. * @returns A promise whose internal state matches the provided promise. */ - resolve(value: T | CoreJS.CoreJSPromiseLike): CoreJSPromise>; + resolve(value: T | PromiseLike): CoreJSPromise>; // allSettled, any, try @@ -73,7 +71,7 @@ declare namespace CoreJS { * @param values - An array or iterable of Promises. * @returns A new Promise. */ - any(values: Iterable>): CoreJSPromise>; + any(values: Iterable>): CoreJSPromise>; /** * Takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result @@ -88,7 +86,7 @@ declare namespace CoreJS { * - Already rejected, if the callback synchronously throws an error. * - Asynchronously fulfilled or rejected, if the callback returns a promise. */ - try(callbackFn: (...args: U) => T | CoreJS.CoreJSPromiseLike, ...args: U): CoreJSPromise>; + try(callbackFn: (...args: U) => T | PromiseLike, ...args: U): CoreJSPromise>; } var CoreJSPromise: CoreJSPromiseConstructor; diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index 82fc9df1460f..73ae47f244df 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -60,7 +60,7 @@ declare namespace CoreJS { * @param callbackFn - A function that is called for each element of the iterator * @returns A `Promise` that resolves when all elements have been processed */ - forEach(callbackFn: (value: T, index: number) => void): CoreJSPromise; + forEach(callbackFn: (value: T, index: number) => void | PromiseLike): CoreJSPromise; /** * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 3e13b8948323..c4a501ebfdc0 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -1,7 +1,6 @@ /// /// /// -/// // Motivation: Has dependencies on internal types @@ -42,7 +41,7 @@ declare namespace CoreJS { interface CoreJSAsyncIterator { next(...[value]: [] | [TNext]): CoreJS.CoreJSPromise>; - return?(value?: TReturn | CoreJS.CoreJSPromiseLike): CoreJS.CoreJSPromise>; + return?(value?: TReturn | PromiseLike): CoreJS.CoreJSPromise>; throw?(e?: any): CoreJS.CoreJSPromise>; } diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index 4e85786b5dd6..a7a49cf6139f 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -41,19 +41,9 @@ declare namespace CoreJS { inclusive?: boolean; } - interface CoreJSPromiseLike { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled - The callback to execute when the Promise is resolved. - * @param onrejected - The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: ((value: T) => TResult1 | CoreJSPromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | CoreJSPromiseLike) | undefined | null): CoreJSPromiseLike; - } - interface CoreJSAsyncIterator { next(...[value]: [] | [TNext]): CoreJS.CoreJSPromise>; - return?(value?: TReturn | CoreJS.CoreJSPromiseLike): CoreJS.CoreJSPromise>; + return?(value?: TReturn | PromiseLike): CoreJS.CoreJSPromise>; throw?(e?: any): CoreJS.CoreJSPromise>; } From a0d53e1730725942fdc637756d1c52101cd11262 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 21 Feb 2026 02:29:38 +0700 Subject: [PATCH 284/315] Add overload for custom WeakSet --- packages/core-js-types/src/base/pure/core-js-types/weak-set.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core-js-types/src/base/pure/core-js-types/weak-set.d.ts b/packages/core-js-types/src/base/pure/core-js-types/weak-set.d.ts index eaad289a7321..22661eb40969 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/weak-set.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/weak-set.d.ts @@ -5,6 +5,7 @@ declare namespace CoreJS { readonly prototype: CoreJSWeakSet; new(values?: readonly T[] | null): CoreJSWeakSet; + new(iterable: Iterable): CoreJSWeakSet; } var CoreJSWeakSet: CoreJSWeakSetConstructor; From c9f0d34bfae015e339cd305e70f2133aa46ca244 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 21 Feb 2026 02:35:52 +0700 Subject: [PATCH 285/315] Add overload for Iterator.zip to keep generic types --- packages/core-js-types/src/base/proposals/iterator-joint.d.ts | 1 + packages/core-js-types/src/base/pure/proposals/iterator.d.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts index a67bc79861cb..4a7b418c9908 100644 --- a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts @@ -22,6 +22,7 @@ interface IteratorConstructor { // @type-options: no-extends * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. */ + zip[]>(iterables: T, options?: ZipOptions): IteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never }, undefined, unknown>; // @type-options: prefix-return-type zip(iterables: Iterable>, options?: ZipOptions): IteratorObject; // @type-options: prefix-return-type /** diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index c4a501ebfdc0..3b369ae1dbdf 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -180,6 +180,7 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. */ + zip[]>(iterables: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never }, undefined, unknown>; zip(iterables: Iterable>, options?: ZipOptions): CoreJSIteratorObject; /** From a47a04832304614d9cf75664f437189e6bb446ef Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 21 Feb 2026 02:44:07 +0700 Subject: [PATCH 286/315] Make readonly rawJSON property in RawJSON type --- .../src/base/proposals/json-parse-with-source.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts index edd47f6b777f..2d56d5e072aa 100644 --- a/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts +++ b/packages/core-js-types/src/base/proposals/json-parse-with-source.d.ts @@ -9,7 +9,7 @@ interface CoreJSReviverContext { // @type-options: no-extends, no-prefix interface CoreJSRawJSON { // @type-options: no-extends, no-prefix readonly __brand: unique symbol; - rawJSON: string; + readonly rawJSON: string; } interface JSON { // @type-options: no-constructor From d6d5e04fbfafa00482c2df2c8854a4bbceaaef90 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 21 Feb 2026 02:47:47 +0700 Subject: [PATCH 287/315] Add type guard to symbol predicates proposal --- .../core-js-types/src/base/proposals/symbol-predicates.d.ts | 4 ++-- packages/core-js-types/src/base/pure/proposals/symbol.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts b/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts index 29db7391b64c..a1ad05b69313 100644 --- a/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts +++ b/packages/core-js-types/src/base/proposals/symbol-predicates.d.ts @@ -5,11 +5,11 @@ interface SymbolConstructor { * Determines whether the given value is a registered symbol. * @param value - The value to check. */ - isRegisteredSymbol(value: any): boolean; + isRegisteredSymbol(value: unknown): value is symbol; /** * Determines whether the given value is a well-known symbol. * @param value - The value to check. */ - isWellKnownSymbol(value: any): boolean; + isWellKnownSymbol(value: unknown): value is symbol; } diff --git a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts index e9d2c3480908..dad0078c4657 100644 --- a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts @@ -58,13 +58,13 @@ declare namespace CoreJS { * Determines whether the given value is a registered symbol. * @param value - The value to be checked. */ - isRegisteredSymbol(value: any): boolean; + isRegisteredSymbol(value: unknown): value is symbol; /** * Determines whether the given value is a well-known symbol. * @param value - The value to be checked. */ - isWellKnownSymbol(value: any): boolean; + isWellKnownSymbol(value: unknown): value is symbol; /** * A method that returns the default async iterator for an object. Called by the semantics of From 30fc406d75e9bd5c497dae92f1b23caadffc0200 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 21 Feb 2026 02:53:35 +0700 Subject: [PATCH 288/315] Fix target & lib rules in test runner --- tests/type-definitions/runner.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index fa9a590f0d0f..88856053b294 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -55,11 +55,11 @@ const LIBS = [ ]; const TARGET_RULES = { - es6: ['**/*es2018*test.ts'], + es6: '**/*es2018*test.ts', }; const LIB_RULES = { - dom: ['**/*dom*test.ts'], + dom: '**/*dom*test.ts', }; let tested = 0; From eda425429424f5705443ee3f42825e694d8db1cb Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 21 Feb 2026 03:18:53 +0700 Subject: [PATCH 289/315] Add support for primitives in Promise.allKeyed & Promise.allSettledKeyed types & add tests --- .../src/base/proposals/await-dictionary.d.ts | 4 +-- .../base/pure/proposals/await-dictionary.d.ts | 4 +-- .../global/proposals/await-dictionary.test.ts | 15 ++++++++--- .../pure/proposals/await-dictionary.test.ts | 26 ++++++++++++++++--- tests/unit-global/esnext.promise.all-keyed.js | 14 ++++++++++ .../esnext.promise.all-settled-keyed.js | 14 ++++++++++ tests/unit-pure/esnext.promise.all-keyed.js | 14 ++++++++++ .../esnext.promise.all-settled-keyed.js | 14 ++++++++++ 8 files changed, 93 insertions(+), 12 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts index b6ea3c125a9c..6617a77817bf 100644 --- a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts @@ -9,7 +9,7 @@ interface PromiseConstructor { * @param promises - An object of promises * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. */ - allKeyed>>(promises: D): Promise<{ [k in keyof D]: Awaited }>; + allKeyed>(promises: D): Promise<{ [k in keyof D]: Awaited }>; /** * Takes an object whose values are promises and returns a single `Promise` that resolves @@ -18,7 +18,7 @@ interface PromiseConstructor { * @returns A new Promise that resolves to an object with the same keys as the input object, * where each key maps to the settlement result (`{ status, value }` or `{ status, reason }`) of the corresponding promise. */ - allSettledKeyed>>(promises: D): Promise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; + allSettledKeyed>(promises: D): Promise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; } declare var Promise: PromiseConstructor; diff --git a/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts index f7f31cc59d8e..08b2a2f8208b 100644 --- a/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts @@ -13,7 +13,7 @@ declare namespace CoreJS { * @param promises - An object of promises * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. */ - allKeyed>>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: Awaited }>; + allKeyed>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: Awaited }>; /** * Takes an object whose values are promises and returns a single `Promise` that resolves @@ -22,7 +22,7 @@ declare namespace CoreJS { * @returns A new Promise that resolves to an object with the same keys as the input object, * where each key maps to the settlement result (`{ status, value }` or `{ status, reason }`) of the corresponding promise. */ - allSettledKeyed>>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; + allSettledKeyed>(promises: D): Promise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; } var CoreJSPromise: CoreJSPromiseConstructor; diff --git a/tests/type-definitions/global/proposals/await-dictionary.test.ts b/tests/type-definitions/global/proposals/await-dictionary.test.ts index a094efd2db94..e467bb962b72 100644 --- a/tests/type-definitions/global/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/global/proposals/await-dictionary.test.ts @@ -23,6 +23,11 @@ const resNS2: Promise<{ a: number, b: string, c: boolean }> = $Promise.allKeyed( const resNS3: Promise<{ [sym]: CoreJSPromiseResult }> = allSettledKeyed({ [sym]: Promise.resolve(1), }); +Promise.allKeyed({ + a: 1, + b: Promise.resolve('string'), + c: 3, +}); // @ts-expect-error allKeyed(); @@ -42,8 +47,6 @@ const res2: Promise<{ [sym]: number }> = Promise.allKeyed({ // @ts-expect-error Promise.allKeyed(); // @ts-expect-error -Promise.allKeyed({ a: 1, b: Promise.resolve(2) }); -// @ts-expect-error Promise.allKeyed([Promise.resolve(1), Promise.resolve(2)]); const resASK: Promise<{ a: CoreJSPromiseResult, b: CoreJSPromiseResult, c: CoreJSPromiseResult }> = Promise.allSettledKeyed({ @@ -56,9 +59,13 @@ const resASK2: Promise<{ [sym]: CoreJSPromiseResult }> = Promise.allSett [sym]: Promise.resolve(1), }); +Promise.allSettledKeyed({ + a: 1, + b: Promise.resolve('string'), + c: 3, +}); + // @ts-expect-error Promise.allSettledKeyed(); // @ts-expect-error -Promise.allSettledKeyed({ a: 1, b: Promise.resolve(2) }); -// @ts-expect-error Promise.allSettledKeyed([Promise.resolve(1), Promise.resolve(2)]); diff --git a/tests/type-definitions/pure/proposals/await-dictionary.test.ts b/tests/type-definitions/pure/proposals/await-dictionary.test.ts index 2651a38ce988..d616ca69a540 100644 --- a/tests/type-definitions/pure/proposals/await-dictionary.test.ts +++ b/tests/type-definitions/pure/proposals/await-dictionary.test.ts @@ -16,16 +16,34 @@ const res2 = promiseAllKeyed({ }); assertCoreJSPromiseLike<{ [sym]: number }>(res2); +promiseAllKeyed({ + a: 1, + b: promiseResolve('string'), + c: 3, +}); + // @ts-expect-error promiseAllKeyed(); // @ts-expect-error -promiseAllKeyed({ a: 1, b: promiseResolve(2) }); -// @ts-expect-error promiseAllKeyed([promiseResolve(1), promiseResolve(2)]); +promiseAllSettledKeyed({ + a: Promise.resolve(1), + b: Promise.resolve('string'), + c: Promise.resolve(true), +}); + +promiseAllSettledKeyed({ + [sym]: Promise.resolve(1), +}); + +promiseAllSettledKeyed({ + a: 1, + b: Promise.resolve('string'), + c: 3, +}); + // @ts-expect-error promiseAllSettledKeyed(); // @ts-expect-error -promiseAllSettledKeyed({ a: 1, b: promiseResolve(2) }); -// @ts-expect-error promiseAllSettledKeyed([promiseResolve(1), promiseResolve(2)]); diff --git a/tests/unit-global/esnext.promise.all-keyed.js b/tests/unit-global/esnext.promise.all-keyed.js index 3856f2d67279..a1809771a6ba 100644 --- a/tests/unit-global/esnext.promise.all-keyed.js +++ b/tests/unit-global/esnext.promise.all-keyed.js @@ -6,6 +6,20 @@ QUnit.test('Promise.allKeyed', assert => { assert.true(Promise.allKeyed({}) instanceof Promise, 'returns a promise'); }); +QUnit.test('Promise.allKeyed, resolved with primitives', assert => { + return Promise.allKeyed({ + a: 1, + b: Promise.resolve(2), + c: 3, + }).then(it => { + assert.deepEqual(it, { + a: 1, + b: 2, + c: 3, + }, 'resolved with a correct value'); + }); +}); + QUnit.test('Promise.allKeyed, resolved', assert => { return Promise.allKeyed({ a: Promise.resolve(1), diff --git a/tests/unit-global/esnext.promise.all-settled-keyed.js b/tests/unit-global/esnext.promise.all-settled-keyed.js index debd013b519a..4ad335f6a308 100644 --- a/tests/unit-global/esnext.promise.all-settled-keyed.js +++ b/tests/unit-global/esnext.promise.all-settled-keyed.js @@ -20,6 +20,20 @@ QUnit.test('Promise.allSettledKeyed, resolved', assert => { }); }); +QUnit.test('Promise.allSettledKeyed, resolved with primitives', assert => { + return Promise.allSettledKeyed({ + a: 1, + b: Promise.resolve(2), + c: 3, + }).then(it => { + assert.deepEqual(it, { + a: { value: 1, status: 'fulfilled' }, + b: { value: 2, status: 'fulfilled' }, + c: { value: 3, status: 'fulfilled' }, + }, 'resolved with a correct value'); + }); +}); + QUnit.test('Promise.allSettledKeyed, resolved with rejection', assert => { return Promise.allSettledKeyed({ a: Promise.resolve(1), diff --git a/tests/unit-pure/esnext.promise.all-keyed.js b/tests/unit-pure/esnext.promise.all-keyed.js index a1f9c1907407..052806d3f871 100644 --- a/tests/unit-pure/esnext.promise.all-keyed.js +++ b/tests/unit-pure/esnext.promise.all-keyed.js @@ -22,6 +22,20 @@ QUnit.test('Promise.allKeyed, resolved', assert => { }); }); +QUnit.test('Promise.allKeyed, resolved with primitives', assert => { + return Promise.allKeyed({ + a: 1, + b: Promise.resolve(2), + c: 3, + }).then(it => { + assert.deepEqual(it, { + a: 1, + b: 2, + c: 3, + }, 'resolved with a correct value'); + }); +}); + QUnit.test('Promise.allKeyed, resolved with rejection', assert => { return Promise.allKeyed({ a: Promise.resolve(1), diff --git a/tests/unit-pure/esnext.promise.all-settled-keyed.js b/tests/unit-pure/esnext.promise.all-settled-keyed.js index c7c4938ff043..a3f2c54f970a 100644 --- a/tests/unit-pure/esnext.promise.all-settled-keyed.js +++ b/tests/unit-pure/esnext.promise.all-settled-keyed.js @@ -22,6 +22,20 @@ QUnit.test('Promise.allSettledKeyed, resolved', assert => { }); }); +QUnit.test('Promise.allSettledKeyed, resolved with primitives', assert => { + return Promise.allSettledKeyed({ + a: 1, + b: Promise.resolve(2), + c: 3, + }).then(it => { + assert.deepEqual(it, { + a: { value: 1, status: 'fulfilled' }, + b: { value: 2, status: 'fulfilled' }, + c: { value: 3, status: 'fulfilled' }, + }, 'resolved with a correct value'); + }); +}); + QUnit.test('Promise.allSettledKeyed, resolved with rejection', assert => { return Promise.allSettledKeyed({ a: Promise.resolve(1), From 802491cc6332d385a46c86148bca8ea9b9249502 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 21 Feb 2026 03:27:51 +0700 Subject: [PATCH 290/315] Fix Promise.allSettledKeyed pure type --- .../core-js-types/src/base/pure/proposals/await-dictionary.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts index 08b2a2f8208b..cba00da91ecb 100644 --- a/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts @@ -22,7 +22,7 @@ declare namespace CoreJS { * @returns A new Promise that resolves to an object with the same keys as the input object, * where each key maps to the settlement result (`{ status, value }` or `{ status, reason }`) of the corresponding promise. */ - allSettledKeyed>(promises: D): Promise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; + allSettledKeyed>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; } var CoreJSPromise: CoreJSPromiseConstructor; From a52c9368b06d6a60b774a92bc11032318aaea396 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Sat, 21 Feb 2026 03:28:28 +0700 Subject: [PATCH 291/315] DOMException type aligned with pure and global versions --- packages/core-js-types/src/base/web/dom-exception.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/core-js-types/src/base/web/dom-exception.d.ts b/packages/core-js-types/src/base/web/dom-exception.d.ts index 2b3374389fcb..d321c3647593 100644 --- a/packages/core-js-types/src/base/web/dom-exception.d.ts +++ b/packages/core-js-types/src/base/web/dom-exception.d.ts @@ -1,7 +1,14 @@ type _DOMException = typeof globalThis extends { onmessage: any } ? {} : DOMException; interface DOMException extends Error { + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code) + */ readonly code: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) */ readonly message: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) */ readonly name: string; readonly INDEX_SIZE_ERR: 1; readonly DOMSTRING_SIZE_ERR: 2; From 7d2dfaa6f58515035a3e3430c0a6c924ddde4c0a Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Mon, 23 Feb 2026 20:37:28 +0200 Subject: [PATCH 292/315] update dependencies --- tests/eslint/package-lock.json | 202 ++++++++++++++++----------------- tests/eslint/package.json | 4 +- 2 files changed, 101 insertions(+), 105 deletions(-) diff --git a/tests/eslint/package-lock.json b/tests/eslint/package-lock.json index 3629009c4737..474fc8a8e4dc 100644 --- a/tests/eslint/package-lock.json +++ b/tests/eslint/package-lock.json @@ -10,8 +10,8 @@ "@eslint/compat": "^2.0.2", "@eslint/markdown": "^7.5.1", "@stylistic/eslint-plugin": "^5.9.0", - "@typescript-eslint/eslint-plugin": "^8.56.0", - "@typescript-eslint/parser": "^8.56.0", + "@typescript-eslint/eslint-plugin": "^8.56.1", + "@typescript-eslint/parser": "^8.56.1", "confusing-browser-globals": "^1.0.11", "eslint": "^10.0.1", "eslint-plugin-array-func": "^5.1.0", @@ -187,22 +187,6 @@ "node": "^20.19.0 || ^22.13.0 || >=24" } }, - "node_modules/@eslint/config-array/node_modules/minimatch": { - "version": "10.2.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.2.tgz", - "integrity": "sha512-+G4CpNBxa5MprY+04MbgOw1v7So6n5JY166pFi9KfYwT78fxScCeSNQSNzp6dpPSW2rONOps6Ocam1wFhCgoVw==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "brace-expansion": "^5.0.2" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@eslint/config-helpers": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.5.2.tgz", @@ -721,17 +705,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.56.0.tgz", - "integrity": "sha512-lRyPDLzNCuae71A3t9NEINBiTn7swyOhvUj3MyUOxb8x6g6vPEFoOU+ZRmGMusNC3X3YMhqMIX7i8ShqhT74Pw==", + "version": "8.56.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.56.1.tgz", + "integrity": "sha512-Jz9ZztpB37dNC+HU2HI28Bs9QXpzCz+y/twHOwhyrIRdbuVDxSytJNDl6z/aAKlaRIwC7y8wJdkBv7FxYGgi0A==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.56.0", - "@typescript-eslint/type-utils": "8.56.0", - "@typescript-eslint/utils": "8.56.0", - "@typescript-eslint/visitor-keys": "8.56.0", + "@typescript-eslint/scope-manager": "8.56.1", + "@typescript-eslint/type-utils": "8.56.1", + "@typescript-eslint/utils": "8.56.1", + "@typescript-eslint/visitor-keys": "8.56.1", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.4.0" @@ -744,22 +728,22 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.56.0", + "@typescript-eslint/parser": "^8.56.1", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "node_modules/@typescript-eslint/parser": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.56.0.tgz", - "integrity": "sha512-IgSWvLobTDOjnaxAfDTIHaECbkNlAlKv2j5SjpB2v7QHKv1FIfjwMy8FsDbVfDX/KjmCmYICcw7uGaXLhtsLNg==", + "version": "8.56.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.56.1.tgz", + "integrity": "sha512-klQbnPAAiGYFyI02+znpBRLyjL4/BrBd0nyWkdC0s/6xFLkXYQ8OoRrSkqacS1ddVxf/LDyODIKbQ5TgKAf/Fg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.56.0", - "@typescript-eslint/types": "8.56.0", - "@typescript-eslint/typescript-estree": "8.56.0", - "@typescript-eslint/visitor-keys": "8.56.0", + "@typescript-eslint/scope-manager": "8.56.1", + "@typescript-eslint/types": "8.56.1", + "@typescript-eslint/typescript-estree": "8.56.1", + "@typescript-eslint/visitor-keys": "8.56.1", "debug": "^4.4.3" }, "engines": { @@ -775,14 +759,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.56.0.tgz", - "integrity": "sha512-M3rnyL1vIQOMeWxTWIW096/TtVP+8W3p/XnaFflhmcFp+U4zlxUxWj4XwNs6HbDeTtN4yun0GNTTDBw/SvufKg==", + "version": "8.56.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.56.1.tgz", + "integrity": "sha512-TAdqQTzHNNvlVFfR+hu2PDJrURiwKsUvxFn1M0h95BB8ah5jejas08jUWG4dBA68jDMI988IvtfdAI53JzEHOQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.56.0", - "@typescript-eslint/types": "^8.56.0", + "@typescript-eslint/tsconfig-utils": "^8.56.1", + "@typescript-eslint/types": "^8.56.1", "debug": "^4.4.3" }, "engines": { @@ -797,14 +781,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.56.0.tgz", - "integrity": "sha512-7UiO/XwMHquH+ZzfVCfUNkIXlp/yQjjnlYUyYz7pfvlK3/EyyN6BK+emDmGNyQLBtLGaYrTAI6KOw8tFucWL2w==", + "version": "8.56.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.56.1.tgz", + "integrity": "sha512-YAi4VDKcIZp0O4tz/haYKhmIDZFEUPOreKbfdAN3SzUDMcPhJ8QI99xQXqX+HoUVq8cs85eRKnD+rne2UAnj2w==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.56.0", - "@typescript-eslint/visitor-keys": "8.56.0" + "@typescript-eslint/types": "8.56.1", + "@typescript-eslint/visitor-keys": "8.56.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -815,9 +799,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.56.0.tgz", - "integrity": "sha512-bSJoIIt4o3lKXD3xmDh9chZcjCz5Lk8xS7Rxn+6l5/pKrDpkCwtQNQQwZ2qRPk7TkUYhrq3WPIHXOXlbXP0itg==", + "version": "8.56.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.56.1.tgz", + "integrity": "sha512-qOtCYzKEeyr3aR9f28mPJqBty7+DBqsdd63eO0yyDwc6vgThj2UjWfJIcsFeSucYydqcuudMOprZ+x1SpF3ZuQ==", "dev": true, "license": "MIT", "engines": { @@ -832,15 +816,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.56.0.tgz", - "integrity": "sha512-qX2L3HWOU2nuDs6GzglBeuFXviDODreS58tLY/BALPC7iu3Fa+J7EOTwnX9PdNBxUI7Uh0ntP0YWGnxCkXzmfA==", + "version": "8.56.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.56.1.tgz", + "integrity": "sha512-yB/7dxi7MgTtGhZdaHCemf7PuwrHMenHjmzgUW1aJpO+bBU43OycnM3Wn+DdvDO/8zzA9HlhaJ0AUGuvri4oGg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.56.0", - "@typescript-eslint/typescript-estree": "8.56.0", - "@typescript-eslint/utils": "8.56.0", + "@typescript-eslint/types": "8.56.1", + "@typescript-eslint/typescript-estree": "8.56.1", + "@typescript-eslint/utils": "8.56.1", "debug": "^4.4.3", "ts-api-utils": "^2.4.0" }, @@ -871,18 +855,18 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.56.0.tgz", - "integrity": "sha512-ex1nTUMWrseMltXUHmR2GAQ4d+WjkZCT4f+4bVsps8QEdh0vlBsaCokKTPlnqBFqqGaxilDNJG7b8dolW2m43Q==", + "version": "8.56.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.56.1.tgz", + "integrity": "sha512-qzUL1qgalIvKWAf9C1HpvBjif+Vm6rcT5wZd4VoMb9+Km3iS3Cv9DY6dMRMDtPnwRAFyAi7YXJpTIEXLvdfPxg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.56.0", - "@typescript-eslint/tsconfig-utils": "8.56.0", - "@typescript-eslint/types": "8.56.0", - "@typescript-eslint/visitor-keys": "8.56.0", + "@typescript-eslint/project-service": "8.56.1", + "@typescript-eslint/tsconfig-utils": "8.56.1", + "@typescript-eslint/types": "8.56.1", + "@typescript-eslint/visitor-keys": "8.56.1", "debug": "^4.4.3", - "minimatch": "^9.0.5", + "minimatch": "^10.2.2", "semver": "^7.7.3", "tinyglobby": "^0.2.15", "ts-api-utils": "^2.4.0" @@ -899,16 +883,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.56.0.tgz", - "integrity": "sha512-RZ3Qsmi2nFGsS+n+kjLAYDPVlrzf7UhTffrDIKr+h2yzAlYP/y5ZulU0yeDEPItos2Ph46JAL5P/On3pe7kDIQ==", + "version": "8.56.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.56.1.tgz", + "integrity": "sha512-HPAVNIME3tABJ61siYlHzSWCGtOoeP2RTIaHXFMPqjrQKCGB9OgUVdiNgH7TJS2JNIQ5qQ4RsAUDuGaGme/KOA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.56.0", - "@typescript-eslint/types": "8.56.0", - "@typescript-eslint/typescript-estree": "8.56.0" + "@typescript-eslint/scope-manager": "8.56.1", + "@typescript-eslint/types": "8.56.1", + "@typescript-eslint/typescript-estree": "8.56.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -923,13 +907,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.56.0.tgz", - "integrity": "sha512-q+SL+b+05Ud6LbEE35qe4A99P+htKTKVbyiNEe45eCbJFyh/HVK9QXwlrbz+Q4L8SOW4roxSVwXYj4DMBT7Ieg==", + "version": "8.56.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.56.1.tgz", + "integrity": "sha512-KiROIzYdEV85YygXw6BI/Dx4fnBlFQu6Mq4QE4MOH9fFnhohw6wX/OAvDY2/C+ut0I3RSPKenvZJIVYqJNkhEw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.56.0", + "@typescript-eslint/types": "8.56.1", "eslint-visitor-keys": "^5.0.0" }, "engines": { @@ -2391,6 +2375,18 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/config-array/node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/config-array/node_modules/minimatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.3.tgz", @@ -2594,18 +2590,6 @@ "license": "MIT", "peer": true }, - "node_modules/eslint-plugin-tsdoc/node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, "node_modules/eslint-plugin-tsdoc/node_modules/eslint": { "version": "9.39.3", "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.3.tgz", @@ -2685,6 +2669,18 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-plugin-tsdoc/node_modules/eslint/node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/eslint-plugin-tsdoc/node_modules/eslint/node_modules/minimatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.3.tgz", @@ -2710,6 +2706,22 @@ "node": ">= 4" } }, + "node_modules/eslint-plugin-tsdoc/node_modules/minimatch": { + "version": "9.0.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.6.tgz", + "integrity": "sha512-kQAVowdR33euIqeA0+VZTDqU+qo1IeVY+hrKYtZMio3Pg0P0vuh/kwRylLUddJhB6pf3q/botcOvRtx4IN1wqQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^5.0.2" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/eslint-plugin-unicorn": { "version": "63.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-63.0.0.tgz", @@ -2902,22 +2914,6 @@ "node": ">= 4" } }, - "node_modules/eslint/node_modules/minimatch": { - "version": "10.2.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.2.tgz", - "integrity": "sha512-+G4CpNBxa5MprY+04MbgOw1v7So6n5JY166pFi9KfYwT78fxScCeSNQSNzp6dpPSW2rONOps6Ocam1wFhCgoVw==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "brace-expansion": "^5.0.2" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/espree": { "version": "10.4.0", "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", @@ -4553,16 +4549,16 @@ } }, "node_modules/minimatch": { - "version": "9.0.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.6.tgz", - "integrity": "sha512-kQAVowdR33euIqeA0+VZTDqU+qo1IeVY+hrKYtZMio3Pg0P0vuh/kwRylLUddJhB6pf3q/botcOvRtx4IN1wqQ==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.2.tgz", + "integrity": "sha512-+G4CpNBxa5MprY+04MbgOw1v7So6n5JY166pFi9KfYwT78fxScCeSNQSNzp6dpPSW2rONOps6Ocam1wFhCgoVw==", "dev": true, - "license": "ISC", + "license": "BlueOak-1.0.0", "dependencies": { "brace-expansion": "^5.0.2" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "18 || 20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" diff --git a/tests/eslint/package.json b/tests/eslint/package.json index a3dd19945266..34e610c024a3 100644 --- a/tests/eslint/package.json +++ b/tests/eslint/package.json @@ -6,8 +6,8 @@ "@eslint/markdown": "^7.5.1", "@eslint-community/eslint-plugin-eslint-comments": "^4.6.0", "@stylistic/eslint-plugin": "^5.9.0", - "@typescript-eslint/eslint-plugin": "^8.56.0", - "@typescript-eslint/parser": "^8.56.0", + "@typescript-eslint/eslint-plugin": "^8.56.1", + "@typescript-eslint/parser": "^8.56.1", "confusing-browser-globals": "^1.0.11", "eslint": "^10.0.1", "eslint-plugin-array-func": "^5.1.0", From 725c6b85b54f6a17ea3eae1d0f5023c3f323710f Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Mon, 23 Feb 2026 23:51:12 +0700 Subject: [PATCH 293/315] Fix subsets in build-types script --- scripts/build-entries-and-types/build-types.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build-entries-and-types/build-types.mjs b/scripts/build-entries-and-types/build-types.mjs index bf1fdccb8b5b..7e11c078c365 100644 --- a/scripts/build-entries-and-types/build-types.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -236,9 +236,9 @@ async function buildTypesForTSVersion(tsVersion) { await buildType('es/index', { template: $path, modules: ESModules, subset: 'es', tsVersion }); await buildType('stable/index', { template: $path, modules: StableModules, subset: 'stable', tsVersion }); - await buildType('actual/index', { template: $path, modules: ActualModules, tsVersion }); + await buildType('actual/index', { template: $path, modules: ActualModules, subset: 'actual', tsVersion }); await buildType('full/index', { template: $path, modules: AllModules, tsVersion }); - await buildType('index', { template: $path, modules: ActualModules, tsVersion }); + await buildType('index', { template: $path, modules: ActualModules, subset: 'actual', tsVersion }); await buildType('configurator', { customType: 'configurator-custom', From f16607675107b620c22b6d64b10fef851a1a3342 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 00:11:50 +0700 Subject: [PATCH 294/315] Fix AsyncIterator types --- .../src/base/proposals/async-iterator-helpers-custom.d.ts | 2 +- .../src/base/proposals/async-iterator-helpers.d.ts | 4 ++-- .../base/pure/proposals/async-iterator-helpers-custom.d.ts | 2 +- .../src/base/pure/proposals/async-iterator-helpers.d.ts | 4 ++-- .../src/ts5-2/proposals/async-iterator-helpers.d.ts | 4 ++-- .../global/proposals/async-iterator-helper.test.ts | 1 + 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers-custom.d.ts index 3ffb48aece14..bee15f31244e 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers-custom.d.ts @@ -7,7 +7,7 @@ declare namespace CoreJS { export type AsyncIteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable | AsyncIterator | AsyncIterable) => AsyncIteratorObject; - export type AsyncIteratorMap = (callback: (value: T, index: number) => U) => AsyncIteratorObject; + export type AsyncIteratorMap = (callback: (value: T, index: number) => U) => AsyncIteratorObject, undefined, unknown>; export type AsyncIteratorReduce = (callback: (accumulator: U, value: T, index: number) => U, initialValue?: U) => Promise; } diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index c77b9853c502..15b4df10e6da 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -8,7 +8,7 @@ interface AsyncIteratorConstructor { * @param iterable - An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` * @returns A new `AsyncIterator` instance */ - from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; + from(iterable: AsyncIterable | Iterable | AsyncIterator): AsyncIteratorObject; } declare var AsyncIterator: AsyncIteratorConstructor; @@ -63,7 +63,7 @@ interface AsyncIterator { * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - map(mapper: (value: T, index: number) => U): AsyncIteratorObject; + map(mapper: (value: T, index: number) => U): AsyncIteratorObject, undefined, unknown>; /** * Reduces the elements of the iterator to a single value using the `reducer` function. diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers-custom.d.ts index df9bc6a21178..b30785c45813 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers-custom.d.ts @@ -8,7 +8,7 @@ declare namespace CoreJS { export type AsyncIteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable | CoreJS.CoreJSAsyncIterator | CoreJS.CoreJSAsyncIterable) => CoreJS.CoreJSAsyncIteratorObject; - export type AsyncIteratorMap = (callback: (value: T, index: number) => U) => CoreJS.CoreJSAsyncIteratorObject; + export type AsyncIteratorMap = (callback: (value: T, index: number) => U) => CoreJS.CoreJSAsyncIteratorObject, undefined, unknown>; export type AsyncIteratorReduce = (callback: (accumulator: U, value: T, index: number) => U, initialValue?: U) => CoreJS.CoreJSPromise; } diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index 73ae47f244df..6d5499a31463 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -13,7 +13,7 @@ declare namespace CoreJS { * @param iterable - An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` * @returns A new `AsyncIterator` instance */ - from(iterable: CoreJSAsyncIterable | Iterable | CoreJSAsyncIteratorObject): CoreJSAsyncIteratorObject; + from(iterable: CoreJSAsyncIterable | Iterable | CoreJSAsyncIterator): CoreJSAsyncIteratorObject; } export interface CoreJSAsyncIterator { @@ -67,7 +67,7 @@ declare namespace CoreJS { * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - map(mapper: (value: T, index: number) => U): CoreJSAsyncIteratorObject; + map(mapper: (value: T, index: number) => U): CoreJSAsyncIteratorObject, undefined, unknown>; /** * Reduces the elements of the iterator to a single value using the `reducer` function. diff --git a/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts index e718ff6f1ccd..ec1cd32d4b6b 100644 --- a/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/ts5-2/proposals/async-iterator-helpers.d.ts @@ -8,7 +8,7 @@ interface AsyncIteratorConstructor { * @param iterable - An `AsyncIterable`, `Iterable`, or `AsyncIterator` to convert to an `AsyncIterator` * @returns A new `AsyncIterator` instance */ - from(iterable: AsyncIterable | Iterable | AsyncIteratorObject): AsyncIteratorObject; + from(iterable: AsyncIterable | Iterable | AsyncIterator): AsyncIteratorObject; } declare var AsyncIterator: AsyncIteratorConstructor; @@ -61,7 +61,7 @@ interface AsyncIterator { * @param mapper - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - map(mapper: (value: T, index: number) => any): AsyncIteratorObject; + map(mapper: (value: T, index: number) => any): AsyncIteratorObject>; /** * Reduces the elements of the iterator to a single value using the `reducer` function. diff --git a/tests/type-definitions/global/proposals/async-iterator-helper.test.ts b/tests/type-definitions/global/proposals/async-iterator-helper.test.ts index c773aee13cdb..0f3864cd2927 100644 --- a/tests/type-definitions/global/proposals/async-iterator-helper.test.ts +++ b/tests/type-definitions/global/proposals/async-iterator-helper.test.ts @@ -50,6 +50,7 @@ AsyncIterator.from((async function * () { AsyncIterator.from(ilb); AsyncIterator.from(ailb); AsyncIterator.from(aio); +AsyncIterator.from(ait); // @ts-expect-error AsyncIterator.from(123); From bd1876e03909e2e9a8b238731ad81d9762a80269 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 00:37:24 +0700 Subject: [PATCH 295/315] Fix `Iterator.range` return type --- packages/core-js-types/src/base/proposals/iterator-range.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/iterator-range.d.ts b/packages/core-js-types/src/base/proposals/iterator-range.d.ts index 502bbe4a9840..542c88632f9d 100644 --- a/packages/core-js-types/src/base/proposals/iterator-range.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-range.d.ts @@ -16,7 +16,7 @@ interface IteratorConstructor { // @type-options: no-extends * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of numbers. */ - range(start: number, end: number | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: number | IteratorRangeOptions): IteratorObject; // @type-options: prefix-return-type + range(start: number, end: number | typeof Infinity | typeof Number.NEGATIVE_INFINITY, options?: number | IteratorRangeOptions): IteratorObject; // @type-options: prefix-return-type /** * Returns an iterator that generates a sequence of bigints within a range. @@ -27,7 +27,7 @@ interface IteratorConstructor { // @type-options: no-extends * - inclusive: If true, the end value is included in the range (default is false). * @returns An iterator of bigints. */ - range(start: bigint, end: bigint, options?: bigint | IteratorRangeOptions): IteratorObject; // @type-options: prefix-return-type + range(start: bigint, end: bigint, options?: bigint | IteratorRangeOptions): IteratorObject; // @type-options: prefix-return-type } declare var Iterator: IteratorConstructor; From dab664f6d847597c9a53afdc9079526b0e4f35a2 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 00:54:13 +0700 Subject: [PATCH 296/315] Fix type `Iterator.zipKeyed` in pure version --- packages/core-js-types/src/base/pure/proposals/iterator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 3b369ae1dbdf..11f00bb977da 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -192,7 +192,7 @@ declare namespace CoreJS { * - padding: an object specifying padding values for each key when mode is 'longest'. * @returns An iterator yielding objects with keys from the input record and values from the corresponding iterables. */ - zipKeyed }>(record: T, options?: ZipKeyedOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; + zipKeyed }>(record: T, options?: ZipKeyedOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never; }, undefined, unknown>; /** * Returns an iterator that generates a sequence of numbers within a range. From 2547771f031b2f5da0287aeb5342dda37798dc58 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 00:57:57 +0700 Subject: [PATCH 297/315] Fix Uint32Array#toSorted TSDocs --- .../src/base/proposals/change-array-by-copy.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts index f047438c3b16..e6ce2a27d640 100644 --- a/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts +++ b/packages/core-js-types/src/base/proposals/change-array-by-copy.d.ts @@ -274,8 +274,8 @@ interface Uint32Array { // @type-options: no-export * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts - * const myNums = Uint32Array.from([11, 2, -22, 1]); - * myNums.toSorted((a, b) => a - b) // Uint32Array(4) [-22, 1, 2, 11] + * const myNums = Uint32Array.from([11, 2, 1]); + * myNums.toSorted((a, b) => a - b) // Uint32Array(3) [1, 2, 11] * ``` */ toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; From 980eeda55633c775b42cfe170debb92f4b5affd1 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 01:15:17 +0700 Subject: [PATCH 298/315] Fix collection of-from proposal types --- .../src/base/proposals/collection-of-from.d.ts | 8 ++++---- .../src/base/pure/proposals/collection-of-from.d.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts index 65666cbba41c..04d97728a9cb 100644 --- a/packages/core-js-types/src/base/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/proposals/collection-of-from.d.ts @@ -52,7 +52,7 @@ interface WeakMapConstructor { * @param thisArg - Value to use as this when executing mapFn. * @returns A new `WeakMap` instance. */ - from(source: Iterable<[K, V]>, mapFn?: (entry: [K, V], index: number) => [KOut, VOut], thisArg?: any): WeakMap; + from(source: Iterable<[K, V]>, mapFn?: (entry: [K, V], index: number) => [KOut, VOut], thisArg?: any): WeakMap; /** * Creates a new `WeakMap` instance from a variable number of arguments, @@ -60,7 +60,7 @@ interface WeakMapConstructor { * @param items - An even number of arguments representing key-value pairs. * @returns A new `WeakMap` instance. */ - of(...items: [K, V][]): WeakMap; + of(...items: [K, V][]): WeakMap; } declare var WeakMap: WeakMapConstructor; @@ -73,14 +73,14 @@ interface WeakSetConstructor { * @param thisArg - Value to use as `this` in `mapFn`. * @returns New `WeakSet` instance. */ - from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): WeakSet; + from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): WeakSet; /** * Creates a new `WeakSet` instance from object arguments. * @param items - Zero or more objects to add as WeakSet elements. * @returns New `WeakSet` instance. */ - of(...items: T[]): WeakSet; + of(...items: T[]): WeakSet; } declare var WeakSet: WeakSetConstructor; diff --git a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts index e02fa3f268a1..bdfe2bce94a1 100644 --- a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts @@ -60,7 +60,7 @@ declare namespace CoreJS { * @param thisArg - Value to use as this when executing mapFn. * @returns A new `WeakMap` instance. */ - from(source: Iterable<[K, V]>, mapFn?: (entry: [K, V], index: number) => [KOut, VOut], thisArg?: any): CoreJS.CoreJSWeakMap; + from(source: Iterable<[K, V]>, mapFn?: (entry: [K, V], index: number) => [KOut, VOut], thisArg?: any): CoreJS.CoreJSWeakMap; /** * Creates a new `WeakMap` instance from a variable number of arguments, @@ -68,7 +68,7 @@ declare namespace CoreJS { * @param items - An even number of arguments representing key-value pairs. * @returns A new `WeakMap` instance. */ - of(...items: [K, V][]): CoreJS.CoreJSWeakMap; + of(...items: [K, V][]): CoreJS.CoreJSWeakMap; } var CoreJSWeakMap: CoreJSWeakMapConstructor; @@ -81,14 +81,14 @@ declare namespace CoreJS { * @param thisArg - Value to use as `this` in `mapFn`. * @returns New `WeakSet` instance. */ - from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): CoreJS.CoreJSWeakSet; + from(source: Iterable, mapFn?: (value: T, index: number) => U, thisArg?: any): CoreJS.CoreJSWeakSet; /** * Creates a new `WeakSet` instance from object arguments. * @param items - Zero or more objects to add as WeakSet elements. * @returns New `WeakSet` instance. */ - of(...items: T[]): CoreJS.CoreJSWeakSet; + of(...items: T[]): CoreJS.CoreJSWeakSet; } var CoreJSWeakSet: CoreJSWeakSetConstructor; From 3c17f5dc08a12907708071c7139d5656f4bd3554 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 01:56:19 +0700 Subject: [PATCH 299/315] Promise types refactoring for pure version --- .../base/proposals/promise-all-settled.d.ts | 4 +- .../src/base/proposals/promise-any.d.ts | 8 +- .../src/base/proposals/promise-finally.d.ts | 2 +- .../src/base/proposals/promise-try.d.ts | 2 +- .../proposals/promise-with-resolvers.d.ts | 4 +- .../pure/core-js-types/aggregate-error.d.ts | 13 +++ .../src/base/pure/core-js-types/promise.d.ts | 89 +++++++++++++++---- .../base/pure/proposals/await-dictionary.d.ts | 31 +------ .../pure/proposals/promise-all-settled.d.ts | 2 + .../src/base/pure/proposals/promise-any.d.ts | 2 + .../src/base/pure/proposals/promise-try.d.ts | 2 + .../proposals/promise-with-resolvers.d.ts | 2 + 12 files changed, 105 insertions(+), 56 deletions(-) create mode 100644 packages/core-js-types/src/base/pure/core-js-types/aggregate-error.d.ts create mode 100644 packages/core-js-types/src/base/pure/proposals/promise-all-settled.d.ts create mode 100644 packages/core-js-types/src/base/pure/proposals/promise-any.d.ts create mode 100644 packages/core-js-types/src/base/pure/proposals/promise-try.d.ts create mode 100644 packages/core-js-types/src/base/pure/proposals/promise-with-resolvers.d.ts diff --git a/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts index 2aa1900fd098..673706f487eb 100644 --- a/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-all-settled.d.ts @@ -13,7 +13,7 @@ interface PromiseConstructor { * @param values - An array of Promises. * @returns A new Promise. */ - allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJS.CoreJSPromiseSettledResult>; }>; // @type-options: prefix-return-type + allSettled(values: T): Promise<{ -readonly [P in keyof T]: CoreJS.CoreJSPromiseSettledResult>; }>; /** * Creates a Promise that is resolved with an array of results when all @@ -21,5 +21,5 @@ interface PromiseConstructor { * @param values - An array of Promises. * @returns A new Promise. */ - allSettled(values: Iterable>): Promise>[]>; // @type-options: prefix-return-type + allSettled(values: Iterable>): Promise>[]>; } diff --git a/packages/core-js-types/src/base/proposals/promise-any.d.ts b/packages/core-js-types/src/base/proposals/promise-any.d.ts index df1d842b42a4..32cd6357a0bf 100644 --- a/packages/core-js-types/src/base/proposals/promise-any.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-any.d.ts @@ -10,21 +10,21 @@ interface PromiseConstructor { * @param values - An array or iterable of Promises. * @returns A new Promise. */ - any(values: T): Promise>; // @type-options: prefix-return-type + any(values: T): Promise>; /** * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. * @param values - An array or iterable of Promises. * @returns A new Promise. */ - any(values: Iterable>): Promise>; // @type-options: prefix-return-type + any(values: Iterable>): Promise>; } -interface AggregateError extends Error { // @type-options: no-redefine +interface AggregateError extends Error { errors: any[]; } -interface AggregateErrorConstructor { // @type-options: no-extends, no-redefine +interface AggregateErrorConstructor { new (errors: Iterable, message?: string): AggregateError; (errors: Iterable, message?: string): AggregateError; readonly prototype: AggregateError; diff --git a/packages/core-js-types/src/base/proposals/promise-finally.d.ts b/packages/core-js-types/src/base/proposals/promise-finally.d.ts index 301ae177a2c1..575869bb8dfd 100644 --- a/packages/core-js-types/src/base/proposals/promise-finally.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-finally.d.ts @@ -11,5 +11,5 @@ interface Promise { * @param onfinally - The callback to execute when the Promise is settled (fulfilled or rejected). * @returns A Promise for the completion of the callback. */ - finally(onfinally?: (() => void) | undefined | null): Promise; // @type-options: prefix-return-type + finally(onfinally?: (() => void) | undefined | null): Promise; } diff --git a/packages/core-js-types/src/base/proposals/promise-try.d.ts b/packages/core-js-types/src/base/proposals/promise-try.d.ts index 9fd477c53e6e..3e5da259e21f 100644 --- a/packages/core-js-types/src/base/proposals/promise-try.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-try.d.ts @@ -18,6 +18,6 @@ interface PromiseConstructor { * - Already rejected, if the callback synchronously throws an error. * - Asynchronously fulfilled or rejected, if the callback returns a promise. */ - try(callbackFn: (...args: U) => T | PromiseLike, ...args: U): Promise>; // @type-options: prefix-return-type + try(callbackFn: (...args: U) => T | PromiseLike, ...args: U): Promise>; } diff --git a/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts index e3fee749a5a9..98a34c818dec 100644 --- a/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts +++ b/packages/core-js-types/src/base/proposals/promise-with-resolvers.d.ts @@ -4,8 +4,8 @@ // https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2024.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt -interface PromiseWithResolvers { // @type-options: no-extends, no-prefix - promise: Promise; // @type-options: prefix-return-type +interface PromiseWithResolvers { + promise: Promise; resolve: (value: T | PromiseLike) => void; diff --git a/packages/core-js-types/src/base/pure/core-js-types/aggregate-error.d.ts b/packages/core-js-types/src/base/pure/core-js-types/aggregate-error.d.ts new file mode 100644 index 000000000000..1da5bf1d9f85 --- /dev/null +++ b/packages/core-js-types/src/base/pure/core-js-types/aggregate-error.d.ts @@ -0,0 +1,13 @@ +declare namespace CoreJS { + export interface CoreJSAggregateError extends Error { + errors: any[]; + } + + export interface CoreJSAggregateErrorConstructor { + new (errors: Iterable, message?: string): CoreJSAggregateError; + (errors: Iterable, message?: string): CoreJSAggregateError; + readonly prototype: CoreJSAggregateError; + } + + var CoreJSAggregateError: CoreJSAggregateErrorConstructor; +} diff --git a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts index 8bc5d64abeb4..c150b1c4c01c 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts @@ -1,6 +1,21 @@ +/// + +// https://github.com/tc39/proposal-await-dictionary + +// https://github.com/tc39/proposal-promise-allSettled + +// https://github.com/tc39/proposal-promise-any + +// https://github.com/tc39/proposal-promise-try + +// https://github.com/tc39/proposal-promise-with-resolvers + // For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/347254895823a36a1b1b1c80471422da54ad77de/src/lib/es2021.promise.d.ts#L16 -// https://github.com/microsoft/TypeScript/blob/347254895823a36a1b1b1c80471422da54ad77de/src/lib/es2025.promise.d.ts#L4 +// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2020.promise.d.ts +// https://github.com/microsoft/TypeScript/blob/347254895823a36a1b1b1c80471422da54ad77de/src/lib/es2021.promise.d.ts +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/es2024.promise.d.ts +// https://github.com/microsoft/TypeScript/blob/347254895823a36a1b1b1c80471422da54ad77de/src/lib/es2025.promise.d.ts +// https://github.com/microsoft/TypeScript/blob/af3a3779de6bc27619c85077e1b4d1de8feddd35/src/lib/esnext.promise.d.ts // License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt declare namespace CoreJS { @@ -31,6 +46,51 @@ declare namespace CoreJS { */ all(values: T): CoreJSPromise<{ -readonly [P in keyof T]: Awaited; }>; + /** + * Takes an object of promises and returns a single Promise that resolves to an object + * with the same keys and fulfilled values, or rejects as soon as any of the input promises rejects. + * @param promises - An object of promises + * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. + */ + allKeyed>(promises: D): CoreJSPromise<{ [k in keyof D]: Awaited }>; + + /** + * Takes an object whose values are promises and returns a single `Promise` that resolves + * to an object with the same keys, after all of the input promises have settled. + * @param promises - An object of promises + * @returns A new Promise that resolves to an object with the same keys as the input object, + * where each key maps to the settlement result (`{ status, value }` or `{ status, reason }`) of the corresponding promise. + */ + allSettledKeyed>(promises: D): CoreJSPromise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; + + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values - An array of Promises. + * @returns A new Promise. + */ + allSettled(values: T): CoreJSPromise<{ -readonly [P in keyof T]: CoreJS.CoreJSPromiseSettledResult>; }>; + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values - An array of Promises. + * @returns A new Promise. + */ + allSettled(values: Iterable>): CoreJSPromise>[]>; + + /** + * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. + * @param values - An array or iterable of Promises. + * @returns A new Promise. + */ + any(values: T): CoreJSPromise>; + /** + * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. + * @param values - An array or iterable of Promises. + * @returns A new Promise. + */ + any(values: Iterable>): CoreJSPromise>; + /** * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved * or rejected. @@ -58,21 +118,6 @@ declare namespace CoreJS { */ resolve(value: T | PromiseLike): CoreJSPromise>; - // allSettled, any, try - - /** - * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. - * @param values - An array or iterable of Promises. - * @returns A new Promise. - */ - any(values: T): CoreJSPromise>; - /** - * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. - * @param values - An array or iterable of Promises. - * @returns A new Promise. - */ - any(values: Iterable>): CoreJSPromise>; - /** * Takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result * in a Promise. @@ -87,6 +132,16 @@ declare namespace CoreJS { * - Asynchronously fulfilled or rejected, if the callback returns a promise. */ try(callbackFn: (...args: U) => T | PromiseLike, ...args: U): CoreJSPromise>; + + /** + * Creates a new Promise and returns it in an object, along with its resolve and reject functions. + * @returns An object with the properties `promise`, `resolve`, and `reject`. + * + * ```ts + * const { promise, resolve, reject } = Promise.withResolvers(); + * ``` + */ + withResolvers(): CoreJSPromiseWithResolvers; } var CoreJSPromise: CoreJSPromiseConstructor; diff --git a/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts index cba00da91ecb..0bb054ebfc51 100644 --- a/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/await-dictionary.d.ts @@ -1,29 +1,2 @@ -/// -/// - -// Motivation: Using our own Promise type in return - -// https://github.com/tc39/proposal-await-dictionary - -declare namespace CoreJS { - export interface CoreJSPromiseConstructor extends PromiseConstructor { - /** - * Takes an object of promises and returns a single Promise that resolves to an object - * with the same keys and fulfilled values, or rejects as soon as any of the input promises rejects. - * @param promises - An object of promises - * @returns A new `Promise` that resolves to an object of fulfilled values or rejects if any promise rejects. - */ - allKeyed>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: Awaited }>; - - /** - * Takes an object whose values are promises and returns a single `Promise` that resolves - * to an object with the same keys, after all of the input promises have settled. - * @param promises - An object of promises - * @returns A new Promise that resolves to an object with the same keys as the input object, - * where each key maps to the settlement result (`{ status, value }` or `{ status, reason }`) of the corresponding promise. - */ - allSettledKeyed>(promises: D): CoreJS.CoreJSPromise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; - } - - var CoreJSPromise: CoreJSPromiseConstructor; -} +// empty +// Moved to ../core-js-types/promise.d.ts diff --git a/packages/core-js-types/src/base/pure/proposals/promise-all-settled.d.ts b/packages/core-js-types/src/base/pure/proposals/promise-all-settled.d.ts new file mode 100644 index 000000000000..0bb054ebfc51 --- /dev/null +++ b/packages/core-js-types/src/base/pure/proposals/promise-all-settled.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ../core-js-types/promise.d.ts diff --git a/packages/core-js-types/src/base/pure/proposals/promise-any.d.ts b/packages/core-js-types/src/base/pure/proposals/promise-any.d.ts new file mode 100644 index 000000000000..0bb054ebfc51 --- /dev/null +++ b/packages/core-js-types/src/base/pure/proposals/promise-any.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ../core-js-types/promise.d.ts diff --git a/packages/core-js-types/src/base/pure/proposals/promise-try.d.ts b/packages/core-js-types/src/base/pure/proposals/promise-try.d.ts new file mode 100644 index 000000000000..0bb054ebfc51 --- /dev/null +++ b/packages/core-js-types/src/base/pure/proposals/promise-try.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ../core-js-types/promise.d.ts diff --git a/packages/core-js-types/src/base/pure/proposals/promise-with-resolvers.d.ts b/packages/core-js-types/src/base/pure/proposals/promise-with-resolvers.d.ts new file mode 100644 index 000000000000..0bb054ebfc51 --- /dev/null +++ b/packages/core-js-types/src/base/pure/proposals/promise-with-resolvers.d.ts @@ -0,0 +1,2 @@ +// empty +// Moved to ../core-js-types/promise.d.ts From 97c67356d2f77e35d14e4c40127bced90d70716e Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 01:57:16 +0700 Subject: [PATCH 300/315] Reuse AsyncIterator type in Iterator for pure version --- .../src/base/pure/proposals/iterator.d.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 11f00bb977da..3bb6b3c057f6 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -1,6 +1,7 @@ /// -/// +/// /// +/// // Motivation: Has dependencies on internal types @@ -39,16 +40,10 @@ declare namespace CoreJS { inclusive?: boolean; } - interface CoreJSAsyncIterator { - next(...[value]: [] | [TNext]): CoreJS.CoreJSPromise>; - return?(value?: TReturn | PromiseLike): CoreJS.CoreJSPromise>; - throw?(e?: any): CoreJS.CoreJSPromise>; - } - - export interface CoreJSAsyncIteratorObject extends CoreJSAsyncIterator {} + export interface CoreJSAsyncIteratorObject extends CoreJS.CoreJSAsyncIterator {} export interface CoreJSAsyncIteratorObject extends CoreJSAsyncDisposable {} export interface CoreJSAsyncIterable { - [CoreJSSymbol.asyncIterator](): CoreJSAsyncIterator; + [CoreJSSymbol.asyncIterator](): CoreJS.CoreJSAsyncIterator; } export interface CoreJSIteratorObject extends CoreJSDisposable {} From 55936378c2ae9bfc0ea549bd0a336692e52a08e8 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 05:23:23 +0700 Subject: [PATCH 301/315] Fix references adjustment & no-export decorator --- scripts/build-entries-and-types/build-types-pure.mjs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/build-entries-and-types/build-types-pure.mjs b/scripts/build-entries-and-types/build-types-pure.mjs index 893bbec0b43b..a27e558630e7 100644 --- a/scripts/build-entries-and-types/build-types-pure.mjs +++ b/scripts/build-entries-and-types/build-types-pure.mjs @@ -41,7 +41,7 @@ function processLines(lines) { } if (noExport) return []; if (options.noExport) { - if (/^[^{]*$/.test(line) || /\{[^}]?\}/.test(line)) return []; + if (/^[^{]*$/.test(line) || /\{[^{}]*\}/.test(line)) return []; noExport = true; return []; } @@ -164,7 +164,14 @@ export async function preparePureTypes(typesPath, initialPath) { const content = await readFile(typePath, 'utf8'); - const result = content.includes('declare namespace') ? content : wrapInNamespace(content); + const adjustedContent = content.replace( + /(?\/\/\/\s*[^"]+)(?"\s*\/>)/g, + (...args) => { + const { open, path, close } = args.at(-1); + return `${ open }../${ path }${ close }`; + }, + ); + const result = content.includes('declare namespace') ? adjustedContent : wrapInNamespace(content); await outputFile(resultFilePath, result); } From 172d27fe399ab25f22a29635895c5a5a2e7d936b Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 05:23:52 +0700 Subject: [PATCH 302/315] Remove unused type --- packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index a7a49cf6139f..38184d647dc7 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -1,6 +1,5 @@ /// /// -/// /// // Motivation: Has dependencies on internal types From 1c0b8339e0678d14bda1f011f96edecd211dc4f1 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 17:51:07 +0700 Subject: [PATCH 303/315] Fix `Iterator.concat` types & tests --- .../core-js-types/src/base/proposals/iterator-sequencing.d.ts | 2 +- packages/core-js-types/src/base/pure/proposals/iterator.d.ts | 2 +- .../global/proposals/iterator-sequencing.test.ts | 3 ++- .../pure/proposals/iterator-sequencing.test.ts | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts index 8b0ce3d82440..73beb4292269 100644 --- a/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-sequencing.d.ts @@ -8,7 +8,7 @@ interface IteratorConstructor { // @type-options: no-extends * @param iterators - The iterables to concatenate. * @returns An iterator yielding values from each input iterable in sequence. */ - concat(...iterators: Iterable[]): IteratorObject; + concat[]>(...iterators: T): IteratorObject ? V : never, undefined, unknown>; } declare var Iterator: IteratorConstructor; diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 3bb6b3c057f6..95f443d8493f 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -216,7 +216,7 @@ declare namespace CoreJS { * @param iterators - The iterables to concatenate. * @returns An iterator yielding values from each input iterable in sequence. */ - concat(...iterators: Iterable[]): CoreJSIteratorObject; + concat[]>(...iterators: T): CoreJSIteratorObject ? V : never, undefined, unknown>; } var CoreJSIterator: CoreJSIteratorConstructor; diff --git a/tests/type-definitions/global/proposals/iterator-sequencing.test.ts b/tests/type-definitions/global/proposals/iterator-sequencing.test.ts index 16da5ada0513..55bc2d864e84 100644 --- a/tests/type-definitions/global/proposals/iterator-sequencing.test.ts +++ b/tests/type-definitions/global/proposals/iterator-sequencing.test.ts @@ -16,7 +16,8 @@ const ri1: Iterator = Iterator.concat(its1); const ri2: Iterator = Iterator.concat(arrs); const ri3: Iterator = Iterator.concat(arrn); const ri4: Iterator = Iterator.concat(arrb, itb1); -const ri5: Iterator = Iterator.concat(); +const ri5: Iterator = Iterator.concat(); +const ri6: Iterator = Iterator.concat(arrs, arrn); // @ts-expect-error Iterator.concat(1); diff --git a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts index 8929e2dbe7a4..563a3b26b407 100644 --- a/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts +++ b/tests/type-definitions/pure/proposals/iterator-sequencing.test.ts @@ -17,6 +17,8 @@ const ri4 = iteratorConcat(arrb, itb1); assertCoreJSIteratorLike(ri4); const ri5 = iteratorConcat(); assertCoreJSIteratorLike(ri5); +const ri6 = iteratorConcat(arrs, arrn); +assertCoreJSIteratorLike(ri6); // @ts-expect-error iteratorConcat(1); From 7bf5d599e08ea7ea4c22222d3ed7d1920a565aaa Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 19:04:18 +0700 Subject: [PATCH 304/315] Fix `Symbol.iterator` for pure version --- .../src/base/pure/core-js-types/url-search-params.d.ts | 5 ++--- .../src/base/pure/proposals/string-match-all.d.ts | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts b/packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts index 8c12104f8fb3..eafc7cc8eec0 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/url-search-params.d.ts @@ -1,5 +1,4 @@ /// -/// declare namespace CoreJS { export interface CoreJSURLSearchParams { @@ -47,14 +46,14 @@ declare namespace CoreJS { toString(): string; forEach(callbackfn: (value: string, key: string, parent: CoreJSURLSearchParams) => void, thisArg?: any): void; - [CoreJS.CoreJSSymbol.iterator](): CoreJSURLSearchParamsIterator<[string, string]>; + [Symbol.iterator](): CoreJSURLSearchParamsIterator<[string, string]>; entries(): CoreJSURLSearchParamsIterator<[string, string]>; keys(): CoreJSURLSearchParamsIterator; values(): CoreJSURLSearchParamsIterator; } interface CoreJSURLSearchParamsIterator extends CoreJSIteratorObject { - [CoreJS.CoreJSSymbol.iterator](): CoreJSURLSearchParamsIterator; + [Symbol.iterator](): CoreJSURLSearchParamsIterator; } export interface CoreJSURLSearchParamsConstructor { diff --git a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts index 75d22139a366..eaef63f867f3 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-match-all.d.ts @@ -1,6 +1,5 @@ /// /// -/// // Motivation: We should use String without the matchAll method to avoid signature conflicts @@ -12,7 +11,7 @@ declare namespace CoreJS { interface CoreJSRegExpStringIterator extends CoreJSIteratorObject { - [CoreJS.CoreJSSymbol.iterator](): CoreJSRegExpStringIterator; + [Symbol.iterator](): CoreJSRegExpStringIterator; } export interface CoreJSString extends StringBase { From c6950536d0615084f1fb2d9e271cb7e0d4b8ee3a Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 19:54:34 +0700 Subject: [PATCH 305/315] Fix es filter in build types script --- scripts/build-entries-and-types/build-types.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-entries-and-types/build-types.mjs b/scripts/build-entries-and-types/build-types.mjs index 7e11c078c365..673c322f14ca 100644 --- a/scripts/build-entries-and-types/build-types.mjs +++ b/scripts/build-entries-and-types/build-types.mjs @@ -69,7 +69,7 @@ async function buildType(entry, options) { switch (subset) { case 'es': filter ??= ESSet; - typesFilter = '/web/'; + typesFilter = 'web/'; break; case 'stable': filter ??= StableSet; From 65bb542cd45745c0a52459cef9a3d87ff4c3c8c8 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 20:02:08 +0700 Subject: [PATCH 306/315] AsyncIterator.flatMap alignment & fix TSDocs --- .../src/base/proposals/async-iterator-helpers.d.ts | 2 +- .../src/base/pure/proposals/async-iterator-helpers.d.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index 15b4df10e6da..774a0c8df7a1 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -45,7 +45,7 @@ interface AsyncIterator { find(predicate: (value: T, index: number) => unknown): Promise; /** - * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. + * Creates a new `AsyncIterator` by applying the `callback` function to each element of the original iterator and flattening the result. * @param callback - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index 6d5499a31463..f7fce9f2ead1 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -49,11 +49,11 @@ declare namespace CoreJS { find(predicate: (value: T, index: number) => unknown): CoreJSPromise; /** - * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator and flattening the result. - * @param mapper - A function that transforms each element of the iterator + * Creates a new `AsyncIterator` by applying the `callback` function to each element of the original iterator and flattening the result. + * @param callback - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - flatMap(mapper: (value: T, index: number) => Iterator | Iterable | CoreJSAsyncIterator | CoreJSAsyncIterable): CoreJSAsyncIteratorObject; + flatMap(callback: (value: T, index: number) => Iterator | Iterable | CoreJSAsyncIterator | CoreJSAsyncIterable): CoreJSAsyncIteratorObject; /** * Executes a provided function once for each element in the iterator. From d433df51e4c09fddf21a37be66d5f2295091460e Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Tue, 24 Feb 2026 20:18:51 +0700 Subject: [PATCH 307/315] Remove unsued type --- .../src/base/proposals/string-replace-all-custom.d.ts | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts diff --git a/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts b/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts deleted file mode 100644 index ca137894a5f5..000000000000 --- a/packages/core-js-types/src/base/proposals/string-replace-all-custom.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Motivation: Custom type needed to keep generics strict - -// https://github.com/tc39/proposal-string-replaceall - -// For ensuring compatibility with TypeScript standard types, this code is aligned with: -// https://github.com/microsoft/TypeScript/blob/f450c1b80ce6dc7b04e81899db00534018932234/src/lib/es2021.string.d.ts -// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt - -declare namespace CoreJS { - export type StringReplaceAll = ((searchValue: string | RegExp, replaceValue: string) => string) | ((searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string) => string); -} From 03468f237ccaacda4be7517d571938e79f5269da Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 25 Feb 2026 00:31:47 +0700 Subject: [PATCH 308/315] TSDocs fixes --- .../src/base/proposals/array-filtering.d.ts | 24 +++++++++---------- .../proposals/array-is-template-object.d.ts | 2 +- .../src/base/proposals/iterator-helpers.d.ts | 2 +- .../src/base/proposals/iterator-joint.d.ts | 6 ++--- .../src/base/proposals/map-upsert.d.ts | 12 ++++++++-- .../src/base/pure/proposals/iterator.d.ts | 2 +- .../src/ts5-2/pure/proposals/iterator.d.ts | 2 +- 7 files changed, 29 insertions(+), 21 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/array-filtering.d.ts b/packages/core-js-types/src/base/proposals/array-filtering.d.ts index 1fcebb5326ad..1ad162437f43 100644 --- a/packages/core-js-types/src/base/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/base/proposals/array-filtering.d.ts @@ -6,7 +6,7 @@ interface Array { // @type-options: no-redefine * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. * @param thisArg - If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. + * callbackFn function. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: T, index: number, target: T[]) => unknown, thisArg?: any): T[]; } @@ -17,7 +17,7 @@ interface ReadonlyArray { // @type-options: no-export * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. * @param thisArg - If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. + * callbackFn function. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: T, index: number, target: readonly T[]) => unknown, thisArg?: any): T[]; } @@ -28,7 +28,7 @@ interface Int8Array { // @type-options: no-export * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. * @param thisArg - If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. + * callbackFn function. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Int8Array) => unknown, thisArg?: any): Int8Array; } @@ -39,7 +39,7 @@ interface Uint8Array { // @type-options: no-export * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. * @param thisArg - If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. + * callbackFn function. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Uint8Array) => unknown, thisArg?: any): Uint8Array; } @@ -50,7 +50,7 @@ interface Uint8ClampedArray { // @type-options: no-export * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. * @param thisArg - If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. + * callbackFn function. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Uint8ClampedArray) => unknown, thisArg?: any): Uint8ClampedArray; } @@ -61,7 +61,7 @@ interface Int16Array { // @type-options: no-export * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. * @param thisArg - If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. + * callbackFn function. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Int16Array) => unknown, thisArg?: any): Int16Array; } @@ -72,7 +72,7 @@ interface Uint16Array { // @type-options: no-export * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. * @param thisArg - If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. + * callbackFn function. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Uint16Array) => unknown, thisArg?: any): Uint16Array; } @@ -83,7 +83,7 @@ interface Int32Array { // @type-options: no-export * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. * @param thisArg - If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. + * callbackFn function. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Int32Array) => unknown, thisArg?: any): Int32Array; } @@ -105,7 +105,7 @@ interface Float32Array { // @type-options: no-export * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. * @param thisArg - If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. + * callbackFn function. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Float32Array) => unknown, thisArg?: any): Float32Array; } @@ -116,7 +116,7 @@ interface Float64Array { // @type-options: no-export * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. * @param thisArg - If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. + * callbackFn function. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Float64Array) => unknown, thisArg?: any): Float64Array; } @@ -127,7 +127,7 @@ interface BigInt64Array { // @type-options: no-export * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. * @param thisArg - If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. + * callbackFn function. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => unknown, thisArg?: any): BigInt64Array; } @@ -138,7 +138,7 @@ interface BigUint64Array { // @type-options: no-export * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. * @param thisArg - If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. + * callbackFn function. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: bigint, index: number, target: BigUint64Array) => unknown, thisArg?: any): BigUint64Array; } diff --git a/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts b/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts index 28e0ab1cf540..d15b9c087439 100644 --- a/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts +++ b/packages/core-js-types/src/base/proposals/array-is-template-object.d.ts @@ -2,7 +2,7 @@ interface ArrayConstructor { // @type-options: no-export /** - * Determines whether an `value` is a `TemplateStringsArray` + * Determines whether a `value` is a `TemplateStringsArray` * @param value - The value to be checked * @returns `true` if `value` is a `TemplateStringsArray`, otherwise `false` */ diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts index bce592dc12a6..033f76342dd2 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers.d.ts @@ -101,7 +101,7 @@ interface IteratorConstructor { // @type-options: no-extends /** * Creates a native iterator from an iterator or iterable object. * Returns its input if the input already inherits from the built-in Iterator class. - * @param value - An iterator or iterable object to convert a native iterator. + * @param value - An iterator or iterable object to convert to a native iterator. */ from(value: Iterator | Iterable): IteratorObject; } diff --git a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts index 4a7b418c9908..e70a73fd1803 100644 --- a/packages/core-js-types/src/base/proposals/iterator-joint.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-joint.d.ts @@ -19,14 +19,14 @@ interface IteratorConstructor { // @type-options: no-extends * @param iterables - An Iterable of iterables. * @param options - Optional object: * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; - * - padding: an object specifying padding values for each key when mode is 'longest'. - * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. + * - padding: an iterable specifying padding values for each position when mode is 'longest'. + * @returns An iterator yielding arrays of values, collected one from each iterable. */ zip[]>(iterables: T, options?: ZipOptions): IteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never }, undefined, unknown>; // @type-options: prefix-return-type zip(iterables: Iterable>, options?: ZipOptions): IteratorObject; // @type-options: prefix-return-type /** - * takes an object whose values are iterables and produces an iterable of objects where keys. + * Takes an object whose values are iterables and produces an iterable of objects where keys * correspond to keys in the passed object. * @param record - An object of iterables. * @param options - Optional object: diff --git a/packages/core-js-types/src/base/proposals/map-upsert.d.ts b/packages/core-js-types/src/base/proposals/map-upsert.d.ts index 32763598548e..bfbf2fbd746a 100644 --- a/packages/core-js-types/src/base/proposals/map-upsert.d.ts +++ b/packages/core-js-types/src/base/proposals/map-upsert.d.ts @@ -8,13 +8,17 @@ interface Map { // @type-options: no-redefine /** * Returns a specified element from the Map object. * If no element is associated with the specified key, a new element with the value `defaultValue` will be inserted into the Map and returned. + * @param key - The key of the element to return. + * @param defaultValue - The value to insert if the key is not already associated with an element. * @returns The element associated with the specified key, which will be `defaultValue` if no element previously existed. */ getOrInsert(key: K, defaultValue: V): V; /** * Returns a specified element from the Map object. * If no element is associated with the specified key, the result of passing the specified key to the `callback` function will be inserted into the Map and returned. - * @returns The element associated with the specific key, which will be the newly computed value if no element previously existed. + * @param key - The key of the element to return. + * @param callback - A function that computes the value to insert if the key is not already associated with an element. It will be passed the key as an argument. + * @returns The element associated with the specified key, which will be the newly computed value if no element previously existed. */ getOrInsertComputed(key: K, callback: (key: K) => V): V; } @@ -23,13 +27,17 @@ interface WeakMap { // @type-options: no-redefine /** * Returns a specified element from the WeakMap object. * If no element is associated with the specified key, a new element with the value `defaultValue` will be inserted into the WeakMap and returned. + * @param key - The key of the element to return. + * @param defaultValue - The value to insert if the key is not already associated with an element. * @returns The element associated with the specified key, which will be `defaultValue` if no element previously existed. */ getOrInsert(key: K, defaultValue: V): V; /** * Returns a specified element from the WeakMap object. * If no element is associated with the specified key, the result of passing the specified key to the `callback` function will be inserted into the WeakMap and returned. - * @returns The element associated with the specific key, which will be the newly computed value if no element previously existed. + * @param key - The key of the element to return. + * @param callback - A function that computes the value to insert if the key is not already associated with an element. It will be passed the key as an argument. + * @returns The element associated with the specified key, which will be the newly computed value if no element previously existed. */ getOrInsertComputed(key: K, callback: (key: K) => V): V; } diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 95f443d8493f..23726a0eb352 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -162,7 +162,7 @@ declare namespace CoreJS { /** * Creates a native iterator from an iterator or iterable object. * Returns its input if the input already inherits from the built-in Iterator class. - * @param value - An iterator or iterable object to convert a native iterator. + * @param value - An iterator or iterable object to convert to a native iterator. */ from(value: Iterator | Iterable): CoreJSIteratorObject; diff --git a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts index 38184d647dc7..3e0f88201120 100644 --- a/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/ts5-2/pure/proposals/iterator.d.ts @@ -168,7 +168,7 @@ declare namespace CoreJS { /** * Creates a native iterator from an iterator or iterable object. * Returns its input if the input already inherits from the built-in Iterator class. - * @param value - An iterator or iterable object to convert a native iterator. + * @param value - An iterator or iterable object to convert to a native iterator. */ from(value: Iterator | Iterable): CoreJSIteratorObject; From 5b3012bef74dfe516de61a998370cd62da85cbd8 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 25 Feb 2026 00:32:44 +0700 Subject: [PATCH 309/315] AsyncIterator methods params alignment --- .../proposals/async-iterator-helpers.d.ts | 16 +++++------ .../proposals/async-iterator-helpers.d.ts | 28 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index 774a0c8df7a1..c1dca22f7972 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -53,24 +53,24 @@ interface AsyncIterator { /** * Executes a provided function once for each element in the iterator. - * @param callbackFn - A function that is called for each element of the iterator + * @param callbackfn - A function that is called for each element of the iterator * @returns A `Promise` that resolves when all elements have been processed */ - forEach(callbackFn: (value: T, index: number) => void | PromiseLike): Promise; + forEach(callbackfn: (value: T, index: number) => void | PromiseLike): Promise; /** - * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. - * @param mapper - A function that transforms each element of the iterator + * Creates a new `AsyncIterator` by applying the `callbackfn` function to each element of the original iterator. + * @param callbackfn - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - map(mapper: (value: T, index: number) => U): AsyncIteratorObject, undefined, unknown>; + map(callbackfn: (value: T, index: number) => U): AsyncIteratorObject, undefined, unknown>; /** - * Reduces the elements of the iterator to a single value using the `reducer` function. - * @param reducer - A function that combines two elements of the iterator + * Reduces the elements of the iterator to a single value using the `callbackfn` function. + * @param callbackfn - A function that combines two elements of the iterator * @returns A promise that resolves to the reduced value */ - reduce(reducer: (accumulator: T, value: T, index: number) => T): Promise; + reduce(callbackfn: (accumulator: T, value: T, index: number) => T): Promise; /** * Reduces the elements of the iterator to a single value using the `reducer` function. diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index f7fce9f2ead1..1d4dc2f2d731 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -57,40 +57,40 @@ declare namespace CoreJS { /** * Executes a provided function once for each element in the iterator. - * @param callbackFn - A function that is called for each element of the iterator + * @param callbackfn - A function that is called for each element of the iterator * @returns A `Promise` that resolves when all elements have been processed */ - forEach(callbackFn: (value: T, index: number) => void | PromiseLike): CoreJSPromise; + forEach(callbackfn: (value: T, index: number) => void | PromiseLike): CoreJSPromise; /** - * Creates a new `AsyncIterator` by applying the `mapper` function to each element of the original iterator. - * @param mapper - A function that transforms each element of the iterator + * Creates a new `AsyncIterator` by applying the `callbackfn` function to each element of the original iterator. + * @param callbackfn - A function that transforms each element of the iterator * @returns A new `AsyncIterator` */ - map(mapper: (value: T, index: number) => U): CoreJSAsyncIteratorObject, undefined, unknown>; + map(callbackfn: (value: T, index: number) => U): CoreJSAsyncIteratorObject, undefined, unknown>; /** - * Reduces the elements of the iterator to a single value using the `reducer` function. - * @param reducer - A function that combines two elements of the iterator + * Reduces the elements of the iterator to a single value using the `callbackfn` function. + * @param callbackfn - A function that combines two elements of the iterator * @returns A `Promise` that resolves to the reduced value */ - reduce(reducer: (accumulator: T, value: T, index: number) => T): CoreJSPromise; + reduce(callbackfn: (accumulator: T, value: T, index: number) => T): CoreJSPromise; /** - * Reduces the elements of the iterator to a single value using the `reducer` function. - * @param reducer - A function that combines two elements of the iterator + * Reduces the elements of the iterator to a single value using the `callbackfn` function. + * @param callbackfn - A function that combines two elements of the iterator * @param initialValue - The initial value to start the reduction * @returns A `Promise` that resolves to the reduced value */ - reduce(reducer: (accumulator: T, value: T, index: number) => T, initialValue: T): CoreJSPromise; + reduce(callbackfn: (accumulator: T, value: T, index: number) => T, initialValue: T): CoreJSPromise; /** - * Reduces the elements of the iterator to a single value using the `reducer` function. - * @param reducer - A function that combines two elements of the iterator + * Reduces the elements of the iterator to a single value using the `callbackfn` function. + * @param callbackfn - A function that combines two elements of the iterator * @param initialValue - The initial value to start the accumulation. Required when the accumulator type differs from the element type. * @returns A `Promise` that resolves to the reduced value */ - reduce(reducer: (accumulator: U, value: T, index: number) => U, initialValue: U): CoreJSPromise; + reduce(callbackfn: (accumulator: U, value: T, index: number) => U, initialValue: U): CoreJSPromise; /** * Checks if any value in the iterator matches a given `predicate` From 541ec828c7735a2fe288cdce133858cd8c6956e6 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev Date: Wed, 25 Feb 2026 00:35:23 +0700 Subject: [PATCH 310/315] Build pure types script cosmetic improvements --- scripts/build-entries-and-types/build-types-pure.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build-entries-and-types/build-types-pure.mjs b/scripts/build-entries-and-types/build-types-pure.mjs index a27e558630e7..4c8a4e7ff314 100644 --- a/scripts/build-entries-and-types/build-types-pure.mjs +++ b/scripts/build-entries-and-types/build-types-pure.mjs @@ -143,6 +143,7 @@ function wrapInNamespace(content) { if (line.trim() || res.at(-1)?.trim()) res.push(line); return res; }, []) + .flatMap(line => line.split('\n')) .map(line => line ? ` ${ line }` : '') .join('\n'); From af43973b7b4dc5e49b1bdcd283fffd4f29d0c095 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Wed, 25 Feb 2026 09:03:19 +0200 Subject: [PATCH 311/315] update dependencies --- tests/eslint/package-lock.json | 1074 ++++---------------------------- tests/eslint/package.json | 4 +- 2 files changed, 117 insertions(+), 961 deletions(-) diff --git a/tests/eslint/package-lock.json b/tests/eslint/package-lock.json index 474fc8a8e4dc..35dc756a3fd2 100644 --- a/tests/eslint/package-lock.json +++ b/tests/eslint/package-lock.json @@ -13,7 +13,7 @@ "@typescript-eslint/eslint-plugin": "^8.56.1", "@typescript-eslint/parser": "^8.56.1", "confusing-browser-globals": "^1.0.11", - "eslint": "^10.0.1", + "eslint": "^10.0.2", "eslint-plugin-array-func": "^5.1.0", "eslint-plugin-ascii": "^2.0.0", "eslint-plugin-depend": "^1.4.0", @@ -31,7 +31,7 @@ "eslint-plugin-redos": "^4.5.0", "eslint-plugin-regexp": "^3.0.0", "eslint-plugin-sonarjs": "^4.0.0", - "eslint-plugin-tsdoc": "^0.5.0", + "eslint-plugin-tsdoc": "^0.5.1", "eslint-plugin-unicorn": "^63.0.0", "eslint-yaml": "^0.1.0", "globals": "^17.3.0", @@ -213,118 +213,6 @@ "node": "^20.19.0 || ^22.13.0 || >=24" } }, - "node_modules/@eslint/eslintrc": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.3.tgz", - "integrity": "sha512-Kr+LPIUVKz2qkx1HAMH8q1q6azbqBAsXJUxBl/ODDuVPX45Z9DfwB8tPjTi6nNZ8BuM3nbJxC5zCAg5elnBUTQ==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^10.0.1", - "globals": "^14.0.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.1", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/@eslint/eslintrc/node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT", - "peer": true - }, - "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@eslint/eslintrc/node_modules/ignore": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", - "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">= 4" - } - }, - "node_modules/@eslint/eslintrc/node_modules/minimatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.3.tgz", - "integrity": "sha512-M2GCs7Vk83NxkUyQV1bkABc4yxgz9kILhHImZiBPAZ9ybuvCb0/H7lEl5XvIg3g+9d4eNotkZA5IWwYl0tibaA==", - "dev": true, - "license": "ISC", - "peer": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/@eslint/eslintrc/node_modules/strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@eslint/js": { - "version": "9.39.3", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.3.tgz", - "integrity": "sha512-1B1VkCq6FuUNlQvlBYb+1jDu/gV297TIs/OeiaSR9l1H27SVW55ONE1e1Vp16NqP683+xEGzxYtv4XCiDPaQiw==", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://eslint.org/donate" - } - }, "node_modules/@eslint/markdown": { "version": "7.5.1", "resolved": "https://registry.npmjs.org/@eslint/markdown/-/markdown-7.5.1.tgz", @@ -459,29 +347,29 @@ "license": "MIT" }, "node_modules/@microsoft/tsdoc-config": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.18.0.tgz", - "integrity": "sha512-8N/vClYyfOH+l4fLkkr9+myAoR6M7akc8ntBJ4DJdWH2b09uVfr71+LTMpNyG19fNqWDg8KEDZhx5wxuqHyGjw==", + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.18.1.tgz", + "integrity": "sha512-9brPoVdfN9k9g0dcWkFeA7IH9bbcttzDJlXvkf8b2OBzd5MueR1V2wkKBL0abn0otvmkHJC6aapBOTJDDeMCZg==", "dev": true, "license": "MIT", "dependencies": { "@microsoft/tsdoc": "0.16.0", - "ajv": "~8.12.0", + "ajv": "~8.18.0", "jju": "~1.4.0", "resolve": "~1.22.2" } }, "node_modules/@microsoft/tsdoc-config/node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz", + "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==", "dev": true, "license": "MIT", "dependencies": { - "fast-deep-equal": "^3.1.1", + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" + "require-from-string": "^2.0.2" }, "funding": { "type": "github", @@ -508,44 +396,6 @@ "@tybys/wasm-util": "^0.10.0" } }, - "node_modules/@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/@ota-meshi/ast-token-store": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/@ota-meshi/ast-token-store/-/ast-token-store-0.3.0.tgz", @@ -1272,14 +1122,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true, - "license": "Python-2.0", - "peer": true - }, "node_modules/balanced-match": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", @@ -1316,19 +1158,6 @@ "node": "18 || 20 || >=22" } }, - "node_modules/braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "dev": true, - "license": "MIT", - "dependencies": { - "fill-range": "^7.1.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/browserslist": { "version": "4.28.1", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.1.tgz", @@ -1386,17 +1215,6 @@ "node": ">= 0.8" } }, - "node_modules/callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">=6" - } - }, "node_modules/caniuse-lite": { "version": "1.0.30001774", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001774.tgz", @@ -1429,41 +1247,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/chalk/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, "node_modules/change-case": { "version": "5.4.4", "resolved": "https://registry.npmjs.org/change-case/-/change-case-5.4.4.tgz", @@ -1536,28 +1319,6 @@ "node": ">=20" } }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, - "license": "MIT", - "peer": true - }, "node_modules/comment-parser": { "version": "1.4.5", "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.5.tgz", @@ -1568,14 +1329,6 @@ "node": ">= 12.0.0" } }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true, - "license": "MIT", - "peer": true - }, "node_modules/config-chain": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz", @@ -1794,9 +1547,9 @@ } }, "node_modules/eslint": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.0.1.tgz", - "integrity": "sha512-20MV9SUdeN6Jd84xESsKhRly+/vxI+hwvpBMA93s+9dAcjdCuCojn4IqUGS3lvVaqjVYGYHSRMCpeFtF2rQYxQ==", + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.0.2.tgz", + "integrity": "sha512-uYixubwmqJZH+KLVYIVKY1JQt7tysXhtj21WSvjcSmU5SVNzMus1bgLe+pAt816yQ8opKfheVVoPLqvVMGejYw==", "dev": true, "license": "MIT", "dependencies": { @@ -1810,7 +1563,7 @@ "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", "@types/estree": "^1.0.6", - "ajv": "^6.12.4", + "ajv": "^6.14.0", "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", @@ -2238,490 +1991,127 @@ "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-7.2.1.tgz", "integrity": "sha512-SWKjd+EuvWkYaS+uN2csvj0KoP43YTu7+phKQ5v+xw6+A0gutVX2yqCeCkC3uLCJFiPfR2dD8Es5L7yUsmvEaA==", "dev": true, - "license": "ISC", - "dependencies": { - "@eslint-community/eslint-utils": "^4.4.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - }, - "peerDependencies": { - "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0" - } - }, - "node_modules/eslint-plugin-qunit": { - "version": "8.2.6", - "resolved": "https://registry.npmjs.org/eslint-plugin-qunit/-/eslint-plugin-qunit-8.2.6.tgz", - "integrity": "sha512-S1jC/DIW9J8VtNX4uG1vlf5FZVrfQFlcuiYmvTHR2IICUhubHqpWA5o+qS1tujh+81Gs39omKV2D4OXfbSJE5g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@eslint-community/eslint-utils": "^4.4.0", - "requireindex": "^1.2.0" - }, - "engines": { - "node": "^16.0.0 || ^18.0.0 || >=20.0.0" - }, - "peerDependencies": { - "eslint": ">=8.38.0" - } - }, - "node_modules/eslint-plugin-redos": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-redos/-/eslint-plugin-redos-4.5.0.tgz", - "integrity": "sha512-MwEEpFRmt7MWoqLCdAgN2DyOKnIVzRm3bqCUIQc/+iMJhkRxDCZ+wYQpkaYAZzemDlqUGGQ+twL3AahTNQtqFA==", - "dev": true, - "license": "MIT", - "dependencies": { - "recheck": "4.5.0" - }, - "engines": { - "node": ">=20" - }, - "peerDependencies": { - "eslint": ">= 3" - } - }, - "node_modules/eslint-plugin-regexp": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-regexp/-/eslint-plugin-regexp-3.0.0.tgz", - "integrity": "sha512-iW7hgAV8NOG6E2dz+VeKpq67YLQ9jaajOKYpoOSic2/q8y9BMdXBKkSR9gcMtbqEhNQzdW41E3wWzvhp8ExYwQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.11.0", - "comment-parser": "^1.4.0", - "jsdoc-type-pratt-parser": "^7.0.0", - "refa": "^0.12.1", - "regexp-ast-analysis": "^0.7.1", - "scslre": "^0.3.0" - }, - "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" - }, - "peerDependencies": { - "eslint": ">=9.38.0" - } - }, - "node_modules/eslint-plugin-sonarjs": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-4.0.0.tgz", - "integrity": "sha512-ihyH9HO52OeeWer/gWRndkW/ZhGqx9HDg+Iptu+ApSfiomT2LzhHgHCoyJrhh7DjCyKhjU3Hmmz1pzcXRf7B3g==", - "dev": true, - "license": "LGPL-3.0-only", - "dependencies": { - "@eslint-community/regexpp": "4.12.2", - "builtin-modules": "3.3.0", - "bytes": "3.1.2", - "functional-red-black-tree": "1.0.1", - "globals": "17.3.0", - "jsx-ast-utils-x": "0.1.0", - "lodash.merge": "4.6.2", - "minimatch": "10.2.1", - "scslre": "0.3.0", - "semver": "7.7.4", - "ts-api-utils": "2.4.0", - "typescript": ">=5" - }, - "peerDependencies": { - "eslint": "^8.0.0 || ^9.0.0 || ^10.0.0" - } - }, - "node_modules/eslint-plugin-sonarjs/node_modules/minimatch": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.1.tgz", - "integrity": "sha512-MClCe8IL5nRRmawL6ib/eT4oLyeKMGCghibcDWK+J0hh0Q8kqSdia6BvbRMVk6mPa6WqUa5uR2oxt6C5jd533A==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "brace-expansion": "^5.0.2" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/eslint-plugin-tsdoc": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.5.0.tgz", - "integrity": "sha512-ush8ehCwub2rgE16OIgQPFyj/o0k3T8kL++9IrAI4knsmupNo8gvfO2ERgDHWWgTC5MglbwLVRswU93HyXqNpw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@microsoft/tsdoc": "0.16.0", - "@microsoft/tsdoc-config": "0.18.0", - "@typescript-eslint/utils": "~8.46.0" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/config-array": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.1.tgz", - "integrity": "sha512-aw1gNayWpdI/jSYVgzN5pL0cfzU02GT3NBpeT/DXbx1/1x7ZKxFPd9bwrzygx/qiwIQiJ1sw/zD8qY/kRvlGHA==", - "dev": true, - "license": "Apache-2.0", - "peer": true, - "dependencies": { - "@eslint/object-schema": "^2.1.7", - "debug": "^4.3.1", - "minimatch": "^3.1.2" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/config-array/node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/config-array/node_modules/minimatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.3.tgz", - "integrity": "sha512-M2GCs7Vk83NxkUyQV1bkABc4yxgz9kILhHImZiBPAZ9ybuvCb0/H7lEl5XvIg3g+9d4eNotkZA5IWwYl0tibaA==", - "dev": true, - "license": "ISC", - "peer": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/config-helpers": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.4.2.tgz", - "integrity": "sha512-gBrxN88gOIf3R7ja5K9slwNayVcZgK6SOUORm2uBzTeIEfeVaIhOpCtTox3P6R7o2jLFwLFTLnC7kU/RGcYEgw==", - "dev": true, - "license": "Apache-2.0", - "peer": true, - "dependencies": { - "@eslint/core": "^0.17.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/core": { - "version": "0.17.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", - "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", - "dev": true, - "license": "Apache-2.0", - "peer": true, - "dependencies": { - "@types/json-schema": "^7.0.15" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/@eslint/object-schema": { - "version": "2.1.7", - "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz", - "integrity": "sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==", - "dev": true, - "license": "Apache-2.0", - "peer": true, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/project-service": { - "version": "8.46.4", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.46.4.tgz", - "integrity": "sha512-nPiRSKuvtTN+no/2N1kt2tUh/HoFzeEgOm9fQ6XQk4/ApGqjx0zFIIaLJ6wooR1HIoozvj2j6vTi/1fgAz7UYQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.46.4", - "@typescript-eslint/types": "^8.46.4", - "debug": "^4.3.4" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "typescript": ">=4.8.4 <6.0.0" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/scope-manager": { - "version": "8.46.4", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.46.4.tgz", - "integrity": "sha512-tMDbLGXb1wC+McN1M6QeDx7P7c0UWO5z9CXqp7J8E+xGcJuUuevWKxuG8j41FoweS3+L41SkyKKkia16jpX7CA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/types": "8.46.4", - "@typescript-eslint/visitor-keys": "8.46.4" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.46.4", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.46.4.tgz", - "integrity": "sha512-+/XqaZPIAk6Cjg7NWgSGe27X4zMGqrFqZ8atJsX3CWxH/jACqWnrWI68h7nHQld0y+k9eTTjb9r+KU4twLoo9A==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "typescript": ">=4.8.4 <6.0.0" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/types": { - "version": "8.46.4", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.46.4.tgz", - "integrity": "sha512-USjyxm3gQEePdUwJBFjjGNG18xY9A2grDVGuk7/9AkjIF1L+ZrVnwR5VAU5JXtUnBL/Nwt3H31KlRDaksnM7/w==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/typescript-estree": { - "version": "8.46.4", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.46.4.tgz", - "integrity": "sha512-7oV2qEOr1d4NWNmpXLR35LvCfOkTNymY9oyW+lUHkmCno7aOmIf/hMaydnJBUTBMRCOGZh8YjkFOc8dadEoNGA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/project-service": "8.46.4", - "@typescript-eslint/tsconfig-utils": "8.46.4", - "@typescript-eslint/types": "8.46.4", - "@typescript-eslint/visitor-keys": "8.46.4", - "debug": "^4.3.4", - "fast-glob": "^3.3.2", - "is-glob": "^4.0.3", - "minimatch": "^9.0.4", - "semver": "^7.6.0", - "ts-api-utils": "^2.1.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "typescript": ">=4.8.4 <6.0.0" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/utils": { - "version": "8.46.4", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.46.4.tgz", - "integrity": "sha512-AbSv11fklGXV6T28dp2Me04Uw90R2iJ30g2bgLz529Koehrmkbs1r7paFqr1vPCZi7hHwYxYtxfyQMRC8QaVSg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@eslint-community/eslint-utils": "^4.7.0", - "@typescript-eslint/scope-manager": "8.46.4", - "@typescript-eslint/types": "8.46.4", - "@typescript-eslint/typescript-estree": "8.46.4" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0", - "typescript": ">=4.8.4 <6.0.0" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/@typescript-eslint/visitor-keys": { - "version": "8.46.4", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.46.4.tgz", - "integrity": "sha512-/++5CYLQqsO9HFGLI7APrxBJYo+5OCMpViuhV8q5/Qa3o5mMrF//eQHks+PXcsAVaLdn817fMuS7zqoXNNZGaw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/types": "8.46.4", - "eslint-visitor-keys": "^4.2.1" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/eslint-plugin-tsdoc/node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT", - "peer": true - }, - "node_modules/eslint-plugin-tsdoc/node_modules/eslint": { - "version": "9.39.3", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.3.tgz", - "integrity": "sha512-VmQ+sifHUbI/IcSopBCF/HO3YiHQx/AVd3UVyYL6weuwW+HvON9VYn5l6Zl1WZzPWXPNZrSQpxwkkZ/VuvJZzg==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@eslint-community/eslint-utils": "^4.8.0", - "@eslint-community/regexpp": "^4.12.1", - "@eslint/config-array": "^0.21.1", - "@eslint/config-helpers": "^0.4.2", - "@eslint/core": "^0.17.0", - "@eslint/eslintrc": "^3.3.1", - "@eslint/js": "9.39.3", - "@eslint/plugin-kit": "^0.4.1", - "@humanfs/node": "^0.16.6", - "@humanwhocodes/module-importer": "^1.0.1", - "@humanwhocodes/retry": "^0.4.2", - "@types/estree": "^1.0.6", - "ajv": "^6.12.4", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.6", - "debug": "^4.3.2", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^8.4.0", - "eslint-visitor-keys": "^4.2.1", - "espree": "^10.4.0", - "esquery": "^1.5.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^8.0.0", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "ignore": "^5.2.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.3" - }, - "bin": { - "eslint": "bin/eslint.js" + "license": "ISC", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "url": "https://eslint.org/donate" + "url": "https://opencollective.com/eslint" }, "peerDependencies": { - "jiti": "*" - }, - "peerDependenciesMeta": { - "jiti": { - "optional": true - } + "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0" } }, - "node_modules/eslint-plugin-tsdoc/node_modules/eslint-scope": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", - "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", + "node_modules/eslint-plugin-qunit": { + "version": "8.2.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-qunit/-/eslint-plugin-qunit-8.2.6.tgz", + "integrity": "sha512-S1jC/DIW9J8VtNX4uG1vlf5FZVrfQFlcuiYmvTHR2IICUhubHqpWA5o+qS1tujh+81Gs39omKV2D4OXfbSJE5g==", "dev": true, - "license": "BSD-2-Clause", - "peer": true, + "license": "MIT", "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" + "@eslint-community/eslint-utils": "^4.4.0", + "requireindex": "^1.2.0" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + "node": "^16.0.0 || ^18.0.0 || >=20.0.0" }, - "funding": { - "url": "https://opencollective.com/eslint" + "peerDependencies": { + "eslint": ">=8.38.0" } }, - "node_modules/eslint-plugin-tsdoc/node_modules/eslint/node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "node_modules/eslint-plugin-redos": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-redos/-/eslint-plugin-redos-4.5.0.tgz", + "integrity": "sha512-MwEEpFRmt7MWoqLCdAgN2DyOKnIVzRm3bqCUIQc/+iMJhkRxDCZ+wYQpkaYAZzemDlqUGGQ+twL3AahTNQtqFA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "recheck": "4.5.0" + }, + "engines": { + "node": ">=20" + }, + "peerDependencies": { + "eslint": ">= 3" } }, - "node_modules/eslint-plugin-tsdoc/node_modules/eslint/node_modules/minimatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.3.tgz", - "integrity": "sha512-M2GCs7Vk83NxkUyQV1bkABc4yxgz9kILhHImZiBPAZ9ybuvCb0/H7lEl5XvIg3g+9d4eNotkZA5IWwYl0tibaA==", + "node_modules/eslint-plugin-regexp": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-regexp/-/eslint-plugin-regexp-3.0.0.tgz", + "integrity": "sha512-iW7hgAV8NOG6E2dz+VeKpq67YLQ9jaajOKYpoOSic2/q8y9BMdXBKkSR9gcMtbqEhNQzdW41E3wWzvhp8ExYwQ==", "dev": true, - "license": "ISC", - "peer": true, + "license": "MIT", "dependencies": { - "brace-expansion": "^1.1.7" + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.11.0", + "comment-parser": "^1.4.0", + "jsdoc-type-pratt-parser": "^7.0.0", + "refa": "^0.12.1", + "regexp-ast-analysis": "^0.7.1", + "scslre": "^0.3.0" }, "engines": { - "node": "*" + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "peerDependencies": { + "eslint": ">=9.38.0" } }, - "node_modules/eslint-plugin-tsdoc/node_modules/ignore": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", - "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "node_modules/eslint-plugin-sonarjs": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-4.0.0.tgz", + "integrity": "sha512-ihyH9HO52OeeWer/gWRndkW/ZhGqx9HDg+Iptu+ApSfiomT2LzhHgHCoyJrhh7DjCyKhjU3Hmmz1pzcXRf7B3g==", "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">= 4" + "license": "LGPL-3.0-only", + "dependencies": { + "@eslint-community/regexpp": "4.12.2", + "builtin-modules": "3.3.0", + "bytes": "3.1.2", + "functional-red-black-tree": "1.0.1", + "globals": "17.3.0", + "jsx-ast-utils-x": "0.1.0", + "lodash.merge": "4.6.2", + "minimatch": "10.2.1", + "scslre": "0.3.0", + "semver": "7.7.4", + "ts-api-utils": "2.4.0", + "typescript": ">=5" + }, + "peerDependencies": { + "eslint": "^8.0.0 || ^9.0.0 || ^10.0.0" } }, - "node_modules/eslint-plugin-tsdoc/node_modules/minimatch": { - "version": "9.0.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.6.tgz", - "integrity": "sha512-kQAVowdR33euIqeA0+VZTDqU+qo1IeVY+hrKYtZMio3Pg0P0vuh/kwRylLUddJhB6pf3q/botcOvRtx4IN1wqQ==", + "node_modules/eslint-plugin-sonarjs/node_modules/minimatch": { + "version": "10.2.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.1.tgz", + "integrity": "sha512-MClCe8IL5nRRmawL6ib/eT4oLyeKMGCghibcDWK+J0hh0Q8kqSdia6BvbRMVk6mPa6WqUa5uR2oxt6C5jd533A==", "dev": true, - "license": "ISC", + "license": "BlueOak-1.0.0", "dependencies": { "brace-expansion": "^5.0.2" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/eslint-plugin-tsdoc": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.5.1.tgz", + "integrity": "sha512-+EFu9XAFzogfoRspo2slmHZZ10amXqLAhmgCG0nbR6RZHNZK2XmsE7gfZ8gBjaO/p6C2DOGn09UpTGOlYy6OdQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@microsoft/tsdoc": "0.16.0", + "@microsoft/tsdoc-config": "0.18.1", + "@typescript-eslint/utils": "~8.56.0" + } + }, "node_modules/eslint-plugin-unicorn": { "version": "63.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-63.0.0.tgz", @@ -2985,36 +2375,6 @@ "dev": true, "license": "MIT" }, - "node_modules/fast-glob": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", - "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.8" - }, - "engines": { - "node": ">=8.6.0" - } - }, - "node_modules/fast-glob/node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -3029,15 +2389,22 @@ "dev": true, "license": "MIT" }, - "node_modules/fastq": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz", - "integrity": "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==", + "node_modules/fast-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz", + "integrity": "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==", "dev": true, - "license": "ISC", - "dependencies": { - "reusify": "^1.0.4" - } + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" }, "node_modules/fault": { "version": "2.0.1", @@ -3084,19 +2451,6 @@ "node": ">=16.0.0" } }, - "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "dev": true, - "license": "MIT", - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -3267,17 +2621,6 @@ "dev": true, "license": "ISC" }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">=8" - } - }, "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", @@ -3314,24 +2657,6 @@ "node": ">= 4" } }, - "node_modules/import-fresh": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", - "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -3430,16 +2755,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.12.0" - } - }, "node_modules/is-plain-obj": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", @@ -3467,20 +2782,6 @@ "dev": true, "license": "MIT" }, - "node_modules/js-yaml": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", - "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/jsdoc-type-pratt-parser": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-7.1.1.tgz", @@ -3903,16 +3204,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, "node_modules/micromark": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", @@ -4521,37 +3812,10 @@ ], "license": "MIT" }, - "node_modules/micromatch": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", - "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", - "dev": true, - "license": "MIT", - "dependencies": { - "braces": "^3.0.3", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/micromatch/node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/minimatch": { - "version": "10.2.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.2.tgz", - "integrity": "sha512-+G4CpNBxa5MprY+04MbgOw1v7So6n5JY166pFi9KfYwT78fxScCeSNQSNzp6dpPSW2rONOps6Ocam1wFhCgoVw==", + "version": "10.2.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.3.tgz", + "integrity": "sha512-Rwi3pnapEqirPSbWbrZaa6N3nmqq4Xer/2XooiOKyV3q12ML06f7MOuc5DVH8ONZIFhwIYQ3yzPH4nt7iWHaTg==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -4722,20 +3986,6 @@ "node": "^20.19.0 || ^22.12.0 || >=24.0.0" } }, - "node_modules/parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "callsites": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -4830,27 +4080,6 @@ "node": ">=6" } }, - "node_modules/queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "node_modules/rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", @@ -5101,17 +4330,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">=4" - } - }, "node_modules/resolve-pkg-maps": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", @@ -5122,41 +4340,6 @@ "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } }, - "node_modules/reusify": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", - "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", - "dev": true, - "license": "MIT", - "engines": { - "iojs": ">=1.0.0", - "node": ">=0.10.0" - } - }, - "node_modules/run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "queue-microtask": "^1.2.2" - } - }, "node_modules/scslre": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/scslre/-/scslre-0.3.0.tgz", @@ -5340,20 +4523,6 @@ "node": ">=0.10.0" } }, - "node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", @@ -5414,19 +4583,6 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, "node_modules/ts-api-utils": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.4.0.tgz", diff --git a/tests/eslint/package.json b/tests/eslint/package.json index 34e610c024a3..046f8c4e8865 100644 --- a/tests/eslint/package.json +++ b/tests/eslint/package.json @@ -9,7 +9,7 @@ "@typescript-eslint/eslint-plugin": "^8.56.1", "@typescript-eslint/parser": "^8.56.1", "confusing-browser-globals": "^1.0.11", - "eslint": "^10.0.1", + "eslint": "^10.0.2", "eslint-plugin-array-func": "^5.1.0", "eslint-plugin-ascii": "^2.0.0", "eslint-plugin-depend": "^1.4.0", @@ -27,7 +27,7 @@ "eslint-plugin-redos": "^4.5.0", "eslint-plugin-regexp": "^3.0.0", "eslint-plugin-sonarjs": "^4.0.0", - "eslint-plugin-tsdoc": "^0.5.0", + "eslint-plugin-tsdoc": "^0.5.1", "eslint-plugin-unicorn": "^63.0.0", "eslint-yaml": "^0.1.0", "globals": "^17.3.0", From 1c4a1452dcb3b9fa1ac16b7d715b159fcdabb01b Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Wed, 25 Feb 2026 09:47:17 +0200 Subject: [PATCH 312/315] fix some jsdoc and param names --- .../base/proposals/array-buffer-base64.d.ts | 3 ++- .../src/base/proposals/array-filtering.d.ts | 2 +- .../src/base/proposals/array-unique.d.ts | 22 +++++++++---------- .../proposals/async-iterator-helpers.d.ts | 18 +++++++-------- .../src/base/proposals/await-dictionary.d.ts | 2 +- .../src/base/pure/core-js-types/promise.d.ts | 2 +- .../pure/proposals/array-buffer-transfer.d.ts | 6 ++--- .../pure/proposals/array-constructor.d.ts | 2 +- .../proposals/async-iterator-helpers.d.ts | 2 +- .../src/base/pure/proposals/iterator.d.ts | 10 ++++++--- .../pure/proposals/string-replace-all.d.ts | 4 ++-- 11 files changed, 39 insertions(+), 34 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts index 8add85e6a149..96c6bb99e99b 100644 --- a/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts +++ b/packages/core-js-types/src/base/proposals/array-buffer-base64.d.ts @@ -36,9 +36,10 @@ interface Uint8ArrayConstructor { /** * Creates a new `Uint8Array` from a base16-encoded string. + * @param string - The base16-encoded string. * @returns A new `Uint8Array` instance. */ - fromHex(str: string): Uint8Array; + fromHex(string: string): Uint8Array; } interface Uint8Array { diff --git a/packages/core-js-types/src/base/proposals/array-filtering.d.ts b/packages/core-js-types/src/base/proposals/array-filtering.d.ts index 1ad162437f43..dda2db1b9f71 100644 --- a/packages/core-js-types/src/base/proposals/array-filtering.d.ts +++ b/packages/core-js-types/src/base/proposals/array-filtering.d.ts @@ -94,7 +94,7 @@ interface Uint32Array { // @type-options: no-export * @param callbackFn - A function that accepts up to three arguments. The filterReject method calls the * callbackFn function one time for each element in the array. * @param thisArg - If provided, it will be used as this value for each invocation of - * predicate. If it is not provided, undefined is used instead. + * callbackFn function. If it is not provided, undefined is used instead. */ filterReject(callbackFn: (value: number, index: number, target: Uint32Array) => unknown, thisArg?: any): Uint32Array; } diff --git a/packages/core-js-types/src/base/proposals/array-unique.d.ts b/packages/core-js-types/src/base/proposals/array-unique.d.ts index 74d16cb72c90..45fb2ae4de0c 100644 --- a/packages/core-js-types/src/base/proposals/array-unique.d.ts +++ b/packages/core-js-types/src/base/proposals/array-unique.d.ts @@ -25,7 +25,7 @@ interface Int8Array { // @type-options: no-export * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item - * @returns A new `Array` with unique items + * @returns A new `Int8Array` with unique items */ uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Int8Array; } @@ -35,7 +35,7 @@ interface Uint8Array { // @type-options: no-export * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item - * @returns A new `Array` with unique items + * @returns A new `Uint8Array` with unique items */ uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Uint8Array; } @@ -45,7 +45,7 @@ interface Uint8ClampedArray { // @type-options: no-export * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item - * @returns A new `Array` with unique items + * @returns A new `Uint8ClampedArray` with unique items */ uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Uint8ClampedArray; } @@ -55,7 +55,7 @@ interface Int16Array { // @type-options: no-export * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item - * @returns A new `Array` with unique items + * @returns A new `Int16Array` with unique items */ uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Int16Array; } @@ -65,7 +65,7 @@ interface Uint16Array { // @type-options: no-export * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item - * @returns A new `Array` with unique items + * @returns A new `Uint16Array` with unique items */ uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Uint16Array; } @@ -75,7 +75,7 @@ interface Int32Array { // @type-options: no-export * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item - * @returns A new `Array` with unique items + * @returns A new `Int32Array` with unique items */ uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Int32Array; } @@ -85,7 +85,7 @@ interface Uint32Array { // @type-options: no-export * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item - * @returns A new `Array` with unique items + * @returns A new `Uint32Array` with unique items */ uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Uint32Array; } @@ -95,7 +95,7 @@ interface Float32Array { // @type-options: no-export * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item - * @returns A new `Array` with unique items + * @returns A new `Float32Array` with unique items */ uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Float32Array; } @@ -105,7 +105,7 @@ interface Float64Array { // @type-options: no-export * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item - * @returns A new `Array` with unique items + * @returns A new `Float64Array` with unique items */ uniqueBy(resolver?: PropertyKey | ((value: number) => unknown)): Float64Array; } @@ -115,7 +115,7 @@ interface BigInt64Array { // @type-options: no-export * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item - * @returns A new `Array` with unique items + * @returns A new `BigInt64Array` with unique items */ uniqueBy(resolver?: PropertyKey | ((value: bigint) => unknown)): BigInt64Array; } @@ -125,7 +125,7 @@ interface BigUint64Array { // @type-options: no-export * Returns a new array with unique items, determined by the resolver function or property key * @param resolver - A function that resolves the value to check uniqueness against, * or a property key to compare the value from each item - * @returns A new `Array` with unique items + * @returns A new `BigUint64Array` with unique items */ uniqueBy(resolver?: PropertyKey | ((value: bigint) => unknown)): BigUint64Array; } diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts index c1dca22f7972..f0958ae57800 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers.d.ts @@ -24,7 +24,7 @@ interface AsyncIterator { /** * Check if every value generated by the iterator passes the `predicate` function. * @param predicate - A function that tests each element of the iterator - * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` + * @returns A `Promise` that resolves to `true` if all elements pass the test, otherwise `false` */ every(predicate: (value: T, index: number) => unknown): Promise; @@ -68,25 +68,25 @@ interface AsyncIterator { /** * Reduces the elements of the iterator to a single value using the `callbackfn` function. * @param callbackfn - A function that combines two elements of the iterator - * @returns A promise that resolves to the reduced value + * @returns A `Promise` that resolves to the reduced value */ reduce(callbackfn: (accumulator: T, value: T, index: number) => T): Promise; /** - * Reduces the elements of the iterator to a single value using the `reducer` function. - * @param reducer - A function that combines two elements of the iterator + * Reduces the elements of the iterator to a single value using the `callbackfn` function. + * @param callbackfn - A function that combines two elements of the iterator * @param initialValue - The initial value to start the reduction - * @returns A promise that resolves to the reduced value + * @returns A `Promise` that resolves to the reduced value */ - reduce(reducer: (accumulator: T, value: T, index: number) => T, initialValue: T): Promise; + reduce(callbackfn: (accumulator: T, value: T, index: number) => T, initialValue: T): Promise; /** - * Reduces the elements of the iterator to a single value using the `reducer` function. - * @param reducer - A function that combines two elements of the iterator + * Reduces the elements of the iterator to a single value using the `callbackfn` function. + * @param callbackfn - A function that combines two elements of the iterator * @param initialValue - The initial value to start the accumulation. Required when the accumulator type differs from the element type. * @returns A `Promise` that resolves to the reduced value */ - reduce(reducer: (accumulator: U, value: T, index: number) => U, initialValue: U): Promise; + reduce(callbackfn: (accumulator: U, value: T, index: number) => U, initialValue: U): Promise; /** * Checks if any value in the iterator matches a given `predicate` diff --git a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts index 6617a77817bf..9ee99a460241 100644 --- a/packages/core-js-types/src/base/proposals/await-dictionary.d.ts +++ b/packages/core-js-types/src/base/proposals/await-dictionary.d.ts @@ -15,7 +15,7 @@ interface PromiseConstructor { * Takes an object whose values are promises and returns a single `Promise` that resolves * to an object with the same keys, after all of the input promises have settled. * @param promises - An object of promises - * @returns A new Promise that resolves to an object with the same keys as the input object, + * @returns A new `Promise` that resolves to an object with the same keys as the input object, * where each key maps to the settlement result (`{ status, value }` or `{ status, reason }`) of the corresponding promise. */ allSettledKeyed>(promises: D): Promise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; diff --git a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts index c150b1c4c01c..4b7813f85ea3 100644 --- a/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts +++ b/packages/core-js-types/src/base/pure/core-js-types/promise.d.ts @@ -58,7 +58,7 @@ declare namespace CoreJS { * Takes an object whose values are promises and returns a single `Promise` that resolves * to an object with the same keys, after all of the input promises have settled. * @param promises - An object of promises - * @returns A new Promise that resolves to an object with the same keys as the input object, + * @returns A new `Promise` that resolves to an object with the same keys as the input object, * where each key maps to the settlement result (`{ status, value }` or `{ status, reason }`) of the corresponding promise. */ allSettledKeyed>(promises: D): CoreJSPromise<{ [k in keyof D]: CoreJS.CoreJSPromiseSettledResult> }>; diff --git a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts index 21677840bbd9..41ca5026f973 100644 --- a/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/array-buffer-transfer.d.ts @@ -14,8 +14,8 @@ declare namespace CoreJS { /** * Creates a new `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. * @param newByteLength - If provided, specifies the `byteLength` of the new `ArrayBuffer` - * @throws `RangeError` If this `ArrayBuffer` is resizable and newByteLength is greater than the `maxByteLength` of this `ArrayBuffer` - * @throws `TypeError` If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @throws RangeError If this `ArrayBuffer` is resizable and newByteLength is greater than the `maxByteLength` of this `ArrayBuffer` + * @throws TypeError If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations * @returns A new `ArrayBuffer` object */ transfer(newByteLength?: number): CoreJSArrayBuffer; @@ -23,7 +23,7 @@ declare namespace CoreJS { /** * Creates a new non-resizable `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. * @param newByteLength - If provided, specifies the `byteLength` of the new `ArrayBuffer` - * @throws `TypeError` If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations + * @throws TypeError If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations * @returns A new `ArrayBuffer` object */ transferToFixedLength(newByteLength?: number): CoreJSArrayBuffer; diff --git a/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts b/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts index 492d272b2bf2..98a056555d9d 100644 --- a/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/array-constructor.d.ts @@ -32,7 +32,7 @@ declare namespace CoreJS { fromAsync(iterableOrArrayLike: CoreJSAsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): CoreJSPromise[]>; /** - * Determines whether an `value` is a `TemplateStringsArray` + * Determines whether a `value` is a `TemplateStringsArray` * @param value - The value to be checked * @returns `true` if `value` is a `TemplateStringsArray`, otherwise `false` */ diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts index 1d4dc2f2d731..d424f90227f3 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers.d.ts @@ -28,7 +28,7 @@ declare namespace CoreJS { /** * Check if every value generated by the iterator passes the `predicate` function. * @param predicate - A function that tests each element of the iterator - * @returns A promise that resolves to `true` if all elements pass the test, otherwise `false` + * @returns A `Promise` that resolves to `true` if all elements pass the test, otherwise `false` */ every(predicate: (value: T, index: number) => unknown): CoreJSPromise; diff --git a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts index 23726a0eb352..e9aa8430a169 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator.d.ts @@ -155,6 +155,10 @@ declare namespace CoreJS { find(predicate: (value: T, index: number) => value is S): S | undefined; find(predicate: (value: T, index: number) => unknown): T | undefined; + /** + * Creates a string by concatenating all elements provided by the iterator, separated by the specified separator. + * @param separator - A string to separate each element. If omitted, the elements are separated by commas. + */ join(separator?: unknown): string; } @@ -172,14 +176,14 @@ declare namespace CoreJS { * @param iterables - An Iterable of iterables. * @param options - Optional object: * - mode: 'shortest' (default) to stop at the shortest iterable | 'longest' to stop at the longest iterable | 'strict' to throw if iterables are not the same length; - * - padding: an object specifying padding values for each key when mode is 'longest'. - * @returns An iterator yielding objects with keys from the input iterables and values from the corresponding iterables. + * - padding: an iterable specifying padding values for each position when mode is 'longest'. + * @returns An iterator yielding arrays of values, collected one from each iterable. */ zip[]>(iterables: T, options?: ZipOptions): CoreJSIteratorObject<{ [K in keyof T]: T[K] extends Iterable ? V : never }, undefined, unknown>; zip(iterables: Iterable>, options?: ZipOptions): CoreJSIteratorObject; /** - * takes an object whose values are iterables and produces an iterable of objects where keys. + * Takes an object whose values are iterables and produces an iterable of objects where keys * correspond to keys in the passed object. * @param record - An object of iterables. * @param options - Optional object: diff --git a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts index e36dc30fed26..884d4c0d23ea 100644 --- a/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/string-replace-all.d.ts @@ -14,8 +14,8 @@ declare namespace CoreJS { /** * Replace all instances of a substring in a string, using a regular expression or search string. * @param searchValue - A string to search for. - * @param replacer - A string containing the text to replace for every successful match of searchValue in this string. - * @param replacer - A function that returns the replacement text. + * @param replacer - A string containing the text to replace for every successful match of searchValue in this string + * - or function that returns the replacement text. */ replaceAll(searchValue: string | RegExp, replacer: string | ((substring: string, ...args: any[]) => string)): string; } From a4ef5debb6796ea76757bed8e33190ea4aa4b2f8 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Wed, 25 Feb 2026 10:13:36 +0200 Subject: [PATCH 313/315] return `test-type-definitions` to `test raw` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9d74512068ae..d4c3cdde392c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "lint": "run-s prepare lint-raw", "lint-raw": "run-s build-types test-eslint bundle-package test-publint", "test": "run-s prepare test-raw", - "test-raw": "run-s lint-raw types-coverage bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check", + "test-raw": "run-s lint-raw test-type-definitions types-coverage bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check", "test-eslint": "npm run zxi time tests/eslint/runner.mjs", "test-publint": "npm run zxi time tests/publint/runner.mjs", "test-unit": "run-s test-unit-karma test-unit-node test-unit-bun", From f84d3ab9eda3ab750c84e235d938817d80d0c0f6 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Wed, 25 Feb 2026 12:06:43 +0200 Subject: [PATCH 314/315] relax definitions tests matrix --- .github/workflows/ci.yml | 2 +- CONTRIBUTING.md | 6 ++- package.json | 7 ++-- tests/type-definitions/runner.mjs | 68 ++++++++++++++++++------------- 4 files changed, 50 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa8be4ee5d2a..9fd14af60d54 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: node-version: 25 cache: npm - run: npm run prepare-monorepo - - run: npx run-s build-types test-type-definitions-all + - run: npx run-s build-types test-type-definitions-ci karma: runs-on: windows-2022 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a3871b29948a..706e5f4e8352 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -85,7 +85,11 @@ If you have no access to all required browsers / versions of browsers, use [Sauc ``` - To test the types, run the command: ```sh - npm run test-type-definitions + npm run test-type-definitions-all + ``` +- To run the fast subset of the types test, run the command: + ```sh + npm run test-type-definitions-smoke ``` ## Style and standards diff --git a/package.json b/package.json index d4c3cdde392c..f5f26ad6eb26 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "lint": "run-s prepare lint-raw", "lint-raw": "run-s build-types test-eslint bundle-package test-publint", "test": "run-s prepare test-raw", - "test-raw": "run-s lint-raw test-type-definitions types-coverage bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check", + "test-raw": "run-s lint-raw test-type-definitions-smoke types-coverage bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check", "test-eslint": "npm run zxi time tests/eslint/runner.mjs", "test-publint": "npm run zxi time tests/publint/runner.mjs", "test-unit": "run-s test-unit-karma test-unit-node test-unit-bun", @@ -56,8 +56,9 @@ "test-compat-data": "npm run zxi tests/compat-data/index.mjs", "test-compat-tools": "npm run zxi tests/compat-tools/index.mjs", "test-templates": "npm run zxi tests/templates/templates.mjs", - "test-type-definitions": "npm run zxi time cd tests/type-definitions/runner.mjs", - "test-type-definitions-all": "ALL_TYPE_DEFINITIONS_TESTS=1 npm run zxi time cd tests/type-definitions/runner.mjs", + "test-type-definitions-all": "TYPE_DEFINITIONS_TESTS=ALL npm run zxi time cd tests/type-definitions/runner.mjs", + "test-type-definitions-ci": "TYPE_DEFINITIONS_TESTS=CI npm run zxi time cd tests/type-definitions/runner.mjs", + "test-type-definitions-smoke": "TYPE_DEFINITIONS_TESTS=SMOKE npm run zxi time cd tests/type-definitions/runner.mjs", "test262": "npm run zxi time cd tests/test262/runner.mjs", "types-coverage": "npm run zxi tests/type-definitions/coverage.mjs", "refresh": "UPDATE_DEPENDENCIES=1 npm run prepare-monorepo && npm run test-raw", diff --git a/tests/type-definitions/runner.mjs b/tests/type-definitions/runner.mjs index 88856053b294..5d5cfdfbbc9d 100644 --- a/tests/type-definitions/runner.mjs +++ b/tests/type-definitions/runner.mjs @@ -3,7 +3,14 @@ import { fs } from 'zx'; const { mkdir, rm, writeJson } = fs; -const ALL_TESTS = process.env.ALL_TYPE_DEFINITIONS_TESTS === '1'; +const { TYPE_DEFINITIONS_TESTS } = process.env; + +if (!['ALL', 'CI', 'SMOKE'].includes(TYPE_DEFINITIONS_TESTS)) { + throw new Error('Incorrect or lack of TYPE_DEFINITIONS_TESTS'); +} + +const ALL_TESTS = TYPE_DEFINITIONS_TESTS === 'ALL'; +const CI_TESTS = TYPE_DEFINITIONS_TESTS === 'CI'; const NUM_CPUS = cpus().length; const TMP_DIR = './tmp/'; @@ -13,9 +20,10 @@ const ES_TARGETS = [ 'es6', ]; -const TYPE_SCRIPT_VERSIONS = ALL_TESTS ? [ +const DEFAULT_TYPE_SCRIPT_VERSION = '5.9'; + +const TYPE_SCRIPT_VERSIONS = [DEFAULT_TYPE_SCRIPT_VERSION, ...ALL_TESTS ? [ '6.0.0-beta', - '5.9', '5.8', '5.7', '5.6', @@ -23,13 +31,14 @@ const TYPE_SCRIPT_VERSIONS = ALL_TESTS ? [ // '5.4', // '5.3', // '5.2', -] : [ - '5.9', +] : CI_TESTS ? [ + '6.0.0-beta', '5.6', -]; +] : [ + // empty +]]; const ENVIRONMENTS = ALL_TESTS ? [ - null, '@types/node@25', '@types/node@24', '@types/node@22', @@ -39,21 +48,24 @@ const ENVIRONMENTS = ALL_TESTS ? [ // '@types/node@15', // fails // '@types/bun@latest', // ArrayBuffer.resize signature incorrect. Return type ArrayBuffer instead of void. // '@types/deno@latest', // fails +] : CI_TESTS ? [ + '@types/node@25', + '@types/node@24', + '@types/node@22', + '@types/node@16', ] : [ - null, '@types/node@25', ]; +const LIBS = [ + 'dom', +]; + const CORE_JS_MODES = [ 'global', 'pure', ]; -const LIBS = [ - 'dom', - null, -]; - const TARGET_RULES = { es6: '**/*es2018*test.ts', }; @@ -79,7 +91,7 @@ async function runTasksInParallel() { })); } -async function runTask({ cwd, ts, config, args = [] }) { +async function runTask({ cwd, ts = DEFAULT_TYPE_SCRIPT_VERSION, config, args = [] }) { const task = $({ cwd, verbose: false })`npx --package typescript@${ ts } tsc --project ${ config } ${ args }`; // eslint-disable-next-line no-underscore-dangle -- third-party code const { cmd } = task._snapshot; @@ -98,8 +110,8 @@ function * buildTasks() { for (const mode of CORE_JS_MODES) { for (const target of ES_TARGETS) { for (const ts of TYPE_SCRIPT_VERSIONS) { - for (const env of ENVIRONMENTS) { - for (const lib of LIBS) { + for (const env of [null, ...ENVIRONMENTS]) { + for (const lib of [null, ...LIBS]) { const tsConfigPostfix = `${ TARGET_RULES[target] ? `.${ target }` : '' }${ LIB_RULES[lib] ? `.${ lib }` : '' }`; const config = env ? `./tsconfig.${ mode }${ tsConfigPostfix }.json` : `${ mode }/tsconfig${ tsConfigPostfix }.json`; const libWithTarget = lib ? `${ target },${ lib }` : target; @@ -156,18 +168,18 @@ async function prepareEnvironments() { } const tasks = [ - { ts: '5.9', config: 'tools/tsconfig.json' }, - { ts: '5.9', config: 'templates/tsconfig.json' }, - { ts: '5.9', config: 'templates/tsconfig.require.json' }, - { ts: '5.9', config: 'entries/full/tsconfig.json' }, - { ts: '5.9', config: 'entries/actual/tsconfig.json' }, - { ts: '5.9', config: 'entries/stable/tsconfig.json' }, - { ts: '5.9', config: 'entries/es/tsconfig.json' }, - { ts: '5.9', config: 'entries/proposals/tsconfig.json' }, - { ts: '5.9', config: 'entries/global-imports/tsconfig.json' }, - { ts: '5.9', config: 'entries/pure-imports/tsconfig.json' }, - { ts: '5.9', config: 'entries/configurator/tsconfig.json' }, - { ts: '5.9', config: 'entries/pure-pollutions/tsconfig.json' }, + { config: 'tools/tsconfig.json' }, + { config: 'templates/tsconfig.json' }, + { config: 'templates/tsconfig.require.json' }, + { config: 'entries/full/tsconfig.json' }, + { config: 'entries/actual/tsconfig.json' }, + { config: 'entries/stable/tsconfig.json' }, + { config: 'entries/es/tsconfig.json' }, + { config: 'entries/proposals/tsconfig.json' }, + { config: 'entries/global-imports/tsconfig.json' }, + { config: 'entries/pure-imports/tsconfig.json' }, + { config: 'entries/configurator/tsconfig.json' }, + { config: 'entries/pure-pollutions/tsconfig.json' }, ...buildTasks(), ]; From 69cd5efb5edfa36f66759428cbeb8d4e6d4b49d2 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Wed, 25 Feb 2026 13:00:49 +0200 Subject: [PATCH 315/315] fix some jsdoc and param names --- .../src/base/proposals/async-iterator-helpers-custom.d.ts | 4 ++-- .../src/base/proposals/iterator-helpers-custom.d.ts | 4 ++-- .../pure/proposals/async-iterator-helpers-custom.d.ts | 4 ++-- .../src/base/pure/proposals/collection-of-from.d.ts | 8 ++++---- .../src/base/pure/proposals/iterator-helpers-custom.d.ts | 4 ++-- .../core-js-types/src/base/pure/proposals/symbol.d.ts | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/core-js-types/src/base/proposals/async-iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/proposals/async-iterator-helpers-custom.d.ts index bee15f31244e..62a19d1f98a5 100644 --- a/packages/core-js-types/src/base/proposals/async-iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/async-iterator-helpers-custom.d.ts @@ -7,7 +7,7 @@ declare namespace CoreJS { export type AsyncIteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable | AsyncIterator | AsyncIterable) => AsyncIteratorObject; - export type AsyncIteratorMap = (callback: (value: T, index: number) => U) => AsyncIteratorObject, undefined, unknown>; + export type AsyncIteratorMap = (callbackfn: (value: T, index: number) => U) => AsyncIteratorObject, undefined, unknown>; - export type AsyncIteratorReduce = (callback: (accumulator: U, value: T, index: number) => U, initialValue?: U) => Promise; + export type AsyncIteratorReduce = (callbackfn: (accumulator: U, value: T, index: number) => U, initialValue?: U) => Promise; } diff --git a/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts index b6943dfc70ba..31749fc7ac57 100644 --- a/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/proposals/iterator-helpers-custom.d.ts @@ -11,7 +11,7 @@ declare namespace CoreJS { export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => IteratorObject; - export type IteratorMap = (callback: (value: T, index: number) => U) => IteratorObject; + export type IteratorMap = (callbackfn: (value: T, index: number) => U) => IteratorObject; - export type IteratorReduce = (callback: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; + export type IteratorReduce = (callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; } diff --git a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers-custom.d.ts index b30785c45813..6909a5b8e883 100644 --- a/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/async-iterator-helpers-custom.d.ts @@ -8,7 +8,7 @@ declare namespace CoreJS { export type AsyncIteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable | CoreJS.CoreJSAsyncIterator | CoreJS.CoreJSAsyncIterable) => CoreJS.CoreJSAsyncIteratorObject; - export type AsyncIteratorMap = (callback: (value: T, index: number) => U) => CoreJS.CoreJSAsyncIteratorObject, undefined, unknown>; + export type AsyncIteratorMap = (callbackfn: (value: T, index: number) => U) => CoreJS.CoreJSAsyncIteratorObject, undefined, unknown>; - export type AsyncIteratorReduce = (callback: (accumulator: U, value: T, index: number) => U, initialValue?: U) => CoreJS.CoreJSPromise; + export type AsyncIteratorReduce = (callbackfn: (accumulator: U, value: T, index: number) => U, initialValue?: U) => CoreJS.CoreJSPromise; } diff --git a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts index bdfe2bce94a1..69ae1cac0a47 100644 --- a/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/collection-of-from.d.ts @@ -10,9 +10,9 @@ declare namespace CoreJS { export interface CoreJSMapConstructor extends MapConstructor { /** - * Creates a new `Map` instance from an iterable or array-like object of [key, value] pairs. + * Creates a new `Map` instance from an iterable object of [key, value] pairs. * Optionally, applies a mapping function to each pair. - * @param source - Iterable or array-like object of [key, value] pairs. + * @param source - Iterable object of [key, value] pairs. * @param mapFn - Function to call on every [key, value] pair before adding to the `Map`. * @param thisArg - Value to use as this when executing mapFn. * @returns A new `Map` instance. @@ -53,9 +53,9 @@ declare namespace CoreJS { export interface CoreJSWeakMapConstructor extends WeakMapConstructor { /** - * Creates a new `WeakMap` instance from an iterable or array-like object of [key, value] pairs. + * Creates a new `WeakMap` instance from an iterable object of [key, value] pairs. * Optionally, applies a mapping function to each pair. - * @param source - Iterable or array-like object of [key, value] pairs. + * @param source - Iterable object of [key, value] pairs. * @param mapFn - Function to call on every [key, value] pair before adding to the `WeakMap`. * @param thisArg - Value to use as this when executing mapFn. * @returns A new `WeakMap` instance. diff --git a/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts b/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts index 5ffb7ff1ef70..0e4e335f2ba7 100644 --- a/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/iterator-helpers-custom.d.ts @@ -11,7 +11,7 @@ declare namespace CoreJS { export type IteratorFlatMap = (callback: (value: T, index: number) => Iterator | Iterable) => CoreJS.CoreJSIteratorObject; - export type IteratorMap = (callback: (value: T, index: number) => U) => CoreJS.CoreJSIteratorObject; + export type IteratorMap = (callbackfn: (value: T, index: number) => U) => CoreJS.CoreJSIteratorObject; - export type IteratorReduce = (callback: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; + export type IteratorReduce = (callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue?: U) => U; } diff --git a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts index dad0078c4657..2ed9cc30b9c5 100644 --- a/packages/core-js-types/src/base/pure/proposals/symbol.d.ts +++ b/packages/core-js-types/src/base/pure/proposals/symbol.d.ts @@ -56,13 +56,13 @@ declare namespace CoreJS { /** * Determines whether the given value is a registered symbol. - * @param value - The value to be checked. + * @param value - The value to check. */ isRegisteredSymbol(value: unknown): value is symbol; /** * Determines whether the given value is a well-known symbol. - * @param value - The value to be checked. + * @param value - The value to check. */ isWellKnownSymbol(value: unknown): value is symbol;