Why does these javscript code not working in Vite

Viewed 19

I found Vite is quite better than rollup. So I started to use Vite. But When i copied the former scripts of javascript, I confronted many errors. For example

<input class = "current_password" type = "password" id="current_password"/>
let x = document.getElementById("current_password");
if (x.type === "password") {
x.type = "text";
// Property 'type' does not exist on type 'HTMLElement'

Or

<div id="book" class="book">
</div>
const book = document.getElementById("book");
book.style.transform = "translateX(50%)";

makes this error

enter image description here

Even querySelector makes an error too!

What is the problem of this? Why they don't work in Vite and works at rollup.js?

0 Answers
Related