INNER CODE UNIT · TypeScript
GType
stepci/garph · src/index.ts:178
class GType<N extends string, T extends AnyTypes> extends Type<T, 'ObjectType'> {
declare _name: N
constructor(name: string, shape: T, interfaces?: AnyInterface[], extend?: AnyTypes[]) {
super()
this.typeDef = {
name,
type: 'ObjectType',
shape,
interfaces,
extend
}
}
implements<D extends AnyInterface>(ref: D | D[]) {
// This is temporary construct, until we figure out how to properly manage to shared schema
this.typeDef.interfaces = Array.isArray(ref) ? ref : [ref]
return new GType<N, T & UnionToIntersection<D['_shape']>>(this.typeDef.name, this.typeDef.shape as any, Array.isArray(ref) ? ref : [ref], this.typeDef.extend)