function buildInherits()

in typescript-generator/src/index.ts [161:188]


function buildInherits (type: M.Interface | M.Request, openGenerics?: string[]): string {
  const inherits = (type.inherits != null ? [type.inherits] : []).filter(type => !skipBehaviors.includes(type.type.name))
  const behaviors = (type.behaviors ?? []).filter(type => !skipBehaviors.includes(type.type.name))
  const extendAll = inherits.concat(behaviors)
    // do not extend from empty interfaces
    .filter(inherit => {
      for (const type of model.types) {
        if (inherit.type.name === type.name.name && inherit.type.namespace === type.name.namespace) {
          switch (type.kind) {
            case 'interface':
              return type.properties.length > 0 || type.inherits != null || type.behaviors != null || type.generics != null
            case 'request':
            case 'response':
              return true
            default:
              return false
          }
        }
      }
      return true
    })
  if (extendAll.length === 0) return ''
  return ` extends ${extendAll.map(buildInheritType).join(', ')}`

  function buildInheritType (type: M.Inherits): string {
    return `${createName(type.type)}${buildGenerics(type.generics, openGenerics)}`
  }
}