@etsoo/shared 1.2.54 → 1.2.56

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.
@@ -1,17 +1,18 @@
1
1
  {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ESNext",
5
- "moduleResolution": "Node10",
6
- "allowJs": false,
7
- "skipLibCheck": true,
8
- "esModuleInterop": true,
9
- "allowSyntheticDefaultImports": true,
10
- "strict": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "declaration": true
16
- }
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ES2022",
5
+ "moduleResolution": "bundler",
6
+ "allowJs": false,
7
+ "skipLibCheck": true,
8
+ "esModuleInterop": true,
9
+ "allowSyntheticDefaultImports": true,
10
+ "strict": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "noEmit": true,
15
+ "declaration": true,
16
+ "types": ["vitest/globals"]
17
+ }
17
18
  }
@@ -158,7 +158,7 @@ export declare namespace Utils {
158
158
  * @param ignoreFields Ignore fields
159
159
  * @returns
160
160
  */
161
- function getDataChanges(input: object, initData: object, ignoreFields?: string[]): string[];
161
+ function getDataChanges<T extends object>(input: T, initData: object, ignoreFields?: string[]): (keyof T & string)[];
162
162
  /**
163
163
  * Get nested value from object
164
164
  * @param data Data
@@ -158,7 +158,7 @@ export declare namespace Utils {
158
158
  * @param ignoreFields Ignore fields
159
159
  * @returns
160
160
  */
161
- function getDataChanges(input: object, initData: object, ignoreFields?: string[]): string[];
161
+ function getDataChanges<T extends object>(input: T, initData: object, ignoreFields?: string[]): (keyof T & string)[];
162
162
  /**
163
163
  * Get nested value from object
164
164
  * @param data Data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/shared",
3
- "version": "1.2.54",
3
+ "version": "1.2.56",
4
4
  "description": "TypeScript shared utilities and functions",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -14,23 +14,7 @@
14
14
  "sideEffects": false,
15
15
  "scripts": {
16
16
  "build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
17
- "test": "jest",
18
- "test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand"
19
- },
20
- "jest": {
21
- "automock": false,
22
- "testMatch": [
23
- "<rootDir>/__tests__/**/*.ts"
24
- ],
25
- "testEnvironment": "jsdom",
26
- "moduleFileExtensions": [
27
- "js",
28
- "ts",
29
- "d.ts"
30
- ],
31
- "transform": {
32
- ".+\\.ts$": "ts-jest"
33
- }
17
+ "test": "vitest"
34
18
  },
35
19
  "repository": {
36
20
  "type": "git",
@@ -54,10 +38,10 @@
54
38
  "devDependencies": {
55
39
  "@types/jest": "^29.5.14",
56
40
  "@types/lodash.isequal": "^4.5.8",
57
- "jest": "^29.7.0",
58
- "jest-environment-jsdom": "^29.7.0",
59
- "ts-jest": "^29.2.5",
60
- "typescript": "^5.6.3"
41
+ "@vitejs/plugin-react": "^4.3.4",
42
+ "jsdom": "^26.0.0",
43
+ "typescript": "^5.7.3",
44
+ "vitest": "^2.1.8"
61
45
  },
62
46
  "dependencies": {
63
47
  "lodash.isequal": "^4.5.0"
package/src/Utils.ts CHANGED
@@ -403,13 +403,13 @@ export namespace Utils {
403
403
  * @param ignoreFields Ignore fields
404
404
  * @returns
405
405
  */
406
- export function getDataChanges(
407
- input: object,
406
+ export function getDataChanges<T extends object>(
407
+ input: T,
408
408
  initData: object,
409
409
  ignoreFields: string[] = ["id"]
410
- ): string[] {
410
+ ): (keyof T & string)[] {
411
411
  // Changed fields
412
- const changes: string[] = [];
412
+ const changes: (keyof T & string)[] = [];
413
413
 
414
414
  Object.entries(input).forEach(([key, value]) => {
415
415
  // Ignore fields, no process
@@ -431,7 +431,7 @@ export namespace Utils {
431
431
  Reflect.deleteProperty(input, key);
432
432
  return;
433
433
  }
434
- changes.push(key);
434
+ changes.push(key as any);
435
435
  return;
436
436
  }
437
437
 
@@ -451,7 +451,7 @@ export namespace Utils {
451
451
  }
452
452
 
453
453
  // Hold the key
454
- changes.push(key);
454
+ changes.push(key as any);
455
455
  });
456
456
 
457
457
  return changes;
package/tsconfig.cjs.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "declaration": true,
11
11
  "strict": true,
12
12
  "esModuleInterop": true,
13
- "skipLibCheck": true,
13
+ "skipLibCheck": false,
14
14
  "forceConsistentCasingInFileNames": true,
15
15
  "lib": ["dom", "dom.iterable", "ESNext"]
16
16
  },
package/tsconfig.json CHANGED
@@ -2,15 +2,15 @@
2
2
  "compilerOptions": {
3
3
  /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
4
  "target": "ES2020",
5
- "module": "ESNext",
6
- "moduleResolution": "Node10",
5
+ "module": "ES2020",
6
+ "moduleResolution": "bundler",
7
7
  "isolatedModules": true,
8
8
  "outDir": "./lib/mjs",
9
9
  "noEmit": false,
10
10
  "declaration": true,
11
11
  "strict": true,
12
12
  "esModuleInterop": true,
13
- "skipLibCheck": true,
13
+ "skipLibCheck": false,
14
14
  "forceConsistentCasingInFileNames": true,
15
15
  "lib": ["dom", "dom.iterable", "esnext"]
16
16
  },
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from "vitest/config";
2
+ import react from "@vitejs/plugin-react";
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ test: {
7
+ globals: true,
8
+ environment: "jsdom",
9
+ include: ["__tests__/**/*.ts(x)?"]
10
+ }
11
+ });