@nestia/fetcher 1.3.2 → 1.3.3

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.
@@ -27,10 +27,12 @@
27
27
  *
28
28
  * @template Instance Target argument type.
29
29
  * @author Jenogho Nam - https://github.com/samchon
30
+ * @author Kyungsu Kang - https://github.com/kakasoo
31
+ * @author Michael - https://github.com/8471919
30
32
  */
31
33
  export type Primitive<T> = Equal<T, PrimitiveMain<T>> extends true ? T : PrimitiveMain<T>;
32
34
  type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
33
- type PrimitiveMain<Instance> = ValueOf<Instance> extends object ? Instance extends object ? Instance extends NativeClass ? {} : Instance extends IJsonable<infer Raw> ? ValueOf<Raw> extends object ? Raw extends object ? PrimitiveObject<Raw> : never : ValueOf<Raw> : PrimitiveObject<Instance> : never : ValueOf<Instance>;
35
+ type PrimitiveMain<Instance> = Instance extends [never] ? never : ValueOf<Instance> extends boolean | number | bigint | string ? ValueOf<Instance> : ValueOf<Instance> extends object ? Instance extends object ? Instance extends NativeClass ? {} : Instance extends IJsonable<infer Raw> ? ValueOf<Raw> extends object ? Raw extends object ? PrimitiveObject<Raw> : never : ValueOf<Raw> : PrimitiveObject<Instance> : never : ValueOf<Instance>;
34
36
  type PrimitiveObject<Instance extends object> = Instance extends Array<infer T> ? IsTuple<Instance> extends true ? PrimitiveTuple<Instance> : PrimitiveMain<T>[] : {
35
37
  [P in keyof Instance]: Instance[P] extends Function ? never : PrimitiveMain<Instance[P]>;
36
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestia/fetcher",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Fetcher library of Nestia SDK",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -34,6 +34,9 @@
34
34
  "rimraf": "^3.0.2",
35
35
  "typescript": "^4.9.4"
36
36
  },
37
+ "peerDependencies": {
38
+ "typescript": ">= 4.7.4"
39
+ },
37
40
  "dependencies": {
38
41
  "import2": "^1.0.3",
39
42
  "node-fetch": "^2.6.7"
package/src/Primitive.ts CHANGED
@@ -27,6 +27,8 @@
27
27
  *
28
28
  * @template Instance Target argument type.
29
29
  * @author Jenogho Nam - https://github.com/samchon
30
+ * @author Kyungsu Kang - https://github.com/kakasoo
31
+ * @author Michael - https://github.com/8471919
30
32
  */
31
33
  export type Primitive<T> = Equal<T, PrimitiveMain<T>> extends true
32
34
  ? T
@@ -34,7 +36,11 @@ export type Primitive<T> = Equal<T, PrimitiveMain<T>> extends true
34
36
 
35
37
  type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
36
38
 
37
- type PrimitiveMain<Instance> = ValueOf<Instance> extends object
39
+ type PrimitiveMain<Instance> = Instance extends [never]
40
+ ? never // (special trick for jsonable | null) type
41
+ : ValueOf<Instance> extends boolean | number | bigint | string
42
+ ? ValueOf<Instance>
43
+ : ValueOf<Instance> extends object
38
44
  ? Instance extends object
39
45
  ? Instance extends NativeClass
40
46
  ? {}