Treora commented on issue #111:
URL: 
https://github.com/apache/incubator-annotator/issues/111#issuecomment-868375110


   I renamed `highlightRange` to `highlightText` (seems a better name in any 
case!), and made it accept either a Node or Range (internally we just use a 
function `toRange` to convert it to a range, easy enough). Your example code 
should work now, if you pull the latest commit and update the import to reflect 
the renaming.
   
   By the way, you could let TypeScript help you find errors like this by 
giving the `matcher` argument a type (instead of `any`). In your case it could 
be `Matcher<Element, Element | Range>`: the `TScope` type parameter only needs 
to be `Element`, because you always pass it `document.body`, and all Matcher 
functions in the dom package yield either `Range`s or `Element`s. Or, if you 
want to make it more generic, I think the type could be `Matcher<Node | Range, 
Node | Range>`: you can pass any `Node` or `Range` to any of the matchers, and 
every Element is a Node so if you like symmetry the `TMatch` type parameter 
could also be made `Node | Range` (as `highlightText` now accepts this too).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to