Type alias TypeGuardFunction<T>

TypeGuardFunction<T>: ((obj) => obj is T)

Type Parameters

  • T

    The type to check against

Type declaration

    • (obj): obj is T
    • A function that checks the input object against a specific type.

      Parameters

      • obj: any

      Returns obj is T

      Example

      type Foo {
      bar: number
      }

      function isFoo(obj: any): obj is Foo {
      const _obj: Partial<Foo> | null | undefined = obj
      return typeof _obj?.bar === "number"
      }

Generated using TypeDoc