import { matches } from "./matches" ; export function closest < K extends keyof HTMLElementTagNameMap > ( element , selectors ) ; export function closest < K extends keyof SVGElementTagNameMap > ( element , selectors ) ; export function closest < T extends Element = Element > ( element , selectors ) ; example export function closest ( element , selectors ) { if ( "closest" in element ) return element . closest ( selectors ) ; do { if ( matches ( element , selectors ) ) return element ; element = ( element . parentElement || element . parentNode ) as any ; } while ( element !== null && element . nodeType === 1 ) ; return null ; }