Skip to content

Commit 5bb9ba1

Browse files
committed
Pure types
1 parent a3e1a9d commit 5bb9ba1

File tree

106 files changed

+2494
-664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+2494
-664
lines changed

packages/core-js-types/src/52/web/url-parse.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare global {
2-
interface URLConstructor {
2+
interface URLConstructor extends URL {
33
parse(url: string | URL, base?: string | URL): URL | null;
44
}
55
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare namespace CoreJS {
2+
export function CoreJSparseFloat(string: string): number;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare namespace CoreJS {
2+
export function CoreJSparseInt(string: string): number;
3+
}

packages/core-js-types/src/56/core-js-types/core-js-types.d.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ declare global {
1717

1818
interface PromiseRejectedResult { status: "rejected"; reason: any; }
1919

20+
interface AsyncIterator<T, TReturn = any, TNext = any> {
21+
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
22+
next(...[value]: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
23+
return?(value?: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
24+
throw?(e?: any): Promise<IteratorResult<T, TReturn>>;
25+
}
26+
27+
interface AsyncIteratorConstructor {}
28+
29+
var AsyncIterator: AsyncIteratorConstructor;
30+
2031
interface AsyncIterable<T, TReturn = any, TNext = any> {
2132
[Symbol.asyncIterator](): AsyncIterator<T, TReturn, TNext>;
2233
}
@@ -28,14 +39,14 @@ export type CoreJSDecoratorMetadataObject = typeof globalThis extends { Decorato
2839

2940
export type CoreJSIteratorObject<T, TReturn = any, TNext = undefined> = IteratorObject<T, TReturn, TNext>;
3041

42+
export type CoreJSPromiseSettledResult<T> = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020
43+
? O
44+
: PromiseFulfilledResult<T> | PromiseRejectedResult;
45+
3146
export type CoreJSFlatArray<Arr, Depth extends number> = typeof globalThis extends { FlatArray: infer O } // from ts 4.4
3247
? O
3348
: {
3449
done: Arr;
3550
recur: Arr extends ReadonlyArray<infer InnerArr> ? CoreJSFlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][Depth]>
3651
: Arr;
3752
}[Depth extends -1 ? "done" : "recur"];
38-
39-
export type CoreJSPromiseSettledResult<T> = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020
40-
? O
41-
: PromiseFulfilledResult<T> | PromiseRejectedResult;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/// <reference types="../proposals/pure/symbol.d.ts" />
2+
/// <reference types="../proposals/pure/iterator.d.ts" />
3+
4+
// For ensuring compatibility with TypeScript standard types, this code is based on:
5+
// https://github.com/microsoft/TypeScript/blob/2a90a739c1c1e87e3c3d0c93e16f7e5baadf8035/src/lib/es2019.array.d.ts
6+
// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt
7+
8+
declare namespace CoreJS {
9+
export type CoreJSDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } // from ts 5.2
10+
? O
11+
: Record<PropertyKey, unknown> & object;
12+
13+
interface PromiseFulfilledResult<T> { status: "fulfilled"; value: T; }
14+
15+
interface PromiseRejectedResult { status: "rejected"; reason: any; }
16+
17+
export type CoreJSPromiseSettledResult<T> = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020
18+
? O
19+
: PromiseFulfilledResult<T> | PromiseRejectedResult;
20+
21+
export type CoreJSFlatArray<Arr, Depth extends number> = typeof globalThis extends { FlatArray: infer O } // from ts 4.4
22+
? O
23+
: {
24+
done: Arr;
25+
recur: Arr extends ReadonlyArray<infer InnerArr> ? CoreJSFlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][Depth]>
26+
: Arr;
27+
}[Depth extends -1 ? "done" : "recur"];
28+
}

packages/core-js-types/src/56/proposals/accessible-object-hasownproperty.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// For ensuring compatibility with TypeScript standard types, this code is based on:
55
// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2022.object.d.ts
66
// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt
7+
78
interface ObjectConstructor {
89
/**
910
* Determines whether an object has a property with the specified name.

packages/core-js-types/src/56/proposals/array-buffer-base64.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ interface Uint8ArrayConstructor {
4242
fromHex(str: string): Uint8Array;
4343
}
4444

45-
interface Uint8Array {
45+
interface Uint8Array { // @type-options no-redefine
4646
/**
4747
* Sets the `Uint8Array` from a base64-encoded string.
4848
* @param string The base64-encoded string.

packages/core-js-types/src/56/proposals/array-buffer-transfer.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// https://github.com/microsoft/TypeScript/blob/4a957b74ea4d716356181644d23f6ad5f10824d6/src/lib/es2024.arraybuffer.d.ts
66
// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt
77

8-
interface ArrayBuffer {
8+
interface ArrayBuffer { // @type-options export-base-constructor
99
// todo hack for modern ts
1010
// get detached(): boolean;
1111

packages/core-js-types/src/56/proposals/array-filtering.d.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// proposal stage: 1
22
// https://github.com/tc39/proposal-array-filtering
33

4-
interface Array<T> {
4+
interface Array<T> { // @type-options no-redefine
55
/**
66
* Removes the items that return true
77
* @param callbackFn A function that accepts up to three arguments. The filterReject method calls the
@@ -12,7 +12,7 @@ interface Array<T> {
1212
filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[];
1313
}
1414

15-
interface Int8Array {
15+
interface Int8Array { // @type-options no-redefine
1616
/**
1717
* Removes the items that return true
1818
* @param callbackFn A function that accepts up to three arguments. The filterReject method calls the
@@ -23,7 +23,7 @@ interface Int8Array {
2323
filterReject(callbackFn: (value: number, index: number, target: Int8Array) => boolean, thisArg?: any): Int8Array;
2424
}
2525

26-
interface Uint8Array {
26+
interface Uint8Array { // @type-options no-redefine
2727
/**
2828
* Removes the items that return true
2929
* @param callbackFn A function that accepts up to three arguments. The filterReject method calls the
@@ -34,7 +34,7 @@ interface Uint8Array {
3434
filterReject(callbackFn: (value: number, index: number, target: Uint8Array) => boolean, thisArg?: any): Uint8Array;
3535
}
3636

37-
interface Uint8ClampedArray {
37+
interface Uint8ClampedArray { // @type-options no-redefine
3838
/**
3939
* Removes the items that return true
4040
* @param callbackFn A function that accepts up to three arguments. The filterReject method calls the
@@ -45,7 +45,7 @@ interface Uint8ClampedArray {
4545
filterReject(callbackFn: (value: number, index: number, target: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray;
4646
}
4747

48-
interface Int16Array {
48+
interface Int16Array { // @type-options no-redefine
4949
/**
5050
* Removes the items that return true
5151
* @param callbackFn A function that accepts up to three arguments. The filterReject method calls the
@@ -56,7 +56,7 @@ interface Int16Array {
5656
filterReject(callbackFn: (value: number, index: number, target: Int16Array) => boolean, thisArg?: any): Int16Array;
5757
}
5858

59-
interface Uint16Array {
59+
interface Uint16Array { // @type-options no-redefine
6060
/**
6161
* Removes the items that return true
6262
* @param callbackFn A function that accepts up to three arguments. The filterReject method calls the
@@ -67,7 +67,7 @@ interface Uint16Array {
6767
filterReject(callbackFn: (value: number, index: number, target: Uint16Array) => boolean, thisArg?: any): Uint16Array;
6868
}
6969

70-
interface Int32Array {
70+
interface Int32Array { // @type-options no-redefine
7171
/**
7272
* Removes the items that return true
7373
* @param callbackFn A function that accepts up to three arguments. The filterReject method calls the
@@ -78,7 +78,7 @@ interface Int32Array {
7878
filterReject(callbackFn: (value: number, index: number, target: Int32Array) => boolean, thisArg?: any): Int32Array;
7979
}
8080

81-
interface Uint32Array {
81+
interface Uint32Array { // @type-options no-redefine
8282
/**
8383
* Removes the items that return true
8484
* @param callbackFn A function that accepts up to three arguments. The filterReject method calls the
@@ -89,7 +89,7 @@ interface Uint32Array {
8989
filterReject(callbackFn: (value: number, index: number, target: Uint32Array) => boolean, thisArg?: any): Uint32Array;
9090
}
9191

92-
interface Float32Array {
92+
interface Float32Array { // @type-options no-redefine
9393
/**
9494
* Removes the items that return true
9595
* @param callbackFn A function that accepts up to three arguments. The filterReject method calls the
@@ -100,11 +100,11 @@ interface Float32Array {
100100
filterReject(callbackFn: (value: number, index: number, target: Float32Array) => boolean, thisArg?: any): Float32Array;
101101
}
102102

103-
interface Float64Array {
103+
interface Float64Array { // @type-options no-redefine
104104
filterReject(callbackFn: (value: number, index: number, target: Float64Array) => boolean, thisArg?: any): Float64Array;
105105
}
106106

107-
interface BigInt64Array {
107+
interface BigInt64Array { // @type-options no-redefine
108108
/**
109109
* Removes the items that return true
110110
* @param callbackFn A function that accepts up to three arguments. The filterReject method calls the
@@ -115,7 +115,7 @@ interface BigInt64Array {
115115
filterReject(callbackFn: (value: bigint, index: number, target: BigInt64Array) => boolean, thisArg?: any): BigInt64Array;
116116
}
117117

118-
interface BigUint64Array {
118+
interface BigUint64Array { // @type-options no-redefine
119119
/**
120120
* Removes the items that return true
121121
* @param callbackFn A function that accepts up to three arguments. The filterReject method calls the

packages/core-js-types/src/56/proposals/array-find-from-last.d.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2023.array.d.ts
66
// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt
77

8-
interface Array<T> {
8+
interface Array<T> { // @type-options no-redefine
99
/**
1010
* Returns the value of the last element in the array where predicate is true, and undefined
1111
* otherwise.
@@ -30,7 +30,7 @@ interface Array<T> {
3030
findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number;
3131
}
3232

33-
interface Int8Array {
33+
interface Int8Array { // @type-options no-redefine
3434
/**
3535
* Returns the value of the last element in the array where predicate is true, and undefined
3636
* otherwise.
@@ -55,7 +55,7 @@ interface Int8Array {
5555
findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number;
5656
}
5757

58-
interface Uint8Array {
58+
interface Uint8Array { // @type-options no-redefine
5959
/**
6060
* Returns the value of the last element in the array where predicate is true, and undefined
6161
* otherwise.
@@ -80,7 +80,7 @@ interface Uint8Array {
8080
findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number;
8181
}
8282

83-
interface Uint8ClampedArray {
83+
interface Uint8ClampedArray { // @type-options no-redefine
8484
/**
8585
* Returns the value of the last element in the array where predicate is true, and undefined
8686
* otherwise.
@@ -105,7 +105,7 @@ interface Uint8ClampedArray {
105105
findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number;
106106
}
107107

108-
interface Int16Array {
108+
interface Int16Array { // @type-options no-redefine
109109
/**
110110
* Returns the value of the last element in the array where predicate is true, and undefined
111111
* otherwise.
@@ -130,7 +130,7 @@ interface Int16Array {
130130
findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number;
131131
}
132132

133-
interface Uint16Array {
133+
interface Uint16Array { // @type-options no-redefine
134134
/**
135135
* Returns the value of the last element in the array where predicate is true, and undefined
136136
* otherwise.
@@ -155,7 +155,7 @@ interface Uint16Array {
155155
findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number;
156156
}
157157

158-
interface Int32Array {
158+
interface Int32Array { // @type-options no-redefine
159159
/**
160160
* Returns the value of the last element in the array where predicate is true, and undefined
161161
* otherwise.
@@ -180,7 +180,7 @@ interface Int32Array {
180180
findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number;
181181
}
182182

183-
interface Uint32Array {
183+
interface Uint32Array { // @type-options no-redefine
184184
/**
185185
* Returns the value of the last element in the array where predicate is true, and undefined
186186
* otherwise.
@@ -205,7 +205,7 @@ interface Uint32Array {
205205
findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number;
206206
}
207207

208-
interface Float32Array {
208+
interface Float32Array { // @type-options no-redefine
209209
/**
210210
* Returns the value of the last element in the array where predicate is true, and undefined
211211
* otherwise.
@@ -230,7 +230,7 @@ interface Float32Array {
230230
findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number;
231231
}
232232

233-
interface Float64Array {
233+
interface Float64Array { // @type-options no-redefine
234234
/**
235235
* Returns the value of the last element in the array where predicate is true, and undefined
236236
* otherwise.
@@ -246,7 +246,7 @@ interface Float64Array {
246246
findLastIndex(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): number;
247247
}
248248

249-
interface BigInt64Array {
249+
interface BigInt64Array { // @type-options no-redefine
250250
/**
251251
* Returns the value of the last element in the array where predicate is true, and undefined
252252
* otherwise.
@@ -271,7 +271,7 @@ interface BigInt64Array {
271271
findLastIndex(predicate: (value: bigint, index: number, array: this) => unknown, thisArg?: any): number;
272272
}
273273

274-
interface BigUint64Array {
274+
interface BigUint64Array { // @type-options no-redefine
275275
/**
276276
* Returns the value of the last element in the array where predicate is true, and undefined
277277
* otherwise.

0 commit comments

Comments
 (0)