6.
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: "John", age: 25 };
Yes, the assignment of obj should be number and string.
Yes, the assignment of str should be number.
Yes, the assignment of num should be string.
No, all assignments are type-safe.
Correct: D
In TypeScript, type annotations help catch potential type errors during the assignment. In this case, all assignments are type-safe and will not generate any type errors. The variable "num" is assigned a number, "str" is assigned a string, "bool" is assigned a boolean, "arr" is assigned an array of numbers, and "obj" is assigned an object with a name (string) and age (number). Hence, there are no type errors in these assignments.