@esportsplus/typescript 0.0.3 → 0.0.4

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/build/types.d.ts CHANGED
@@ -1,10 +1,6 @@
1
- type ExtractMethods<T> = {
2
- [K in keyof T as T[K] extends Function ? K : never]: T[K];
3
- };
4
- type Mutable<T> = {
5
- -readonly [P in keyof T]: T[P];
6
- };
1
+ type Function = (...args: unknown[]) => Promise<unknown> | unknown;
7
2
  type Prettify<T> = {
8
3
  [K in keyof T]: T[K];
9
4
  } & {};
10
- export { ExtractMethods, Mutable, Prettify };
5
+ type SyncFunction<T, R = T extends Function ? ReturnType<T> : T> = T extends Promise<unknown> ? never : T extends Function ? SyncFunction<R> extends never ? never : T : T;
6
+ export { Prettify, SyncFunction };
package/package.json CHANGED
@@ -22,5 +22,5 @@
22
22
  "prepublishOnly": "npm run build"
23
23
  },
24
24
  "types": "build/index.d.ts",
25
- "version": "0.0.3"
25
+ "version": "0.0.4"
26
26
  }
package/src/types.ts CHANGED
@@ -1,14 +1,17 @@
1
- type ExtractMethods<T> = {
2
- [K in keyof T as T[K] extends Function ? K : never]: T[K]
3
- };
4
-
5
- type Mutable<T> = {
6
- -readonly [P in keyof T]: T[P];
7
- };
1
+ type Function = (...args: unknown[]) => Promise<unknown> | unknown;
8
2
 
9
3
  type Prettify<T> = {
10
4
  [K in keyof T]: T[K];
11
5
  } & {};
12
6
 
7
+ type SyncFunction<T, R = T extends Function ? ReturnType<T> : T> =
8
+ T extends Promise<unknown>
9
+ ? never
10
+ : T extends Function
11
+ ? SyncFunction<R> extends never
12
+ ? never
13
+ : T
14
+ : T;
15
+
13
16
 
14
- export { ExtractMethods, Mutable, Prettify };
17
+ export { Prettify, SyncFunction };