With this module you can avoid typical typescript errors, such as making mistakes when you are selecting elements from the DOM
Instance Verification is a module that will allow us to obtain elements from the DOM making sure they exist before taking them
Many times we put the ID wrong in our constant and there is no error until we want to manipulate it, with these functions, those problems cease to exist, or also, when we get confused and let typescript treat our elements with instances that really are not the correct ones.
const btn = getElementWithId('btnID', HTMLButtonElement)
const btn = getElementsWithClassName('btnClass', HTMLButtonElement)
const btn = getElementsWithName('btnName', HTMLButtonElement)
const btn = getFirstElementWithClassName('btnClass', HTMLButtonElement)
const btn = getFirstElementWithName('btnName', HTMLButtonElement)
<div class="div"></div>
<div class="div"></div>
<button class="div"></button>
<div class="div"></div>
<div class="div"></div>
const divs = getElementsWithClassName('div', HTMLDivElement)