strict-ts-lib-v5.9 0.6.1 → 0.6.3
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/CHANGELOG.md +56 -0
- package/libs/decorators/index.d.ts +11 -4
- package/libs/es2015/reflect/index.d.ts +2 -1
- package/libs/es2015/symbol-wellknown/index.d.ts +12 -3
- package/libs/es2021/string/index.d.ts +4 -1
- package/libs/es5/index.d.ts +50 -14
- package/libs-branded/decorators/index.d.ts +11 -4
- package/libs-branded/es2015/reflect/index.d.ts +2 -1
- package/libs-branded/es2015/symbol-wellknown/index.d.ts +12 -3
- package/libs-branded/es2021/string/index.d.ts +4 -1
- package/libs-branded/es5/index.d.ts +50 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# strict-ts-lib-v5.9
|
|
2
2
|
|
|
3
|
+
## 0.6.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 90bf42e: Two fixes to declarations that compiled fine and went wrong at the use site.
|
|
8
|
+
|
|
9
|
+
**`ReturnType<typeof setTimeout>` no longer comes out `unknown`.** `ReturnType`
|
|
10
|
+
and `InstanceType` spelled their conditional's `extends` clause
|
|
11
|
+
`(...args: readonly never[]) => infer R`. An overload set whose last member is
|
|
12
|
+
generic, with a rest parameter computed from its own type parameter, does not
|
|
13
|
+
match that — so the conditional took its false branch and produced `unknown`,
|
|
14
|
+
silently, because a false branch is a type rather than an error. `@types/node`'s
|
|
15
|
+
`setTimeout<TArgs extends any[]>(cb, ms?, ...args: MakeVoidParameterOptional<TArgs>)`
|
|
16
|
+
is exactly that shape once it merges with the DOM's `setTimeout`, so
|
|
17
|
+
`ReturnType<typeof setTimeout>` was `unknown` and could not be handed back to
|
|
18
|
+
`clearTimeout`.
|
|
19
|
+
|
|
20
|
+
The spelling is now a bare `never`, which is what the stock library itself uses
|
|
21
|
+
for `ThisParameterType` and `OmitThisParameter`, and which gives up none of the
|
|
22
|
+
`any` removal this library exists for. The type-parameter constraint is spelled
|
|
23
|
+
the same way, so the false branch is unreachable for any `T` the constraint
|
|
24
|
+
admits: "did not resolve" can no longer arrive as an `unknown` that propagates.
|
|
25
|
+
|
|
26
|
+
That `never` now has a name, `StrictLibInternals.AnyArguments`, declared in
|
|
27
|
+
`lib.es5.d.ts`. `any` reads two ways in a function type and only one of them is
|
|
28
|
+
what this library removes: `any` as a _value_ becomes `unknown` or `never` by
|
|
29
|
+
variance, while `any` as a _wildcard_ — the `(...args: any)` in `ReturnType` —
|
|
30
|
+
describes nothing at all and is there only to switch the parameter comparison
|
|
31
|
+
off. The stock library spells that wildcard two ways (`any` in `ReturnType`,
|
|
32
|
+
`never` in `ThisParameterType`); this library spells it one way, and the name
|
|
33
|
+
says which of the two readings is meant. Every such position uses it: the four
|
|
34
|
+
utility types and `ThisParameterType` in `lib.es5.d.ts`, the decorator context
|
|
35
|
+
type parameters in `lib.decorators.d.ts`, and `Reflect.construct`'s `newTarget`
|
|
36
|
+
in `lib.es2015.reflect.d.ts`. The last two were not broken; one spelling is so
|
|
37
|
+
that the trap cannot be re-dug, and so that grepping the name finds all of
|
|
38
|
+
them.
|
|
39
|
+
|
|
40
|
+
**A replacement callback's trailing arguments are `string | undefined`, not
|
|
41
|
+
`unknown`.** `String.prototype.replace` / `replaceAll` and the
|
|
42
|
+
`[Symbol.replace]` they dispatch to typed the captured groups `readonly
|
|
43
|
+
unknown[]`, which forced every caller to narrow with `isString` before using a
|
|
44
|
+
group that the pattern shows can never be absent. They are now
|
|
45
|
+
`readonly (string | undefined)[]` — the type of a capture group — so contextual
|
|
46
|
+
typing gives `string | undefined` and a `?? ''` or a `!== undefined` check is
|
|
47
|
+
enough. Reading the participating-group count off a regular expression literal
|
|
48
|
+
is not something the type system can do, so this trades a little soundness for
|
|
49
|
+
it: a callback may declare a parameter past the last capture as
|
|
50
|
+
`string | undefined` and be handed the offset instead. That is still narrower
|
|
51
|
+
than the `any[]` the stock library ships.
|
|
52
|
+
|
|
53
|
+
## 0.6.2
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- 68452d4: Allow `0` as `toExponential`'s `fractionDigits`: the parameter type becomes `UintRangeInclusive<0, 100>`. ECMA-262 accepts 0–100 — `(1).toExponential(0)` is legal and returns `'1e+0'` — so the previous lower bound of 1 rejected a valid call.
|
|
58
|
+
|
|
3
59
|
## 0.6.1
|
|
4
60
|
|
|
5
61
|
### Patch Changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference no-default-lib="true"/>
|
|
2
|
+
/// <reference lib="es5" />
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The decorator context types provided to class element decorators.
|
|
@@ -28,8 +29,11 @@ type DecoratorMetadata = typeof globalThis extends {
|
|
|
28
29
|
* @template Class The type of the decorated class associated with this context.
|
|
29
30
|
*/
|
|
30
31
|
interface ClassDecoratorContext<
|
|
31
|
-
Class extends abstract new (
|
|
32
|
-
|
|
32
|
+
Class extends abstract new (
|
|
33
|
+
...args: StrictLibInternals.AnyArguments
|
|
34
|
+
) => unknown = abstract new (
|
|
35
|
+
...args: StrictLibInternals.AnyArguments
|
|
36
|
+
) => unknown,
|
|
33
37
|
> {
|
|
34
38
|
/** The kind of element that was decorated. */
|
|
35
39
|
readonly kind: 'class';
|
|
@@ -67,9 +71,12 @@ interface ClassDecoratorContext<
|
|
|
67
71
|
*/
|
|
68
72
|
interface ClassMethodDecoratorContext<
|
|
69
73
|
This = unknown,
|
|
70
|
-
Value extends (
|
|
74
|
+
Value extends (
|
|
75
|
+
this: This,
|
|
76
|
+
...args: StrictLibInternals.AnyArguments
|
|
77
|
+
) => unknown = (
|
|
71
78
|
this: This,
|
|
72
|
-
...args:
|
|
79
|
+
...args: StrictLibInternals.AnyArguments
|
|
73
80
|
) => unknown,
|
|
74
81
|
> {
|
|
75
82
|
/** The kind of class element that was decorated. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference no-default-lib="true"/>
|
|
2
|
+
/// <reference lib="es5" />
|
|
2
3
|
|
|
3
4
|
declare namespace Reflect {
|
|
4
5
|
/**
|
|
@@ -29,7 +30,7 @@ declare namespace Reflect {
|
|
|
29
30
|
function construct<A extends readonly unknown[], R>(
|
|
30
31
|
target: new (...args: A) => R,
|
|
31
32
|
argumentsList: Readonly<A>,
|
|
32
|
-
newTarget?: new (...args:
|
|
33
|
+
newTarget?: new (...args: StrictLibInternals.AnyArguments) => unknown,
|
|
33
34
|
): R;
|
|
34
35
|
function construct(
|
|
35
36
|
target: Function,
|
|
@@ -189,7 +189,10 @@ interface RegExp {
|
|
|
189
189
|
*/
|
|
190
190
|
[Symbol.replace](
|
|
191
191
|
string: string,
|
|
192
|
-
replacer: (
|
|
192
|
+
replacer: (
|
|
193
|
+
substring: string,
|
|
194
|
+
...args: readonly (string | undefined)[]
|
|
195
|
+
) => string,
|
|
193
196
|
): string;
|
|
194
197
|
|
|
195
198
|
/**
|
|
@@ -250,10 +253,16 @@ interface String {
|
|
|
250
253
|
searchValue: {
|
|
251
254
|
[Symbol.replace](
|
|
252
255
|
string: string,
|
|
253
|
-
replacer: (
|
|
256
|
+
replacer: (
|
|
257
|
+
substring: string,
|
|
258
|
+
...args: readonly (string | undefined)[]
|
|
259
|
+
) => string,
|
|
254
260
|
): string;
|
|
255
261
|
},
|
|
256
|
-
replacer: (
|
|
262
|
+
replacer: (
|
|
263
|
+
substring: string,
|
|
264
|
+
...args: readonly (string | undefined)[]
|
|
265
|
+
) => string,
|
|
257
266
|
): string;
|
|
258
267
|
|
|
259
268
|
/**
|
|
@@ -15,6 +15,9 @@ interface String {
|
|
|
15
15
|
*/
|
|
16
16
|
replaceAll(
|
|
17
17
|
searchValue: string | RegExp,
|
|
18
|
-
replacer: (
|
|
18
|
+
replacer: (
|
|
19
|
+
substring: string,
|
|
20
|
+
...args: readonly (string | undefined)[]
|
|
21
|
+
) => string,
|
|
19
22
|
): string;
|
|
20
23
|
}
|
package/libs/es5/index.d.ts
CHANGED
|
@@ -352,7 +352,10 @@ declare const Function: FunctionConstructor;
|
|
|
352
352
|
/**
|
|
353
353
|
* Extracts the type of the 'this' parameter of a function type, or 'unknown' if the function type has no 'this' parameter.
|
|
354
354
|
*/
|
|
355
|
-
type ThisParameterType<T> = T extends (
|
|
355
|
+
type ThisParameterType<T> = T extends (
|
|
356
|
+
this: infer U,
|
|
357
|
+
...args: StrictLibInternals.AnyArguments
|
|
358
|
+
) => unknown
|
|
356
359
|
? U
|
|
357
360
|
: unknown;
|
|
358
361
|
|
|
@@ -533,7 +536,10 @@ interface String {
|
|
|
533
536
|
*/
|
|
534
537
|
replace(
|
|
535
538
|
searchValue: string | RegExp,
|
|
536
|
-
replacer: (
|
|
539
|
+
replacer: (
|
|
540
|
+
substring: string,
|
|
541
|
+
...args: readonly (string | undefined)[]
|
|
542
|
+
) => string,
|
|
537
543
|
): string;
|
|
538
544
|
|
|
539
545
|
/**
|
|
@@ -647,7 +653,7 @@ interface Number {
|
|
|
647
653
|
* @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.
|
|
648
654
|
*/
|
|
649
655
|
toExponential(
|
|
650
|
-
fractionDigits?: import('ts-type-forge').UintRangeInclusive<
|
|
656
|
+
fractionDigits?: import('ts-type-forge').UintRangeInclusive<0, 100>,
|
|
651
657
|
): string;
|
|
652
658
|
|
|
653
659
|
/**
|
|
@@ -1899,25 +1905,23 @@ type NonNullable<T> = T & {};
|
|
|
1899
1905
|
/**
|
|
1900
1906
|
* Obtain the parameters of a function type in a tuple
|
|
1901
1907
|
*/
|
|
1902
|
-
type Parameters<
|
|
1903
|
-
...args:
|
|
1904
|
-
) => unknown
|
|
1905
|
-
? P
|
|
1906
|
-
: never;
|
|
1908
|
+
type Parameters<
|
|
1909
|
+
T extends (...args: StrictLibInternals.AnyArguments) => unknown,
|
|
1910
|
+
> = T extends (...args: infer P) => unknown ? P : never;
|
|
1907
1911
|
|
|
1908
1912
|
/**
|
|
1909
1913
|
* Obtain the parameters of a constructor function type in a tuple
|
|
1910
1914
|
*/
|
|
1911
1915
|
type ConstructorParameters<
|
|
1912
|
-
T extends abstract new (...args:
|
|
1916
|
+
T extends abstract new (...args: StrictLibInternals.AnyArguments) => unknown,
|
|
1913
1917
|
> = T extends abstract new (...args: infer P) => unknown ? P : never;
|
|
1914
1918
|
|
|
1915
1919
|
/**
|
|
1916
1920
|
* Obtain the return type of a function type
|
|
1917
1921
|
*/
|
|
1918
|
-
type ReturnType<
|
|
1919
|
-
...args:
|
|
1920
|
-
) => infer R
|
|
1922
|
+
type ReturnType<
|
|
1923
|
+
T extends (...args: StrictLibInternals.AnyArguments) => unknown,
|
|
1924
|
+
> = T extends (...args: StrictLibInternals.AnyArguments) => infer R
|
|
1921
1925
|
? R
|
|
1922
1926
|
: unknown;
|
|
1923
1927
|
|
|
@@ -1925,8 +1929,10 @@ type ReturnType<T extends (...args: readonly never[]) => unknown> = T extends (
|
|
|
1925
1929
|
* Obtain the return type of a constructor function type
|
|
1926
1930
|
*/
|
|
1927
1931
|
type InstanceType<
|
|
1928
|
-
T extends abstract new (...args:
|
|
1929
|
-
> = T extends abstract new (...args:
|
|
1932
|
+
T extends abstract new (...args: StrictLibInternals.AnyArguments) => unknown,
|
|
1933
|
+
> = T extends abstract new (...args: StrictLibInternals.AnyArguments) => infer R
|
|
1934
|
+
? R
|
|
1935
|
+
: unknown;
|
|
1930
1936
|
|
|
1931
1937
|
/**
|
|
1932
1938
|
* Convert string literal type to uppercase
|
|
@@ -5851,6 +5857,36 @@ interface Date {
|
|
|
5851
5857
|
): string;
|
|
5852
5858
|
}
|
|
5853
5859
|
|
|
5860
|
+
declare namespace StrictLibInternals {
|
|
5861
|
+
/**
|
|
5862
|
+
* The rest-parameter type that means "matches any argument list". A
|
|
5863
|
+
* marker rather than a type anything has: it is `never`.
|
|
5864
|
+
*
|
|
5865
|
+
* `any` reads two ways in a function type, and only one of them is what
|
|
5866
|
+
* this library removes. `any` as a *value* — a return type, a property,
|
|
5867
|
+
* an argument a caller supplies — is the unsound one, and becomes
|
|
5868
|
+
* `unknown` or `never` here according to variance. `any` as a *wildcard*
|
|
5869
|
+
* — the `(...args: any)` in `ReturnType` — describes nothing at all: it
|
|
5870
|
+
* is there to switch the parameter comparison off, so that the
|
|
5871
|
+
* conditional matches whatever signature it is handed. The stock library
|
|
5872
|
+
* spells that marker two ways, `(...args: any)` in `ReturnType` and
|
|
5873
|
+
* `(...args: never)` in `ThisParameterType`. This library spells it one
|
|
5874
|
+
* way, and without `any`.
|
|
5875
|
+
*
|
|
5876
|
+
* Keep it a bare `never`. `never[]` and `readonly never[]` are ordinary
|
|
5877
|
+
* array types, checked like any array: neither is assignable to a tuple
|
|
5878
|
+
* with a required element, which is what the parameter list of the
|
|
5879
|
+
* signature being matched turns into once that signature's own rest
|
|
5880
|
+
* parameter stops being an array — as `@types/node`'s generic
|
|
5881
|
+
* `setTimeout` overload does. That is what made
|
|
5882
|
+
* `ReturnType<typeof setTimeout>` resolve to `unknown`, silently, a
|
|
5883
|
+
* conditional's false branch being a type rather than an error.
|
|
5884
|
+
*
|
|
5885
|
+
* @internal
|
|
5886
|
+
*/
|
|
5887
|
+
type AnyArguments = never;
|
|
5888
|
+
}
|
|
5889
|
+
|
|
5854
5890
|
type RawDateMutType = Date;
|
|
5855
5891
|
|
|
5856
5892
|
type RawDateType = Readonly<RawDateMutType>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference no-default-lib="true"/>
|
|
2
|
+
/// <reference lib="es5" />
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The decorator context types provided to class element decorators.
|
|
@@ -28,8 +29,11 @@ type DecoratorMetadata = typeof globalThis extends {
|
|
|
28
29
|
* @template Class The type of the decorated class associated with this context.
|
|
29
30
|
*/
|
|
30
31
|
interface ClassDecoratorContext<
|
|
31
|
-
Class extends abstract new (
|
|
32
|
-
|
|
32
|
+
Class extends abstract new (
|
|
33
|
+
...args: StrictLibInternals.AnyArguments
|
|
34
|
+
) => unknown = abstract new (
|
|
35
|
+
...args: StrictLibInternals.AnyArguments
|
|
36
|
+
) => unknown,
|
|
33
37
|
> {
|
|
34
38
|
/** The kind of element that was decorated. */
|
|
35
39
|
readonly kind: 'class';
|
|
@@ -67,9 +71,12 @@ interface ClassDecoratorContext<
|
|
|
67
71
|
*/
|
|
68
72
|
interface ClassMethodDecoratorContext<
|
|
69
73
|
This = unknown,
|
|
70
|
-
Value extends (
|
|
74
|
+
Value extends (
|
|
75
|
+
this: This,
|
|
76
|
+
...args: StrictLibInternals.AnyArguments
|
|
77
|
+
) => unknown = (
|
|
71
78
|
this: This,
|
|
72
|
-
...args:
|
|
79
|
+
...args: StrictLibInternals.AnyArguments
|
|
73
80
|
) => unknown,
|
|
74
81
|
> {
|
|
75
82
|
/** The kind of class element that was decorated. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference no-default-lib="true"/>
|
|
2
|
+
/// <reference lib="es5" />
|
|
2
3
|
|
|
3
4
|
declare namespace Reflect {
|
|
4
5
|
/**
|
|
@@ -29,7 +30,7 @@ declare namespace Reflect {
|
|
|
29
30
|
function construct<A extends readonly unknown[], R>(
|
|
30
31
|
target: new (...args: A) => R,
|
|
31
32
|
argumentsList: Readonly<A>,
|
|
32
|
-
newTarget?: new (...args:
|
|
33
|
+
newTarget?: new (...args: StrictLibInternals.AnyArguments) => unknown,
|
|
33
34
|
): R;
|
|
34
35
|
function construct(
|
|
35
36
|
target: Function,
|
|
@@ -189,7 +189,10 @@ interface RegExp {
|
|
|
189
189
|
*/
|
|
190
190
|
[Symbol.replace](
|
|
191
191
|
string: string,
|
|
192
|
-
replacer: (
|
|
192
|
+
replacer: (
|
|
193
|
+
substring: string,
|
|
194
|
+
...args: readonly (string | undefined)[]
|
|
195
|
+
) => string,
|
|
193
196
|
): string;
|
|
194
197
|
|
|
195
198
|
/**
|
|
@@ -253,10 +256,16 @@ interface String {
|
|
|
253
256
|
searchValue: {
|
|
254
257
|
[Symbol.replace](
|
|
255
258
|
string: string,
|
|
256
|
-
replacer: (
|
|
259
|
+
replacer: (
|
|
260
|
+
substring: string,
|
|
261
|
+
...args: readonly (string | undefined)[]
|
|
262
|
+
) => string,
|
|
257
263
|
): string;
|
|
258
264
|
},
|
|
259
|
-
replacer: (
|
|
265
|
+
replacer: (
|
|
266
|
+
substring: string,
|
|
267
|
+
...args: readonly (string | undefined)[]
|
|
268
|
+
) => string,
|
|
260
269
|
): string;
|
|
261
270
|
|
|
262
271
|
/**
|
|
@@ -15,6 +15,9 @@ interface String {
|
|
|
15
15
|
*/
|
|
16
16
|
replaceAll(
|
|
17
17
|
searchValue: string | RegExp,
|
|
18
|
-
replacer: (
|
|
18
|
+
replacer: (
|
|
19
|
+
substring: string,
|
|
20
|
+
...args: readonly (string | undefined)[]
|
|
21
|
+
) => string,
|
|
19
22
|
): string;
|
|
20
23
|
}
|
|
@@ -354,7 +354,10 @@ declare const Function: FunctionConstructor;
|
|
|
354
354
|
/**
|
|
355
355
|
* Extracts the type of the 'this' parameter of a function type, or 'unknown' if the function type has no 'this' parameter.
|
|
356
356
|
*/
|
|
357
|
-
type ThisParameterType<T> = T extends (
|
|
357
|
+
type ThisParameterType<T> = T extends (
|
|
358
|
+
this: infer U,
|
|
359
|
+
...args: StrictLibInternals.AnyArguments
|
|
360
|
+
) => unknown
|
|
358
361
|
? U
|
|
359
362
|
: unknown;
|
|
360
363
|
|
|
@@ -541,7 +544,10 @@ interface String {
|
|
|
541
544
|
*/
|
|
542
545
|
replace(
|
|
543
546
|
searchValue: string | RegExp,
|
|
544
|
-
replacer: (
|
|
547
|
+
replacer: (
|
|
548
|
+
substring: string,
|
|
549
|
+
...args: readonly (string | undefined)[]
|
|
550
|
+
) => string,
|
|
545
551
|
): string;
|
|
546
552
|
|
|
547
553
|
/**
|
|
@@ -667,7 +673,7 @@ interface Number {
|
|
|
667
673
|
* @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.
|
|
668
674
|
*/
|
|
669
675
|
toExponential(
|
|
670
|
-
fractionDigits?: import('ts-type-forge').UintRangeInclusive<
|
|
676
|
+
fractionDigits?: import('ts-type-forge').UintRangeInclusive<0, 100>,
|
|
671
677
|
): string;
|
|
672
678
|
|
|
673
679
|
/**
|
|
@@ -2054,25 +2060,23 @@ type NonNullable<T> = T & {};
|
|
|
2054
2060
|
/**
|
|
2055
2061
|
* Obtain the parameters of a function type in a tuple
|
|
2056
2062
|
*/
|
|
2057
|
-
type Parameters<
|
|
2058
|
-
...args:
|
|
2059
|
-
) => unknown
|
|
2060
|
-
? P
|
|
2061
|
-
: never;
|
|
2063
|
+
type Parameters<
|
|
2064
|
+
T extends (...args: StrictLibInternals.AnyArguments) => unknown,
|
|
2065
|
+
> = T extends (...args: infer P) => unknown ? P : never;
|
|
2062
2066
|
|
|
2063
2067
|
/**
|
|
2064
2068
|
* Obtain the parameters of a constructor function type in a tuple
|
|
2065
2069
|
*/
|
|
2066
2070
|
type ConstructorParameters<
|
|
2067
|
-
T extends abstract new (...args:
|
|
2071
|
+
T extends abstract new (...args: StrictLibInternals.AnyArguments) => unknown,
|
|
2068
2072
|
> = T extends abstract new (...args: infer P) => unknown ? P : never;
|
|
2069
2073
|
|
|
2070
2074
|
/**
|
|
2071
2075
|
* Obtain the return type of a function type
|
|
2072
2076
|
*/
|
|
2073
|
-
type ReturnType<
|
|
2074
|
-
...args:
|
|
2075
|
-
) => infer R
|
|
2077
|
+
type ReturnType<
|
|
2078
|
+
T extends (...args: StrictLibInternals.AnyArguments) => unknown,
|
|
2079
|
+
> = T extends (...args: StrictLibInternals.AnyArguments) => infer R
|
|
2076
2080
|
? R
|
|
2077
2081
|
: unknown;
|
|
2078
2082
|
|
|
@@ -2080,8 +2084,10 @@ type ReturnType<T extends (...args: readonly never[]) => unknown> = T extends (
|
|
|
2080
2084
|
* Obtain the return type of a constructor function type
|
|
2081
2085
|
*/
|
|
2082
2086
|
type InstanceType<
|
|
2083
|
-
T extends abstract new (...args:
|
|
2084
|
-
> = T extends abstract new (...args:
|
|
2087
|
+
T extends abstract new (...args: StrictLibInternals.AnyArguments) => unknown,
|
|
2088
|
+
> = T extends abstract new (...args: StrictLibInternals.AnyArguments) => infer R
|
|
2089
|
+
? R
|
|
2090
|
+
: unknown;
|
|
2085
2091
|
|
|
2086
2092
|
/**
|
|
2087
2093
|
* Convert string literal type to uppercase
|
|
@@ -6512,6 +6518,36 @@ interface Date {
|
|
|
6512
6518
|
): string;
|
|
6513
6519
|
}
|
|
6514
6520
|
|
|
6521
|
+
declare namespace StrictLibInternals {
|
|
6522
|
+
/**
|
|
6523
|
+
* The rest-parameter type that means "matches any argument list". A
|
|
6524
|
+
* marker rather than a type anything has: it is `never`.
|
|
6525
|
+
*
|
|
6526
|
+
* `any` reads two ways in a function type, and only one of them is what
|
|
6527
|
+
* this library removes. `any` as a *value* — a return type, a property,
|
|
6528
|
+
* an argument a caller supplies — is the unsound one, and becomes
|
|
6529
|
+
* `unknown` or `never` here according to variance. `any` as a *wildcard*
|
|
6530
|
+
* — the `(...args: any)` in `ReturnType` — describes nothing at all: it
|
|
6531
|
+
* is there to switch the parameter comparison off, so that the
|
|
6532
|
+
* conditional matches whatever signature it is handed. The stock library
|
|
6533
|
+
* spells that marker two ways, `(...args: any)` in `ReturnType` and
|
|
6534
|
+
* `(...args: never)` in `ThisParameterType`. This library spells it one
|
|
6535
|
+
* way, and without `any`.
|
|
6536
|
+
*
|
|
6537
|
+
* Keep it a bare `never`. `never[]` and `readonly never[]` are ordinary
|
|
6538
|
+
* array types, checked like any array: neither is assignable to a tuple
|
|
6539
|
+
* with a required element, which is what the parameter list of the
|
|
6540
|
+
* signature being matched turns into once that signature's own rest
|
|
6541
|
+
* parameter stops being an array — as `@types/node`'s generic
|
|
6542
|
+
* `setTimeout` overload does. That is what made
|
|
6543
|
+
* `ReturnType<typeof setTimeout>` resolve to `unknown`, silently, a
|
|
6544
|
+
* conditional's false branch being a type rather than an error.
|
|
6545
|
+
*
|
|
6546
|
+
* @internal
|
|
6547
|
+
*/
|
|
6548
|
+
type AnyArguments = never;
|
|
6549
|
+
}
|
|
6550
|
+
|
|
6515
6551
|
type RawDateMutType = Date;
|
|
6516
6552
|
|
|
6517
6553
|
type RawDateType = Readonly<RawDateMutType>;
|