Function inheritStaticMembers

  • Copies static members from a source constructor to a target constructor, excluding specified keys.

    Parameters

    • target: TConstructor

      The target constructor to inherit static members.

    • source: TConstructor

      The source constructor to copy static members from.

    • ignoreKeys: string[] = []

      An optional array of keys to exclude from copying.

    Returns TConstructor

    The target constructor with the inherited static members.

    Throws

    If target or source is not a constructor.

    Example

    class Parent {
    static parentStaticMethod() {
    return 'Parent static method'
    }
    }
    class Child {
    static childStaticMethod() {
    return 'Child static method'
    }
    }
    inheritStaticMembers(Child, Parent)
    Child.parentStaticMethod() //=> 'Parent static method'

Generated using TypeDoc