@zwa73/utils 1.0.74 → 1.0.75
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/dist/UtilFunctions.d.ts +1 -1
- package/package.json +1 -1
- package/src/UtilFunctions.ts +5 -5
package/dist/UtilFunctions.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare namespace UtilFunc {
|
|
|
12
12
|
* @param defaultVal - 默认值
|
|
13
13
|
* @returns 最终值
|
|
14
14
|
*/
|
|
15
|
-
function initField<T>(obj:
|
|
15
|
+
function initField<T extends object, K extends keyof T>(obj: T, field: K, defaultVal: T[K]): T[K];
|
|
16
16
|
/**生成一串uuid
|
|
17
17
|
* @returns uuid
|
|
18
18
|
*/
|
package/package.json
CHANGED
package/src/UtilFunctions.ts
CHANGED
|
@@ -19,11 +19,11 @@ export function getTime(): number {
|
|
|
19
19
|
* @param defaultVal - 默认值
|
|
20
20
|
* @returns 最终值
|
|
21
21
|
*/
|
|
22
|
-
export function initField<T>(
|
|
23
|
-
obj:
|
|
24
|
-
field:
|
|
25
|
-
defaultVal: T
|
|
26
|
-
): T {
|
|
22
|
+
export function initField<T extends object,K extends keyof T>(
|
|
23
|
+
obj: T,
|
|
24
|
+
field: K,
|
|
25
|
+
defaultVal: T[K]
|
|
26
|
+
): T[K] {
|
|
27
27
|
if (!(field in obj)) obj[field] = defaultVal;
|
|
28
28
|
return obj[field];
|
|
29
29
|
}
|