Closed eddie-englund closed 1 year ago
Thank you,
will add it to the typescript rewrite https://github.com/ThibaultJanBeyer/DragSelect/pull/174.
Actually it should never be null
. null
is a special value to force-unset the param. So setting null
as area will break DragSelect. So these types are correct to warn you that the element has to be available.
In your example typescript warns you that the element might be null
, if that is the case, you should not pass it as area. But if you know that the element you are selecting is always available, you should use type cast it to the correct type. i.e. as HTMLElement
if it is a HTMLElement.
Interestingly enough in my quick test document.getElementById('something')
is actually always HTMLElement 🤔
Describe the bug The type of "area" is:
It should also have
null
in the union type because document.getElementById's type is:To Reproduce Install the package and add an area like in the docs: https://dragselect.com/docs/guided-examples/Area Expected behavior It should not throw a type error.
Screenshots