@salesforce/ts-types 1.7.1 → 1.7.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/LICENSE.txt +1 -1
- package/lib/experimental/index.d.ts +4 -4
- package/lib/types/alias.d.ts +2 -2
- package/lib/types/conditional.d.ts +4 -4
- package/lib/types/function.d.ts +2 -2
- package/lib/types/json.d.ts +3 -3
- package/lib/types/mapped.d.ts +5 -5
- package/lib/types/union.d.ts +3 -3
- package/package.json +8 -8
package/LICENSE.txt
CHANGED
|
@@ -2,22 +2,22 @@ import { AnyConstructor, Dictionary, Nullable, Optional, View } from '../types';
|
|
|
2
2
|
/**
|
|
3
3
|
* @ignore
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type PrimitiveType = 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined';
|
|
6
6
|
/**
|
|
7
7
|
* @ignore
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type VerifiableType = PrimitiveType | AnyConstructor;
|
|
10
10
|
/**
|
|
11
11
|
* @ignore
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type PropertyShape = {
|
|
14
14
|
type: VerifiableType;
|
|
15
15
|
optional: boolean;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* @ignore
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export type ObjectShape = Dictionary<VerifiableType | PropertyShape>;
|
|
21
21
|
/**
|
|
22
22
|
* @ignore
|
|
23
23
|
*/
|
package/lib/types/alias.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* An alias for the commonly needed `Extract<keyof T, string>`.
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type KeyOf<T> = Extract<keyof T, string>;
|
|
5
5
|
/**
|
|
6
6
|
* An alias for a tuple of type `[string, T]' for a given generic type `T`. `T` defaults to `unknown` if not otherwise
|
|
7
7
|
* defined.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type KeyValue<T = unknown> = [string, T];
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Subtracts `undefined` from any union type `T`. This is the opposite of {@link Optional}.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type NonOptional<T> = T extends undefined ? never : T;
|
|
8
8
|
/**
|
|
9
9
|
* Converts a type `T` that may have optional properties into a type `T` with only required
|
|
10
10
|
* properties (e.g. `undefined` values are not allowed). Explicit `null`s in value unions
|
|
@@ -17,7 +17,7 @@ export declare type NonOptional<T> = T extends undefined ? never : T;
|
|
|
17
17
|
* // RequiredNonOptionalFoo -> { bar: string | null };
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export type RequiredNonOptional<T> = T extends object ? {
|
|
21
21
|
[P in keyof T]-?: NonOptional<T[P]>;
|
|
22
22
|
} : T;
|
|
23
23
|
/**
|
|
@@ -30,14 +30,14 @@ export declare type RequiredNonOptional<T> = T extends object ? {
|
|
|
30
30
|
* // RequiredNonNullableFoo -> { bar: string };
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
export
|
|
33
|
+
export type RequiredNonNullable<T> = T extends object ? Required<{
|
|
34
34
|
[P in keyof T]: NonNullable<T[P]>;
|
|
35
35
|
}> : T;
|
|
36
36
|
/**
|
|
37
37
|
* Extracts literally defined property names from a type `T` as a union of key name strings, minus
|
|
38
38
|
* any index signatures.
|
|
39
39
|
*/
|
|
40
|
-
export
|
|
40
|
+
export type Literals<T> = Extract<{
|
|
41
41
|
[K in keyof T]: string extends K ? never : number extends K ? never : K;
|
|
42
42
|
} extends {
|
|
43
43
|
[_ in keyof T]: infer U;
|
package/lib/types/function.d.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Any `function` returning type `T`. `T` defaults to `unknown` when not explicitly supplied.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type AnyFunction<T = unknown> = (...args: any[]) => T;
|
|
8
8
|
/**
|
|
9
9
|
* A constructor for any type `T`. `T` defaults to `object` when not explicitly supplied.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type AnyConstructor<T = object> = new (...args: any[]) => T;
|
package/lib/types/json.d.ts
CHANGED
|
@@ -5,15 +5,15 @@ import { Dictionary } from './collection';
|
|
|
5
5
|
/**
|
|
6
6
|
* Any valid JSON primitive value.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type JsonPrimitive = null | boolean | number | string;
|
|
9
9
|
/**
|
|
10
10
|
* Any valid JSON collection value.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type JsonCollection = JsonMap | JsonArray;
|
|
13
13
|
/**
|
|
14
14
|
* Any valid JSON value.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type AnyJson = JsonPrimitive | JsonCollection;
|
|
17
17
|
/**
|
|
18
18
|
* Any JSON-compatible object.
|
|
19
19
|
*/
|
package/lib/types/mapped.d.ts
CHANGED
|
@@ -36,22 +36,22 @@ import { Literals } from './conditional';
|
|
|
36
36
|
* // }
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
export
|
|
39
|
+
export type LiteralsRecord<T, U> = Record<Literals<T>, U>;
|
|
40
40
|
/**
|
|
41
41
|
* Creates a new type that omits keys in union type `K` of a target type `T`.
|
|
42
42
|
*/
|
|
43
|
-
export
|
|
43
|
+
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
44
44
|
/**
|
|
45
45
|
* Converts readonly properties of a type `T` to writable properties. This is the opposite of the
|
|
46
46
|
* `Readonly<T>` builtin mapped type.
|
|
47
47
|
*/
|
|
48
|
-
export
|
|
48
|
+
export type ReadWrite<T> = {
|
|
49
49
|
-readonly [K in keyof T]: T[K];
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
52
|
* A view over an `object` with constrainable properties.
|
|
53
53
|
*/
|
|
54
|
-
export
|
|
54
|
+
export type View<K extends string, V = unknown> = {
|
|
55
55
|
[_ in K]: V;
|
|
56
56
|
};
|
|
57
57
|
/**
|
|
@@ -66,6 +66,6 @@ export declare type View<K extends string, V = unknown> = {
|
|
|
66
66
|
* // type of NameAndOptionalNumericValue -> { name: string } & { value?: number | undefined }
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
|
-
export
|
|
69
|
+
export type Overwrite<T1, T2> = {
|
|
70
70
|
[P in Exclude<keyof T1, keyof T2>]: T1[P];
|
|
71
71
|
} & T2;
|
package/lib/types/union.d.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* A union type for either the parameterized type `T` or `undefined` -- the opposite of {@link NonOptional}.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type Optional<T> = T | undefined;
|
|
8
8
|
/**
|
|
9
9
|
* A union type for either the parameterized type `T`, `null`, or `undefined` -- the opposite of
|
|
10
10
|
* the `NonNullable` builtin conditional type.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type Nullable<T> = Optional<T | null>;
|
|
13
13
|
/**
|
|
14
14
|
* A union type for either the parameterized type `T` or an array of `T`.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type Many<T> = T | T[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/ts-types",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "Types and related utilities for TypeScript",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": "forcedotcom/ts-types",
|
|
@@ -32,25 +32,25 @@
|
|
|
32
32
|
"@salesforce/dev-config": "^3.0.0",
|
|
33
33
|
"@salesforce/dev-scripts": "^3.1.0",
|
|
34
34
|
"@salesforce/prettier-config": "^0.0.2",
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
36
|
-
"@typescript-eslint/parser": "^5.
|
|
37
|
-
"chai": "^4.
|
|
38
|
-
"eslint": "^8.
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^5.47.1",
|
|
36
|
+
"@typescript-eslint/parser": "^5.47.1",
|
|
37
|
+
"chai": "^4.3.7",
|
|
38
|
+
"eslint": "^8.31.0",
|
|
39
39
|
"eslint-config-prettier": "^8.5.0",
|
|
40
40
|
"eslint-config-salesforce": "^1.1.0",
|
|
41
41
|
"eslint-config-salesforce-license": "^0.1.6",
|
|
42
42
|
"eslint-config-salesforce-typescript": "^1.1.1",
|
|
43
43
|
"eslint-plugin-header": "^3.0.0",
|
|
44
44
|
"eslint-plugin-import": "2.26.0",
|
|
45
|
-
"eslint-plugin-jsdoc": "^39.
|
|
45
|
+
"eslint-plugin-jsdoc": "^39.6.4",
|
|
46
46
|
"eslint-plugin-prefer-arrow": "^1.2.1",
|
|
47
47
|
"husky": "^7.0.4",
|
|
48
48
|
"mocha": "^9.1.3",
|
|
49
49
|
"nyc": "^15.1.0",
|
|
50
|
-
"prettier": "^2.
|
|
50
|
+
"prettier": "^2.8.1",
|
|
51
51
|
"pretty-quick": "^3.1.0",
|
|
52
52
|
"sinon": "10.0.0",
|
|
53
53
|
"ts-node": "^10.0.0",
|
|
54
|
-
"typescript": "^4.
|
|
54
|
+
"typescript": "^4.9.4"
|
|
55
55
|
}
|
|
56
56
|
}
|