type-fest 1.2.3 → 2.1.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/index.d.ts +63 -2
- package/package.json +10 -16
- package/readme.md +28 -25
- package/source/basic.d.ts +19 -6
- package/{ts41 → source}/camel-case.d.ts +3 -3
- package/{ts41 → source}/camel-cased-properties-deep.d.ts +0 -0
- package/{ts41 → source}/camel-cased-properties.d.ts +0 -0
- package/{ts41 → source}/delimiter-case.d.ts +1 -1
- package/{ts41 → source}/delimiter-cased-properties-deep.d.ts +1 -1
- package/{ts41 → source}/delimiter-cased-properties.d.ts +2 -2
- package/source/entries.d.ts +1 -1
- package/source/entry.d.ts +1 -1
- package/{ts41 → source}/get.d.ts +3 -1
- package/source/includes.d.ts +31 -0
- package/source/jsonify.d.ts +55 -0
- package/{ts41 → source}/kebab-case.d.ts +0 -0
- package/{ts41 → source}/kebab-cased-properties-deep.d.ts +0 -0
- package/{ts41 → source}/kebab-cased-properties.d.ts +0 -0
- package/{ts41 → source}/last-array-element.d.ts +2 -2
- package/source/literal-union.d.ts +1 -1
- package/source/observable-like.d.ts +3 -3
- package/source/opaque.d.ts +9 -2
- package/source/package-json.d.ts +5 -0
- package/{ts41 → source}/pascal-case.d.ts +0 -0
- package/{ts41 → source}/pascal-cased-properties-deep.d.ts +0 -0
- package/{ts41 → source}/pascal-cased-properties.d.ts +1 -1
- package/source/promise-value.d.ts +1 -1
- package/source/require-at-least-one.d.ts +1 -1
- package/source/require-exactly-one.d.ts +1 -4
- package/{ts41 → source}/screaming-snake-case.d.ts +1 -9
- package/source/simplify.d.ts +20 -0
- package/{ts41 → source}/snake-case.d.ts +0 -0
- package/{ts41 → source}/snake-cased-properties-deep.d.ts +0 -0
- package/{ts41 → source}/snake-cased-properties.d.ts +0 -0
- package/{ts41 → source}/split.d.ts +1 -1
- package/{ts41 → source}/trim.d.ts +0 -0
- package/source/tsconfig-json.d.ts +234 -14
- package/source/typed-array.d.ts +0 -2
- package/base.d.ts +0 -41
- package/ts41/index.d.ts +0 -24
- package/ts41/utilities.d.ts +0 -8
package/index.d.ts
CHANGED
|
@@ -1,2 +1,63 @@
|
|
|
1
|
-
//
|
|
2
|
-
export * from './
|
|
1
|
+
// Basic
|
|
2
|
+
export * from './source/primitive';
|
|
3
|
+
export * from './source/typed-array';
|
|
4
|
+
export * from './source/basic';
|
|
5
|
+
export * from './source/observable-like';
|
|
6
|
+
|
|
7
|
+
// Utilities
|
|
8
|
+
export {Except} from './source/except';
|
|
9
|
+
export {Mutable} from './source/mutable';
|
|
10
|
+
export {Merge} from './source/merge';
|
|
11
|
+
export {MergeExclusive} from './source/merge-exclusive';
|
|
12
|
+
export {RequireAtLeastOne} from './source/require-at-least-one';
|
|
13
|
+
export {RequireExactlyOne} from './source/require-exactly-one';
|
|
14
|
+
export {PartialDeep} from './source/partial-deep';
|
|
15
|
+
export {ReadonlyDeep} from './source/readonly-deep';
|
|
16
|
+
export {LiteralUnion} from './source/literal-union';
|
|
17
|
+
export {Promisable} from './source/promisable';
|
|
18
|
+
export {Opaque} from './source/opaque';
|
|
19
|
+
export {SetOptional} from './source/set-optional';
|
|
20
|
+
export {SetRequired} from './source/set-required';
|
|
21
|
+
export {ValueOf} from './source/value-of';
|
|
22
|
+
export {PromiseValue} from './source/promise-value';
|
|
23
|
+
export {AsyncReturnType} from './source/async-return-type';
|
|
24
|
+
export {ConditionalExcept} from './source/conditional-except';
|
|
25
|
+
export {ConditionalKeys} from './source/conditional-keys';
|
|
26
|
+
export {ConditionalPick} from './source/conditional-pick';
|
|
27
|
+
export {UnionToIntersection} from './source/union-to-intersection';
|
|
28
|
+
export {Stringified} from './source/stringified';
|
|
29
|
+
export {FixedLengthArray} from './source/fixed-length-array';
|
|
30
|
+
export {IterableElement} from './source/iterable-element';
|
|
31
|
+
export {Entry} from './source/entry';
|
|
32
|
+
export {Entries} from './source/entries';
|
|
33
|
+
export {SetReturnType} from './source/set-return-type';
|
|
34
|
+
export {Asyncify} from './source/asyncify';
|
|
35
|
+
export {Simplify} from './source/simplify';
|
|
36
|
+
export {Jsonify} from './source/jsonify';
|
|
37
|
+
|
|
38
|
+
// Template literal types
|
|
39
|
+
export {CamelCase} from './source/camel-case';
|
|
40
|
+
export {CamelCasedProperties} from './source/camel-cased-properties';
|
|
41
|
+
export {CamelCasedPropertiesDeep} from './source/camel-cased-properties-deep';
|
|
42
|
+
export {KebabCase} from './source/kebab-case';
|
|
43
|
+
export {KebabCasedProperties} from './source/kebab-cased-properties';
|
|
44
|
+
export {KebabCasedPropertiesDeep} from './source/kebab-cased-properties-deep';
|
|
45
|
+
export {PascalCase} from './source/pascal-case';
|
|
46
|
+
export {PascalCasedProperties} from './source/pascal-cased-properties';
|
|
47
|
+
export {PascalCasedPropertiesDeep} from './source/pascal-cased-properties-deep';
|
|
48
|
+
export {SnakeCase} from './source/snake-case';
|
|
49
|
+
export {SnakeCasedProperties} from './source/snake-cased-properties';
|
|
50
|
+
export {SnakeCasedPropertiesDeep} from './source/snake-cased-properties-deep';
|
|
51
|
+
export {ScreamingSnakeCase} from './source/screaming-snake-case';
|
|
52
|
+
export {DelimiterCase} from './source/delimiter-case';
|
|
53
|
+
export {DelimiterCasedProperties} from './source/delimiter-cased-properties';
|
|
54
|
+
export {DelimiterCasedPropertiesDeep} from './source/delimiter-cased-properties-deep';
|
|
55
|
+
export {Split} from './source/split';
|
|
56
|
+
export {Trim} from './source/trim';
|
|
57
|
+
export {Includes} from './source/includes';
|
|
58
|
+
export {Get} from './source/get';
|
|
59
|
+
export {LastArrayElement} from './source/last-array-element';
|
|
60
|
+
|
|
61
|
+
// Miscellaneous
|
|
62
|
+
export {PackageJson} from './source/package-json';
|
|
63
|
+
export {TsConfigJson} from './source/tsconfig-json';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "type-fest",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A collection of essential TypeScript types",
|
|
5
5
|
"license": "(MIT OR CC0-1.0)",
|
|
6
6
|
"repository": "sindresorhus/type-fest",
|
|
@@ -11,16 +11,14 @@
|
|
|
11
11
|
"url": "https://sindresorhus.com"
|
|
12
12
|
},
|
|
13
13
|
"engines": {
|
|
14
|
-
"node": ">=
|
|
14
|
+
"node": ">=12.20"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"test": "xo && tsd && tsc"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"index.d.ts",
|
|
21
|
-
"
|
|
22
|
-
"source",
|
|
23
|
-
"ts41"
|
|
21
|
+
"source"
|
|
24
22
|
],
|
|
25
23
|
"keywords": [
|
|
26
24
|
"typescript",
|
|
@@ -35,24 +33,20 @@
|
|
|
35
33
|
],
|
|
36
34
|
"devDependencies": {
|
|
37
35
|
"@sindresorhus/tsconfig": "~0.7.0",
|
|
38
|
-
"expect-type": "^0.
|
|
39
|
-
"tsd": "^0.
|
|
36
|
+
"expect-type": "^0.12.0",
|
|
37
|
+
"tsd": "^0.17.0",
|
|
40
38
|
"typescript": "^4.1.3",
|
|
41
|
-
"xo": "^0.
|
|
39
|
+
"xo": "^0.43.0"
|
|
42
40
|
},
|
|
43
41
|
"types": "./index.d.ts",
|
|
44
|
-
"typesVersions": {
|
|
45
|
-
">=4.1": {
|
|
46
|
-
"*": [
|
|
47
|
-
"ts41/*"
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
42
|
"xo": {
|
|
52
43
|
"rules": {
|
|
53
44
|
"@typescript-eslint/ban-types": "off",
|
|
54
45
|
"@typescript-eslint/indent": "off",
|
|
55
|
-
"node/no-unsupported-features/es-builtins": "off"
|
|
46
|
+
"node/no-unsupported-features/es-builtins": "off",
|
|
47
|
+
"import/extensions": "off",
|
|
48
|
+
"@typescript-eslint/no-redeclare": "off",
|
|
49
|
+
"@typescript-eslint/no-confusing-void-expression": "off"
|
|
56
50
|
}
|
|
57
51
|
}
|
|
58
52
|
}
|
package/readme.md
CHANGED
|
@@ -60,7 +60,7 @@ PR welcome for additional commonly needed types and docs improvements. Read the
|
|
|
60
60
|
$ npm install type-fest
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
*Requires TypeScript >=
|
|
63
|
+
*Requires TypeScript >=4.2*
|
|
64
64
|
|
|
65
65
|
## Usage
|
|
66
66
|
|
|
@@ -83,8 +83,10 @@ Click the type names for complete docs.
|
|
|
83
83
|
### Basic
|
|
84
84
|
|
|
85
85
|
- [`Primitive`](source/primitive.d.ts) - Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
86
|
-
- [`Class`](source/basic.d.ts) - Matches a [`class`
|
|
86
|
+
- [`Class`](source/basic.d.ts) - Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
|
87
|
+
- [`Constructor`](source/basic.d.ts) - Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
|
87
88
|
- [`TypedArray`](source/typed-array.d.ts) - Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
|
|
89
|
+
- [`JsonPrimitive`](source/basic.d.ts) - Matches a JSON primitive.
|
|
88
90
|
- [`JsonObject`](source/basic.d.ts) - Matches a JSON object.
|
|
89
91
|
- [`JsonArray`](source/basic.d.ts) - Matches a JSON array.
|
|
90
92
|
- [`JsonValue`](source/basic.d.ts) - Matches any valid JSON value.
|
|
@@ -119,36 +121,37 @@ Click the type names for complete docs.
|
|
|
119
121
|
- [`Entries`](source/entries.d.ts) - Create a type that represents the type of the entries of a collection.
|
|
120
122
|
- [`SetReturnType`](source/set-return-type.d.ts) - Create a function type with a return type of your choice and the same parameters as the given function type.
|
|
121
123
|
- [`Asyncify`](source/asyncify.d.ts) - Create an async version of the given function type.
|
|
124
|
+
- [`Includes`](source/includes.d.ts) - Returns a boolean for whether the given array includes the given item.
|
|
125
|
+
- [`Simplify`](source/simplify.d.ts) - Flatten the type output to improve type hints shown in editors.
|
|
126
|
+
- [`Jsonify`](source/jsonify.d.ts) - Transform a type to one that is assignable to the `JsonValue` type.
|
|
122
127
|
|
|
123
128
|
### Template literal types
|
|
124
129
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
- [`
|
|
128
|
-
- [`
|
|
129
|
-
- [`
|
|
130
|
-
- [`
|
|
131
|
-
- [`
|
|
132
|
-
- [`
|
|
133
|
-
- [`
|
|
134
|
-
- [`
|
|
135
|
-
- [`
|
|
136
|
-
- [`
|
|
137
|
-
- [`
|
|
138
|
-
- [`
|
|
139
|
-
- [`
|
|
140
|
-
- [`
|
|
141
|
-
- [`
|
|
142
|
-
- [`
|
|
143
|
-
- [`
|
|
144
|
-
- [`
|
|
145
|
-
- [`Get`](ts41/get.d.ts) - Get a deeply-nested property from an object using a key path, like [Lodash's `.get()`](https://lodash.com/docs/latest#get) function.
|
|
146
|
-
- [`LastArrayElement`](ts41/last-array-element.d.ts) - Extracts the type of the last element of an array.
|
|
130
|
+
- [`CamelCase`](source/camel-case.d.ts) – Convert a string literal to camel-case (`fooBar`).
|
|
131
|
+
- [`CamelCasedProperties`](source/camel-cased-properties.d.ts) – Convert object properties to camel-case (`fooBar`).
|
|
132
|
+
- [`CamelCasedPropertiesDeep`](source/camel-cased-properties-deep.d.ts) – Convert object properties to camel-case recursively (`fooBar`).
|
|
133
|
+
- [`KebabCase`](source/kebab-case.d.ts) – Convert a string literal to kebab-case (`foo-bar`).
|
|
134
|
+
- [`KebabCasedProperties`](source/kebab-cased-properties.d.ts) – Convert a object properties to kebab-case recursively (`foo-bar`).
|
|
135
|
+
- [`KebabCasedPropertiesDeep`](source/kebab-cased-properties-deep.d.ts) – Convert object properties to kebab-case (`foo-bar`).
|
|
136
|
+
- [`PascalCase`](source/pascal-case.d.ts) – Converts a string literal to pascal-case (`FooBar`)
|
|
137
|
+
- [`PascalCasedProperties`](source/pascal-cased-properties.d.ts) – Converts object properties to pascal-case (`FooBar`)
|
|
138
|
+
- [`PascalCasedPropertiesDeep`](source/pascal-cased-properties-deep.d.ts) – Converts object properties to pascal-case (`FooBar`)
|
|
139
|
+
- [`SnakeCase`](source/snake-case.d.ts) – Convert a string literal to snake-case (`foo_bar`).
|
|
140
|
+
- [`SnakeCasedProperties`](source/snake-cased-properties-deep.d.ts) – Convert object properties to snake-case (`foo_bar`).
|
|
141
|
+
- [`SnakeCasedPropertiesDeep`](source/snake-cased-properties-deep.d.ts) – Convert object properties to snake-case recursively (`foo_bar`).
|
|
142
|
+
- [`ScreamingSnakeCase`](source/screaming-snake-case.d.ts) - Convert a string literal to screaming-snake-case (`FOO_BAR`).
|
|
143
|
+
- [`DelimiterCase`](source/delimiter-case.d.ts) – Convert a string literal to a custom string delimiter casing.
|
|
144
|
+
- [`DelimiterCasedProperties`](source/delimiter-cased-properties.d.ts) – Convert object properties to a custom string delimiter casing.
|
|
145
|
+
- [`DelimiterCasedPropertiesDeep`](source/delimiter-cased-properties-deep.d.ts) – Convert object properties to a custom string delimiter casing recursively.
|
|
146
|
+
- [`Split`](source/split.d.ts) - Represents an array of strings split using a given character or character set.
|
|
147
|
+
- [`Trim`](source/trim.d.ts) - Remove leading and trailing spaces from a string.
|
|
148
|
+
- [`Get`](source/get.d.ts) - Get a deeply-nested property from an object using a key path, like [Lodash's `.get()`](https://lodash.com/docs/latest#get) function.
|
|
149
|
+
- [`LastArrayElement`](source/last-array-element.d.ts) - Extracts the type of the last element of an array.
|
|
147
150
|
|
|
148
151
|
### Miscellaneous
|
|
149
152
|
|
|
150
153
|
- [`PackageJson`](source/package-json.d.ts) - Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file).
|
|
151
|
-
- [`TsConfigJson`](source/tsconfig-json.d.ts) - Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) (TypeScript
|
|
154
|
+
- [`TsConfigJson`](source/tsconfig-json.d.ts) - Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) (TypeScript 4.4).
|
|
152
155
|
|
|
153
156
|
## Declined types
|
|
154
157
|
|
package/source/basic.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
|
3
|
+
|
|
4
|
+
@category Basic
|
|
5
|
+
*/
|
|
6
|
+
export type Class<T, Arguments extends unknown[] = any[]> = Constructor<T, Arguments> & {prototype: T};
|
|
7
|
+
|
|
2
8
|
/**
|
|
3
9
|
Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
|
4
10
|
|
|
5
11
|
@category Basic
|
|
6
12
|
*/
|
|
7
|
-
export type
|
|
13
|
+
export type Constructor<T, Arguments extends unknown[] = any[]> = new(...arguments_: Arguments) => T;
|
|
8
14
|
|
|
9
15
|
/**
|
|
10
16
|
Matches a JSON object.
|
|
@@ -20,13 +26,20 @@ Matches a JSON array.
|
|
|
20
26
|
|
|
21
27
|
@category Basic
|
|
22
28
|
*/
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
export type JsonArray = JsonValue[];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
Matches any valid JSON primitive value.
|
|
33
|
+
|
|
34
|
+
@category Basic
|
|
35
|
+
*/
|
|
36
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
26
37
|
|
|
27
38
|
/**
|
|
28
39
|
Matches any valid JSON value.
|
|
29
40
|
|
|
41
|
+
@see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
|
|
42
|
+
|
|
30
43
|
@category Basic
|
|
31
44
|
*/
|
|
32
|
-
export type JsonValue =
|
|
45
|
+
export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {WordSeparators} from '../source/utilities';
|
|
2
|
-
import {Split} from './
|
|
2
|
+
import {Split} from './split';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
Step by step takes the first item in an array literal, formats it and adds it to a string literal, and then recursively appends the remainder.
|
|
@@ -8,7 +8,7 @@ Only to be used by `CamelCaseStringArray<>`.
|
|
|
8
8
|
|
|
9
9
|
@see CamelCaseStringArray
|
|
10
10
|
*/
|
|
11
|
-
type InnerCamelCaseStringArray<Parts extends any[], PreviousPart> =
|
|
11
|
+
type InnerCamelCaseStringArray<Parts extends readonly any[], PreviousPart> =
|
|
12
12
|
Parts extends [`${infer FirstPart}`, ...infer RemainingParts]
|
|
13
13
|
? FirstPart extends undefined
|
|
14
14
|
? ''
|
|
@@ -24,7 +24,7 @@ It's separate from `InnerCamelCaseStringArray<>` to keep a clean API outwards to
|
|
|
24
24
|
|
|
25
25
|
@see Split
|
|
26
26
|
*/
|
|
27
|
-
type CamelCaseStringArray<Parts extends string[]> =
|
|
27
|
+
type CamelCaseStringArray<Parts extends readonly string[]> =
|
|
28
28
|
Parts extends [`${infer FirstPart}`, ...infer RemainingParts]
|
|
29
29
|
? Uncapitalize<`${FirstPart}${InnerCamelCaseStringArray<RemainingParts, FirstPart>}`>
|
|
30
30
|
: never;
|
|
File without changes
|
|
File without changes
|
|
@@ -36,7 +36,7 @@ It receives `UsedWordSeparators` and `UsedUpperCaseCharacters` as input to ensur
|
|
|
36
36
|
|
|
37
37
|
@see SplitIncludingDelimiters
|
|
38
38
|
*/
|
|
39
|
-
type StringArrayToDelimiterCase<Parts extends any[], UsedWordSeparators extends string, UsedUpperCaseCharacters extends string, Delimiter extends string> =
|
|
39
|
+
type StringArrayToDelimiterCase<Parts extends readonly any[], UsedWordSeparators extends string, UsedUpperCaseCharacters extends string, Delimiter extends string> =
|
|
40
40
|
Parts extends [`${infer FirstPart}`, ...infer RemainingParts]
|
|
41
41
|
? `${StringPartToDelimiterCase<FirstPart, UsedWordSeparators, UsedUpperCaseCharacters, Delimiter>}${StringArrayToDelimiterCase<RemainingParts, UsedWordSeparators, UsedUpperCaseCharacters, Delimiter>}`
|
|
42
42
|
: '';
|
|
@@ -42,7 +42,7 @@ const result: DelimiterCasedPropertiesDeep<UserWithFriends, '-'> = {
|
|
|
42
42
|
*/
|
|
43
43
|
export type DelimiterCasedPropertiesDeep<
|
|
44
44
|
Value,
|
|
45
|
-
Delimiter extends string
|
|
45
|
+
Delimiter extends string,
|
|
46
46
|
> = Value extends Function
|
|
47
47
|
? Value
|
|
48
48
|
: Value extends Array<infer U>
|
|
@@ -25,9 +25,9 @@ const result: DelimiterCasedProperties<User, '-'> = {
|
|
|
25
25
|
*/
|
|
26
26
|
export type DelimiterCasedProperties<
|
|
27
27
|
Value,
|
|
28
|
-
Delimiter extends string
|
|
28
|
+
Delimiter extends string,
|
|
29
29
|
> = Value extends Function
|
|
30
30
|
? Value
|
|
31
31
|
: Value extends Array<infer U>
|
|
32
32
|
? Value
|
|
33
|
-
: {
|
|
33
|
+
: {[K in keyof Value as DelimiterCase<K, Delimiter>]: Value[K]};
|
package/source/entries.d.ts
CHANGED
|
@@ -54,6 +54,6 @@ const setEntries: Entries<typeof setExample> = [['a', 'a'], [1, 1]];
|
|
|
54
54
|
export type Entries<BaseType> =
|
|
55
55
|
BaseType extends Map<unknown, unknown> ? MapEntries<BaseType>
|
|
56
56
|
: BaseType extends Set<unknown> ? SetEntries<BaseType>
|
|
57
|
-
: BaseType extends unknown[] ? ArrayEntries<BaseType>
|
|
57
|
+
: BaseType extends readonly unknown[] ? ArrayEntries<BaseType>
|
|
58
58
|
: BaseType extends object ? ObjectEntries<BaseType>
|
|
59
59
|
: never;
|
package/source/entry.d.ts
CHANGED
|
@@ -57,6 +57,6 @@ const setEntryNumber: Entry<typeof setExample> = [1, 1];
|
|
|
57
57
|
export type Entry<BaseType> =
|
|
58
58
|
BaseType extends Map<unknown, unknown> ? MapEntry<BaseType>
|
|
59
59
|
: BaseType extends Set<unknown> ? SetEntry<BaseType>
|
|
60
|
-
: BaseType extends unknown[] ? ArrayEntry<BaseType>
|
|
60
|
+
: BaseType extends readonly unknown[] ? ArrayEntry<BaseType>
|
|
61
61
|
: BaseType extends object ? ObjectEntry<BaseType>
|
|
62
62
|
: never;
|
package/{ts41 → source}/get.d.ts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {Split} from './utilities';
|
|
2
1
|
import {StringDigit} from '../source/utilities';
|
|
2
|
+
import {Split} from './split';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
Like the `Get` type but receives an array of strings as a path parameter.
|
|
@@ -81,6 +81,8 @@ type PropertyOf<BaseType, Key extends string> =
|
|
|
81
81
|
? undefined
|
|
82
82
|
: Key extends keyof BaseType
|
|
83
83
|
? BaseType[Key]
|
|
84
|
+
: BaseType extends [] | [unknown, ...unknown[]]
|
|
85
|
+
? unknown // It's a tuple, but `Key` did not extend `keyof BaseType`. So the index is out of bounds.
|
|
84
86
|
: BaseType extends {
|
|
85
87
|
[n: number]: infer Item;
|
|
86
88
|
length: number; // Note: This is needed to avoid being too lax with records types using number keys like `{0: string; 1: boolean}`.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Returns a boolean for whether the two given types are equal.
|
|
3
|
+
|
|
4
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
5
|
+
*/
|
|
6
|
+
type IsEqual<T, U> =
|
|
7
|
+
(<G>() => G extends T ? 1 : 2) extends
|
|
8
|
+
(<G>() => G extends U ? 1 : 2)
|
|
9
|
+
? true
|
|
10
|
+
: false;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
Returns a boolean for whether the given array includes the given item.
|
|
14
|
+
|
|
15
|
+
This can be useful if another type wants to make a decision based on whether the array includes that item.
|
|
16
|
+
|
|
17
|
+
@example
|
|
18
|
+
```
|
|
19
|
+
import {Includes} from 'type-fest';
|
|
20
|
+
|
|
21
|
+
type hasRed<array extends any[]> = Includes<array, 'red'>;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
@category Utilities
|
|
25
|
+
*/
|
|
26
|
+
export type Includes<Value extends readonly any[], Item> =
|
|
27
|
+
IsEqual<Value[0], Item> extends true
|
|
28
|
+
? true
|
|
29
|
+
: Value extends [Value[0], ...infer rest]
|
|
30
|
+
? Includes<rest, Item>
|
|
31
|
+
: false;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {JsonPrimitive} from './basic';
|
|
2
|
+
|
|
3
|
+
// Note: The return value has to be `any` and not `unknown` so it can match `void`.
|
|
4
|
+
type NotJsonable = ((...args: any[]) => any) | undefined;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
Transform a type to one that is assignable to the `JsonValue` type.
|
|
8
|
+
|
|
9
|
+
@remarks
|
|
10
|
+
|
|
11
|
+
An interface cannot be structurally compared to `JsonValue` because an interface can be re-opened to add properties that may not be satisfy `JsonValue`.
|
|
12
|
+
|
|
13
|
+
@example
|
|
14
|
+
```
|
|
15
|
+
interface Geometry {
|
|
16
|
+
type: 'Point' | 'Polygon';
|
|
17
|
+
coordinates: [number, number];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const point: Geometry = {
|
|
21
|
+
type: 'Point',
|
|
22
|
+
coordinates: [1, 1]
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const problemFn = (data: JsonValue) => {
|
|
26
|
+
// Does something with data
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
problemFn(point); // Error: type Geometry is not assignable to parameter of type JsonValue because it is an interface
|
|
30
|
+
|
|
31
|
+
const fixedFn = <T>(data: Jsonify<T>) => {
|
|
32
|
+
// Does something with data
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
fixedFn(point); // Good: point is assignable. Jsonify<T> transforms Geometry into value assignable to JsonValue
|
|
36
|
+
fixedFn(new Date()); // Error: As expected, Date is not assignable. Jsonify<T> cannot transforms Date into value assignable to JsonValue
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
@link https://github.com/Microsoft/TypeScript/issues/1897#issuecomment-710744173
|
|
40
|
+
|
|
41
|
+
@category Utilities
|
|
42
|
+
*/
|
|
43
|
+
type Jsonify<T> =
|
|
44
|
+
// Check if there are any non-JSONable types represented in the union.
|
|
45
|
+
// Note: The use of tuples in this first condition side-steps distributive conditional types
|
|
46
|
+
// (see https://github.com/microsoft/TypeScript/issues/29368#issuecomment-453529532)
|
|
47
|
+
[Extract<T, NotJsonable>] extends [never]
|
|
48
|
+
? T extends JsonPrimitive
|
|
49
|
+
? T // Primitive is acceptable
|
|
50
|
+
: T extends Array<infer U>
|
|
51
|
+
? Array<Jsonify<U>> // It's an array: recursive call for its children
|
|
52
|
+
: T extends object
|
|
53
|
+
? {[P in keyof T]: Jsonify<T[P]>} // It's an object: recursive call for its children
|
|
54
|
+
: never // Otherwise any other non-object is removed
|
|
55
|
+
: never; // Otherwise non-JSONable type union was found not empty
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -7,7 +7,7 @@ Use-case: Defining the return type of functions that extract the last element of
|
|
|
7
7
|
```
|
|
8
8
|
import {LastArrayElement} from 'type-fest';
|
|
9
9
|
|
|
10
|
-
declare function lastOf<V extends any[]>(array: V): LastArrayElement<V>;
|
|
10
|
+
declare function lastOf<V extends readonly any[]>(array: V): LastArrayElement<V>;
|
|
11
11
|
|
|
12
12
|
const array = ['foo', 2];
|
|
13
13
|
|
|
@@ -17,7 +17,7 @@ typeof lastOf(array);
|
|
|
17
17
|
|
|
18
18
|
@category Template Literals
|
|
19
19
|
*/
|
|
20
|
-
export type LastArrayElement<ValueType extends unknown[]> =
|
|
20
|
+
export type LastArrayElement<ValueType extends readonly unknown[]> =
|
|
21
21
|
ValueType extends [infer ElementType]
|
|
22
22
|
? ElementType
|
|
23
23
|
: ValueType extends [infer _, ...infer Tail]
|
|
@@ -9,7 +9,7 @@ Matches a value that is like an [Observable](https://github.com/tc39/proposal-ob
|
|
|
9
9
|
|
|
10
10
|
@category Basic
|
|
11
11
|
*/
|
|
12
|
-
export interface ObservableLike {
|
|
13
|
-
subscribe(observer: (value:
|
|
14
|
-
[Symbol.observable](): ObservableLike
|
|
12
|
+
export interface ObservableLike<ValueType = unknown> {
|
|
13
|
+
subscribe(observer: (value: ValueType) => void): void;
|
|
14
|
+
[Symbol.observable](): ObservableLike<ValueType>;
|
|
15
15
|
}
|
package/source/opaque.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
declare const tag: unique symbol;
|
|
2
|
+
|
|
3
|
+
declare type Tagged<Token> = {
|
|
4
|
+
readonly [tag]: Token;
|
|
5
|
+
};
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
Create an opaque type, which hides its internal details from the public, and can only be created by being used explicitly.
|
|
3
9
|
|
|
@@ -6,6 +12,7 @@ The generic type parameter can be anything. It doesn't have to be an object.
|
|
|
6
12
|
[Read more about opaque types.](https://codemix.com/opaque-types-in-javascript/)
|
|
7
13
|
|
|
8
14
|
There have been several discussions about adding this feature to TypeScript via the `opaque type` operator, similar to how Flow does it. Unfortunately, nothing has (yet) moved forward:
|
|
15
|
+
- [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
|
|
9
16
|
- [Microsoft/TypeScript#15408](https://github.com/Microsoft/TypeScript/issues/15408)
|
|
10
17
|
- [Microsoft/TypeScript#15807](https://github.com/Microsoft/TypeScript/issues/15807)
|
|
11
18
|
|
|
@@ -16,7 +23,7 @@ import {Opaque} from 'type-fest';
|
|
|
16
23
|
type AccountNumber = Opaque<number, 'AccountNumber'>;
|
|
17
24
|
type AccountBalance = Opaque<number, 'AccountBalance'>;
|
|
18
25
|
|
|
19
|
-
// The Token parameter allows the compiler to differentiate between types, whereas "unknown" will not. For example, consider the following structures:
|
|
26
|
+
// The `Token` parameter allows the compiler to differentiate between types, whereas "unknown" will not. For example, consider the following structures:
|
|
20
27
|
type ThingOne = Opaque<string>;
|
|
21
28
|
type ThingTwo = Opaque<string>;
|
|
22
29
|
|
|
@@ -64,4 +71,4 @@ type Person = {
|
|
|
64
71
|
|
|
65
72
|
@category Utilities
|
|
66
73
|
*/
|
|
67
|
-
export type Opaque<Type, Token = unknown> = Type &
|
|
74
|
+
export type Opaque<Type, Token = unknown> = Type & Tagged<Token>;
|
package/source/package-json.d.ts
CHANGED
|
@@ -269,6 +269,11 @@ declare namespace PackageJson {
|
|
|
269
269
|
*/
|
|
270
270
|
types?: string;
|
|
271
271
|
|
|
272
|
+
/**
|
|
273
|
+
Version selection map of TypeScript.
|
|
274
|
+
*/
|
|
275
|
+
typesVersions?: Record<string, Record<string, string[]>>;
|
|
276
|
+
|
|
272
277
|
/**
|
|
273
278
|
Location of the bundled TypeScript declaration file. Alias of `types`.
|
|
274
279
|
*/
|
|
File without changes
|
|
File without changes
|
|
@@ -25,5 +25,5 @@ let recursiveAsyncData: PromiseValue<RecursiveAsyncData> = Promise.resolve(Promi
|
|
|
25
25
|
@category Utilities
|
|
26
26
|
*/
|
|
27
27
|
export type PromiseValue<PromiseType, Otherwise = PromiseType> = PromiseType extends Promise<infer Value>
|
|
28
|
-
? {
|
|
28
|
+
? {0: PromiseValue<Value>; 1: Value}[PromiseType extends Promise<unknown> ? 0 : 1]
|
|
29
29
|
: Otherwise;
|
|
@@ -24,7 +24,7 @@ const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
|
|
|
24
24
|
*/
|
|
25
25
|
export type RequireAtLeastOne<
|
|
26
26
|
ObjectType,
|
|
27
|
-
KeysType extends keyof ObjectType = keyof ObjectType
|
|
27
|
+
KeysType extends keyof ObjectType = keyof ObjectType,
|
|
28
28
|
> = {
|
|
29
29
|
// For each `Key` in `KeysType` make a mapped type:
|
|
30
30
|
[Key in KeysType]-?: Required<Pick<ObjectType, Key>> & // 1. Make `Key`'s type required
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// TODO: Remove this when we target TypeScript >=3.5.
|
|
2
|
-
type _Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
Create a type that requires exactly one of the given keys and disallows more. The remaining keys are kept as is.
|
|
6
3
|
|
|
@@ -34,4 +31,4 @@ export type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = ke
|
|
|
34
31
|
{[Key in KeysType]: (
|
|
35
32
|
Required<Pick<ObjectType, Key>> &
|
|
36
33
|
Partial<Record<Exclude<KeysType, Key>, never>>
|
|
37
|
-
)}[KeysType] &
|
|
34
|
+
)}[KeysType] & Omit<ObjectType, KeysType>;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import {SplitIncludingDelimiters} from './delimiter-case';
|
|
2
2
|
import {SnakeCase} from './snake-case';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
Returns a boolean for whether the given array includes the given item.
|
|
6
|
-
*/
|
|
7
|
-
type Includes<Value extends any[], Item> = {
|
|
8
|
-
[P in keyof Value & number as Value[P]]: true;
|
|
9
|
-
}[Item] extends true
|
|
10
|
-
? true
|
|
11
|
-
: false;
|
|
3
|
+
import {Includes} from './includes';
|
|
12
4
|
|
|
13
5
|
/**
|
|
14
6
|
Returns a boolean for whether the string is screaming snake case.
|
package/source/simplify.d.ts
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
Flatten the type output to improve type hints shown in editors.
|
|
3
|
+
|
|
4
|
+
@example
|
|
5
|
+
```
|
|
6
|
+
import {Simplify} from 'type-fest';
|
|
7
|
+
|
|
8
|
+
type PositionProps = {
|
|
9
|
+
top: number;
|
|
10
|
+
left: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type SizeProps = {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
19
|
+
type Props = Simplify<PositionProps & SizeProps>;
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
@category Utilities
|
|
3
23
|
*/
|
|
4
24
|
export type Simplify<T> = {[KeyType in keyof T]: T[KeyType]};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,6 +3,8 @@ declare namespace TsConfigJson {
|
|
|
3
3
|
export type JSX =
|
|
4
4
|
| 'preserve'
|
|
5
5
|
| 'react'
|
|
6
|
+
| 'react-jsx'
|
|
7
|
+
| 'react-jsxdev'
|
|
6
8
|
| 'react-native';
|
|
7
9
|
|
|
8
10
|
export type Module =
|
|
@@ -12,6 +14,7 @@ declare namespace TsConfigJson {
|
|
|
12
14
|
| 'UMD'
|
|
13
15
|
| 'ES6'
|
|
14
16
|
| 'ES2015'
|
|
17
|
+
| 'ES2020'
|
|
15
18
|
| 'ESNext'
|
|
16
19
|
| 'None'
|
|
17
20
|
// Lowercase alternatives
|
|
@@ -21,6 +24,7 @@ declare namespace TsConfigJson {
|
|
|
21
24
|
| 'umd'
|
|
22
25
|
| 'es6'
|
|
23
26
|
| 'es2015'
|
|
27
|
+
| 'es2020'
|
|
24
28
|
| 'esnext'
|
|
25
29
|
| 'none';
|
|
26
30
|
|
|
@@ -41,6 +45,7 @@ declare namespace TsConfigJson {
|
|
|
41
45
|
| 'ES2018'
|
|
42
46
|
| 'ES2019'
|
|
43
47
|
| 'ES2020'
|
|
48
|
+
| 'ES2021'
|
|
44
49
|
| 'ESNext'
|
|
45
50
|
// Lowercase alternatives
|
|
46
51
|
| 'es3'
|
|
@@ -52,6 +57,7 @@ declare namespace TsConfigJson {
|
|
|
52
57
|
| 'es2018'
|
|
53
58
|
| 'es2019'
|
|
54
59
|
| 'es2020'
|
|
60
|
+
| 'es2021'
|
|
55
61
|
| 'esnext';
|
|
56
62
|
|
|
57
63
|
export type Lib =
|
|
@@ -77,6 +83,7 @@ declare namespace TsConfigJson {
|
|
|
77
83
|
| 'ES2017.String'
|
|
78
84
|
| 'ES2017.TypedArrays'
|
|
79
85
|
| 'ES2018'
|
|
86
|
+
| 'ES2018.AsyncGenerator'
|
|
80
87
|
| 'ES2018.AsyncIterable'
|
|
81
88
|
| 'ES2018.Intl'
|
|
82
89
|
| 'ES2018.Promise'
|
|
@@ -87,19 +94,31 @@ declare namespace TsConfigJson {
|
|
|
87
94
|
| 'ES2019.String'
|
|
88
95
|
| 'ES2019.Symbol'
|
|
89
96
|
| 'ES2020'
|
|
97
|
+
| 'ES2020.BigInt'
|
|
98
|
+
| 'ES2020.Promise'
|
|
90
99
|
| 'ES2020.String'
|
|
91
100
|
| 'ES2020.Symbol.WellKnown'
|
|
101
|
+
| 'ES2020.SharedMemory'
|
|
102
|
+
| 'ES2020.Intl'
|
|
103
|
+
| 'ES2021'
|
|
104
|
+
| 'ES2021.Promise'
|
|
105
|
+
| 'ES2021.String'
|
|
106
|
+
| 'ES2021.WeakRef'
|
|
92
107
|
| 'ESNext'
|
|
93
108
|
| 'ESNext.Array'
|
|
94
109
|
| 'ESNext.AsyncIterable'
|
|
95
110
|
| 'ESNext.BigInt'
|
|
96
111
|
| 'ESNext.Intl'
|
|
112
|
+
| 'ESNext.Promise'
|
|
113
|
+
| 'ESNext.String'
|
|
97
114
|
| 'ESNext.Symbol'
|
|
115
|
+
| 'ESNext.WeakRef'
|
|
98
116
|
| 'DOM'
|
|
99
117
|
| 'DOM.Iterable'
|
|
100
118
|
| 'ScriptHost'
|
|
101
119
|
| 'WebWorker'
|
|
102
120
|
| 'WebWorker.ImportScripts'
|
|
121
|
+
| 'WebWorker.Iterable'
|
|
103
122
|
// Lowercase alternatives
|
|
104
123
|
| 'es5'
|
|
105
124
|
| 'es6'
|
|
@@ -123,6 +142,7 @@ declare namespace TsConfigJson {
|
|
|
123
142
|
| 'es2017.string'
|
|
124
143
|
| 'es2017.typedarrays'
|
|
125
144
|
| 'es2018'
|
|
145
|
+
| 'es2018.asyncgenerator'
|
|
126
146
|
| 'es2018.asynciterable'
|
|
127
147
|
| 'es2018.intl'
|
|
128
148
|
| 'es2018.promise'
|
|
@@ -133,19 +153,31 @@ declare namespace TsConfigJson {
|
|
|
133
153
|
| 'es2019.string'
|
|
134
154
|
| 'es2019.symbol'
|
|
135
155
|
| 'es2020'
|
|
156
|
+
| 'es2020.bigint'
|
|
157
|
+
| 'es2020.promise'
|
|
136
158
|
| 'es2020.string'
|
|
137
159
|
| 'es2020.symbol.wellknown'
|
|
160
|
+
| 'es2020.sharedmemory'
|
|
161
|
+
| 'es2020.intl'
|
|
162
|
+
| 'es2021'
|
|
163
|
+
| 'es2021.promise'
|
|
164
|
+
| 'es2021.string'
|
|
165
|
+
| 'es2021.weakref'
|
|
138
166
|
| 'esnext'
|
|
139
167
|
| 'esnext.array'
|
|
140
168
|
| 'esnext.asynciterable'
|
|
141
169
|
| 'esnext.bigint'
|
|
142
170
|
| 'esnext.intl'
|
|
171
|
+
| 'esnext.promise'
|
|
172
|
+
| 'esnext.string'
|
|
143
173
|
| 'esnext.symbol'
|
|
174
|
+
| 'esnext.weakref'
|
|
144
175
|
| 'dom'
|
|
145
176
|
| 'dom.iterable'
|
|
146
177
|
| 'scripthost'
|
|
147
178
|
| 'webworker'
|
|
148
|
-
| 'webworker.importscripts'
|
|
179
|
+
| 'webworker.importscripts'
|
|
180
|
+
| 'webworker.iterable';
|
|
149
181
|
|
|
150
182
|
export interface Plugin {
|
|
151
183
|
[key: string]: unknown;
|
|
@@ -154,6 +186,35 @@ declare namespace TsConfigJson {
|
|
|
154
186
|
*/
|
|
155
187
|
name?: string;
|
|
156
188
|
}
|
|
189
|
+
|
|
190
|
+
export type ImportsNotUsedAsValues =
|
|
191
|
+
| 'remove'
|
|
192
|
+
| 'preserve'
|
|
193
|
+
| 'error';
|
|
194
|
+
|
|
195
|
+
export type FallbackPolling =
|
|
196
|
+
| 'fixedPollingInterval'
|
|
197
|
+
| 'priorityPollingInterval'
|
|
198
|
+
| 'dynamicPriorityPolling'
|
|
199
|
+
| 'fixedInterval'
|
|
200
|
+
| 'priorityInterval'
|
|
201
|
+
| 'dynamicPriority'
|
|
202
|
+
| 'fixedChunkSize';
|
|
203
|
+
|
|
204
|
+
export type WatchDirectory =
|
|
205
|
+
| 'useFsEvents'
|
|
206
|
+
| 'fixedPollingInterval'
|
|
207
|
+
| 'dynamicPriorityPolling'
|
|
208
|
+
| 'fixedChunkSizePolling';
|
|
209
|
+
|
|
210
|
+
export type WatchFile =
|
|
211
|
+
| 'fixedPollingInterval'
|
|
212
|
+
| 'priorityPollingInterval'
|
|
213
|
+
| 'dynamicPriorityPolling'
|
|
214
|
+
| 'useFsEvents'
|
|
215
|
+
| 'useFsEventsOnParentDirectory'
|
|
216
|
+
| 'fixedChunkSizePolling';
|
|
217
|
+
|
|
157
218
|
}
|
|
158
219
|
|
|
159
220
|
export interface CompilerOptions {
|
|
@@ -192,6 +253,24 @@ declare namespace TsConfigJson {
|
|
|
192
253
|
*/
|
|
193
254
|
diagnostics?: boolean;
|
|
194
255
|
|
|
256
|
+
/**
|
|
257
|
+
Reduce the number of projects loaded automatically by TypeScript.
|
|
258
|
+
|
|
259
|
+
Requires TypeScript version 4.0 or later.
|
|
260
|
+
|
|
261
|
+
@default false
|
|
262
|
+
*/
|
|
263
|
+
disableReferencedProjectLoad?: boolean;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
Enforces using indexed accessors for keys declared using an indexed type.
|
|
267
|
+
|
|
268
|
+
Requires TypeScript version 4.2 or later.
|
|
269
|
+
|
|
270
|
+
@default false
|
|
271
|
+
*/
|
|
272
|
+
noPropertyAccessFromIndexSignature?: boolean;
|
|
273
|
+
|
|
195
274
|
/**
|
|
196
275
|
Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
|
|
197
276
|
|
|
@@ -206,6 +285,15 @@ declare namespace TsConfigJson {
|
|
|
206
285
|
*/
|
|
207
286
|
emitDeclarationOnly?: boolean;
|
|
208
287
|
|
|
288
|
+
/**
|
|
289
|
+
Differentiate between undefined and not present when type checking.
|
|
290
|
+
|
|
291
|
+
Requires TypeScript version 4.4 or later.
|
|
292
|
+
|
|
293
|
+
@default false
|
|
294
|
+
*/
|
|
295
|
+
exactOptionalPropertyTypes?: boolean;
|
|
296
|
+
|
|
209
297
|
/**
|
|
210
298
|
Enable incremental compilation.
|
|
211
299
|
|
|
@@ -237,7 +325,7 @@ declare namespace TsConfigJson {
|
|
|
237
325
|
inlineSources?: boolean;
|
|
238
326
|
|
|
239
327
|
/**
|
|
240
|
-
Specify JSX code
|
|
328
|
+
Specify what JSX code is generated.
|
|
241
329
|
|
|
242
330
|
@default 'preserve'
|
|
243
331
|
*/
|
|
@@ -250,6 +338,33 @@ declare namespace TsConfigJson {
|
|
|
250
338
|
*/
|
|
251
339
|
reactNamespace?: string;
|
|
252
340
|
|
|
341
|
+
/**
|
|
342
|
+
Specify the JSX factory function to use when targeting React JSX emit, e.g. `React.createElement` or `h`.
|
|
343
|
+
|
|
344
|
+
Requires TypeScript version 2.1 or later.
|
|
345
|
+
|
|
346
|
+
@default 'React.createElement'
|
|
347
|
+
*/
|
|
348
|
+
jsxFactory?: string;
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.
|
|
352
|
+
|
|
353
|
+
Requires TypeScript version 4.0 or later.
|
|
354
|
+
|
|
355
|
+
@default 'React.Fragment'
|
|
356
|
+
*/
|
|
357
|
+
jsxFragmentFactory?: string;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.
|
|
361
|
+
|
|
362
|
+
Requires TypeScript version 4.1 or later.
|
|
363
|
+
|
|
364
|
+
@default 'react'
|
|
365
|
+
*/
|
|
366
|
+
jsxImportSource?: string;
|
|
367
|
+
|
|
253
368
|
/**
|
|
254
369
|
Print names of files part of the compilation.
|
|
255
370
|
|
|
@@ -269,6 +384,13 @@ declare namespace TsConfigJson {
|
|
|
269
384
|
*/
|
|
270
385
|
module?: CompilerOptions.Module;
|
|
271
386
|
|
|
387
|
+
/**
|
|
388
|
+
Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6).
|
|
389
|
+
|
|
390
|
+
@default ['AMD', 'System', 'ES6'].includes(module) ? 'classic' : 'node'
|
|
391
|
+
*/
|
|
392
|
+
moduleResolution?: 'classic' | 'node';
|
|
393
|
+
|
|
272
394
|
/**
|
|
273
395
|
Specifies the end of line sequence to be used when emitting files: 'crlf' (Windows) or 'lf' (Unix).
|
|
274
396
|
|
|
@@ -461,6 +583,15 @@ declare namespace TsConfigJson {
|
|
|
461
583
|
*/
|
|
462
584
|
target?: CompilerOptions.Target;
|
|
463
585
|
|
|
586
|
+
/**
|
|
587
|
+
Default catch clause variables as `unknown` instead of `any`.
|
|
588
|
+
|
|
589
|
+
Requires TypeScript version 4.4 or later.
|
|
590
|
+
|
|
591
|
+
@default false
|
|
592
|
+
*/
|
|
593
|
+
useUnknownInCatchVariables?: boolean;
|
|
594
|
+
|
|
464
595
|
/**
|
|
465
596
|
Watch input files.
|
|
466
597
|
|
|
@@ -468,6 +599,31 @@ declare namespace TsConfigJson {
|
|
|
468
599
|
*/
|
|
469
600
|
watch?: boolean;
|
|
470
601
|
|
|
602
|
+
/**
|
|
603
|
+
Specify the polling strategy to use when the system runs out of or doesn't support native file watchers.
|
|
604
|
+
|
|
605
|
+
Requires TypeScript version 3.8 or later.
|
|
606
|
+
*/
|
|
607
|
+
fallbackPolling?: CompilerOptions.FallbackPolling;
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
Specify the strategy for watching directories under systems that lack recursive file-watching functionality.
|
|
611
|
+
|
|
612
|
+
Requires TypeScript version 3.8 or later.
|
|
613
|
+
|
|
614
|
+
@default 'useFsEvents'
|
|
615
|
+
*/
|
|
616
|
+
watchDirectory?: CompilerOptions.WatchDirectory;
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
Specify the strategy for watching individual files.
|
|
620
|
+
|
|
621
|
+
Requires TypeScript version 3.8 or later.
|
|
622
|
+
|
|
623
|
+
@default 'useFsEvents'
|
|
624
|
+
*/
|
|
625
|
+
watchFile?: CompilerOptions.WatchFile;
|
|
626
|
+
|
|
471
627
|
/**
|
|
472
628
|
Enables experimental support for ES7 decorators.
|
|
473
629
|
|
|
@@ -482,13 +638,6 @@ declare namespace TsConfigJson {
|
|
|
482
638
|
*/
|
|
483
639
|
emitDecoratorMetadata?: boolean;
|
|
484
640
|
|
|
485
|
-
/**
|
|
486
|
-
Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6).
|
|
487
|
-
|
|
488
|
-
@default ['AMD', 'System', 'ES6'].includes(module) ? 'classic' : 'node'
|
|
489
|
-
*/
|
|
490
|
-
moduleResolution?: 'classic' | 'node';
|
|
491
|
-
|
|
492
641
|
/**
|
|
493
642
|
Do not report errors on unused labels.
|
|
494
643
|
|
|
@@ -503,6 +652,15 @@ declare namespace TsConfigJson {
|
|
|
503
652
|
*/
|
|
504
653
|
noImplicitReturns?: boolean;
|
|
505
654
|
|
|
655
|
+
/**
|
|
656
|
+
Add `undefined` to a type when accessed using an index.
|
|
657
|
+
|
|
658
|
+
Requires TypeScript version 4.1 or later.
|
|
659
|
+
|
|
660
|
+
@default false
|
|
661
|
+
*/
|
|
662
|
+
noUncheckedIndexedAccess?: boolean;
|
|
663
|
+
|
|
506
664
|
/**
|
|
507
665
|
Report errors for fallthrough cases in switch statement.
|
|
508
666
|
|
|
@@ -510,6 +668,13 @@ declare namespace TsConfigJson {
|
|
|
510
668
|
*/
|
|
511
669
|
noFallthroughCasesInSwitch?: boolean;
|
|
512
670
|
|
|
671
|
+
/**
|
|
672
|
+
Ensure overriding members in derived classes are marked with an override modifier.
|
|
673
|
+
|
|
674
|
+
@default false
|
|
675
|
+
*/
|
|
676
|
+
noImplicitOverride?: boolean;
|
|
677
|
+
|
|
513
678
|
/**
|
|
514
679
|
Do not report errors on unreachable code.
|
|
515
680
|
|
|
@@ -524,6 +689,15 @@ declare namespace TsConfigJson {
|
|
|
524
689
|
*/
|
|
525
690
|
forceConsistentCasingInFileNames?: boolean;
|
|
526
691
|
|
|
692
|
+
/**
|
|
693
|
+
Emit a v8 CPU profile of the compiler run for debugging.
|
|
694
|
+
|
|
695
|
+
Requires TypeScript version 3.7 or later.
|
|
696
|
+
|
|
697
|
+
@default 'profile.cpuprofile'
|
|
698
|
+
*/
|
|
699
|
+
generateCpuProfile?: string;
|
|
700
|
+
|
|
527
701
|
/**
|
|
528
702
|
Base directory to resolve non-relative module names.
|
|
529
703
|
*/
|
|
@@ -646,13 +820,11 @@ declare namespace TsConfigJson {
|
|
|
646
820
|
importHelpers?: boolean;
|
|
647
821
|
|
|
648
822
|
/**
|
|
649
|
-
Specify
|
|
823
|
+
Specify emit/checking behavior for imports that are only used for types.
|
|
650
824
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
@default 'React.createElement'
|
|
825
|
+
@default 'remove'
|
|
654
826
|
*/
|
|
655
|
-
|
|
827
|
+
importsNotUsedAsValues?: CompilerOptions.ImportsNotUsedAsValues;
|
|
656
828
|
|
|
657
829
|
/**
|
|
658
830
|
Parse in strict mode and emit `'use strict'` for each source file.
|
|
@@ -766,6 +938,54 @@ declare namespace TsConfigJson {
|
|
|
766
938
|
@default false
|
|
767
939
|
*/
|
|
768
940
|
resolveJsonModule?: boolean;
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it.
|
|
944
|
+
|
|
945
|
+
Requires TypeScript version 3.8 or later.
|
|
946
|
+
|
|
947
|
+
@default false
|
|
948
|
+
*/
|
|
949
|
+
assumeChangesOnlyAffectDirectDependencies?: boolean;
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
Output more detailed compiler performance information after building.
|
|
953
|
+
|
|
954
|
+
@default false
|
|
955
|
+
*/
|
|
956
|
+
extendedDiagnostics?: boolean;
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
Print names of files that are part of the compilation and then stop processing.
|
|
960
|
+
|
|
961
|
+
@default false
|
|
962
|
+
*/
|
|
963
|
+
listFilesOnly?: boolean;
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
Disable preferring source files instead of declaration files when referencing composite projects.
|
|
967
|
+
|
|
968
|
+
@default true if composite, false otherwise
|
|
969
|
+
*/
|
|
970
|
+
disableSourceOfProjectReferenceRedirect?: boolean;
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
Opt a project out of multi-project reference checking when editing.
|
|
974
|
+
|
|
975
|
+
Requires TypeScript version 3.8 or later.
|
|
976
|
+
|
|
977
|
+
@default false
|
|
978
|
+
*/
|
|
979
|
+
disableSolutionSearching?: boolean;
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
Print names of files which TypeScript sees as a part of your project and the reason they are part of the compilation.
|
|
983
|
+
|
|
984
|
+
Requires TypeScript version 4.2 or later.
|
|
985
|
+
|
|
986
|
+
@default false
|
|
987
|
+
*/
|
|
988
|
+
explainFiles?: boolean;
|
|
769
989
|
}
|
|
770
990
|
|
|
771
991
|
/**
|
package/source/typed-array.d.ts
CHANGED
package/base.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Types that are compatible with all supported TypeScript versions.
|
|
2
|
-
// It's shared between all TypeScript version-specific definitions.
|
|
3
|
-
|
|
4
|
-
// Basic
|
|
5
|
-
export * from './source/primitive';
|
|
6
|
-
export * from './source/typed-array';
|
|
7
|
-
export * from './source/basic';
|
|
8
|
-
export * from './source/observable-like';
|
|
9
|
-
|
|
10
|
-
// Utilities
|
|
11
|
-
export {Except} from './source/except';
|
|
12
|
-
export {Mutable} from './source/mutable';
|
|
13
|
-
export {Merge} from './source/merge';
|
|
14
|
-
export {MergeExclusive} from './source/merge-exclusive';
|
|
15
|
-
export {RequireAtLeastOne} from './source/require-at-least-one';
|
|
16
|
-
export {RequireExactlyOne} from './source/require-exactly-one';
|
|
17
|
-
export {PartialDeep} from './source/partial-deep';
|
|
18
|
-
export {ReadonlyDeep} from './source/readonly-deep';
|
|
19
|
-
export {LiteralUnion} from './source/literal-union';
|
|
20
|
-
export {Promisable} from './source/promisable';
|
|
21
|
-
export {Opaque} from './source/opaque';
|
|
22
|
-
export {SetOptional} from './source/set-optional';
|
|
23
|
-
export {SetRequired} from './source/set-required';
|
|
24
|
-
export {ValueOf} from './source/value-of';
|
|
25
|
-
export {PromiseValue} from './source/promise-value';
|
|
26
|
-
export {AsyncReturnType} from './source/async-return-type';
|
|
27
|
-
export {ConditionalExcept} from './source/conditional-except';
|
|
28
|
-
export {ConditionalKeys} from './source/conditional-keys';
|
|
29
|
-
export {ConditionalPick} from './source/conditional-pick';
|
|
30
|
-
export {UnionToIntersection} from './source/union-to-intersection';
|
|
31
|
-
export {Stringified} from './source/stringified';
|
|
32
|
-
export {FixedLengthArray} from './source/fixed-length-array';
|
|
33
|
-
export {IterableElement} from './source/iterable-element';
|
|
34
|
-
export {Entry} from './source/entry';
|
|
35
|
-
export {Entries} from './source/entries';
|
|
36
|
-
export {SetReturnType} from './source/set-return-type';
|
|
37
|
-
export {Asyncify} from './source/asyncify';
|
|
38
|
-
|
|
39
|
-
// Miscellaneous
|
|
40
|
-
export {PackageJson} from './source/package-json';
|
|
41
|
-
export {TsConfigJson} from './source/tsconfig-json';
|
package/ts41/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// These are all the basic types that's compatible with all supported TypeScript versions.
|
|
2
|
-
export * from '../base';
|
|
3
|
-
|
|
4
|
-
// These are special types that require at least TypeScript 4.1.
|
|
5
|
-
export {CamelCase} from './camel-case';
|
|
6
|
-
export {CamelCasedProperties} from './camel-cased-properties';
|
|
7
|
-
export {CamelCasedPropertiesDeep} from './camel-cased-properties-deep';
|
|
8
|
-
export {KebabCase} from './kebab-case';
|
|
9
|
-
export {KebabCasedProperties} from './kebab-cased-properties';
|
|
10
|
-
export {KebabCasedPropertiesDeep} from './kebab-cased-properties-deep';
|
|
11
|
-
export {PascalCase} from './pascal-case';
|
|
12
|
-
export {PascalCasedProperties} from './pascal-cased-properties';
|
|
13
|
-
export {PascalCasedPropertiesDeep} from './pascal-cased-properties-deep';
|
|
14
|
-
export {SnakeCase} from './snake-case';
|
|
15
|
-
export {SnakeCasedProperties} from './snake-cased-properties';
|
|
16
|
-
export {SnakeCasedPropertiesDeep} from './snake-cased-properties-deep';
|
|
17
|
-
export {ScreamingSnakeCase} from './screaming-snake-case';
|
|
18
|
-
export {DelimiterCase} from './delimiter-case';
|
|
19
|
-
export {DelimiterCasedProperties} from './delimiter-cased-properties';
|
|
20
|
-
export {DelimiterCasedPropertiesDeep} from './delimiter-cased-properties-deep';
|
|
21
|
-
export {Split} from './split';
|
|
22
|
-
export {Trim} from './trim';
|
|
23
|
-
export {Get} from './get';
|
|
24
|
-
export {LastArrayElement} from './last-array-element';
|
package/ts41/utilities.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
Recursively split a string literal into two parts on the first occurence of the given string, returning an array literal of all the separate parts.
|
|
3
|
-
*/
|
|
4
|
-
export type Split<S extends string, D extends string> =
|
|
5
|
-
string extends S ? string[] :
|
|
6
|
-
S extends '' ? [] :
|
|
7
|
-
S extends `${infer T}${D}${infer U}` ? [T, ...Split<U, D>] :
|
|
8
|
-
[S];
|