In general, the elements of a selection will be DOM elements (HTML or SVG.) These could be captured with the current constraint the type BaseType = Element
for d3-selection
, d3-transition
and DOM event related packages like d3-drag
and d3-zoom
.
However, EnterElement (or EnterNode) elements constituting the group elements of the enter()
selection after a data join do not meet this minimal requirement (see EnterElement
interface in d3-selection.
Also, there may be use cases, albeit exceptional, where the constituent element of a selection
(transition
), is of a general nature, i.e. could be any
. In which case, some methods of the Selection
or Transition
will not work, as the element misses properties/methods which are internally used by the respective D3 modules.
See the d3- selection issue and the DOM-to-Canvas Example.
As the Selection
and Transition
interfaces and related selection methods are generisized, not explicitly stating the type, may use type inference, based on typed arguments or return values to determine the type of this
where it is tied to the element type. If inference is not possible, the BaseType
would be the default value.
So, while strictly a type BaseType = Element
or something likeinterface BaseType extends Node, QuerySelector {}
would be too restrictive, it may be preferable in 99% (?) of use cases due to the default behavior.