@ddd-ts/freeze 0.0.0-fix-get-handler.1 → 0.0.0-fix-get-handler.2

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 +1 @@
1
- {"version":3,"file":"get-pretty-type.d.ts","sourceRoot":"","sources":["../../src/utils/get-pretty-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAe,IAAI,EAAE,MAAM,UAAU,CAAC;AAEzE,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,GAAG;IAC5D,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,oBAAoB,CAAC;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAmCA"}
1
+ {"version":3,"file":"get-pretty-type.d.ts","sourceRoot":"","sources":["../../src/utils/get-pretty-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAe,IAAI,EAAE,MAAM,UAAU,CAAC;AAEzE,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,GAAG;IAC5D,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,oBAAoB,CAAC;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CA0DA"}
@@ -7,11 +7,34 @@ function getPrettyType(type, contextNode) {
7
7
  const typeTextForEmbedding = project.getTypeChecker().compilerObject.typeToString(type.compilerType, void 0, ts_morph.ts.TypeFormatFlags.NoTruncation | ts_morph.ts.TypeFormatFlags.UseFullyQualifiedType | ts_morph.ts.TypeFormatFlags.InTypeAlias);
8
8
  const fileName = `__pretty_${Date.now()}_${Math.random().toString(16).slice(2)}.ts`;
9
9
  const sf = project.createSourceFile(fileName, `
10
- type DeepPretty<T> = T extends object
11
- ? T extends Function
12
- ? T
13
- : { [K in keyof T]: DeepPretty<T[K]> } & {}
14
- : T;
10
+ type UnknownArray = readonly unknown[];
11
+ type MapsSetsOrArrays = ReadonlyMap<unknown, unknown> | WeakMap<WeakKey, unknown> | ReadonlySet<unknown> | WeakSet<WeakKey> | UnknownArray;
12
+ type Primitive =
13
+ | null
14
+ | undefined
15
+ | string
16
+ | number
17
+ | boolean
18
+ | symbol
19
+ | bigint;
20
+ type IsNever<T> = [T] extends [never] ? true : false;
21
+ type BuiltIns = Primitive | void | Date | RegExp;
22
+ type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown) | Promise<unknown>;
23
+ type IsPlainObject<T> =
24
+ IsNever<T> extends true
25
+ ? false
26
+ : T extends NonRecursiveType | MapsSetsOrArrays
27
+ ? false
28
+ : T extends object
29
+ ? true
30
+ : false;
31
+ // the code above is from type-fest. it's an extract of the IsPlainObject type with all the dependencies it has
32
+
33
+ type DeepPretty<T> = IsPlainObject<T> extends true
34
+ ? { [K in keyof T]: DeepPretty<T[K]> } & {}
35
+ : T extends (infer U)[]
36
+ ? DeepPretty<U>[] & {}
37
+ : T;
15
38
  declare const __v: ${typeTextForEmbedding};
16
39
  export type __X = DeepPretty<typeof __v>;
17
40
  `, { overwrite: true });
@@ -6,11 +6,34 @@ function getPrettyType(type, contextNode) {
6
6
  const typeTextForEmbedding = project.getTypeChecker().compilerObject.typeToString(type.compilerType, void 0, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseFullyQualifiedType | ts.TypeFormatFlags.InTypeAlias);
7
7
  const fileName = `__pretty_${Date.now()}_${Math.random().toString(16).slice(2)}.ts`;
8
8
  const sf = project.createSourceFile(fileName, `
9
- type DeepPretty<T> = T extends object
10
- ? T extends Function
11
- ? T
12
- : { [K in keyof T]: DeepPretty<T[K]> } & {}
13
- : T;
9
+ type UnknownArray = readonly unknown[];
10
+ type MapsSetsOrArrays = ReadonlyMap<unknown, unknown> | WeakMap<WeakKey, unknown> | ReadonlySet<unknown> | WeakSet<WeakKey> | UnknownArray;
11
+ type Primitive =
12
+ | null
13
+ | undefined
14
+ | string
15
+ | number
16
+ | boolean
17
+ | symbol
18
+ | bigint;
19
+ type IsNever<T> = [T] extends [never] ? true : false;
20
+ type BuiltIns = Primitive | void | Date | RegExp;
21
+ type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown) | Promise<unknown>;
22
+ type IsPlainObject<T> =
23
+ IsNever<T> extends true
24
+ ? false
25
+ : T extends NonRecursiveType | MapsSetsOrArrays
26
+ ? false
27
+ : T extends object
28
+ ? true
29
+ : false;
30
+ // the code above is from type-fest. it's an extract of the IsPlainObject type with all the dependencies it has
31
+
32
+ type DeepPretty<T> = IsPlainObject<T> extends true
33
+ ? { [K in keyof T]: DeepPretty<T[K]> } & {}
34
+ : T extends (infer U)[]
35
+ ? DeepPretty<U>[] & {}
36
+ : T;
14
37
  declare const __v: ${typeTextForEmbedding};
15
38
  export type __X = DeepPretty<typeof __v>;
16
39
  `, { overwrite: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-ts/freeze",
3
- "version": "0.0.0-fix-get-handler.1",
3
+ "version": "0.0.0-fix-get-handler.2",
4
4
  "types": "dist/index.d.ts",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,15 +17,15 @@
17
17
  "typescript": "^5.5.4"
18
18
  },
19
19
  "dependencies": {
20
- "@ddd-ts/core": "0.0.0-fix-get-handler.1",
21
- "@ddd-ts/shape": "0.0.0-fix-get-handler.1",
22
- "@ddd-ts/traits": "0.0.0-fix-get-handler.1",
23
- "@ddd-ts/types": "0.0.0-fix-get-handler.1",
20
+ "@ddd-ts/core": "0.0.0-fix-get-handler.2",
21
+ "@ddd-ts/shape": "0.0.0-fix-get-handler.2",
22
+ "@ddd-ts/traits": "0.0.0-fix-get-handler.2",
23
+ "@ddd-ts/types": "0.0.0-fix-get-handler.2",
24
24
  "@prettier/sync": "^0.6.1",
25
25
  "prettier": "^3.8.1"
26
26
  },
27
27
  "devDependencies": {
28
- "@ddd-ts/tools": "0.0.0-fix-get-handler.1",
28
+ "@ddd-ts/tools": "0.0.0-fix-get-handler.2",
29
29
  "@types/jest": "^29.5.1",
30
30
  "@types/node": "^22.14.1"
31
31
  },