How to setSelection to text of a node found via view.posAtDOM?

I’m new to ProseMirror and would like to know if the below is the best practice for how one would make a TextSelection at the node they just found via view.posAtDOM

handleDOMEvents: {
  mouseover: (view, event) => {
    const pos = editor.view.posAtDOM(, 0);
    const node = editor.state.doc.nodeAt(pos);

    const linkMark = node?.marks.find(mark => === "link")

    if (!linkMark) return false;

    const resolvedPos = editor.state.doc.resolve(pos);
    const resolvedEndPos = editor.state.doc.resolve(pos + node.nodeSize);

        new TextSelection(resolvedPos, resolvedEndPos)

    return false;

In the above, I successfully detected when the user hovered over a node with a link. I then set the selection to that node.

It currently seems to work, but I don’t know if it is working by chance. Is this how one would properly use pos and pos + node.nodeSize?