Function isInstanceOf

  • TypeGuard wrapper for instanceof keyword.

    Type Parameters

    • Entity

      The type of the entity class.

    Parameters

    • instance: unknown

      The instance of the class to check.

    • entity: Class<Entity>

      The class to ensure the instance is from.

    Returns instance is Entity

    Example

    class Person {
    constructor(public name: string) {}
    }

    const john = new Person("John");
    isInstanceOf(john, Person);
    // => true
    // john is instanceof Person

Generated using TypeDoc