5.
Will the following assignments generate any type errors?
let num: number = 5;
let str: string = "hello";
let bool: boolean = true;
let arr: number[] = [1, 2, 3];
let obj: { name: string, age: number } = { name: 5, age: "John" };
Yes, the assignment of obj should have a number for the age property and a string for the name property.
Yes, the assignment of str should be number.
Yes, the assignment of num should be string.
No, all assignments are type-safe.
Correct: A
In TypeScript, type annotations help catch potential type errors during the assignment. However, in this case, there are type errors present. The assignment of "obj" should have a number for the age property, but it is assigned a string, and a string for the name property instead of a number. Hence, there are type errors in these assignments.