type-fest 2.12.1 → 2.12.2
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/package.json +1 -1
- package/source/get.d.ts +7 -2
- package/source/jsonify.d.ts +8 -1
- package/source/tsconfig-json.d.ts +75 -0
package/package.json
CHANGED
package/source/get.d.ts
CHANGED
|
@@ -97,10 +97,15 @@ type WithStringsKeys = keyof WithStrings;
|
|
|
97
97
|
//=> 'foo' | '0'
|
|
98
98
|
```
|
|
99
99
|
*/
|
|
100
|
-
type WithStringKeys<BaseType
|
|
101
|
-
[Key in StringKeyOf<BaseType>]: BaseType
|
|
100
|
+
type WithStringKeys<BaseType> = {
|
|
101
|
+
[Key in StringKeyOf<BaseType>]: UncheckedIndex<BaseType, Key>
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
Perform a `T[U]` operation if `T` supports indexing.
|
|
106
|
+
*/
|
|
107
|
+
type UncheckedIndex<T, U extends string | number> = [T] extends [Record<string | number, any>] ? T[U] : never;
|
|
108
|
+
|
|
104
109
|
/**
|
|
105
110
|
Get a property of an object or array. Works when indexing arrays using number-literal-strings, for example, `PropertyOf<number[], '0'> = number`, and when indexing objects with number keys.
|
|
106
111
|
|
package/source/jsonify.d.ts
CHANGED
|
@@ -3,6 +3,13 @@ import {JsonPrimitive, JsonValue} from './basic';
|
|
|
3
3
|
// Note: The return value has to be `any` and not `unknown` so it can match `void`.
|
|
4
4
|
type NotJsonable = ((...args: any[]) => any) | undefined;
|
|
5
5
|
|
|
6
|
+
// Note: Handles special case where Arrays with `undefined` are transformed to `'null'` by `JSON.stringify()`
|
|
7
|
+
// Only use with array members
|
|
8
|
+
type JsonifyArrayMember<T> =
|
|
9
|
+
T extends undefined ?
|
|
10
|
+
null | Exclude<T, undefined> :
|
|
11
|
+
Jsonify<T>;
|
|
12
|
+
|
|
6
13
|
/**
|
|
7
14
|
Transform a type to one that is assignable to the `JsonValue` type.
|
|
8
15
|
|
|
@@ -64,7 +71,7 @@ type Jsonify<T> =
|
|
|
64
71
|
? T extends JsonPrimitive
|
|
65
72
|
? T // Primitive is acceptable
|
|
66
73
|
: T extends Array<infer U>
|
|
67
|
-
? Array<
|
|
74
|
+
? Array<JsonifyArrayMember<U>> // It's an array: recursive call for its children
|
|
68
75
|
: T extends object
|
|
69
76
|
? T extends {toJSON(): infer J}
|
|
70
77
|
? (() => J) extends (() => JsonValue) // Is J assignable to JsonValue?
|
|
@@ -598,6 +598,7 @@ declare namespace TsConfigJson {
|
|
|
598
598
|
Watch input files.
|
|
599
599
|
|
|
600
600
|
@default false
|
|
601
|
+
@deprecated Use watchOptions instead.
|
|
601
602
|
*/
|
|
602
603
|
watch?: boolean;
|
|
603
604
|
|
|
@@ -605,6 +606,8 @@ declare namespace TsConfigJson {
|
|
|
605
606
|
Specify the polling strategy to use when the system runs out of or doesn't support native file watchers.
|
|
606
607
|
|
|
607
608
|
Requires TypeScript version 3.8 or later.
|
|
609
|
+
|
|
610
|
+
@deprecated Use watchOptions.fallbackPolling instead.
|
|
608
611
|
*/
|
|
609
612
|
fallbackPolling?: CompilerOptions.FallbackPolling;
|
|
610
613
|
|
|
@@ -614,6 +617,7 @@ declare namespace TsConfigJson {
|
|
|
614
617
|
Requires TypeScript version 3.8 or later.
|
|
615
618
|
|
|
616
619
|
@default 'useFsEvents'
|
|
620
|
+
@deprecated Use watchOptions.watchDirectory instead.
|
|
617
621
|
*/
|
|
618
622
|
watchDirectory?: CompilerOptions.WatchDirectory;
|
|
619
623
|
|
|
@@ -623,6 +627,7 @@ declare namespace TsConfigJson {
|
|
|
623
627
|
Requires TypeScript version 3.8 or later.
|
|
624
628
|
|
|
625
629
|
@default 'useFsEvents'
|
|
630
|
+
@deprecated Use watchOptions.watchFile instead.
|
|
626
631
|
*/
|
|
627
632
|
watchFile?: CompilerOptions.WatchFile;
|
|
628
633
|
|
|
@@ -990,6 +995,71 @@ declare namespace TsConfigJson {
|
|
|
990
995
|
explainFiles?: boolean;
|
|
991
996
|
}
|
|
992
997
|
|
|
998
|
+
namespace WatchOptions {
|
|
999
|
+
export type WatchFileKind =
|
|
1000
|
+
| 'FixedPollingInterval'
|
|
1001
|
+
| 'PriorityPollingInterval'
|
|
1002
|
+
| 'DynamicPriorityPolling'
|
|
1003
|
+
| 'FixedChunkSizePolling'
|
|
1004
|
+
| 'UseFsEvents'
|
|
1005
|
+
| 'UseFsEventsOnParentDirectory';
|
|
1006
|
+
|
|
1007
|
+
export type WatchDirectoryKind =
|
|
1008
|
+
| 'UseFsEvents'
|
|
1009
|
+
| 'FixedPollingInterval'
|
|
1010
|
+
| 'DynamicPriorityPolling'
|
|
1011
|
+
| 'FixedChunkSizePolling';
|
|
1012
|
+
|
|
1013
|
+
export type PollingWatchKind =
|
|
1014
|
+
| 'FixedInterval'
|
|
1015
|
+
| 'PriorityInterval'
|
|
1016
|
+
| 'DynamicPriority'
|
|
1017
|
+
| 'FixedChunkSize';
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
export interface WatchOptions {
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
Specify the strategy for watching individual files.
|
|
1024
|
+
|
|
1025
|
+
Requires TypeScript version 3.8 or later.
|
|
1026
|
+
|
|
1027
|
+
@default 'UseFsEvents'
|
|
1028
|
+
*/
|
|
1029
|
+
watchFile?: WatchOptions.WatchFileKind | Lowercase<WatchOptions.WatchFileKind>;
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
Specify the strategy for watching directories under systems that lack recursive file-watching functionality.
|
|
1033
|
+
|
|
1034
|
+
Requires TypeScript version 3.8 or later.
|
|
1035
|
+
|
|
1036
|
+
@default 'UseFsEvents'
|
|
1037
|
+
*/
|
|
1038
|
+
watchDirectory?: WatchOptions.WatchDirectoryKind | Lowercase<WatchOptions.WatchDirectoryKind>;
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
Specify the polling strategy to use when the system runs out of or doesn't support native file watchers.
|
|
1042
|
+
|
|
1043
|
+
Requires TypeScript version 3.8 or later.
|
|
1044
|
+
*/
|
|
1045
|
+
fallbackPolling?: WatchOptions.PollingWatchKind | Lowercase<WatchOptions.PollingWatchKind>;
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
Enable synchronous updates on directory watchers for platforms that don't support recursive watching natively.
|
|
1049
|
+
*/
|
|
1050
|
+
synchronousWatchDirectory?: boolean;
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
Specifies a list of directories to exclude from watch
|
|
1054
|
+
*/
|
|
1055
|
+
excludeDirectories?: string[];
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
Specifies a list of files to exclude from watch
|
|
1059
|
+
*/
|
|
1060
|
+
excludeFiles?: string[];
|
|
1061
|
+
}
|
|
1062
|
+
|
|
993
1063
|
/**
|
|
994
1064
|
Auto type (.d.ts) acquisition options for this project.
|
|
995
1065
|
|
|
@@ -1048,6 +1118,11 @@ export interface TsConfigJson {
|
|
|
1048
1118
|
*/
|
|
1049
1119
|
compilerOptions?: TsConfigJson.CompilerOptions;
|
|
1050
1120
|
|
|
1121
|
+
/**
|
|
1122
|
+
Instructs the TypeScript compiler how to watch files.
|
|
1123
|
+
*/
|
|
1124
|
+
watchOptions?: TsConfigJson.WatchOptions;
|
|
1125
|
+
|
|
1051
1126
|
/**
|
|
1052
1127
|
Auto type (.d.ts) acquisition options for this project.
|
|
1053
1128
|
|