@fkui/logic
    Preparing search index...

    Function assertRef

    • Assertion function to assert that a nullable Vue ref holds a non-null value. Typically used with template refs but any nullable ref can be used.

      Throws MissingValueError if the ref holds null or undefined, or the ref itself is null or undefined.

      Type Parameters

      • T

      Parameters

      • ref: undefined | null | { value: null | T }

        the value asserted to be a ref.

      • message: string = "Expected ref to have a non-null value, but it did not"

        an optional exception message to use if the check fails.

      Returns asserts ref is { value: T }

      const element = useTemplateRef("my-template-ref");
      // ^? Readonly<ShallowRef<HTMLElement | null>>

      assertRef(element);

      // element is now guaranteed to be a HTMLElement ref

      v6.15.0

      MissingValueError if value is not set.