Here are some questions to test what you have learned in this first chapter. The answers can be found in the appendix.
Good luck!
- What are the 5 primitive types?
- What would the inferred type be for the flag variable be in the following code?
const flag = false;
- What's the difference between an interface and a type alias?
- What is wrong with the following code? How could this be resolved?
class Product {
constructor(public name: string, public unitPrice: number) {}
}
let table = new Product();
table.name = "Table";
table.unitPrice = 700;
- If we want our TypeScript program to support IE11, what should the compiler--target option be?
- Is it possible to get the TypeScript compiler to transpile ES6 .js files? If so, how?
- How can we prevent console.log() statements from getting into our code?