@kotlin-mui: I’m trying to make an extension funct...
# javascript
m
@kotlin-mui: I’m trying to make an extension function to set the
min
attribute and cannot figure out how to do it correctly:
Copy code
var InputBaseComponentProps.min: String
  get() = throw IllegalStateException()
  set(value) {
    return when (this) {
      is HTMLInputElement -> min = value
      else -> throw IllegalArgumentException("There is no min in this InputBaseComponentProps")
    }
  }
This results in an exception because it apparently does not match with HTMLInputElement. As a reference, this works:
Copy code
val HTMLElement.value: String
  get() = when (this) {
    is HTMLInputElement -> value
    is HTMLTextAreaElement -> value
    else -> throw IllegalArgumentException("There is no value in this HTMLElement")
  }
t
Copy code
var InputBaseComponentProps.min: Double?
  get() = asDynamic().min
  set(value) {
    asDynamic().min = value
  }
m
So there’s no way without
asDynamic()
t
InputBaseComponentProps
is simple JS object, like all typical props
Yes, because it’s JSO
m
Ok, thanks 👍🏼
key
and
ref
are write-only, because they are reserved