Skip to content

Commit 8dcdd8f

Browse files
committed
Types improvements
1 parent 88a0f47 commit 8dcdd8f

Some content is hidden

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

49 files changed

+111
-74
lines changed

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ node_modules/
2020
/packages/core-js/stable/
2121
/packages/core-js/stage/
2222
/packages/core-js/index.js
23-
/packages/core-js/index.d.ts
2423
/packages/core-js/LICENSE
2524
/packages/core-js-babel-plugin/LICENSE
2625
/packages/core-js-builder/LICENSE
@@ -44,11 +43,11 @@ node_modules/
4443
/packages/core-js-pure/proposals/
4544
/packages/core-js-pure/stable/
4645
/packages/core-js-pure/stage/
47-
/packages/core-js-pure/types/
4846
/packages/core-js-pure/LICENSE
4947
/packages/core-js-pure/index.js
50-
/packages/core-js-pure/index.d.ts
5148
/packages/core-js-pure/configurator.js
49+
/packages/core-js-types/dist/
50+
/packages/core-js-types/LICENSE
5251
/tests/**/bundles/
5352
/tests/compat/*.jar
5453
/tests/compat/compat-data.js

packages/core-js-types/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/core-js-types/src/56/common/immediate.d.ts renamed to packages/core-js-types/src/56/common/efficient-script-yielding.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
type Immediate = number | object;
22

33
declare function setImmediate(handler: (...args: any[]) => void, ...args: any[]): Immediate;
4+
45
declare function clearImmediate(immediate: Immediate): void;

packages/core-js-types/src/56/common/object-extend.d.ts renamed to packages/core-js-types/src/56/common/object-prototype-accessor-methods.d.ts

File renamed without changes.

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

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

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

20-
interface AsyncIterable<T, TReturn = any, TNext = any> { [Symbol.asyncIterator](): AsyncIterator<T, TReturn, TNext>; }
20+
interface AsyncIterable<T, TReturn = any, TNext = any> {
21+
[Symbol.asyncIterator](): AsyncIterator<T, TReturn, TNext>;
22+
}
2123
}
2224

23-
export type CoreJsDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O }
25+
export type CoreJSDecoratorMetadataObject = typeof globalThis extends { DecoratorMetadataObject: infer O } // from ts 5.2
2426
? O
2527
: Record<PropertyKey, unknown> & object;
2628

27-
export type CoreJsIteratorObject<T, TReturn = any, TNext = undefined> = IteratorObject<T, TReturn, TNext>;
29+
export type CoreJSIteratorObject<T, TReturn = any, TNext = undefined> = IteratorObject<T, TReturn, TNext>;
2830

29-
export type CoreJsFlatArray<Arr, Depth extends number> = typeof globalThis extends { FlatArray: infer O }
31+
export type CoreJSFlatArray<Arr, Depth extends number> = typeof globalThis extends { FlatArray: infer O } // from ts 4.4
3032
? O
3133
: {
3234
done: Arr;
33-
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]>
35+
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]>
3436
: Arr;
3537
}[Depth extends -1 ? "done" : "recur"];
3638

37-
export type CoreJsPromiseSettledResult<T> = typeof globalThis extends { PromiseSettledResult: infer O }
39+
export type CoreJSPromiseSettledResult<T> = typeof globalThis extends { PromiseSettledResult: infer O } // from ts 3.8 and es2020
3840
? O
3941
: PromiseFulfilledResult<T> | PromiseRejectedResult;

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,38 @@
44
// For ensuring compatibility with TypeScript standard types, this code is based on:
55
// https://github.com/microsoft/TypeScript/blob/d3be7e171bf3149fe93c3ce5a85280f1eba3ef8d/src/lib/esnext.typedarrays.d.ts
66
// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt
7+
78
type alphabet = 'base64' | 'base64url';
9+
810
type lastChunkHandling = 'loose' | 'strict' | 'stop-before-partial';
11+
912
type fromBase64Options = {
1013
alphabet?: alphabet;
1114
lastChunkHandling?: lastChunkHandling;
1215
}
16+
1317
type toBase64Options = {
1418
alphabet?: alphabet;
1519
omitPadding?: boolean;
1620
}
21+
1722
type processMetadata = {
1823
read: number;
1924
written: number;
2025
}
2126

2227
interface Uint8ArrayConstructor {
2328
fromBase64(str: string, opts?: fromBase64Options): Uint8Array;
29+
2430
fromHex(str: string): Uint8Array;
2531
}
2632

2733
interface Uint8Array {
2834
setFromBase64(str: string, opts?: fromBase64Options): processMetadata;
35+
2936
setFromHex(str: string): processMetadata;
37+
3038
toBase64(opts?: toBase64Options): string;
39+
3140
toHex(): string;
3241
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// proposal stage: 4
22
// https://github.com/tc39/proposal-arraybuffer-transfer
3+
34
interface ArrayBuffer {
45
// todo hack for modern ts
56
// get detached(): boolean;
67

78
transfer(newByteLength?: number): ArrayBuffer;
9+
810
transferToFixedLength(newByteLength?: number): ArrayBuffer;
911
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// proposal stage: 1
22
// https://github.com/tc39/proposal-array-filtering
3+
34
interface Array<T> {
45
filterReject(callbackFn: (value: T, index: number, target: T[]) => boolean, thisArg?: any): T[];
56
}

packages/core-js-types/src/56/proposals/array-find-from-last.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/es2023.array.d.ts
66
// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt
7+
78
interface Array<T> {
89
findLast<S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined;
910

packages/core-js-types/src/56/proposals/array-flat-map-custom.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
// https://github.com/microsoft/TypeScript/blob/069de743dbd17b47cc2fc58e1d16da5410911284/src/lib/es2019.array.d.ts#L46
66
// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt
77

8-
declare namespace CoreJs {
8+
declare namespace CoreJS {
99
export type ArrayFlatMap<T, U, This = undefined> = (callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray<U>, thisArg?: This) => U[];
1010
}

0 commit comments

Comments
 (0)