Why my typescript in htmlinput,function and button has an error?

Viewed 30

So, I'm having a simple problem with typescript even though I follow a tutorial from 2020 but I think the update has changed. So my problem here in this code

const button_click = document.querySelector("button");
const inputFirst = document.getElementById("num1")! as HTMLInputElement;
const inputSecond = document.getElementById("num2")! as HTMLInputElement;

function Add(num1: number,num2: number) {
    return num1 + num2;
}

button_click?.addEventListener("click",function () {
    console.log(Add(+inputFirst.value, +inputSecond.value))
});

Which is the button_click says the error Cannot redeclare block-scoped variable 'button_click'.ts(2451) and the same as two inputs Cannot redeclare block-scoped variable 'inputFirst'.ts(2451) and for the function Add() giving me a Duplicate function implementation.ts(2393)

This are the red underlines. enter image description here

The tutorial I follow is in here and I can't find the wrong code here https://www.youtube.com/watch?v=BwuLxPH8IDs at 16:43

EDIT Answer: Solution: Oh I'm sorry I have to remove only the javascript file and only open the typescript file.

0 Answers
Related