@etsoo/shared 1.1.66 → 1.1.67

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.
@@ -14,6 +14,7 @@ test('Tests for addBlankItem', () => {
14
14
  test('Tests for correctTypes', () => {
15
15
  const input = {
16
16
  id: '1',
17
+ ignore: '2',
17
18
  price: '6.0',
18
19
  amount: '',
19
20
  date: '2022/01/28',
@@ -66,7 +66,7 @@ export declare namespace Utils {
66
66
  * @param fields Fields to correct
67
67
  */
68
68
  function correctTypes<T extends object, F extends {
69
- [P in keyof T]: DataTypes.BasicNames;
69
+ [P in keyof T]?: DataTypes.BasicNames;
70
70
  }>(input: T, fields: F): void;
71
71
  /**
72
72
  * Two values equal
package/lib/cjs/Utils.js CHANGED
@@ -88,8 +88,11 @@ var Utils;
88
88
  */
89
89
  function correctTypes(input, fields) {
90
90
  for (const field in fields) {
91
+ const type = fields[field];
92
+ if (type == null)
93
+ continue;
91
94
  const value = Reflect.get(input, field);
92
- const newValue = DataTypes_1.DataTypes.convertByType(value, fields[field]);
95
+ const newValue = DataTypes_1.DataTypes.convertByType(value, type);
93
96
  if (newValue !== value) {
94
97
  Reflect.set(input, field, newValue);
95
98
  }
@@ -66,7 +66,7 @@ export declare namespace Utils {
66
66
  * @param fields Fields to correct
67
67
  */
68
68
  function correctTypes<T extends object, F extends {
69
- [P in keyof T]: DataTypes.BasicNames;
69
+ [P in keyof T]?: DataTypes.BasicNames;
70
70
  }>(input: T, fields: F): void;
71
71
  /**
72
72
  * Two values equal
package/lib/mjs/Utils.js CHANGED
@@ -85,8 +85,11 @@ export var Utils;
85
85
  */
86
86
  function correctTypes(input, fields) {
87
87
  for (const field in fields) {
88
+ const type = fields[field];
89
+ if (type == null)
90
+ continue;
88
91
  const value = Reflect.get(input, field);
89
- const newValue = DataTypes.convertByType(value, fields[field]);
92
+ const newValue = DataTypes.convertByType(value, type);
90
93
  if (newValue !== value) {
91
94
  Reflect.set(input, field, newValue);
92
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/shared",
3
- "version": "1.1.66",
3
+ "version": "1.1.67",
4
4
  "description": "TypeScript shared utilities and functions",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -55,13 +55,13 @@
55
55
  "homepage": "https://github.com/ETSOO/Shared#readme",
56
56
  "devDependencies": {
57
57
  "@types/jest": "^29.2.0",
58
- "@typescript-eslint/eslint-plugin": "^5.40.1",
59
- "@typescript-eslint/parser": "^5.40.1",
60
- "eslint": "^8.25.0",
58
+ "@typescript-eslint/eslint-plugin": "^5.41.0",
59
+ "@typescript-eslint/parser": "^5.41.0",
60
+ "eslint": "^8.26.0",
61
61
  "eslint-config-airbnb-base": "^15.0.0",
62
62
  "eslint-plugin-import": "^2.26.0",
63
- "jest": "^29.2.1",
64
- "jest-environment-jsdom": "^29.2.1",
63
+ "jest": "^29.2.2",
64
+ "jest-environment-jsdom": "^29.2.2",
65
65
  "ts-jest": "^29.0.3",
66
66
  "typescript": "^4.8.4"
67
67
  }
package/src/Utils.ts CHANGED
@@ -156,11 +156,13 @@ export namespace Utils {
156
156
  */
157
157
  export function correctTypes<
158
158
  T extends object,
159
- F extends { [P in keyof T]: DataTypes.BasicNames }
159
+ F extends { [P in keyof T]?: DataTypes.BasicNames }
160
160
  >(input: T, fields: F) {
161
161
  for (const field in fields) {
162
+ const type = fields[field];
163
+ if (type == null) continue;
162
164
  const value = Reflect.get(input, field);
163
- const newValue = DataTypes.convertByType(value, fields[field]);
165
+ const newValue = DataTypes.convertByType(value, type);
164
166
  if (newValue !== value) {
165
167
  Reflect.set(input, field, newValue);
166
168
  }