INNER CODE UNIT · TypeScript

GInterface

stepci/garph · src/index.ts:225

class GInterface<N extends string, T extends AnyTypes> extends Type<T, 'InterfaceType'> {
  declare _name: N

  constructor(name: string, shape: T, interfaces?: AnyInterface[], extend?: AnyTypes[]) {
    super()
    this.typeDef = {
      name,
      type: 'InterfaceType',
      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 GInterface<N ,T & UnionToIntersection<D['_shape']>>(this.typeDef.name, this.typeDef.shape as any, Array.isArray(ref) ? ref : [ref], this.typeDef.extend)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…