TypeScript Basics Test

Test your understanding of annotations, inference, interfaces, unions and safe unknown values.

6 questions. Choose the best answer for each question, then review every explanation.

Question 1 of 6

1 of 6
Question 1Which declaration explicitly requires a number?
Question 2What is an interface commonly used to describe?
Question 3What values can this variable accept?
let id: string | number;
Question 4What does the question mark mean on this property?
interface User { nickname?: string }
Question 5What type does TypeScript infer here?
const active = true;
Question 6Why is unknown generally safer than any?