11import { Value } from './Value' ;
22import { toText } from '../json-type/typescript/toText' ;
33import { TypeSystem } from '../json-type/system/TypeSystem' ;
4+ import { printTree } from 'sonic-forest/lib/print/printTree' ;
45import type { ResolveType } from '../json-type' ;
56import type * as classes from '../json-type/type' ;
67import type * as ts from '../json-type/typescript/types' ;
78import type { TypeBuilder } from '../json-type/type/TypeBuilder' ;
9+ import type { Printable } from 'sonic-forest/lib/print/types' ;
810
911export type UnObjectType < T > = T extends classes . ObjectType < infer U > ? U : never ;
1012export 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
3133type PropDefinition < K extends string , V extends classes . Type > = [ key : K , val : V , data : ResolveType < V > ] ;
3234type PropDef = < K extends string , V extends classes . Type > ( key : K , val : V , data : ResolveType < V > ) => PropDefinition < K , V > ;
3335
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 {
3537 public static create = ( system : TypeSystem = new TypeSystem ( ) ) => new ObjectValue ( system . t . obj , { } ) ;
3638
3739 public get system ( ) : TypeSystem {
@@ -155,4 +157,8 @@ export class ObjectValue<T extends classes.ObjectType<any>> extends Value<T> {
155157 public toTypeScript ( ) : string {
156158 return toText ( this . toTypeScriptModuleAst ( ) ) ;
157159 }
160+
161+ public toString ( tab : string = '' ) : string {
162+ return this . constructor . name + printTree ( tab , [ ( tab ) => this . type . toString ( tab ) ] ) ;
163+ }
158164}
0 commit comments