Complete the code to declare a variable with a type in TypeScript.
let age: [1] = 25;
In TypeScript, number is used to declare a variable that holds numeric values.
Complete the code to define a function that returns a string in TypeScript.
function greet(): [1] { return "Hello!"; }
void when the function returns a value.number or boolean incorrectly.The function returns a text, so its return type should be string.
Fix the error in the TypeScript interface declaration.
interface Person {
name: string;
age: [1];
}string for numeric properties.The age property should be a number type because it holds numeric values.
Fill both blanks to create a typed array of strings in TypeScript.
let fruits: [1] = ["apple", "banana", "cherry"]; // array of [2]
number[] or boolean[] for string arrays.The variable fruits is an array of strings, so the type is string[] and the comment describes the element type as string.
Fill all three blanks to create a typed object with optional and readonly properties in TypeScript.
interface Car {
readonly make: [1];
model: [2];
year?: [3];
}boolean for text or number properties.The make and model are text values, so they use string. The year is a number and optional, so it uses number with a question mark.