@etsoo/shared 1.1.65 → 1.1.66

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.
@@ -180,3 +180,18 @@ test('Tests for jsonReplacer', () => {
180
180
  );
181
181
  expect(json2).toBe('{"c":{"c2":false}}');
182
182
  });
183
+
184
+ test('Tests for AddAndEditType', () => {
185
+ type Entity = DataTypes.AddAndEditType<{
186
+ id: number;
187
+ name: string;
188
+ age?: number;
189
+ }>;
190
+
191
+ const data1: Entity = { id: 1, name: 'hello', changedFields: ['name'] };
192
+ const data2: Entity = { id: undefined, name: 'hello' };
193
+ const data3: Entity = { name: 'hello' };
194
+
195
+ expect(data1.name).toBe(data2.name);
196
+ expect(data2.name).toBe(data3.name);
197
+ });
@@ -125,7 +125,7 @@ export declare namespace DataTypes {
125
125
  type AddAndEditType<T extends {
126
126
  [key in D]: IdType;
127
127
  }, D extends string = 'id'> = (Omit<T, D> & {
128
- [key in D]: undefined | never;
128
+ [key in D]?: undefined | never;
129
129
  }) | (Partial<T> & Readonly<Pick<T, D>> & {
130
130
  changedFields?: string[];
131
131
  });
@@ -125,7 +125,7 @@ export declare namespace DataTypes {
125
125
  type AddAndEditType<T extends {
126
126
  [key in D]: IdType;
127
127
  }, D extends string = 'id'> = (Omit<T, D> & {
128
- [key in D]: undefined | never;
128
+ [key in D]?: undefined | never;
129
129
  }) | (Partial<T> & Readonly<Pick<T, D>> & {
130
130
  changedFields?: string[];
131
131
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/shared",
3
- "version": "1.1.65",
3
+ "version": "1.1.66",
4
4
  "description": "TypeScript shared utilities and functions",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -54,14 +54,14 @@
54
54
  },
55
55
  "homepage": "https://github.com/ETSOO/Shared#readme",
56
56
  "devDependencies": {
57
- "@types/jest": "^29.1.2",
58
- "@typescript-eslint/eslint-plugin": "^5.40.0",
59
- "@typescript-eslint/parser": "^5.40.0",
57
+ "@types/jest": "^29.2.0",
58
+ "@typescript-eslint/eslint-plugin": "^5.40.1",
59
+ "@typescript-eslint/parser": "^5.40.1",
60
60
  "eslint": "^8.25.0",
61
61
  "eslint-config-airbnb-base": "^15.0.0",
62
62
  "eslint-plugin-import": "^2.26.0",
63
- "jest": "^29.2.0",
64
- "jest-environment-jsdom": "^29.2.0",
63
+ "jest": "^29.2.1",
64
+ "jest-environment-jsdom": "^29.2.1",
65
65
  "ts-jest": "^29.0.3",
66
66
  "typescript": "^4.8.4"
67
67
  }
package/src/DataTypes.ts CHANGED
@@ -161,7 +161,7 @@ export namespace DataTypes {
161
161
  T extends { [key in D]: IdType },
162
162
  D extends string = 'id'
163
163
  > =
164
- | (Omit<T, D> & { [key in D]: undefined | never })
164
+ | (Omit<T, D> & { [key in D]?: undefined | never })
165
165
  | (Partial<T> & Readonly<Pick<T, D>> & { changedFields?: string[] });
166
166
 
167
167
  /**