- Create a simple TypeScript file
- Understand the basic syntax of TypeScript
- Transpile TypeScript to JavaScript
- Run the JavaScript file
- Create a new file called
app.ts in the root of your project.
- Write a simple TypeScript code that declares a variable
message and assigns a string to it.
- Write the
message variable using console.log
- Transpile the TypeScript file to JavaScript using the
tsc command.
- Run the JavaScript file using the
node command.
- Declare a user type with the following properties:
name, age, email.
- Create a variable
user and assign an object that respects the user type.
console.log the user variable.
console.log the user's email property.
- run the command jusing the --watch flag to watch for changes in the file.
- Create a function that takes a user as a parameter and returns a string with the user's name and age.
- ex: 'Thomas is 39 years old'
- Call the function with the
user variable and log the result.
- Run the JavaScript file using the
node command.