NPM install -g typescript

Create a new TypeScript file and paste the following:

function greeter(person) {
    return "Hello, " + person;
}

var user = "Jane User";

document.body.innerHTML = greeter(user); 
Copy the code

Using the command line TSC 1.ts to compile, you get a JavaScript file with the same name:



Create a new HTML and paste the 1.js code into it:

Final effect:

For more of Jerry’s original articles, please follow the public account “Wang Zixi “: