Function safeSetProperty

  • Set value only if setter exists

    Type Parameters

    • T

    • K extends string | number | symbol

    Parameters

    • object: T

      object to set

    • prop: K

      property to set

    • value: NonNullable<T>[K]

      value to set

    • allowWritable: boolean = true

      allow writable properties without setter

    • allowAny: boolean = false

      allow any property (even if it doesn't exist)

    Returns boolean