strict-ts-lib-v5.4 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/libs/decorators/index.d.ts +364 -0
- package/libs/decorators/legacy/index.d.ts +19 -0
- package/libs/dom/asynciterable/index.d.ts +14 -0
- package/libs/dom/index.d.ts +35333 -0
- package/libs/dom/iterable/index.d.ts +748 -0
- package/libs/es2015/collection/index.d.ts +148 -0
- package/libs/es2015/core/index.d.ts +574 -0
- package/libs/es2015/generator/index.d.ts +65 -0
- package/libs/es2015/index.d.ts +12 -0
- package/libs/es2015/iterable/index.d.ts +524 -0
- package/libs/es2015/promise/index.d.ts +74 -0
- package/libs/es2015/proxy/index.d.ts +131 -0
- package/libs/es2015/reflect/index.d.ts +145 -0
- package/libs/es2015/symbol/index.d.ts +30 -0
- package/libs/es2015/symbol-wellknown/index.d.ts +331 -0
- package/libs/es2016/array-include/index.d.ts +115 -0
- package/libs/es2016/full/index.d.ts +7 -0
- package/libs/es2016/index.d.ts +5 -0
- package/libs/es2016/intl/index.d.ts +15 -0
- package/libs/es2017/date/index.d.ts +23 -0
- package/libs/es2017/full/index.d.ts +7 -0
- package/libs/es2017/index.d.ts +9 -0
- package/libs/es2017/intl/index.d.ts +28 -0
- package/libs/es2017/object/index.d.ts +115 -0
- package/libs/es2017/sharedmemory/index.d.ts +244 -0
- package/libs/es2017/string/index.d.ts +29 -0
- package/libs/es2017/typedarrays/index.d.ts +37 -0
- package/libs/es2018/asyncgenerator/index.d.ts +69 -0
- package/libs/es2018/asynciterable/index.d.ts +31 -0
- package/libs/es2018/full/index.d.ts +8 -0
- package/libs/es2018/index.d.ts +8 -0
- package/libs/es2018/intl/index.d.ts +103 -0
- package/libs/es2018/promise/index.d.ts +14 -0
- package/libs/es2018/regexp/index.d.ts +21 -0
- package/libs/es2019/array/index.d.ts +94 -0
- package/libs/es2019/full/index.d.ts +8 -0
- package/libs/es2019/index.d.ts +8 -0
- package/libs/es2019/intl/index.d.ts +7 -0
- package/libs/es2019/object/index.d.ts +143 -0
- package/libs/es2019/string/index.d.ts +21 -0
- package/libs/es2019/symbol/index.d.ts +8 -0
- package/libs/es2020/bigint/index.d.ts +833 -0
- package/libs/es2020/date/index.d.ts +35 -0
- package/libs/es2020/full/index.d.ts +8 -0
- package/libs/es2020/index.d.ts +11 -0
- package/libs/es2020/intl/index.d.ts +473 -0
- package/libs/es2020/number/index.d.ts +15 -0
- package/libs/es2020/promise/index.d.ts +37 -0
- package/libs/es2020/sharedmemory/index.d.ts +119 -0
- package/libs/es2020/string/index.d.ts +30 -0
- package/libs/es2020/symbol-wellknown/index.d.ts +21 -0
- package/libs/es2021/full/index.d.ts +8 -0
- package/libs/es2021/index.d.ts +7 -0
- package/libs/es2021/intl/index.d.ts +161 -0
- package/libs/es2021/promise/index.d.ts +34 -0
- package/libs/es2021/string/index.d.ts +20 -0
- package/libs/es2021/weakref/index.d.ts +60 -0
- package/libs/es2022/array/index.d.ts +105 -0
- package/libs/es2022/error/index.d.ts +57 -0
- package/libs/es2022/full/index.d.ts +8 -0
- package/libs/es2022/index.d.ts +10 -0
- package/libs/es2022/intl/index.d.ts +112 -0
- package/libs/es2022/object/index.d.ts +41 -0
- package/libs/es2022/regexp/index.d.ts +23 -0
- package/libs/es2022/sharedmemory/index.d.ts +37 -0
- package/libs/es2022/string/index.d.ts +9 -0
- package/libs/es2023/array/index.d.ts +906 -0
- package/libs/es2023/collection/index.d.ts +5 -0
- package/libs/es2023/full/index.d.ts +8 -0
- package/libs/es2023/index.d.ts +5 -0
- package/libs/es5/index.d.ts +5738 -0
- package/libs/es6/index.d.ts +7 -0
- package/libs/esnext/collection/index.d.ts +13 -0
- package/libs/esnext/decorators/index.d.ts +12 -0
- package/libs/esnext/disposable/index.d.ts +169 -0
- package/libs/esnext/full/index.d.ts +8 -0
- package/libs/esnext/index.d.ts +9 -0
- package/libs/esnext/intl/index.d.ts +15 -0
- package/libs/esnext/object/index.d.ts +13 -0
- package/libs/esnext/promise/index.d.ts +19 -0
- package/libs/scripthost/index.d.ts +310 -0
- package/libs/webworker/asynciterable/index.d.ts +14 -0
- package/libs/webworker/importscripts/index.d.ts +7 -0
- package/libs/webworker/index.d.ts +11758 -0
- package/libs/webworker/iterable/index.d.ts +543 -0
- package/package.json +23 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
|
|
3
|
+
/// <reference lib="es2018.asynciterable" />
|
|
4
|
+
|
|
5
|
+
interface AsyncGenerator<
|
|
6
|
+
T = unknown,
|
|
7
|
+
TReturn = any,
|
|
8
|
+
TNext = unknown,
|
|
9
|
+
> extends AsyncIterator<T, TReturn, TNext> {
|
|
10
|
+
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
|
11
|
+
next(
|
|
12
|
+
...args: readonly [] | readonly [TNext]
|
|
13
|
+
): Promise<IteratorResult<T, TReturn>>;
|
|
14
|
+
return(
|
|
15
|
+
value: TReturn | PromiseLike<TReturn>,
|
|
16
|
+
): Promise<IteratorResult<T, TReturn>>;
|
|
17
|
+
throw(e: unknown): Promise<IteratorResult<T, TReturn>>;
|
|
18
|
+
[Symbol.asyncIterator](): AsyncGenerator<T, TReturn, TNext>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface AsyncGeneratorFunction {
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new AsyncGenerator object.
|
|
24
|
+
* @param args A list of arguments the function accepts.
|
|
25
|
+
*/
|
|
26
|
+
new (...args: readonly unknown[]): AsyncGenerator;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new AsyncGenerator object.
|
|
29
|
+
* @param args A list of arguments the function accepts.
|
|
30
|
+
*/
|
|
31
|
+
(...args: readonly unknown[]): AsyncGenerator;
|
|
32
|
+
/**
|
|
33
|
+
* The length of the arguments.
|
|
34
|
+
*/
|
|
35
|
+
readonly length: number;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the name of the function.
|
|
38
|
+
*/
|
|
39
|
+
readonly name: string;
|
|
40
|
+
/**
|
|
41
|
+
* A reference to the prototype.
|
|
42
|
+
*/
|
|
43
|
+
readonly prototype: AsyncGenerator;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface AsyncGeneratorFunctionConstructor {
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new AsyncGenerator function.
|
|
49
|
+
* @param args A list of arguments the function accepts.
|
|
50
|
+
*/
|
|
51
|
+
new (...args: readonly string[]): AsyncGeneratorFunction;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new AsyncGenerator function.
|
|
54
|
+
* @param args A list of arguments the function accepts.
|
|
55
|
+
*/
|
|
56
|
+
(...args: readonly string[]): AsyncGeneratorFunction;
|
|
57
|
+
/**
|
|
58
|
+
* The length of the arguments.
|
|
59
|
+
*/
|
|
60
|
+
readonly length: number;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the name of the function.
|
|
63
|
+
*/
|
|
64
|
+
readonly name: string;
|
|
65
|
+
/**
|
|
66
|
+
* A reference to the prototype.
|
|
67
|
+
*/
|
|
68
|
+
readonly prototype: AsyncGeneratorFunction;
|
|
69
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
|
|
3
|
+
/// <reference lib="es2015.symbol" />
|
|
4
|
+
/// <reference lib="es2015.iterable" />
|
|
5
|
+
|
|
6
|
+
interface SymbolConstructor {
|
|
7
|
+
/**
|
|
8
|
+
* A method that returns the default async iterator for an object. Called by the semantics of
|
|
9
|
+
* the for-await-of statement.
|
|
10
|
+
*/
|
|
11
|
+
readonly asyncIterator: unique symbol;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface AsyncIterator<T, TReturn = any, TNext = undefined> {
|
|
15
|
+
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
|
16
|
+
next(
|
|
17
|
+
...args: readonly [] | readonly [TNext]
|
|
18
|
+
): Promise<IteratorResult<T, TReturn>>;
|
|
19
|
+
return?(
|
|
20
|
+
value?: TReturn | PromiseLike<TReturn>,
|
|
21
|
+
): Promise<IteratorResult<T, TReturn>>;
|
|
22
|
+
throw?(e?: unknown): Promise<IteratorResult<T, TReturn>>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface AsyncIterable<T> {
|
|
26
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface AsyncIterableIterator<T> extends AsyncIterator<T> {
|
|
30
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
|
|
3
|
+
/// <reference lib="es2018" />
|
|
4
|
+
/// <reference lib="dom" />
|
|
5
|
+
/// <reference lib="webworker.importscripts" />
|
|
6
|
+
/// <reference lib="scripthost" />
|
|
7
|
+
/// <reference lib="dom.iterable" />
|
|
8
|
+
/// <reference lib="dom.asynciterable" />
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
|
|
3
|
+
/// <reference lib="es2017" />
|
|
4
|
+
/// <reference lib="es2018.asynciterable" />
|
|
5
|
+
/// <reference lib="es2018.asyncgenerator" />
|
|
6
|
+
/// <reference lib="es2018.promise" />
|
|
7
|
+
/// <reference lib="es2018.regexp" />
|
|
8
|
+
/// <reference lib="es2018.intl" />
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
|
|
3
|
+
declare namespace Intl {
|
|
4
|
+
// http://cldr.unicode.org/index/cldr-spec/plural-rules#TOC-Determining-Plural-Categories
|
|
5
|
+
type LDMLPluralRule = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other';
|
|
6
|
+
type PluralRuleType = 'cardinal' | 'ordinal';
|
|
7
|
+
|
|
8
|
+
interface PluralRulesOptions {
|
|
9
|
+
readonly localeMatcher?: 'lookup' | 'best fit' | undefined;
|
|
10
|
+
readonly type?: PluralRuleType | undefined;
|
|
11
|
+
readonly minimumIntegerDigits?:
|
|
12
|
+
| import('ts-type-forge').UintRange<1, 22>
|
|
13
|
+
| undefined;
|
|
14
|
+
readonly minimumFractionDigits?:
|
|
15
|
+
| import('ts-type-forge').UintRange<0, 21>
|
|
16
|
+
| undefined;
|
|
17
|
+
readonly maximumFractionDigits?:
|
|
18
|
+
| import('ts-type-forge').UintRange<0, 21>
|
|
19
|
+
| undefined;
|
|
20
|
+
readonly minimumSignificantDigits?:
|
|
21
|
+
| import('ts-type-forge').UintRange<1, 22>
|
|
22
|
+
| undefined;
|
|
23
|
+
readonly maximumSignificantDigits?:
|
|
24
|
+
| import('ts-type-forge').UintRange<1, 22>
|
|
25
|
+
| undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface ResolvedPluralRulesOptions {
|
|
29
|
+
readonly locale: string;
|
|
30
|
+
readonly pluralCategories: readonly LDMLPluralRule[];
|
|
31
|
+
readonly type: PluralRuleType;
|
|
32
|
+
readonly minimumIntegerDigits: import('ts-type-forge').UintRange<1, 22>;
|
|
33
|
+
readonly minimumFractionDigits: import('ts-type-forge').UintRange<0, 21>;
|
|
34
|
+
readonly maximumFractionDigits: import('ts-type-forge').UintRange<0, 21>;
|
|
35
|
+
readonly minimumSignificantDigits?: import('ts-type-forge').UintRange<
|
|
36
|
+
1,
|
|
37
|
+
22
|
|
38
|
+
>;
|
|
39
|
+
readonly maximumSignificantDigits?: import('ts-type-forge').UintRange<
|
|
40
|
+
1,
|
|
41
|
+
22
|
|
42
|
+
>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface PluralRules {
|
|
46
|
+
resolvedOptions(): ResolvedPluralRulesOptions;
|
|
47
|
+
select(n: number): LDMLPluralRule;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface PluralRulesConstructor {
|
|
51
|
+
new (
|
|
52
|
+
locales?: string | readonly string[],
|
|
53
|
+
options?: PluralRulesOptions,
|
|
54
|
+
): PluralRules;
|
|
55
|
+
(
|
|
56
|
+
locales?: string | readonly string[],
|
|
57
|
+
options?: PluralRulesOptions,
|
|
58
|
+
): PluralRules;
|
|
59
|
+
supportedLocalesOf(
|
|
60
|
+
locales: string | readonly string[],
|
|
61
|
+
options?: { readonly localeMatcher?: 'lookup' | 'best fit' },
|
|
62
|
+
): string[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const PluralRules: PluralRulesConstructor;
|
|
66
|
+
|
|
67
|
+
// We can only have one definition for 'type' in TypeScript, and so you can learn where the keys come from here:
|
|
68
|
+
type ES2018NumberFormatPartType =
|
|
69
|
+
| 'literal'
|
|
70
|
+
| 'nan'
|
|
71
|
+
| 'infinity'
|
|
72
|
+
| 'percent'
|
|
73
|
+
| 'integer'
|
|
74
|
+
| 'group'
|
|
75
|
+
| 'decimal'
|
|
76
|
+
| 'fraction'
|
|
77
|
+
| 'plusSign'
|
|
78
|
+
| 'minusSign'
|
|
79
|
+
| 'percentSign'
|
|
80
|
+
| 'currency'
|
|
81
|
+
| 'code'
|
|
82
|
+
| 'symbol'
|
|
83
|
+
| 'name';
|
|
84
|
+
type ES2020NumberFormatPartType =
|
|
85
|
+
| 'compact'
|
|
86
|
+
| 'exponentInteger'
|
|
87
|
+
| 'exponentMinusSign'
|
|
88
|
+
| 'exponentSeparator'
|
|
89
|
+
| 'unit'
|
|
90
|
+
| 'unknown';
|
|
91
|
+
type NumberFormatPartTypes =
|
|
92
|
+
| ES2018NumberFormatPartType
|
|
93
|
+
| ES2020NumberFormatPartType;
|
|
94
|
+
|
|
95
|
+
interface NumberFormatPart {
|
|
96
|
+
readonly type: NumberFormatPartTypes;
|
|
97
|
+
readonly value: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface NumberFormat {
|
|
101
|
+
formatToParts(number?: number | bigint): NumberFormatPart[];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents the completion of an asynchronous operation
|
|
5
|
+
*/
|
|
6
|
+
interface Promise<T> {
|
|
7
|
+
/**
|
|
8
|
+
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
|
9
|
+
* resolved value cannot be modified from the callback.
|
|
10
|
+
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
|
|
11
|
+
* @returns A Promise for the completion of the callback.
|
|
12
|
+
*/
|
|
13
|
+
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
|
|
3
|
+
interface RegExpMatchArray {
|
|
4
|
+
readonly groups?: {
|
|
5
|
+
readonly [key: string]: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface RegExpExecArray {
|
|
10
|
+
readonly groups?: {
|
|
11
|
+
readonly [key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface RegExp {
|
|
16
|
+
/**
|
|
17
|
+
* Returns a Boolean value indicating the state of the dotAll flag (s) used with a regular expression.
|
|
18
|
+
* Default is false. Read-only.
|
|
19
|
+
*/
|
|
20
|
+
readonly dotAll: boolean;
|
|
21
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
|
|
3
|
+
type FlatArray<Arr, Depth extends number> = {
|
|
4
|
+
readonly done: Arr;
|
|
5
|
+
readonly recur: Arr extends ReadonlyArray<infer InnerArr>
|
|
6
|
+
? FlatArray<
|
|
7
|
+
InnerArr,
|
|
8
|
+
(readonly [
|
|
9
|
+
-1,
|
|
10
|
+
0,
|
|
11
|
+
1,
|
|
12
|
+
2,
|
|
13
|
+
3,
|
|
14
|
+
4,
|
|
15
|
+
5,
|
|
16
|
+
6,
|
|
17
|
+
7,
|
|
18
|
+
8,
|
|
19
|
+
9,
|
|
20
|
+
10,
|
|
21
|
+
11,
|
|
22
|
+
12,
|
|
23
|
+
13,
|
|
24
|
+
14,
|
|
25
|
+
15,
|
|
26
|
+
16,
|
|
27
|
+
17,
|
|
28
|
+
18,
|
|
29
|
+
19,
|
|
30
|
+
20,
|
|
31
|
+
])[Depth]
|
|
32
|
+
>
|
|
33
|
+
: Arr;
|
|
34
|
+
}[Depth extends -1 ? 'done' : 'recur'];
|
|
35
|
+
|
|
36
|
+
interface ReadonlyArray<T> {
|
|
37
|
+
/**
|
|
38
|
+
* Calls a defined callback function on each element of an array. Then, flattens the result into
|
|
39
|
+
* a new array.
|
|
40
|
+
* This is identical to a map followed by flat with depth 1.
|
|
41
|
+
*
|
|
42
|
+
* @param callback A function that accepts up to three arguments. The flatMap method calls the
|
|
43
|
+
* callback function one time for each element in the array.
|
|
44
|
+
* @param thisArg An object to which the this keyword can refer in the callback function. If
|
|
45
|
+
* thisArg is omitted, undefined is used as the this value.
|
|
46
|
+
*/
|
|
47
|
+
flatMap<U, This = undefined>(
|
|
48
|
+
callback: (
|
|
49
|
+
this: This,
|
|
50
|
+
value: T,
|
|
51
|
+
index: number,
|
|
52
|
+
array: readonly T[],
|
|
53
|
+
) => U | ReadonlyArray<U>,
|
|
54
|
+
thisArg?: This,
|
|
55
|
+
): U[];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
|
|
59
|
+
* specified depth.
|
|
60
|
+
*
|
|
61
|
+
* @param depth The maximum recursion depth
|
|
62
|
+
*/
|
|
63
|
+
flat<A, D extends number = 1>(this: A, depth?: D): FlatArray<A, D>[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface Array<T> {
|
|
67
|
+
/**
|
|
68
|
+
* Calls a defined callback function on each element of an array. Then, flattens the result into
|
|
69
|
+
* a new array.
|
|
70
|
+
* This is identical to a map followed by flat with depth 1.
|
|
71
|
+
*
|
|
72
|
+
* @param callback A function that accepts up to three arguments. The flatMap method calls the
|
|
73
|
+
* callback function one time for each element in the array.
|
|
74
|
+
* @param thisArg An object to which the this keyword can refer in the callback function. If
|
|
75
|
+
* thisArg is omitted, undefined is used as the this value.
|
|
76
|
+
*/
|
|
77
|
+
flatMap<U, This = undefined>(
|
|
78
|
+
callback: (
|
|
79
|
+
this: This,
|
|
80
|
+
value: T,
|
|
81
|
+
index: number,
|
|
82
|
+
array: readonly T[],
|
|
83
|
+
) => U | ReadonlyArray<U>,
|
|
84
|
+
thisArg?: This,
|
|
85
|
+
): U[];
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
|
|
89
|
+
* specified depth.
|
|
90
|
+
*
|
|
91
|
+
* @param depth The maximum recursion depth
|
|
92
|
+
*/
|
|
93
|
+
flat<A, D extends number = 1>(this: A, depth?: D): FlatArray<A, D>[];
|
|
94
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
|
|
3
|
+
/// <reference lib="es2019" />
|
|
4
|
+
/// <reference lib="dom" />
|
|
5
|
+
/// <reference lib="webworker.importscripts" />
|
|
6
|
+
/// <reference lib="scripthost" />
|
|
7
|
+
/// <reference lib="dom.iterable" />
|
|
8
|
+
/// <reference lib="dom.asynciterable" />
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
|
|
3
|
+
/// <reference lib="es2018" />
|
|
4
|
+
/// <reference lib="es2019.array" />
|
|
5
|
+
/// <reference lib="es2019.object" />
|
|
6
|
+
/// <reference lib="es2019.string" />
|
|
7
|
+
/// <reference lib="es2019.symbol" />
|
|
8
|
+
/// <reference lib="es2019.intl" />
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
/// <reference lib="es5" />
|
|
3
|
+
|
|
4
|
+
/// <reference lib="es2015.iterable" />
|
|
5
|
+
|
|
6
|
+
declare namespace StrictLibInternals {
|
|
7
|
+
type RecursionLimit = 20;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* - `[['x', 1], ['y', 3]]` -> `{ x: 1, y: 3 }`
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export type EntriesToObject<
|
|
15
|
+
Entries extends readonly (readonly [PropertyKey, unknown])[],
|
|
16
|
+
> = import('ts-type-forge').MergeIntersection<
|
|
17
|
+
EntriesToObjectImpl<{}, Entries>
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
/** @internal */
|
|
21
|
+
type EntriesToObjectImpl<
|
|
22
|
+
R,
|
|
23
|
+
Entries extends readonly (readonly [PropertyKey, unknown])[],
|
|
24
|
+
> = import('ts-type-forge').TypeEq<Entries['length'], 0> extends true
|
|
25
|
+
? R
|
|
26
|
+
: EntriesToObjectImpl<
|
|
27
|
+
R & { [key in Entries[0][0]]: Entries[0][1] },
|
|
28
|
+
import('ts-type-forge').List.Tail<Entries>
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* - `['x' | 'y' | 'z', number][]]` -> `'x' | 'y' | 'z'`
|
|
33
|
+
* - `[['a' | 'b' | 'c', number], ...['x' | 'y' | 'z', number][]]` -> `'a' | 'b' |
|
|
34
|
+
* 'c' | 'x' | 'y' | 'z'`
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
37
|
+
*
|
|
38
|
+
* @note 上の2個目の例に対応するためには、無限長の Entries に対しても再帰を回す必要があるが、
|
|
39
|
+
* 止めるタイミングを決められないので再帰制限を設けている。
|
|
40
|
+
*/
|
|
41
|
+
export type KeysOfEntries<
|
|
42
|
+
Entries extends readonly (readonly [PropertyKey, unknown])[],
|
|
43
|
+
> = KeysOfEntriesImpl<never, Entries, RecursionLimit>;
|
|
44
|
+
|
|
45
|
+
/** @internal */
|
|
46
|
+
type KeysOfEntriesImpl<
|
|
47
|
+
K,
|
|
48
|
+
Entries extends readonly (readonly [PropertyKey, unknown])[],
|
|
49
|
+
RemainingNumRecursions extends number,
|
|
50
|
+
> = import('ts-type-forge').TypeEq<RemainingNumRecursions, 0> extends true
|
|
51
|
+
? K
|
|
52
|
+
: import('ts-type-forge').TypeEq<Entries['length'], 0> extends true
|
|
53
|
+
? K
|
|
54
|
+
: KeysOfEntriesImpl<
|
|
55
|
+
K | Entries[0][0],
|
|
56
|
+
import('ts-type-forge').List.Tail<Entries>,
|
|
57
|
+
import('ts-type-forge').Decrement<RemainingNumRecursions>
|
|
58
|
+
>;
|
|
59
|
+
|
|
60
|
+
/** @internal */
|
|
61
|
+
export type ValuesOfEntries<
|
|
62
|
+
Entries extends readonly (readonly [PropertyKey, unknown])[],
|
|
63
|
+
> = ValuesOfEntriesImpl<never, Entries, RecursionLimit>;
|
|
64
|
+
|
|
65
|
+
/** @internal */
|
|
66
|
+
type ValuesOfEntriesImpl<
|
|
67
|
+
K,
|
|
68
|
+
Entries extends readonly (readonly [PropertyKey, unknown])[],
|
|
69
|
+
RemainingNumRecursions extends number,
|
|
70
|
+
> = import('ts-type-forge').TypeEq<RemainingNumRecursions, 0> extends true
|
|
71
|
+
? K
|
|
72
|
+
: import('ts-type-forge').TypeEq<Entries['length'], 0> extends true
|
|
73
|
+
? K
|
|
74
|
+
: ValuesOfEntriesImpl<
|
|
75
|
+
K | Entries[0][1],
|
|
76
|
+
import('ts-type-forge').List.Tail<Entries>,
|
|
77
|
+
import('ts-type-forge').Decrement<RemainingNumRecursions>
|
|
78
|
+
>;
|
|
79
|
+
|
|
80
|
+
/** @internal */
|
|
81
|
+
export type PartialIfKeyIsUnion<K, T> =
|
|
82
|
+
import('ts-type-forge').IsUnion<K> extends true ? Partial<T> : T;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface ObjectConstructor {
|
|
86
|
+
/**
|
|
87
|
+
* Returns an object created by key-value entries for properties and methods
|
|
88
|
+
* @param entries An iterable object that contains key-value entries for properties and methods.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* const entries = [
|
|
92
|
+
* ['x', 1],
|
|
93
|
+
* ['y', 3],
|
|
94
|
+
* ] as const satisfies [['x', 1], ['y', 3]];
|
|
95
|
+
*
|
|
96
|
+
* const obj = Object.fromEntries(entries) satisfies { x: 1; y: 3 };
|
|
97
|
+
*
|
|
98
|
+
* @note `entries` がタプル型の場合には key-value の組み合わせも反映した型にする。
|
|
99
|
+
* そうでない場合、 `K` が union 型の場合、`entries` がそのすべてを網羅しているとは限らないため、
|
|
100
|
+
* `fromEntries` の返り値型がその union 要素すべてを含む型になってしまわないように `Partial` を付けている。
|
|
101
|
+
*
|
|
102
|
+
* index signature の record では `Object.entries` の key が `string` そのものになり
|
|
103
|
+
* union ではなくなるため、`Partial` は付かない(`WithOpenString` 参照)。
|
|
104
|
+
*/
|
|
105
|
+
fromEntries<
|
|
106
|
+
const Entries extends readonly (readonly [PropertyKey, unknown])[],
|
|
107
|
+
>(
|
|
108
|
+
entries: Entries,
|
|
109
|
+
): import('ts-type-forge').IsFixedLengthList<Entries> extends true
|
|
110
|
+
? StrictLibInternals.EntriesToObject<Entries>
|
|
111
|
+
: StrictLibInternals.PartialIfKeyIsUnion<
|
|
112
|
+
StrictLibInternals.KeysOfEntries<Entries>,
|
|
113
|
+
import('ts-type-forge').MutableRecord<
|
|
114
|
+
StrictLibInternals.KeysOfEntries<Entries>,
|
|
115
|
+
StrictLibInternals.ValuesOfEntries<Entries>
|
|
116
|
+
>
|
|
117
|
+
>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Returns an object created by key-value entries for properties and methods
|
|
121
|
+
* @param entries An iterable object that contains key-value entries for properties and methods.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* const entries: readonly (readonly ['x' | 'y' | 'z' | 4, 1 | 2 | 3])[] = [
|
|
125
|
+
* ['x', 1],
|
|
126
|
+
* ['y', 2],
|
|
127
|
+
* ['z', 3],
|
|
128
|
+
* [4, 3],
|
|
129
|
+
* ] as const;
|
|
130
|
+
*
|
|
131
|
+
* const obj = Object.fromEntries(entries); // Record<'x' | 'y' | 'z' | 4, 1 | 2 | 3>
|
|
132
|
+
*
|
|
133
|
+
*/
|
|
134
|
+
fromEntries<K extends PropertyKey, V>(
|
|
135
|
+
entries: Iterable<readonly [K, V]>,
|
|
136
|
+
): import('ts-type-forge').MutableRecord<K, V>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Returns an object created by key-value entries for properties and methods
|
|
140
|
+
* @param entries An iterable object that contains key-value entries for properties and methods.
|
|
141
|
+
*/
|
|
142
|
+
fromEntries(entries: Iterable<readonly unknown[]>): unknown;
|
|
143
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
|
|
3
|
+
interface String {
|
|
4
|
+
/** Removes the trailing white space and line terminator characters from a string. */
|
|
5
|
+
trimEnd(): string;
|
|
6
|
+
|
|
7
|
+
/** Removes the leading white space and line terminator characters from a string. */
|
|
8
|
+
trimStart(): string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Removes the leading white space and line terminator characters from a string.
|
|
12
|
+
* @deprecated A legacy feature for browser compatibility. Use `trimStart` instead
|
|
13
|
+
*/
|
|
14
|
+
trimLeft(): string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Removes the trailing white space and line terminator characters from a string.
|
|
18
|
+
* @deprecated A legacy feature for browser compatibility. Use `trimEnd` instead
|
|
19
|
+
*/
|
|
20
|
+
trimRight(): string;
|
|
21
|
+
}
|