1
1
import { Value } from './Value' ;
2
2
import { toText } from '../json-type/typescript/toText' ;
3
3
import { TypeSystem } from '../json-type/system/TypeSystem' ;
4
+ import { printTree } from 'sonic-forest/lib/print/printTree' ;
4
5
import type { ResolveType } from '../json-type' ;
5
6
import type * as classes from '../json-type/type' ;
6
7
import type * as ts from '../json-type/typescript/types' ;
7
8
import type { TypeBuilder } from '../json-type/type/TypeBuilder' ;
9
+ import type { Printable } from 'sonic-forest/lib/print/types' ;
8
10
9
11
export type UnObjectType < T > = T extends classes . ObjectType < infer U > ? U : never ;
10
12
export type UnObjectValue < T > = T extends ObjectValue < infer U > ? U : never ;
@@ -31,7 +33,7 @@ export type TuplesToFields<T> = T extends PropDefinition<infer K, infer V>[] ? c
31
33
type PropDefinition < K extends string , V extends classes . Type > = [ key : K , val : V , data : ResolveType < V > ] ;
32
34
type PropDef = < K extends string , V extends classes . Type > ( key : K , val : V , data : ResolveType < V > ) => PropDefinition < K , V > ;
33
35
34
- export class ObjectValue < T extends classes . ObjectType < any > > extends Value < T > {
36
+ export class ObjectValue < T extends classes . ObjectType < any > > extends Value < T > implements Printable {
35
37
public static create = ( system : TypeSystem = new TypeSystem ( ) ) => new ObjectValue ( system . t . obj , { } ) ;
36
38
37
39
public get system ( ) : TypeSystem {
@@ -155,4 +157,8 @@ export class ObjectValue<T extends classes.ObjectType<any>> extends Value<T> {
155
157
public toTypeScript ( ) : string {
156
158
return toText ( this . toTypeScriptModuleAst ( ) ) ;
157
159
}
160
+
161
+ public toString ( tab : string = '' ) : string {
162
+ return this . constructor . name + printTree ( tab , [ ( tab ) => this . type . toString ( tab ) ] ) ;
163
+ }
158
164
}
0 commit comments